Changeset 3036107
- Timestamp:
- 02/15/2024 09:10:49 AM (5 months ago)
- Location:
- iyzico-woocommerce/trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
iyzico-woocommerce/trunk/library/iyzico-for-woocommerce-gateway-formobjectgenerate.php
r2934987 r3036107 42 42 $iyzico->callbackUrl = add_query_arg('wc-api', 'WC_Gateway_Iyzico', $data->get_checkout_order_received_url()); 43 43 $iyzico->cardUserKey = $iyziModel->findUserCardKey($user->ID,$apiKey); 44 $iyzico->paymentSource = 'WOOCOMMERCE|'.WOOCOMMERCE_VERSION.'|CARRERA-3.2.6'.$affiliate; 45 //$iyzico->goBackUrl = "test.php"; 44 $iyzico->paymentSource = 'WOOCOMMERCE|'.WOOCOMMERCE_VERSION.'|CARRERA-3.4.0'.$affiliate; 46 45 47 46 … … 77 76 $iyzico->callbackUrl = add_query_arg('wc-api', 'WC_Gateway_Iyzico', $data->get_checkout_order_received_url()); 78 77 $iyzico->cancelUrl = get_site_url(); 79 $iyzico->paymentSource = 'WOOCOMMERCE|'.WOOCOMMERCE_VERSION.'|CARRERA-PWI-3. 2.6'.$affiliate;78 $iyzico->paymentSource = 'WOOCOMMERCE|'.WOOCOMMERCE_VERSION.'|CARRERA-PWI-3.'.$affiliate; 80 79 81 80 -
iyzico-woocommerce/trunk/library/iyzico-for-woocommerce-gateway-pkibuilder.php
r2934987 r3036107 1 1 <?php 2 if ( ! defined( 'ABSPATH' )) {2 if () { 3 3 exit; 4 4 } 5 5 6 class Iyzico_Checkout_For_WooCommerce_PkiBuilder { 6 class Iyzico_Checkout_For_WooCommerce_PkiBuilder 7 { 7 8 8 public function pkiStringGenerate($objectData) { 9 public function pkiStringGenerate($objectData) 10 { 9 11 $pki_value = "["; 10 12 foreach ($objectData as $key => $data) { 11 if (is_object($data)) {13 if(is_object($data)) { 12 14 $name = var_export($key, true); 13 15 $name = str_replace("'", "", $name); 14 $pki_value .= $name ."=[";16 $pki_value .= $name"=["; 15 17 $end_key = count(get_object_vars($data)); 16 18 $count = 0; … … 19 21 $name = var_export($key, true); 20 22 $name = str_replace("'", "", $name); 21 $pki_value .= $name ."="."".$value;22 if ($end_key != $count)23 $pki_value .= $name$value; 24 if($end_key != $count) 23 25 $pki_value .= ","; 24 26 } 25 27 $pki_value .= "]"; 26 } else if (is_array($data)) {28 } else if(is_array($data)) { 27 29 $name = var_export($key, true); 28 30 $name = str_replace("'", "", $name); 29 $pki_value .= $name ."=[";31 $pki_value .= $name"=["; 30 32 $end_key = count($data); 31 33 $count = 0; … … 38 40 $name = str_replace("'", "", $name); 39 41 40 $pki_value .= $name."="."".$item; 41 if(end($result) != $item) { 42 $pki_value .= $name . "=" . "" . $item; 43 $reResult = (array) $result; 44 $newResult = $reResult[array_key_last($reResult)]; 45 46 if ($newResult != $item) { 42 47 $pki_value .= ","; 43 48 } 44 if(end($result) == $item) { 45 if($end_key != $count) { 49 50 if ($newResult == $item) { 51 52 if ($end_key != $count) { 46 53 $pki_value .= "], "; 47 48 54 } else { 49 55 $pki_value .= "]"; … … 52 58 } 53 59 } 54 if(end($data) == $result) 60 61 $reData = (array) $data; 62 $newData = $reData[array_key_last($reData)]; 63 if ($newData == $result) 55 64 $pki_value .= "]"; 56 57 65 } else { 58 66 $name = var_export($key, true); 59 67 $name = str_replace("'", "", $name); 60 68 61 $pki_value .= $name ."="."".$data."";69 $pki_value .= $name""; 62 70 } 63 if(end($objectData) != $data) 71 72 $reObjectData = (array)$objectData; 73 $newobjectData = $reObjectData[array_key_last($reObjectData)]; 74 75 if ($newobjectData != $data) 64 76 $pki_value .= ","; 65 77 } … … 68 80 } 69 81 70 public function createFormObjectSort($objectData) { 82 public function createFormObjectSort($objectData) 83 { 71 84 72 85 … … 92 105 $form_object->basketItems[$key] = new stdClass(); 93 106 $form_object->basketItems[$key] = $item; 94 95 107 } 96 108 … … 101 113 $form_object->forceThreeDS = $objectData->forceThreeDS; 102 114 $form_object->cardUserKey = $objectData->cardUserKey; 103 //$form_object->goBackUrl = $objectData->goBackUrl;104 115 105 116 return $form_object; 106 117 } 107 118 108 public function createFormObjectSortPwi($objectData) { 119 public function createFormObjectSortPwi($objectData) 120 { 109 121 110 122 … … 130 142 $form_object->basketItems[$key] = new stdClass(); 131 143 $form_object->basketItems[$key] = $item; 132 133 144 } 134 145 … … 142 153 } 143 154 144 public function authorizationGenerate($pkiString,$apiKey,$secretKey,$rand) { 155 public function authorizationGenerate($pkiString, $apiKey, $secretKey, $rand) 156 { 145 157 146 $hash_value = $apiKey .$rand.$secretKey.$pkiString;147 $hash = base64_encode(sha1($hash_value, true));158 $hash_value = $apiKey$pkiString; 159 $hash = base64_encode(sha1($hash_value,true)); 148 160 149 $authorization = 'IYZWS ' .$apiKey.':'.$hash;161 $authorization = 'IYZWS '$hash; 150 162 151 163 $authorization_data = array( … … 156 168 return $authorization_data; 157 169 } 158 159 170 } -
iyzico-woocommerce/trunk/library/iyzico-for-woocommerce-gateway.php
r2934987 r3036107 1 1 <?php 2 2 3 if ( ! defined( 'ABSPATH' )) {3 if () { 4 4 exit; 5 5 } 6 6 7 class Iyzico_Checkout_For_WooCommerce_Gateway extends WC_Payment_Gateway { 8 9 public function __construct() { 10 7 class Iyzico_Checkout_For_WooCommerce_Gateway extends WC_Payment_Gateway 8 { 9 10 public function __construct() 11 { 11 12 12 13 $this->id = 'iyzico'; 13 $this->iyziV = '3. 2.6';14 $this->iyziV = '3.'; 14 15 $this->method_title = __('iyzico Checkout', 'woocommerce-iyzico'); 15 16 $this->method_description = __('Best Payment Solution', 'woocommerce-iyzico'); … … 21 22 $this->init_settings(); 22 23 23 $this->title = __($this->get_option( 'title' ),'woocommerce-iyzico');24 $this->description = __($this->get_option( 'description'),'woocommerce-iyzico');25 $this->enabled = $this->get_option( 'enabled');26 $this->affiliate = $this->get_option( 'affiliate_network');27 $this->icon = plugins_url() .IYZICO_PLUGIN_NAME.'/image/cards.png?v=3';24 $this->title = __($this->get_option('woocommerce-iyzico'); 25 $this->description = __($this->get_option('woocommerce-iyzico'); 26 $this->enabled = $this->get_option(); 27 $this->affiliate = $this->get_option(); 28 $this->icon = plugins_url()'/image/cards.png?v=3'; 28 29 add_action('init', array(&$this, 'iyzico_response')); 29 add_action('admin_init', array($this , 'initIyzicoWebhookUrl'));30 add_action('admin_init', array($this); 30 31 add_action('woocommerce_api_wc_gateway_iyzico', array($this, 'iyzico_response')); 31 add_action( 'woocommerce_thankyou', array( $this, 'thankYouSubtitle' ), 5, 1);32 33 add_action( 32 add_action(); 33 34 add_action('woocommerce_update_options_payment_gateways_' . $this->id, array( 34 35 $this, 35 36 'process_admin_options', 36 ) 37 38 add_action( 37 )); 38 39 add_action('woocommerce_update_options_payment_gateways_' . $this->id, array( 39 40 $this, 40 41 'admin_overlay_script', 41 ) 42 )); 42 43 43 44 add_action('woocommerce_receipt_iyzico', array($this, 'iyzico_loading_bar')); 44 45 add_action('woocommerce_receipt_iyzico', array($this, 'iyzico_payment_form')); 45 46 46 47 48 49 50 if(isset($_GET['section']) && $_GET['section'] == 'iyzico') { 47 if (isset($_GET['section']) && $_GET['section'] == 'iyzico') { 51 48 52 49 $this->valid_js(); 53 50 } 54 55 } 56 57 public function getApiKey(){51 } 52 53 public function getApiKey() 54 { 58 55 return $this->settings['api_key']; 59 56 } 60 57 61 58 62 public function admin_overlay_script() { 59 public function admin_overlay_script() 60 { 63 61 64 62 $helper = new Iyzico_Checkout_For_WooCommerce_Helper(); … … 69 67 $secretKey = $this->settings['secret_key']; 70 68 $baseUrl = $this->settings['api_type']; 71 $randNumer = rand(100000, 99999999);69 $randNumer = rand(100000,99999999); 72 70 73 71 $overlayObject = new stdClass(); … … 77 75 78 76 $pkiString = $pkiBuilder->pkiStringGenerate($overlayObject); 79 $authorizationData = $pkiBuilder->authorizationGenerate($pkiString, $apiKey,$secretKey,$randNumer);80 81 82 $iyzicoJson = json_encode($overlayObject, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);83 84 $requestResponse = $iyzicoRequest->iyzicoOverlayScriptRequest($baseUrl, $iyzicoJson,$authorizationData);77 $authorizationData = $pkiBuilder->authorizationGenerate($pkiString,$randNumer); 78 79 80 $iyzicoJson = json_encode($overlayObject,JSON_UNESCAPED_UNICODE); 81 82 $requestResponse = $iyzicoRequest->iyzicoOverlayScriptRequest($baseUrl,$authorizationData); 85 83 86 84 … … 89 87 90 88 91 if (isset($requestResponse->protectedShopId)) {89 if(isset($requestResponse->protectedShopId)) { 92 90 93 91 $requestResponse->protectedShopId = esc_js($requestResponse->protectedShopId); 94 92 95 if(empty($iyzicoOverlayToken) && empty($iyzicoOverlayPosition)) { 96 97 add_option('iyzico_overlay_token',$requestResponse->protectedShopId,'','no'); 98 add_option('iyzico_overlay_position',$this->settings['overlay_script'],'','no'); 99 93 if (empty($iyzicoOverlayToken) && empty($iyzicoOverlayPosition)) { 94 95 add_option('iyzico_overlay_token', $requestResponse->protectedShopId, '', 'no'); 96 add_option('iyzico_overlay_position', $this->settings['overlay_script'], '', 'no'); 100 97 } else { 101 98 102 update_option('iyzico_overlay_token',$requestResponse->protectedShopId); 103 update_option('iyzico_overlay_position',$this->settings['overlay_script']); 104 } 105 99 update_option('iyzico_overlay_token', $requestResponse->protectedShopId); 100 update_option('iyzico_overlay_position', $this->settings['overlay_script']); 101 } 106 102 } else { 107 103 108 if(empty($iyzicoOverlayPosition)) { 109 110 add_option('iyzico_overlay_position',$this->settings['overlay_script'],'','no'); 111 104 if (empty($iyzicoOverlayPosition)) { 105 106 add_option('iyzico_overlay_position', $this->settings['overlay_script'], '', 'no'); 112 107 } else { 113 108 114 update_option('iyzico_overlay_position',$this->settings['overlay_script']); 115 116 } 117 109 update_option('iyzico_overlay_position', $this->settings['overlay_script']); 110 } 118 111 } 119 112 return true; 120 121 } 122 123 124 125 public function admin_options(){113 } 114 115 116 117 public function admin_options() 118 { 126 119 ob_start(); 127 120 parent::admin_options(); … … 130 123 131 124 echo $parent_options; 132 $pluginUrl = plugins_url() .IYZICO_PLUGIN_NAME;133 134 $html = '<style scoped>@media (max-width:768px){.iyziBrand{position:fixed;bottom:0;top:auto!important;right:0!important}}</style><div class="iyziBrandWrap"><div class="iyziBrand" style="clear:both;position:absolute;right: 50px;top:440px;display: flex;flex-direction: column;justify-content: center;"><img src=' .$pluginUrl.'/image/iyzico_logo.png style="width: 250px;margin-left: auto;"><p style="text-align:center;"><strong>V: </strong>'.$this->iyziV.'</p></div></div>';125 $pluginUrl = plugins_url()IYZICO_PLUGIN_NAME; 126 127 $html = '<style scoped>@media (max-width:768px){.iyziBrand{position:fixed;bottom:0;top:auto!important;right:0!important}}</style><div class="iyziBrandWrap"><div class="iyziBrand" style="clear:both;position:absolute;right: 50px;top:440px;display: flex;flex-direction: column;justify-content: center;"><img src=''</p></div></div>'; 135 128 echo $html; 136 129 } 137 130 138 public function valid_js() { 139 140 wp_enqueue_script('script', plugins_url().IYZICO_PLUGIN_NAME.'/media/js/valid_api.js',true,'1.0','all'); 141 142 } 143 public function init_form_fields() { 131 public function valid_js() 132 { 133 134 wp_enqueue_script('script', plugins_url() . IYZICO_PLUGIN_NAME . '/media/js/valid_api.js', true, '1.0', 'all'); 135 } 136 public function init_form_fields() 137 { 144 138 145 139 $this->form_fields = Iyzico_Checkout_For_WooCommerce_Fields::iyzicoAdminFields(); 146 147 } 148 149 public function process_payment($order_id){140 } 141 142 public function process_payment($order_id) 143 { 150 144 151 145 $order = wc_get_order($order_id); … … 155 149 'redirect' => $order->get_checkout_payment_url(true) 156 150 ); 157 158 } 159 160 public function iyzico_loading_bar(){151 } 152 153 public function iyzico_loading_bar() 154 { 161 155 162 156 echo '<style>.loading{width:40px;height:40px;background-color:#1E64FF;margin:auto;-webkit-animation:sk-rotateplane 1.2s infinite ease-in-out;animation:sk-rotateplane 1.2s infinite ease-in-out}@-webkit-keyframes sk-rotateplane{0%{-webkit-transform:perspective(120px)}50%{-webkit-transform:perspective(120px) rotateY(180deg)}100%{-webkit-transform:perspective(120px) rotateY(180deg) rotateX(180deg)}}@keyframes sk-rotateplane{0%{transform:perspective(120px) rotateX(0) rotateY(0);-webkit-transform:perspective(120px) rotateX(0) rotateY(0)}50%{transform:perspective(120px) rotateX(-180.1deg) rotateY(0);-webkit-transform:perspective(120px) rotateX(-180.1deg) rotateY(0)}100%{transform:perspective(120px) rotateX(-180deg) rotateY(-179.9deg);-webkit-transform:perspective(120px) rotateX(-180deg) rotateY(-179.9deg)}}</style>'; … … 169 163 </div> 170 164 </div>'; 171 172 } 173 174 private function setcookieSameSite($name, $value, $expire, $path, $domain, $secure, $httponly){165 } 166 167 private function setcookieSameSite($name, $value, $expire, $path, $domain, $secure, $httponly) 168 { 175 169 176 170 if (PHP_VERSION_ID < 70300) { 177 171 178 172 setcookie($name, $value, $expire, "$path; samesite=None", $domain, $secure, $httponly); 179 } 180 else { 173 } else { 181 174 setcookie($name, $value, [ 182 175 'expires' => $expire, … … 187 180 'httponly' => $httponly, 188 181 ]); 189 190 191 } 192 } 193 194 195 public function iyzico_payment_form($order_id,$payMethod = null) { 182 } 183 } 184 185 186 public function iyzico_payment_form($order_id, $payMethod = null) 187 { 196 188 197 189 $wooCommerceCookieKey = 'wp_woocommerce_session_'; 198 190 foreach ($_COOKIE as $name => $value) { 199 if (stripos($name, $wooCommerceCookieKey) === 0) {191 if (stripos($name,$wooCommerceCookieKey) === 0) { 200 192 $wooCommerceCookieKey = $name; 201 193 } 202 194 } 203 195 204 $setCookie = $this->setcookieSameSite($wooCommerceCookieKey, $_COOKIE[$wooCommerceCookieKey], time() + 86400, "/", $_SERVER['SERVER_NAME'],true, true);196 $setCookie = $this->setcookieSameSite($wooCommerceCookieKey,true, true); 205 197 206 198 $this->versionCheck(); … … 216 208 $baseUrl = $this->settings['api_type']; 217 209 $language = $this->settings['form_language']; 218 $rand = rand(1, 99999);210 $rand = rand(1,99999); 219 211 $user = wp_get_current_user(); 220 $iyzicoConversationId = WC()->session->set('iyzicoConversationId', $order_id);221 $iyzicoCustomerId = WC()->session->set('iyzicoCustomerId', $user->ID);222 $totalAmount = WC()->session->set('iyzicoOrderTotalAmount', $getOrder->get_total());212 $iyzicoConversationId = WC()->session->set('iyzicoConversationId',$order_id); 213 $iyzicoCustomerId = WC()->session->set('iyzicoCustomerId',$user->ID); 214 $totalAmount = WC()->session->set('iyzicoOrderTotalAmount',$getOrder->get_total()); 223 215 224 216 … … 228 220 $iyzicoRequest = new Iyzico_Checkout_For_WooCommerce_iyzicoRequest(); 229 221 230 if ($payMethod != "pwi") {231 $iyzico = $formObjectGenerate->generateOption($customerCart, $language,$getOrder,$apiKey,$this->affiliate);222 if($payMethod != "pwi") { 223 $iyzico = $formObjectGenerate->generateOption($customerCart,$this->affiliate); 232 224 } else { 233 $iyzico = $formObjectGenerate->generateOptionPwi($customerCart, $language,$getOrder,$apiKey,$this->affiliate);225 $iyzico = $formObjectGenerate->generateOptionPwi($customerCart,$this->affiliate); 234 226 } 235 227 … … 237 229 $iyzico->shippingAddress = $formObjectGenerate->generateShippingAddress($getOrder); 238 230 $iyzico->billingAddress = $formObjectGenerate->generateBillingAddress($getOrder); 239 $iyzico->basketItems = $formObjectGenerate->generateBasketItems($customerCart, $getOrder);240 241 if ($payMethod != "pwi") {231 $iyzico->basketItems = $formObjectGenerate->generateBasketItems($customerCart,$getOrder); 232 233 if($payMethod != "pwi") { 242 234 $orderObject = $pkiBuilder->createFormObjectSort($iyzico); 243 235 } else { … … 247 239 $pkiString = $pkiBuilder->pkiStringGenerate($orderObject); 248 240 249 $authorizationData = $pkiBuilder->authorizationGenerate($pkiString, $apiKey,$secretKey,$rand);250 251 $iyzicoJson = json_encode($iyzico, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);252 253 254 255 256 if ($payMethod != "pwi") {257 $requestResponse = $iyzicoRequest->iyzicoCheckoutFormRequest($baseUrl, $iyzicoJson,$authorizationData);241 $authorizationData = $pkiBuilder->authorizationGenerate($pkiString,$rand); 242 243 $iyzicoJson = json_encode($iyzico,JSON_UNESCAPED_UNICODE); 244 245 246 247 248 if($payMethod != "pwi") { 249 $requestResponse = $iyzicoRequest->iyzicoCheckoutFormRequest($baseUrl,$authorizationData); 258 250 } else { 259 251 260 $requestResponse = $iyzicoRequest->iyzicoPwiRequest($baseUrl, $iyzicoJson,$authorizationData);252 $requestResponse = $iyzicoRequest->iyzicoPwiRequest($baseUrl,$authorizationData); 261 253 262 254 return $requestResponse->payWithIyzicoPageUrl; … … 264 256 265 257 $className = $this->get_option('form_class'); 266 $message = '<p id="infoBox" style="display:none;">' . $this->settings['payment_checkout_value']. '</p>';258 $message = '<p id="infoBox" style="display:none;">' .. '</p>'; 267 259 268 260 269 261 echo '<script>jQuery(window).on("load", function(){document.getElementById("loadingBar").style.display="none",document.getElementById("infoBox").style.display="block",document.getElementById("iyzipay-checkout-form").style.display="block"});</script>'; 270 262 271 if (isset($requestResponse->status)) {272 if ($requestResponse->status == 'success') {263 if(isset($requestResponse->status)) { 264 if($requestResponse->status == 'success') { 273 265 echo $message; 274 echo ' <div style="display:none" id="iyzipay-checkout-form" class='.$className.'>' . $requestResponse->checkoutFormContent . '</div>'; 275 echo '<p style="display:none;" id="iyziVersion">'.$this->iyziV.'</p>'; 266 267 echo ' <div style="display:none" id="iyzipay-checkout-form" class=' . $className . '>' . $requestResponse->checkoutFormContent . '</div>'; 268 echo '<p style="display:none;" id="iyziVersion">' . $this->iyziV . '</p>'; 276 269 } else { 277 270 echo $requestResponse->errorMessage; 278 271 } 279 280 272 } else { 281 273 echo 'Not Connection...'; 282 274 } 283 284 } 285 286 public function iyzico_response($webhook = null, $webhookPaymentConversationId = null, $webhookToken = null, $webhookIyziEventType = null){275 } 276 277 public function iyzico_response($webhook = null, $webhookPaymentConversationId = null, $webhookToken = null, $webhookIyziEventType = null) 278 { 287 279 288 280 global $woocommerce; 289 281 290 291 282 try { 292 if(!isset($_POST['token']) && $webhook != 'webhook') 293 { 294 exit; 295 } 296 if(!isset($webhookToken) && $webhook == 'webhook') 297 { 298 exit; 299 } 283 if (!isset($_POST['token']) && $webhook != 'webhook') { 284 exit; 285 } 286 if (!isset($webhookToken) && $webhook == 'webhook') { 287 exit; 288 } 300 289 301 290 $token = $_POST['token']; … … 303 292 $secretKey = $this->settings['secret_key']; 304 293 $baseUrl = $this->settings['api_type']; 305 $rand = rand(1, 99999);294 $rand = rand(1,99999); 306 295 $conversationId = ""; 307 296 308 if ($webhook == 'webhook') {297 if ($webhook == 'webhook'){ 309 298 $token = $webhookToken; 310 299 $conversationId = $webhookPaymentConversationId; … … 312 301 313 302 314 $iyziModel = new Iyzico_Checkout_For_WooCommerce_Model();303 $iyziModel = new Iyzico_Checkout_For_WooCommerce_Model(); 315 304 316 305 $responseObjectGenerate = new Iyzico_Checkout_For_WooCommerce_ResponseObjectGenerate(); … … 318 307 $iyzicoRequest = new Iyzico_Checkout_For_WooCommerce_iyzicoRequest(); 319 308 320 $tokenDetailObject = $responseObjectGenerate->generateTokenDetailObject($conversationId, $token);309 $tokenDetailObject = $responseObjectGenerate->generateTokenDetailObject($conversationId,$token); 321 310 $pkiString = $pkiBuilder->pkiStringGenerate($tokenDetailObject); 322 $authorizationData = $pkiBuilder->authorizationGenerate($pkiString,$apiKey,$secretKey,$rand); 323 $tokenDetailObject = json_encode($tokenDetailObject,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); 324 $requestResponse = $iyzicoRequest->iyzicoCheckoutFormDetailRequest($baseUrl,$tokenDetailObject,$authorizationData); 325 326 if(!isset($requestResponse->basketId)) 327 { 328 exit; 329 } 311 $authorizationData = $pkiBuilder->authorizationGenerate($pkiString, $apiKey, $secretKey, $rand); 312 $tokenDetailObject = json_encode($tokenDetailObject, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); 313 $requestResponse = $iyzicoRequest->iyzicoCheckoutFormDetailRequest($baseUrl, $tokenDetailObject, $authorizationData); 314 315 if (!isset($requestResponse->basketId)) { 316 exit; 317 } 330 318 $order = new WC_Order($requestResponse->basketId); 331 319 … … 333 321 334 322 335 if ($webhook == 'webhook' && $requestResponse->status == 'failure'){ 336 return new WP_Error( $requestResponse->errorCode, $requestResponse->errorMessage, array( 'status' => 404 ) ); 337 } 338 339 if($webhook == 'webhook') 340 { 341 if($webhookIyziEventType == 'CREDIT_PAYMENT_PENDING' && $requestResponse->paymentStatus == 'PENDING_CREDIT') 342 { 343 $orderMessage = 'Alışveriş kredisi başvurusu sürecindedir.'; 344 $order->add_order_note($orderMessage,0,true); 345 $order->update_status("on-hold"); 323 if ($webhook == 'webhook' && $requestResponse->status == 'failure') { 324 return new WP_Error($requestResponse->errorCode, $requestResponse->errorMessage, array('status' => 404)); 325 } 326 327 if ($webhook == 'webhook') { 328 if ($webhookIyziEventType == 'CREDIT_PAYMENT_PENDING' && $requestResponse->paymentStatus == 'PENDING_CREDIT') { 329 $orderMessage = 'Alışveriş kredisi başvurusu sürecindedir.'; 330 $order->add_order_note($orderMessage, 0, true); 331 $order->update_status("on-hold"); 332 return http_response_code(200); 333 } 334 if ($webhookIyziEventType == 'CREDIT_PAYMENT_AUTH' && $requestResponse->status == 'success') { 335 $orderMessage = 'Alışveriş kredisi işlemi başarıyla tamamlandı.'; 336 $order->add_order_note($orderMessage, 0, true); 337 $order->update_status("processing"); 338 return http_response_code(200); 339 } 340 if ($webhookIyziEventType == 'CREDIT_PAYMENT_INIT' && $requestResponse->status == 'INIT_CREDIT') { 341 $orderMessage = 'Alışveriş kredisi işlemi başlatıldı.'; 342 $order->add_order_note($orderMessage, 0, true); 343 $order->update_status("on-hold"); 344 return http_response_code(200); 345 } 346 } 347 348 if ($webhook == 'webhook' && $order->get_status() == 'processing') { 346 349 return http_response_code(200); 347 } 348 if($webhookIyziEventType == 'CREDIT_PAYMENT_AUTH' && $requestResponse->status == 'success') 349 { 350 $orderMessage = 'Alışveriş kredisi işlemi başarıyla tamamlandı.'; 351 $order->add_order_note($orderMessage,0,true); 352 $order->update_status("processing"); 353 return http_response_code(200); 354 } 355 if($webhookIyziEventType =='CREDIT_PAYMENT_INIT' && $requestResponse->status == 'INIT_CREDIT') 356 { 357 $orderMessage = 'Alışveriş kredisi işlemi başlatıldı.'; 358 $order->add_order_note($orderMessage,0,true); 359 $order->update_status("on-hold"); 360 return http_response_code(200); 361 } 362 363 364 } 365 366 if ($webhook == 'webhook' && $order->get_status() == 'processing'){ 367 return http_response_code(200); 368 } 369 370 if(!$order->get_payment_method_title()) { 350 } 351 352 if (!$order->get_payment_method_title()) { 371 353 $order->set_payment_method_title("iyzico ile Öde"); 372 354 } 373 355 374 if ($requestResponse->paymentStatus == 'INIT_BANK_TRANSFER' && $requestResponse->status == 'success') {356 if($requestResponse->paymentStatus == 'INIT_BANK_TRANSFER' && $requestResponse->status == 'success') { 375 357 376 358 $order->update_status("on-hold"); 377 359 $orderMessage = 'iyzico Banka havalesi/EFT ödemesi bekleniyor.'; 378 $order->add_order_note($orderMessage, 0,true);360 $order->add_order_note($orderMessage,true); 379 361 $woocommerce->cart->empty_cart(); 380 update_option('iyzico_thank_you', 0);362 update_option('iyzico_thank_you',0); 381 363 $checkoutOrderUrl = $order->get_checkout_order_received_url(); 382 364 $redirectUrl = add_query_arg(array('msg' => 'Thank You', 'type' => 'woocommerce-message'), $checkoutOrderUrl); … … 384 366 } 385 367 $thankYouPage = get_option('iyzico_thank_you'); 386 if(!$thankYouPage) 387 { 388 add_option('iyzico_thank_you',0,'','no'); 389 } 390 if($webhook != 'webhook' && $requestResponse->paymentStatus == 'PENDING_CREDIT' && $requestResponse->status == 'success') { 368 if (!$thankYouPage) { 369 add_option('iyzico_thank_you', 0, '', 'no'); 370 } 371 if ($webhook != 'webhook' && $requestResponse->paymentStatus == 'PENDING_CREDIT' && $requestResponse->status == 'success') { 391 372 392 373 $order->update_status("on-hold"); 393 $orderMessage = 'PAYMENT ID:' .$requestResponse->paymentId;394 $order->add_order_note($orderMessage, 0,true);374 $orderMessage = 'PAYMENT ID:'$requestResponse->paymentId; 375 $order->add_order_note($orderMessage,true); 395 376 $woocommerce->cart->empty_cart(); 396 377 $checkoutOrderUrl = $order->get_checkout_order_received_url(); 397 update_option('iyzico_thank_you', 1);398 $redirectUrl = add_query_arg(array('msg' => 'Thank You', 'type' => 'woocommerce-message' ), $checkoutOrderUrl);378 update_option('iyzico_thank_you',1); 379 $redirectUrl = add_query_arg(array('msg' => 'Thank You', 'type' => 'woocommerce-message'); 399 380 return wp_redirect($redirectUrl); 400 381 } … … 414 395 415 396 416 if ($requestResponse->paymentStatus != 'SUCCESS' || $requestResponse->status != 'success' || $orderId != $requestResponse->basketId) {417 418 if ($requestResponse->status == 'success' && $requestResponse->paymentStatus == 'FAILURE') {397 if) { 398 399 if($requestResponse->status == 'success' && $requestResponse->paymentStatus == 'FAILURE') { 419 400 420 401 throw new \Exception(__("3D security has not been validated for your card.", 'woocommerce-iyzico')); 421 422 402 } 423 403 /* Redirect Error */ … … 428 408 429 409 /* Save Card */ 430 if(isset($requestResponse->cardUserKey)) { 431 432 if($customerId) { 433 434 $cardUserKey = $iyziModel->findUserCardKey($customerId,$apiKey); 435 436 if($requestResponse->cardUserKey != $cardUserKey) { 437 438 $insertCardUserKey = $iyziModel->insertCardUserKey($customerId,$requestResponse->cardUserKey,$apiKey); 439 410 if (isset($requestResponse->cardUserKey)) { 411 412 if ($customerId) { 413 414 $cardUserKey = $iyziModel->findUserCardKey($customerId, $apiKey); 415 416 if ($requestResponse->cardUserKey != $cardUserKey) { 417 418 $insertCardUserKey = $iyziModel->insertCardUserKey($customerId, $requestResponse->cardUserKey, $apiKey); 440 419 } 441 442 420 } 443 444 } 445 446 447 448 $orderMessage = 'PAYMENT ID:'.$requestResponse->paymentId; 449 $order->add_order_note($orderMessage,0,true); 450 451 if($baseUrl == 'https://sandbox-api.iyzipay.com') { 421 } 422 423 $orderMessage = 'PAYMENT ID:' . $requestResponse->paymentId; 424 $order->add_order_note($orderMessage, 0, true); 425 426 if ($baseUrl == 'https://sandbox-api.iyzipay.com') { 452 427 453 428 $orderMessage = '<strong><p style="color:red">TEST ÖDEMESİ</a></strong>'; 454 $order->add_order_note($orderMessage, 0,true);429 $order->add_order_note($orderMessage,true); 455 430 } 456 431 … … 463 438 464 439 $item_fee = new WC_Order_Item_Fee(); 465 $item_fee->set_name($requestResponse->installment . " " . __("Installment Commission", 'woocommerce-iyzico'));440 $item_fee->set_name($requestResponse->installment . " " .__("Installment Commission", 'woocommerce-iyzico')); 466 441 $item_fee->set_amount($installment_fee); 467 $item_fee->set_tax_class( '');468 $item_fee->set_tax_status( 'none');442 $item_fee->set_tax_class(); 443 $item_fee->set_tax_status(); 469 444 $item_fee->set_total($installment_fee); 470 445 471 $order->add_item( $item_fee);446 $order->add_item(); 472 447 $order->calculate_totals(true); 473 448 474 update_post_meta($orderId, 'iyzico_no_of_installment', $requestResponse->installment);449 update_post_meta($orderId, 'iyzico_no_of_installment',$requestResponse->installment); 475 450 update_post_meta($orderId, 'iyzico_installment_fee', $installment_fee); 476 451 } … … 482 457 $orderStatus = $this->settings['order_status']; 483 458 484 if ($orderStatus != 'default' && !empty($orderStatus)) {459 if($orderStatus != 'default' && !empty($orderStatus)) { 485 460 $order->update_status($orderStatus); 486 461 } 487 462 488 463 489 if ($webhook == 'webhook'){464 if{ 490 465 return http_response_code(200); 491 466 } 492 467 493 468 $woocommerce->cart->empty_cart(); 494 update_option('iyzico_thank_you', 0);469 update_option('iyzico_thank_you',0); 495 470 496 471 $checkoutOrderUrl = $order->get_checkout_order_received_url(); 497 $redirectUrl = add_query_arg(array('msg' => 'Thank You', 'type' => 'woocommerce-message' 472 $redirectUrl = add_query_arg(array('msg' => 'Thank You', 'type' => 'woocommerce-message'), $checkoutOrderUrl); 498 473 499 474 500 475 501 476 return wp_redirect($redirectUrl); 502 503 477 } catch (Exception $e) { 504 478 505 if ($webhook == 'webhook') {506 return new WP_Error( $requestResponse->errorCode, $requestResponse->errorMessage, array( 'status' => 404 ));479 if ($webhook == 'webhook'){ 480 return new WP_Error(); 507 481 } 508 482 … … 510 484 $order = new WC_Order($orderId); 511 485 $order->update_status('failed'); 512 $order->add_order_note($respMsg, 0,true);486 $order->add_order_note($respMsg,true); 513 487 514 488 wc_add_notice(__($respMsg, 'woocommerce-message'), 'error'); … … 517 491 return wp_redirect($redirectUrl); 518 492 } 519 520 493 } 521 494 522 495 523 496 /*ThankYou Page Edit */ 524 public function thankYouSubtitle() { 525 $thankYouPage = get_option('iyzico_thank_you'); 526 527 if($thankYouPage == 1) 528 { 529 $thankYouPageText = 'Alışveriş Kredisi için başvurunuz alınmıştır. Başvurunuz, en kısa sürede sonuçlandırılacaktır.'; 530 531 $sh = '<h4><center>'.$thankYouPageText.'</center></h4><br></br>'; 532 $sh .='<div class="tx_account"></div>'; 533 534 echo $sh; 535 536 } 537 538 } 539 540 public function initIyzicoWebhookUrl() { 497 public function thankYouSubtitle() 498 { 499 $thankYouPage = get_option('iyzico_thank_you'); 500 501 if ($thankYouPage == 1) { 502 $thankYouPageText = 'Alışveriş Kredisi için başvurunuz alınmıştır. Başvurunuz, en kısa sürede sonuçlandırılacaktır.'; 503 504 $sh = '<h4><center>' . $thankYouPageText . '</center></h4><br></br>'; 505 $sh .= '<div class="tx_account"></div>'; 506 507 echo $sh; 508 } 509 } 510 511 public function initIyzicoWebhookUrl() 512 { 541 513 542 514 $initInstallWebhookUrl = get_option('init_active_webhook_url'); 543 if (!$initInstallWebhookUrl){544 545 add_option('init_active_webhook_url', 0,'','no');515 if{ 516 517 add_option('init_active_webhook_url','no'); 546 518 } 547 519 548 520 return self::initSetWebhookUrlKey(); 549 } 550 551 552 /*Set Webhook request */ 553 public function initSetWebhookUrlKey() { 554 555 $initInstallWebhookUrl = get_option('init_active_webhook_url'); 556 $iyzicoWebhookUrlKey = IyzicoWebhook::getIyziUrlId(); 557 if($initInstallWebhookUrl == 0) 558 { 559 if(isset($this->settings['api_key']) && isset($this->settings['secret_key']) && isset($iyzicoWebhookUrlKey) && isset($_SERVER['HTTPS'])) 560 { 561 562 $pkiBuilder = new Iyzico_Checkout_For_WooCommerce_PkiBuilder(); 563 $iyzicoRequest = new Iyzico_Checkout_For_WooCommerce_iyzicoRequest(); 564 565 $apiKey = $this->settings['api_key']; 566 $secretKey = $this->settings['secret_key']; 567 $baseUrl = $this->settings['api_type']; 568 $randNumer = rand(100000,99999999); 569 570 $setWebhookUrl = new stdClass(); 571 $setWebhookUrl->webhookUrl = get_site_url()."/wp-json/iyzico/v1/webhook/". IyzicoWebhook::getIyziUrlId(); 572 573 $pkiString = $pkiBuilder->pkiStringGenerate($setWebhookUrl); 574 $authorizationData = $pkiBuilder->authorizationGenerate($pkiString,$apiKey,$secretKey,$randNumer); 575 576 577 $iyzicoJson = json_encode($setWebhookUrl,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); 578 579 $requestResponseWebhook = $iyzicoRequest->iyzicoPostWebhookUrlKey($baseUrl,$iyzicoJson,$authorizationData); 580 581 582 583 if($requestResponseWebhook->merchantNotificationUpdateStatus == 'UPDATED' || $requestResponseWebhook->merchantNotificationUpdateStatus == 'CREATED') 584 { 585 update_option('init_active_webhook_url',1); 586 return true; 587 } 588 elseif ($requestResponseWebhook->merchantNotificationUpdateStatus == 'NOT_UPDATED') { 589 update_option('init_active_webhook_url',2); 590 return false; 591 } 592 else { 593 update_option('init_active_webhook_url',2); 594 } 595 } 596 } 597 return true; 598 } 599 600 /* Submit Webhook*/ 601 public static function iyzicoWebhookSubmitbutton($submitSave = null) 602 { 521 } 522 523 524 /*Set Webhook request */ 525 public function initSetWebhookUrlKey() 526 { 527 603 528 $initInstallWebhookUrl = get_option('init_active_webhook_url'); 604 if($initInstallWebhookUrl == 2) 605 { 606 if($submitSave == 'submit') 607 { 608 return update_option('init_active_webhook_url',0); 609 } 610 611 } 612 613 } 614 615 616 private function versionCheck() { 529 $iyzicoWebhookUrlKey = IyzicoWebhook::getIyziUrlId(); 530 if ($initInstallWebhookUrl == 0) { 531 if (isset($this->settings['api_key']) && isset($this->settings['secret_key']) && isset($iyzicoWebhookUrlKey) && isset($_SERVER['HTTPS'])) { 532 533 $pkiBuilder = new Iyzico_Checkout_For_WooCommerce_PkiBuilder(); 534 $iyzicoRequest = new Iyzico_Checkout_For_WooCommerce_iyzicoRequest(); 535 536 $apiKey = $this->settings['api_key']; 537 $secretKey = $this->settings['secret_key']; 538 $baseUrl = $this->settings['api_type']; 539 $randNumer = rand(100000, 99999999); 540 541 $setWebhookUrl = new stdClass(); 542 $setWebhookUrl->webhookUrl = get_site_url() . "/wp-json/iyzico/v1/webhook/" . IyzicoWebhook::getIyziUrlId(); 543 544 $pkiString = $pkiBuilder->pkiStringGenerate($setWebhookUrl); 545 $authorizationData = $pkiBuilder->authorizationGenerate($pkiString, $apiKey, $secretKey, $randNumer); 546 547 548 $iyzicoJson = json_encode($setWebhookUrl, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); 549 550 $requestResponseWebhook = $iyzicoRequest->iyzicoPostWebhookUrlKey($baseUrl, $iyzicoJson, $authorizationData); 551 552 553 554 if ($requestResponseWebhook->merchantNotificationUpdateStatus == 'UPDATED' || $requestResponseWebhook->merchantNotificationUpdateStatus == 'CREATED') { 555 update_option('init_active_webhook_url', 1); 556 return true; 557 } elseif ($requestResponseWebhook->merchantNotificationUpdateStatus == 'NOT_UPDATED') { 558 update_option('init_active_webhook_url', 2); 559 return false; 560 } else { 561 update_option('init_active_webhook_url', 2); 562 } 563 } 564 } 565 return true; 566 } 567 568 /* Submit Webhook*/ 569 public static function iyzicoWebhookSubmitbutton($submitSave = null) 570 { 571 $initInstallWebhookUrl = get_option('init_active_webhook_url'); 572 if ($initInstallWebhookUrl == 2) { 573 if ($submitSave == 'submit') { 574 return update_option('init_active_webhook_url', 0); 575 } 576 } 577 } 578 579 public function is_available() 580 { 581 return true; 582 } 583 584 585 private function versionCheck() 586 { 617 587 618 588 $phpVersion = phpversion(); … … 623 593 /* Required PHP */ 624 594 $warningMessage = 'Required PHP 5.4 and greater for iyzico WooCommerce Payment Gateway'; 625 if ($locale == 'tr') {595 if($locale == 'tr') { 626 596 $warningMessage = 'iyzico WooCommerce eklentisini çalıştırabilmek için, PHP 5.4 veya üzeri versiyonları kullanmanız gerekmektedir. '; 627 597 } 628 598 629 if ($phpVersion < $requiredPhpVersion) {599 if($phpVersion < $requiredPhpVersion) { 630 600 echo $warningMessage; 631 601 exit; … … 638 608 $warningMessage = 'Required WooCommerce 3.0 and greater for iyzico WooCommerce Payment Gateway'; 639 609 640 if ($locale == 'tr') {610 if($locale == 'tr') { 641 611 $warningMessage = 'iyzico WooCommerce eklentisini çalıştırabilmek için, WooCommerce 3.0 veya üzeri versiyonları kullanmanız gerekmektedir. '; 642 612 } 643 613 644 if ($wooCommerceVersion < $requiredWoocommerceVersion) {614 if($wooCommerceVersion < $requiredWoocommerceVersion) { 645 615 echo $warningMessage; 646 616 exit; … … 651 621 $tlsVersion = get_option('iyziTLS'); 652 622 653 if (!$tlsVersion) {623 if(!$tlsVersion) { 654 624 655 625 $result = $this->verifyTLS($tlsUrl); 656 if ($result) {657 add_option('iyziTLS', 1.2,'','no');626 if($result) { 627 add_option('iyziTLS','no'); 658 628 $tlsVersion = get_option('iyziTLS'); 659 629 } 660 661 } elseif($tlsVersion != 1.2) { 630 } elseif ($tlsVersion != 1.2) { 662 631 663 632 $result = $this->verifyTLS($tlsUrl); 664 if ($result) {665 update_option('iyziTLS', 1.2);633 if($result) { 634 update_option('iyziTLS',1.2); 666 635 $tlsVersion = get_option('iyziTLS'); 667 636 } … … 673 642 $warningMessage = 'WARNING! Minimum TLS v1.2 will be supported after March 2018. Please upgrade your openssl version to minimum 1.0.1.'; 674 643 675 if ($locale == 'tr') {644 if($locale == 'tr') { 676 645 $warningMessage = "UYARI! Ödeme formunuzu görüntüleyebilmeniz için, TLS versiyonunuzun minimum TLS v1.2 olması gerekmektedir. Lütfen servis sağlayıcınız ile görüşerek openssl versiyonunuzu minimum 1.0.1'e yükseltin."; 677 646 } 678 647 679 if ($tlsVersion < $requiredTlsVersion) {648 if($tlsVersion < $requiredTlsVersion) { 680 649 echo $warningMessage; 681 650 exit; … … 683 652 } 684 653 685 private function verifyTLS($url) { 654 private function verifyTLS($url) 655 { 686 656 687 657 $curl = curl_init(); -
iyzico-woocommerce/trunk/library/iyzico-pwi-for-woocommerce-gateway.php
r2893353 r3036107 10 10 11 11 $this->id = 'iyzico_pwi'; 12 $this->iyziV = ' 1.0.5';12 $this->iyziV = ''; 13 13 $this->method_title = __('Pay with iyzico', 'woocommerce-iyzico'); 14 14 $this->method_description = __('Best Payment Solution', 'woocommerce-iyzico'); … … 135 135 echo $html; 136 136 } 137 138 139 140 141 137 142 } -
iyzico-woocommerce/trunk/readme.txt
r2934987 r3036107 1 1 === iyzico WooCommerce === 2 2 Contributors: iyzico,mehmetselim,sozgat,feyzullahdemir 3 Tags: payment, ecommerce, credit card,checkout woocommerce,iyzico,wordpress ecommerce4 Tested up to: 6. 2.25 Stable tag: 3. 2.63 Tags: payment, ecommerce,wordpress ecommerce 4 Tested up to: 6. 5 Stable tag: 3. 6 6 Requires at least: 4.7 7 7 Requires PHP: 5.4 … … 58 58 59 59 == Changelog == 60 61 62 63 60 64 61 65 = 3.2.6 = -
iyzico-woocommerce/trunk/woocommerce-gateway-iyzico.php
r2934987 r3036107 1 1 <?php 2 2 3 /** 3 4 * Plugin Name: iyzico WooCommerce … … 6 7 * Author: iyzico 7 8 * Author URI: https://iyzico.com 8 * Version: 3. 2.69 * Version: 3. 9 10 * Text Domain: iyzico WooCommerce 10 11 * Domain Path: /i18n/languages/ 11 12 * WC requires at least: 3.0.0 12 * WC tested up to: 7.8.013 * WC tested up to: 13 14 */ 14 define('IYZICO_PATH',untrailingslashit( plugin_dir_path( __FILE__ ))); 15 define('IYZICO_LANG_PATH',plugin_basename(dirname(__FILE__)) . '/i18n/languages/'); 16 define('IYZICO_PLUGIN_NAME','/'.plugin_basename(dirname(__FILE__))); 15 16 use Automattic\WooCommerce\Utilities\FeaturesUtil; 17 18 define('IYZICO_PATH', untrailingslashit(plugin_dir_path(__FILE__))); 19 define('IYZICO_LANG_PATH', plugin_basename(dirname(__FILE__)) . '/i18n/languages/'); 20 define('IYZICO_PLUGIN_NAME', '/' . plugin_basename(dirname(__FILE__))); 17 21 define('IYZICO_WEBHOOK_URL_KEY', 'iyzicoWebhookUrlKey'); 18 22 … … 20 24 exit; 21 25 } 22 if ( ! class_exists( 'Iyzico_For_WooCommerce' ) ) { 23 24 class Iyzico_For_WooCommerce { 26 if (!class_exists('Iyzico_For_WooCommerce')) { 27 28 class Iyzico_For_WooCommerce 29 { 25 30 26 31 public static $webhookUrlValue; 27 32 protected static $instance; 28 33 29 public static function get_instance() { 30 31 if ( null === self::$instance ) { 34 public static function get_instance() 35 { 36 37 if (null === self::$instance) { 32 38 self::$instance = new self(); 33 39 } … … 36 42 } 37 43 38 protected function __construct() { 39 40 add_action('plugins_loaded', array($this,'init')); 41 42 } 43 44 public static function IyzicoActive() { 44 protected function __construct() 45 { 46 add_action('plugins_loaded', array($this, 'init')); 47 // Blocks Support 48 add_action('woocommerce_blocks_loaded', array($this, 'iyzico_woocommerce_blocks_support')); 49 add_action('before_woocommerce_init', array($this, 'iyzico_cart_checkout_blocks_compatibility')); 50 } 51 52 public static function IyzicoActive() 53 { 45 54 46 55 global $wpdb; … … 59 68 ) $charset_collate;"; 60 69 61 require_once( ABSPATH . 'wp-admin/includes/upgrade.php');70 require_once(); 62 71 dbDelta($sql); 63 72 … … 72 81 ) $charset_collate;"; 73 82 dbDelta($sql); 74 75 76 } 77 78 public static function IyzicoDeactive() { 83 } 84 85 public static function IyzicoDeactive() 86 { 79 87 80 88 global $wpdb; … … 96 104 } 97 105 98 public static function paymentIdAlterTable(){ 99 global $wpdb; 100 $table = $wpdb->prefix . 'iyzico_order'; 101 $sql = "ALTER TABLE `{$table}` 106 public static function paymentIdAlterTable() 107 { 108 global $wpdb; 109 $table = $wpdb->prefix . 'iyzico_order'; 110 $sql = "ALTER TABLE `{$table}` 102 111 MODIFY COLUMN `payment_id` bigint(11) NOT NULL;"; 103 require_once( ABSPATH . 'wp-admin/includes/upgrade.php');104 $query_result = $wpdb->query( $sql);105 } 106 107 public function init() {108 112 ); 113 ); 114 } 115 116 public function init() 117 { 109 118 $this->InitIyzicoPaymentGateway(); 110 119 self::createIyzicoWebhookUrlKey(); 111 120 self::paymentIdAlterTable(); 112 113 114 } 115 116 117 public static function installLanguage() { 118 119 load_plugin_textdomain('woocommerce-iyzico',false,IYZICO_LANG_PATH); 120 121 } 122 123 public function InitIyzicoPaymentGateway() { 124 125 if ( ! class_exists('WC_Payment_Gateway')) { 121 } 122 123 124 /** 125 * 126 * @since 3.2.0 127 * @version 1.0.0 128 * action: before_woocommerce_init 129 * 130 */ 131 public function iyzico_cart_checkout_blocks_compatibility() 132 { 133 if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) { 134 FeaturesUtil::declare_compatibility('cart_checkout_blocks', __FILE__, true); 135 } 136 } 137 138 /** 139 * 140 * @since 3.2.0 141 * @version 1.0.0 142 * action: woocommerce_blocks_loaded 143 * 144 */ 145 public function iyzico_woocommerce_blocks_support() 146 { 147 if (!class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) { 148 return; 149 } 150 151 include_once IYZICO_PATH . '/library/iyzico-for-woocommerce-blocks.php'; 152 153 add_action( 154 'woocommerce_blocks_payment_method_type_registration', 155 function (Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry) { 156 $payment_method_registry->register(new Iyzico_For_WooCommerce_Blocks); 157 } 158 ); 159 } 160 161 162 163 public static function installLanguage() 164 { 165 166 load_plugin_textdomain('woocommerce-iyzico', false, IYZICO_LANG_PATH); 167 } 168 169 public function InitIyzicoPaymentGateway() 170 { 171 172 if (!class_exists('WC_Payment_Gateway')) { 126 173 return; 127 174 } … … 141 188 include_once IYZICO_PATH . '/library/iyzico-pwi-for-woocommerce-gateway-fields.php'; 142 189 143 add_action( 'rest_api_init', array('IyzicoWebhook','iyzicoRegisterRestRoutes') ); 144 145 add_filter('woocommerce_payment_gateways',array($this,'AddIyzicoGateway')); 146 147 add_action( 'wp_footer', 148 array('Iyzico_Checkout_For_WooCommerce_Buyer_Protection', 149 'iyzicoOverlayScriptMobileCss') ); 150 151 152 153 154 add_action('wp_footer', 155 array('Iyzico_Checkout_For_WooCommerce_Buyer_Protection', 156 'getOverlayScript')); 157 158 add_action('woocommerce_admin_order_data_after_shipping_address', 159 array('Iyzico_Checkout_For_WooCommerce_Buyer_Protection', 160 'iyziCargoTracking')); 161 162 add_action('woocommerce_process_shop_order_meta', 163 array('Iyzico_Checkout_For_WooCommerce_Buyer_Protection', 164 'iyziCargoTrackingSave')); 165 166 if (is_admin()){ 167 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 168 array($this, 169 'actionLinks' ) ); 170 } 171 } 172 173 public function AddIyzicoGateway($methods) { 190 add_action('rest_api_init', array('IyzicoWebhook', 'iyzicoRegisterRestRoutes')); 191 192 add_filter('woocommerce_payment_gateways', array($this, 'AddIyzicoGateway')); 193 194 add_action( 195 'wp_footer', 196 array( 197 'Iyzico_Checkout_For_WooCommerce_Buyer_Protection', 198 'iyzicoOverlayScriptMobileCss' 199 ) 200 ); 201 202 add_action( 203 'wp_footer', 204 array( 205 'Iyzico_Checkout_For_WooCommerce_Buyer_Protection', 206 'getOverlayScript' 207 ) 208 ); 209 210 add_action( 211 'woocommerce_admin_order_data_after_shipping_address', 212 array( 213 'Iyzico_Checkout_For_WooCommerce_Buyer_Protection', 214 'iyziCargoTracking' 215 ) 216 ); 217 218 add_action( 219 'woocommerce_process_shop_order_meta', 220 array( 221 'Iyzico_Checkout_For_WooCommerce_Buyer_Protection', 222 'iyziCargoTrackingSave' 223 ) 224 ); 225 226 if (is_admin()) { 227 add_filter( 228 'plugin_action_links_' . plugin_basename(__FILE__), 229 array( 230 $this, 231 'actionLinks' 232 ) 233 ); 234 } 235 } 236 237 public function AddIyzicoGateway($methods) 238 { 174 239 175 240 $methods[] = 'Iyzico_Checkout_For_WooCommerce_Gateway'; … … 187 252 * @return array 188 253 */ 189 public function actionLinks( $links ) { 254 public function actionLinks($links) 255 { 190 256 $custom_links = array(); 191 $custom_links[] = '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=iyzico' ) . '">' . __( 'Settings', 'woocommerce') . '</a>';192 $custom_links[] = '<a target="_blank" href="https://dev.iyzipay.com/tr/acik-kaynak/woocommerce">' . __( 'Docs', 'woocommerce') . '</a>';193 $custom_links[] = '<a target="_blank" href="https://www.iyzico.com/destek/iletisim">' . __( 'Support', 'woocommerce-iyzico') . '</a>';194 return array_merge( $custom_links, $links);257 $custom_links[] = '<a href="' . admin_url() . '</a>'; 258 $custom_links[] = '<a target="_blank" href="https://dev.iyzipay.com/tr/acik-kaynak/woocommerce">' . __() . '</a>'; 259 $custom_links[] = '<a target="_blank" href="https://www.iyzico.com/destek/iletisim">' . __() . '</a>'; 260 return array_merge(); 195 261 } 196 262 … … 201 267 * @since 3.1.0 202 268 */ 203 private function createIyzicoWebhookUrlKey(){ 204 $uniqueUrlId = substr(base64_encode(time() . mt_rand()),15,6); 269 private function createIyzicoWebhookUrlKey() 270 { 271 $uniqueUrlId = substr(base64_encode(time() . mt_rand()), 15, 6); 205 272 $iyziUrlId = get_option(IYZICO_WEBHOOK_URL_KEY); 206 if (!$iyziUrlId){ 207 add_option(IYZICO_WEBHOOK_URL_KEY, $uniqueUrlId , '' ,'no'); 208 } 209 210 } 211 212 273 if (!$iyziUrlId) { 274 add_option(IYZICO_WEBHOOK_URL_KEY, $uniqueUrlId, '', 'no'); 275 } 276 } 213 277 } 214 278 215 Iyzico_For_WooCommerce::get_instance(); 216 add_action('plugins_loaded',array('Iyzico_For_WooCommerce','installLanguage')); 217 add_action( 'before_woocommerce_init', function() { 218 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 219 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 220 } 221 } ); 222 register_activation_hook(__FILE__, array('Iyzico_For_WooCommerce','IyzicoActive')); 223 register_deactivation_hook(__FILE__,array('Iyzico_For_WooCommerce','IyzicoDeactive')); 279 Iyzico_For_WooCommerce::get_instance(); 280 add_action('plugins_loaded', array('Iyzico_For_WooCommerce', 'installLanguage')); 281 register_activation_hook(__FILE__, array('Iyzico_For_WooCommerce', 'IyzicoActive')); 282 register_deactivation_hook(__FILE__, array('Iyzico_For_WooCommerce', 'IyzicoDeactive')); 224 283 }
Note: See TracChangeset
for help on using the changeset viewer.