diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..cfd0b5d Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..9913083 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# iyzico Subscription - WooCommerce Payment Gateway +------------ +* Create live account at https://merchant.iyzipay.com +* Create test account at https://sandbox-merchant.iyzipay.com + + +# Requirements +------------ +* PHP 5.4 and greater. +* cURL +* WooCommerce 2.0 requires WordPress 3.5+ + + +# Installation +--------------- +* Click "clone or download" and Download ZIP then Install with wordpress extension installer page +* Wordpress Marketplace in search "iyzico-subscription-woocommerce" and install + +* Detailed Info + + +# Notes +--------------- +* Developed and Tested on vanilla Wordpress + WooCommerce Installation diff --git a/i18n/.DS_Store b/i18n/.DS_Store new file mode 100644 index 0000000..ea6f39e Binary files /dev/null and b/i18n/.DS_Store differ diff --git a/i18n/languages/.DS_Store b/i18n/languages/.DS_Store new file mode 100644 index 0000000..b0419b5 Binary files /dev/null and b/i18n/languages/.DS_Store differ diff --git a/i18n/languages/woocommerce-iyzico-subscription-en_US.mo b/i18n/languages/woocommerce-iyzico-subscription-en_US.mo new file mode 100644 index 0000000..53e2b33 Binary files /dev/null and b/i18n/languages/woocommerce-iyzico-subscription-en_US.mo differ diff --git a/i18n/languages/woocommerce-iyzico-subscription-en_US.po b/i18n/languages/woocommerce-iyzico-subscription-en_US.po new file mode 100644 index 0000000..3c524c2 --- /dev/null +++ b/i18n/languages/woocommerce-iyzico-subscription-en_US.po @@ -0,0 +1,145 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2022-04-27 08:19+0000\n" +"PO-Revision-Date: 2022-04-27 08:20+0000\n" +"Last-Translator: \n" +"Language-Team: English (United States)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Loco https://localise.biz/\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"Language: en_US\n" +"Report-Msgid-Bugs-To: \n" +"X-Loco-Version: 2.6.1; wp-5.9.3" + +# This file is distributed under the GNU General Public License v2 or later. +msgid "Api Type" +msgstr "Api Type" + +msgid "Api Key" +msgstr "Api Key" + +msgid "Secret Key" +msgstr "Secret Key" + +msgid "Payment Value" +msgstr "Payment Value\"" + +msgid "Payment Value Message" +msgstr "Payment Value Message" + +msgid "Payment Form Description Value" +msgstr "Payment Form Description Value\"" + +msgid "Enable/Disable" +msgstr "Enable/Disable" + +msgid "Enable iyzico checkout" +msgstr "Enable iyzico checkout" + +msgid "Payment Form Design" +msgstr "Payment Form Design" + +msgid "Left" +msgstr "Bottom Left" + +msgid "Right" +msgstr "Bottom Right" + +msgid "Hide" +msgstr "Hide" + +msgid "Overlay Script" +msgstr "Overlay Script" + +msgid "Installment" +msgstr "Installment" + +msgid "Installment Fee" +msgstr "Installment Fee" + +msgid "This message will show to the user during checkout." +msgstr "This message will show to the user during checkout." + +msgid "Pay with your credit card via iyzico." +msgstr "Pay with your credit card via iyzico." + +msgid "" +"Thank you for your order, please click the button below to pay with iyzico " +"Checkout." +msgstr "" +"Thank you for your order, please click the button below to pay with iyzico " +"Checkout." + +msgid "Pay With Card" +msgstr "Pay with Credit/Bank Card" + +msgid "Order Status" +msgstr "Order Status" + +msgid "Recommended, Default" +msgstr "Recommended, Default" + +msgid "Siparişi onayla" +msgstr "Pay with Credit/Bank Card" + +msgid "Default" +msgstr "Default" + +msgid "Pending" +msgstr "Pending" + +msgid "Processing" +msgstr "Processing" + +msgid "On-Hold" +msgstr "On-Hold" + +msgid "Completed" +msgstr "Completed" + +msgid "Cancelled" +msgstr "Cancelled" + +msgid "Refunded" +msgstr "Refunded" + +msgid "Failed" +msgstr "Failed" + +msgid "iyzico Protected Shopping, Shipping Tracking" +msgstr "iyzico Protected Shopping, Shipping Tracking" + +msgid "" +"By entering the shipping tracking number of this order, you can ensure your " +"customer have real time order tracking." +msgstr "" +"By entering the shipping tracking number of this order, you can ensure your " +"customer have real time order tracking." + +msgid "Select" +msgstr "Select" + +msgid "Shipping Company" +msgstr "Shipping Company" + +msgid "Shipping Tracking Number" +msgstr "Shipping Tracking Number" + +msgid "" +"The iyzico subscription API provides the opportunity to quickly create " +"subscriptions to merchants that can receive online payments." +msgstr "" +"The iyzico subscription API provides the opportunity to quickly create " +"subscriptions to merchants that can receive online payments ." + +msgid "Amount Withdrawn" +msgstr "Amount Withdrawn" + +msgid "Thank you for your order, please enter your card information in the payment form below to pay with iyzico checkout." +msgstr "Thank you for your order, please enter your card information in the payment form below to pay with iyzico checkout." + +msgid "Thank you for your order, please click the button below to pay with iyzico checkout." +msgstr "Thank you for your order, please click the button below to pay with iyzico checkout." diff --git a/i18n/languages/woocommerce-iyzico-subscription-tr_TR.mo b/i18n/languages/woocommerce-iyzico-subscription-tr_TR.mo new file mode 100644 index 0000000..f864fb0 Binary files /dev/null and b/i18n/languages/woocommerce-iyzico-subscription-tr_TR.mo differ diff --git a/i18n/languages/woocommerce-iyzico-subscription-tr_TR.po b/i18n/languages/woocommerce-iyzico-subscription-tr_TR.po new file mode 100644 index 0000000..8c469fe --- /dev/null +++ b/i18n/languages/woocommerce-iyzico-subscription-tr_TR.po @@ -0,0 +1,163 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2022-04-27 07:49+0000\n" +"PO-Revision-Date: 2022-05-12 06:58+0000\n" +"Last-Translator: \n" +"Language-Team: Türkçe\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Loco https://localise.biz/\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"Language: tr_TR\n" +"Report-Msgid-Bugs-To: \n" +"X-Loco-Version: 2.6.1; wp-6.1-alpha-53391" + +# This file is distributed under the GNU General Public License v2 or later. +msgid "Api Type" +msgstr "Api Türü" + +msgid "Api Key" +msgstr "Api Anahtarı" + +msgid "Secret Key" +msgstr "Güvenlik Anahtarı" + +msgid "Payment Value" +msgstr "Ödeme Seçeneği Metni" + +msgid "Payment Value Message" +msgstr "Online Payment" + +msgid "Payment Form Description Value" +msgstr "Ödeme Seçeneği Açıklaması" + +msgid "Enable/Disable" +msgstr "Eklenti Durumu" + +msgid "Enable iyzico checkout" +msgstr "iyzico ile ödemeyi etkinleştir" + +msgid "Payment Form Design" +msgstr "Ödeme Formu Görünümü" + +msgid "Left" +msgstr "Alt Sol" + +msgid "Right" +msgstr "Alt Sağ" + +msgid "Hide" +msgstr "Gizli" + +msgid "Overlay Script" +msgstr "Korumalı Alışveriş" + +msgid "Installment" +msgstr "Taksit" + +msgid "Installment Fee" +msgstr "Taksit Tutarı" + +msgid "This message will show to the user during checkout." +msgstr "Bu mesaj ödeme sırasında kullanıcıya gösterecektir." + +msgid "Pay with your credit card via iyzico." +msgstr "Kredi Kartı - iyzico" + +msgid "" +"Thank you for your order, please click the button below to pay with iyzico " +"Checkout." +msgstr "" +"Siparişiniz için teşekkür ederiz, iyzico ile ödemek için aşağıdaki düğmeyi " +"tıklayın." + +msgid "Pay With Card" +msgstr "Kredi/Banka Kartı ile Öde" + +msgid "Order Status" +msgstr "Sipariş Durumu" + +msgid "Recommended, Default" +msgstr "Önerilen, Varsayılan" + +msgid "Siparişi onayla" +msgstr "Kredi/Banka Kartı ile Öde" + +msgid "Default" +msgstr "Varsayılan" + +msgid "Pending" +msgstr "Ödeme Bekleniyor" + +msgid "Processing" +msgstr "İşleniyor" + +msgid "On-Hold" +msgstr "Beklemede" + +msgid "Completed" +msgstr "Tamamlandı" + +msgid "Cancelled" +msgstr "İptal Edildi" + +msgid "Refunded" +msgstr "İade Edildi" + +msgid "Failed" +msgstr "Başarısız" + +msgid "iyzico Protected Shopping, Shipping Tracking" +msgstr "iyzico Korumalı Alışveriş, Kargo Takibi" + +msgid "" +"By entering the shipping tracking number of this order, you can ensure your " +"customer have real time order tracking." +msgstr "" +"Siparişin kargo takip numarasını girerek, müşterinizin anlık kargo takibi " +"yapmasını sağlayabilirsiniz." + +msgid "Select" +msgstr "Seçiniz" + +msgid "Shipping Company" +msgstr "Kargo Firması" + +msgid "Shipping Tracking Number" +msgstr "Kargo Takip Numarası" + +msgid "" +"The iyzico subscription API provides the opportunity to quickly create " +"subscriptions to merchants that can receive online payments." +msgstr "" +"iyzico subscription API, online ödeme alabilen üye işyerlerine hızlıca " +"abonelik oluşturma imkanı sağlar" + +msgid "iyzico Subscription Pay" +msgstr "iyzico Woocommerce Abonelik" + +msgid "" +"* Do not forget to add the reference code to the Product > Edit > " +"Pricing Plan Code section." +msgstr "" +" * Ürün > Düzenle > Pricing Plan Code bölümüne referans kodu eklemeyi " +"unutmayınız." + +msgid "Amount Withdrawn" +msgstr "Çekilen Abonelik Tutarı" + +msgid "" +"Thank you for your order, please enter your card information in the payment " +"form below to pay with iyzico checkout." +msgstr "" +"Siparişiniz için teşekkür ederiz, iyzico ile ödemek için aşağıdaki ödeme " +"formu alanına kart bilgilerinizi girebilirsiniz." + +msgid "" +"Thank you for your order, please click the button below to pay with iyzico " +"checkout." +msgstr "" +"Siparişiniz için teşekkür ederiz, iyzico ile ödemek için Ödeme Formunu Aç " +"butonuna tıklayarak kart bilgilerinizi girebilirsiniz." diff --git a/image/.DS_Store b/image/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/image/.DS_Store differ diff --git a/image/cards.png b/image/cards.png new file mode 100644 index 0000000..e5a8d90 Binary files /dev/null and b/image/cards.png differ diff --git a/image/iyzico_logo.png b/image/iyzico_logo.png new file mode 100644 index 0000000..007a285 Binary files /dev/null and b/image/iyzico_logo.png differ diff --git a/image/newcards.png b/image/newcards.png new file mode 100644 index 0000000..e5a8d90 Binary files /dev/null and b/image/newcards.png differ diff --git a/image/zihni.png b/image/zihni.png new file mode 100644 index 0000000..e47b951 Binary files /dev/null and b/image/zihni.png differ diff --git a/library/.DS_Store b/library/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/library/.DS_Store differ diff --git a/library/index.php b/library/index.php new file mode 100644 index 0000000..9962ee8 --- /dev/null +++ b/library/index.php @@ -0,0 +1,254 @@ + + + + + + +
+ + +
+ +
+
+

Günlük Cari Rapor

+ +
+ + +
+
+
+
+ + + + +
+ +
+
+

qSQL("SELECT SUM(products_price) as sales_total FROM sales INNER JOIN products ON products.products_id=sales.products_id WHERE DAY(sales_date)=DAY(CURDATE())"); + $sales_total=$sql->fetch(PDO::FETCH_ASSOC); + echo number_format($sales_total=$sales_total['sales_total']); + ?> ₺

+ +

Toplam Satış

+
+
+ +
+
+
+ + + + +
+ +
+
+

qSQL("SELECT SUM(operation_price) as revenue FROM operation WHERE operation.operation_type='Gelir' AND DAY(operation_date)=DAY(CURDATE()) "); + $revenue=$sql->fetch(PDO::FETCH_ASSOC); + echo number_format($revenue=$revenue['revenue']); + ?> ₺

+ +

Toplam Gelir (Tahsilat)

+
+
+ +
+
+
+ + + +
+ +
+
+

qSQL("SELECT SUM(operation_price) as revenue FROM operation WHERE operation.operation_type='Gider' AND DAY(operation_date)=DAY(CURDATE()) "); + $revenue=$sql->fetch(PDO::FETCH_ASSOC); + echo number_format($revenue=$revenue['revenue']); + ?> ₺

+ +

Toplam Gider

+
+
+ +
+
+
+ + + +
+ +
+
+

qSQL(" + SELECT SUM( + CASE WHEN operation_type='Gelir' THEN operation_price ELSE 0 END + )-SUM( + CASE WHEN operation_type='Gider' THEN operation_price ELSE 0 END + ) as safe FROM operation WHERE DAY(operation_date)=DAY(CURDATE()) + "); + $rows=$sql->fetch(PDO::FETCH_ASSOC); + echo number_format($rows['safe']); + ?> ₺

+ +

Kasa

+
+
+ +
+
+
+ + + + + +
+
+ + + +
+ + + +
+
+

Genel Cari Rapor

+ +
+ + +
+
+
+
+ + + + +
+ +
+
+

qSQL("SELECT SUM(products_price) as sales_total FROM sales INNER JOIN products ON products.products_id=sales.products_id"); + $sales_total=$sql->fetch(PDO::FETCH_ASSOC); + echo number_format($sales_total=$sales_total['sales_total']); + ?> ₺

+ +

Toplam Satış

+
+
+ +
+
+
+ + + + +
+ +
+
+

qSQL("SELECT SUM(operation_price) as revenue FROM operation WHERE operation.operation_type='Gelir' "); + $revenue=$sql->fetch(PDO::FETCH_ASSOC); + echo number_format($revenue=$revenue['revenue']); + ?> ₺

+ +

Toplam Gelir (Tahsilat)

+
+
+ +
+
+
+ + + +
+ +
+
+

qSQL("SELECT SUM(operation_price) as revenue FROM operation WHERE operation.operation_type='Gider' "); + $revenue=$sql->fetch(PDO::FETCH_ASSOC); + echo number_format($revenue=$revenue['revenue']); + ?> ₺

+ +

Toplam Gider

+
+
+ +
+
+
+ + + +
+ +
+
+

qSQL(" + SELECT SUM( + CASE WHEN operation_type='Gelir' THEN operation_price ELSE 0 END + )-SUM( + CASE WHEN operation_type='Gider' THEN operation_price ELSE 0 END + ) as safe FROM operation + "); + $rows=$sql->fetch(PDO::FETCH_ASSOC); + echo number_format($rows['safe']); + ?> ₺

+ +

Kasa

+
+
+ +
+
+
+ + + + + +
+
+ + + +
+ + +
+ +
+ + + diff --git a/library/iyzico-subscription-for-woocommerce-gateway-authorization.php b/library/iyzico-subscription-for-woocommerce-gateway-authorization.php new file mode 100644 index 0000000..23d8ec6 --- /dev/null +++ b/library/iyzico-subscription-for-woocommerce-gateway-authorization.php @@ -0,0 +1,51 @@ +getHmacSHA256Signature($uri, $secretKey, $randomString, $request); + + $hashStr = base64_encode($hashStr); + + $hashStr = "IYZWSv2 ".$hashStr; + + $authorization_data = array( + 'authorization' => $hashStr, + 'rand_value' => $randomString + ); + + return $authorization_data; + + } + + private function getHmacSHA256Signature($uri, $secretKey, $randomString, $request = null) + { + $dataToEncrypt = $randomString . $this->getPayload($uri, $request); + + $hash = hash_hmac('sha256', $dataToEncrypt, $secretKey, true); + $token = bin2hex($hash); + + return $token; + } + + private function getPayload($uri, $request = null) + { + + $startNumber = strpos($uri, '/v2'); + $endNumber = strpos($uri, '?'); + $endNumber-= $startNumber; + + $uriPath = substr($uri, $startNumber, $endNumber); + + if (!empty($request) && $request != '[]') + $uriPath = $uriPath.$request; + + return $uriPath; + } + +} \ No newline at end of file diff --git a/library/iyzico-subscription-for-woocommerce-gateway-fields.php b/library/iyzico-subscription-for-woocommerce-gateway-fields.php new file mode 100644 index 0000000..7d42e57 --- /dev/null +++ b/library/iyzico-subscription-for-woocommerce-gateway-fields.php @@ -0,0 +1,77 @@ + array( + 'description' => __('* Do not forget to add the reference code to the Product > Edit > Pricing Plan Code section.' ,'woocommerce-iyzico-subscription' ), + 'type' => 'title' + ), + 'api_type' => array( + 'title' => __('Api Type', 'woocommerce-iyzico-subscription'), + 'type' => 'select', + 'required' => true, + 'default' => 'popup', + 'options' => + array( + 'https://api.iyzipay.com' => __('Live', 'woocommerce-iyzico-subscription'), + 'https://sandbox-api.iyzipay.com' => __('Sandbox / Test', 'woocommerce-iyzico-subscription') + )), + 'api_key' => array( + 'title' => __('Api Key', 'woocommerce-iyzico-subscription'), + 'type' => 'text' + ), + 'secret_key' => array( + 'title' => __('Secret Key', 'woocommerce-iyzico-subscription'), + 'type' => 'text' + ), + 'title' => array( + 'title' => __('Payment Value', 'woocommerce-iyzico-subscription'), + 'type' => 'text', + 'description' => __('This message will show to the user during checkout.', 'woocommerce-iyzico-subscription'), + 'default' => __('Online Payment - iyzico Subscription', 'woocommerce-iyzico-subscription') + ), + 'description' => array( + 'title' => __('Payment Form Description Value', 'woocommerce-iyzico-subscription'), + 'type' => 'text', + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-iyzico-subscription'), + 'default' => __('Pay with your credit card via iyzico.', 'woocommerce-iyzico-subscription'), + 'desc_tip' => true, + ), + 'form_class' => array( + 'title' => __('Payment Form Design', 'woocommerce-iyzico-subscription'), + 'type' => 'select', + 'default' => 'popup', + 'options' => array('responsive' => __('Responsive', 'woocommerce-iyzico-subscription'), 'popup' => __('Popup', 'woocommerce-iyzico-subscription')) + ), + + 'order_status' => array( + 'title' => __('Order Status', 'woocommerce-iyzico-subscription'), + 'type' => 'select', + 'description' => __('Recommended, Default', 'woocommerce-iyzico-subscription'), + 'default' => 'default', + 'options' => array('default' => __('Default', 'woocommerce-iyzico-subscription'), + 'pending' => __('Pending', 'woocommerce-iyzico-subscription'), + 'processing' => __('Processing', 'woocommerce-iyzico-subscription'), + 'on-hold' => __('On-Hold', 'woocommerce-iyzico-subscription'), + 'completed' => __('Completed', 'woocommerce-iyzico-subscription'), + 'cancelled' => __('Cancelled', 'woocommerce-iyzico-subscription'), + 'refunded' => __('Refunded', 'woocommerce-iyzico-subscription'), + 'failed' => __('Failed', 'woocommerce-iyzico-subscription')) + ), + + 'enabled' => array( + 'title' => __('Enable/Disable', 'woocommerce-iyzico-subscription'), + 'label' => __('Enable iyzico checkout', 'woocommerce-iyzico-subscription'), + 'type' => 'checkbox', + 'default' => 'yes' + ), + ); + } +} diff --git a/library/iyzico-subscription-for-woocommerce-gateway-formobjectgenerate.php b/library/iyzico-subscription-for-woocommerce-gateway-formobjectgenerate.php new file mode 100644 index 0000000..1dc0da9 --- /dev/null +++ b/library/iyzico-subscription-for-woocommerce-gateway-formobjectgenerate.php @@ -0,0 +1,92 @@ +helper = new Iyzico_Subscription_For_WooCommerce_Helper(); + } + + + public function subscripotionObjectGenerate($orderData,$customerCart) { + + $product_id = 0; + $customerCartCheck = count($customerCart); + /* Quantity Check */ + + if($customerCartCheck == 1) { + foreach ($customerCart as $key => $cart) { + + if($cart['quantity'] > 1) { + echo 'Birden fazla ürün ile abonelik başlatamazsınız.'; + exit; + } + $product_id = $cart['product_id']; + } + } else { + + echo 'Birden fazla ürün ile abonelik başlatamazsınız.'; + exit; + } + + $pricingPlanCode = 'pricing_plan_code_'.$product_id; + $pricingPlanCodeOption = get_option($pricingPlanCode); + + + $subscriptionObject = new stdClass(); + $subscriptionObject->callbackUrl = add_query_arg('wc-api', 'WC_Gateway_Iyzico', $orderData->get_checkout_order_received_url()); + $subscriptionObject->locale = $this->helper->cutLocale(get_locale()); + $subscriptionObject->conversationId = $orderData->get_id(); + $subscriptionObject->subscriptionInitialStatus = "ACTIVE"; + $subscriptionObject->pricingPlanReferenceCode = $pricingPlanCodeOption; + + return $subscriptionObject; + + } + + + public function subscriptionCustomerObjectGenerate($orderData) { + + $subscriptionCustomerObject = new stdClass(); + + $subscriptionCustomerObject->name = $this->helper->dataCheck($orderData->get_billing_first_name()); + $subscriptionCustomerObject->surname = $this->helper->dataCheck($orderData->get_billing_last_name()); + $subscriptionCustomerObject->email = $this->helper->dataCheck($orderData->get_billing_email()); + $subscriptionCustomerObject->gsmNumber = "+9".$this->helper->dataCheck($orderData->get_billing_phone()); + $subscriptionCustomerObject->identityNumber = "11111111111"; + + return $subscriptionCustomerObject; + } + + + public function subscriptionBillingAddressGenerate($orderData) { + + $subscriptionBilingAddressObject = new stdClass(); + + $address = $this->helper->trimString($orderData->get_billing_address_1(),$orderData->get_billing_address_2()); + + $subscriptionBilingAddressObject->address = $this->helper->dataCheck($address); + $subscriptionBilingAddressObject->zipCode = $this->helper->dataCheck($orderData->get_billing_postcode()); + $subscriptionBilingAddressObject->contactName = $this->helper->dataCheck($orderData->get_billing_first_name().$orderData->get_billing_last_name()); + $subscriptionBilingAddressObject->city = $this->helper->dataCheck(WC()->countries->states[$orderData->get_billing_country()][$orderData->get_billing_state()]); + $subscriptionBilingAddressObject->country = $this->helper->dataCheck(WC()->countries->countries[$orderData->get_billing_country()]); + + return $subscriptionBilingAddressObject; + } + + public function generateTokenDetailObject($conversationId,$token) { + + $tokenDetail = new stdClass(); + + $tokenDetail->locale = $this->helper->cutLocale(get_locale()); + $tokenDetail->conversationId = $conversationId; + $tokenDetail->token = $token; + + return $tokenDetail; + + } +} diff --git a/library/iyzico-subscription-for-woocommerce-gateway-helper.php b/library/iyzico-subscription-for-woocommerce-gateway-helper.php new file mode 100644 index 0000000..076b0a8 --- /dev/null +++ b/library/iyzico-subscription-for-woocommerce-gateway-helper.php @@ -0,0 +1,109 @@ +get_total(); + $price = $this->priceParser($price); + + return $price; + } + + + foreach ($items as $item) { + + $productId = $item['product_id']; + $product = wc_get_product($productId); + $realPrice = $this->realPrice($product->get_sale_price(),$product->get_price()); + + + $price+= round($realPrice, 2); + + $keyNumber++; + + } + + $shipping = $data->get_total_shipping() + $data->get_shipping_tax(); + + if($shipping) { + + $price+= $shipping; + } + + $price = $this->priceParser($price); + + return $price; + + } + + public function cutLocale($locale) { + + $locale = explode('_',$locale); + $locale = $locale[0]; + + return $locale; + } + + public function priceParser($price) { + + if (strpos($price, ".") === false) { + return $price . ".0"; + } + $subStrIndex = 0; + $priceReversed = strrev($price); + for ($i = 0; $i < strlen($priceReversed); $i++) { + if (strcmp($priceReversed[$i], "0") == 0) { + $subStrIndex = $i + 1; + } else if (strcmp($priceReversed[$i], ".") == 0) { + $priceReversed = "0" . $priceReversed; + break; + } else { + break; + } + } + + return strrev(substr($priceReversed, $subStrIndex)); + } + + + public function trimString($address1,$address2) { + + $address = trim($address1)." ".trim($address2); + + return $address; + } + + + public function dataCheck($data) { + + if(!$data || $data == ' ') { + + $data = "NOT PROVIDED"; + } + + return $data; + + } + + public function realPrice($salePrice,$regularPrice) { + + if(empty($salePrice)) { + + $salePrice = $regularPrice; + } + + return $salePrice; + + } + +} \ No newline at end of file diff --git a/library/iyzico-subscription-for-woocommerce-gateway-model.php b/library/iyzico-subscription-for-woocommerce-gateway-model.php new file mode 100644 index 0000000..04523df --- /dev/null +++ b/library/iyzico-subscription-for-woocommerce-gateway-model.php @@ -0,0 +1,62 @@ +database = $GLOBALS['wpdb']; + } + + + public function addSubscription($subscription) { + + $addSubscription = $this->database->insert( + $this->database->prefix.'subscription_iyzico', + array( + 'subscription_reference_code' => $subscription->referenceCode, + 'order_id' => $subscription->orderId, + 'user_id' => $subscription->userId, + ), + array( + '%s', + '%d', + '%d' + ) + ); + + return $addSubscription; + + } + + + public function findSubscription($subscriptionReferenceCode) { + + $tableName = $this->database->prefix .'subscription_iyzico'; + + $query = $this->database->prepare(" + SELECT * FROM {$tableName} + WHERE subscription_reference_code = %s + ORDER BY subscription_iyzico_id DESC LIMIT 1; + ",$subscriptionReferenceCode + ); + + $result = $this->database->get_row($query); + + + if(isset($result->subscription_iyzico_id)) { + + return $result; + + } else { + + return ''; + } + + } + + + +} \ No newline at end of file diff --git a/library/iyzico-subscription-for-woocommerce-gateway-pkibuilder.php b/library/iyzico-subscription-for-woocommerce-gateway-pkibuilder.php new file mode 100644 index 0000000..02e2d3c --- /dev/null +++ b/library/iyzico-subscription-for-woocommerce-gateway-pkibuilder.php @@ -0,0 +1,122 @@ + $data) { + if(is_object($data)) { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + $pki_value .= $name."=["; + $end_key = count(get_object_vars($data)); + $count = 0; + foreach ($data as $key => $value) { + $count++; + $name = var_export($key, true); + $name = str_replace("'", "", $name); + $pki_value .= $name."="."".$value; + if($end_key != $count) + $pki_value .= ","; + } + $pki_value .= "]"; + } else if(is_array($data)) { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + $pki_value .= $name."=["; + $end_key = count($data); + $count = 0; + foreach ($data as $key => $result) { + $count++; + $pki_value .= "["; + + foreach ($result as $key => $item) { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + + $pki_value .= $name."="."".$item; + if(end($result) != $item) { + $pki_value .= ","; + } + if(end($result) == $item) { + if($end_key != $count) { + $pki_value .= "], "; + + } else { + $pki_value .= "]"; + } + } + } + } + if(end($data) == $result) + $pki_value .= "]"; + + } else { + $name = var_export($key, true); + $name = str_replace("'", "", $name); + + $pki_value .= $name."="."".$data.""; + } + if(end($objectData) != $data) + $pki_value .= ","; + } + $pki_value .= "]"; + return $pki_value; + } + + public function createFormObjectSort($objectData) { + + + $form_object = new stdClass(); + + $form_object->locale = $objectData->locale; + $form_object->conversationId = $objectData->conversationId; + $form_object->price = $objectData->price; + $form_object->basketId = $objectData->basketId; + $form_object->paymentGroup = $objectData->paymentGroup; + + $form_object->buyer = new stdClass(); + $form_object->buyer = $objectData->buyer; + + $form_object->shippingAddress = new stdClass(); + $form_object->shippingAddress = $objectData->shippingAddress; + + $form_object->billingAddress = new stdClass(); + $form_object->billingAddress = $objectData->billingAddress; + + foreach ($objectData->basketItems as $key => $item) { + + $form_object->basketItems[$key] = new stdClass(); + $form_object->basketItems[$key] = $item; + + } + + $form_object->callbackUrl = $objectData->callbackUrl; + $form_object->paymentSource = $objectData->paymentSource; + $form_object->currency = $objectData->currency; + $form_object->paidPrice = $objectData->paidPrice; + $form_object->forceThreeDS = $objectData->forceThreeDS; + $form_object->cardUserKey = $objectData->cardUserKey; + + return $form_object; + } + + public function authorizationGenerate($pkiString,$apiKey,$secretKey,$rand) { + + $hash_value = $apiKey.$rand.$secretKey.$pkiString; + $hash = base64_encode(sha1($hash_value,true)); + + $authorization = 'IYZWS '.$apiKey.':'.$hash; + + $authorization_data = array( + 'authorization' => $authorization, + 'rand_value' => $rand + ); + + return $authorization_data; + } + +} \ No newline at end of file diff --git a/library/iyzico-subscription-for-woocommerce-gateway-request.php b/library/iyzico-subscription-for-woocommerce-gateway-request.php new file mode 100644 index 0000000..08dafc0 --- /dev/null +++ b/library/iyzico-subscription-for-woocommerce-gateway-request.php @@ -0,0 +1,141 @@ +curlPost($json,$authorizationData,$url); + + } + + public function iyzicoSubscriptionRequest($baseUrl,$json,$authorizationData) { + + $url = $baseUrl; + + return $this->curlPostV2($json,$authorizationData,$url); + + } + + public function iyzicoSubscriptionRetrieveRequest($baseUrl,$json,$authorizationData) { + + $url = $baseUrl; + + return $this->curlGetV2($json,$authorizationData,$url); + + } + + public function iyzicoCheckoutFormDetailRequest($baseUrl,$json,$authorizationData) { + + $url = $baseUrl.'/payment/iyzipos/checkoutform/auth/ecom/detail'; + + return $this->curlPost($json,$authorizationData,$url); + + } + + + public function iyzicoOverlayScriptRequest($baseUrl,$json,$authorizationData) { + + $baseUrl = "https://iyziup.iyzipay.com/"; + $url = $baseUrl."v1/iyziup/protected/shop/detail/overlay-script"; + + + return $this->curlPost($json,$authorizationData,$url); + + } + + public function iyzicoCargoTracking($baseUrl,$json,$authorizationData) { + + $url = $baseUrl.'/v1/iyziup/create-zen-order-shipment-over-plugin-framework'; + + return $this->curlPost($json,$authorizationData,$url); + } + + public function curlPost($json,$authorizationData,$url) { + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + $content_length = 0; + if ($json) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($curl, CURLOPT_POSTFIELDS, $json); + } + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); + curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + curl_setopt($curl, CURLOPT_TIMEOUT, 150); + + curl_setopt( + $curl, CURLOPT_HTTPHEADER, array( + "Authorization: " .$authorizationData['authorization'], + "x-iyzi-rnd:".$authorizationData['rand_value'], + "Content-Type: application/json", + ) + ); + + $result = json_decode(curl_exec($curl)); + curl_close($curl); + + + + return $result; + } + + public function curlPostV2($json,$authorizationData,$url) { + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + if ($json) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($curl, CURLOPT_POSTFIELDS, $json); + } + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); + curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + curl_setopt($curl, CURLOPT_TIMEOUT, 150); + + curl_setopt( + $curl, CURLOPT_HTTPHEADER, array( + "Content-Type: application/json", + "Authorization: " .$authorizationData['authorization'], + ) + ); + + $result = json_decode(curl_exec($curl)); + curl_close($curl); + + + + return $result; + } + + public function curlGetV2($json,$authorizationData,$url) { + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); + curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + curl_setopt($curl, CURLOPT_TIMEOUT, 150); + + curl_setopt( + $curl, CURLOPT_HTTPHEADER, array( + "Content-Type: application/json", + "Authorization: " .$authorizationData['authorization'], + ) + ); + + $result = json_decode(curl_exec($curl)); + curl_close($curl); + + return $result; + } + + +} \ No newline at end of file diff --git a/library/iyzico-subscription-for-woocommerce-gateway.php b/library/iyzico-subscription-for-woocommerce-gateway.php new file mode 100644 index 0000000..eb8da37 --- /dev/null +++ b/library/iyzico-subscription-for-woocommerce-gateway.php @@ -0,0 +1,484 @@ +id = 'iyzico_subscription'; + $this->iyziV = '1.0.3'; + $this->method_title = __('iyzico Subscription Pay', 'woocommerce-iyzico-subscription'); + $this->method_description = __('The iyzico subscription API provides the opportunity to quickly create subscriptions to merchants that can receive online payments.','woocommerce-iyzico-subscription'); + $this->has_fields = true; + $this->order_button_text = __('Pay With Card', 'woocommerce-iyzico-subscription'); + + $this->has_fields = true; + $this->supports = array('products'); + + $this->init_form_fields(); + $this->init_settings(); + + + + $this->title = __($this->get_option( 'title' ),'woocommerce-iyzico-subscription'); + $this->description = __($this->get_option( 'description'),'woocommerce-iyzico-subscription'); + $this->enabled = $this->get_option( 'enabled' ); + $this->icon = plugins_url().IYZICO_PLUGIN_NAME.'/image/newcards.png'; + + + + add_action('init', array(&$this, 'iyzico_response')); + add_action('woocommerce_api_wc_gateway_iyzico', array($this, 'iyzico_response')); + + + add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( + $this, + 'process_admin_options', + ) ); + + add_action('woocommerce_receipt_iyzico_subscription', array($this, 'iyzico_subscription_form')); + + if(isset($_GET['section']) && $_GET['section'] == 'iyzico') { + + $this->valid_js(); + } + + } + + public function admin_options() { + ob_start(); + parent::admin_options(); + $parent_options = ob_get_contents(); + ob_end_clean(); + + echo $parent_options; + $pluginUrl = plugins_url().IYZICO_PLUGIN_NAME; + + $html = '

V: '.$this->iyziV.'

'; + + echo $html; + } + public function valid_js() { + wp_enqueue_script('script', plugins_url().IYZICO_PLUGIN_NAME.'/media/js/valid_api.js',true,'1.0','all'); + + } + + public function init_form_fields() { + + $this->form_fields = Iyzico_Subscription_For_WooCommerce_Fields::iyzicoAdminFields(); + + } + + + private function setcookieSameSite($name, $value, $expire, $path, $domain, $secure, $httponly) { + + if (PHP_VERSION_ID < 70300) { + + setcookie($name, $value, $expire, "$path; samesite=None", $domain, $secure, $httponly); + } + else { + setcookie($name, $value, [ + 'expires' => $expire, + 'path' => $path, + 'domain' => $domain, + 'samesite' => 'None', + 'secure' => $secure, + 'httponly' => $httponly, + ]); + + + } + } + + public function process_payment($order_id) { + + $order = wc_get_order($order_id); + + return array( + 'result' => 'success', + 'redirect' => $order->get_checkout_payment_url(true) + ); + + } + + public function iyzico_subscription_form($order_id) { + + $wooCommerceCookieKey = 'wp_woocommerce_session_'; + + foreach ($_COOKIE as $name => $value) { + if (stripos($name,$wooCommerceCookieKey) === 0) { + $wooCommerceCookieKey = $name; + } + } + $setCookie = $this->setcookieSameSite($wooCommerceCookieKey,$_COOKIE[$wooCommerceCookieKey], time() + 86400, "/", $_SERVER['SERVER_NAME'],true, true); + + $this->versionCheck(); + + global $woocommerce; + + $getOrder = new WC_Order($order_id); + $customerCart = $woocommerce->cart->get_cart(); + + $apiKey = $this->settings['api_key']; + $secretKey = $this->settings['secret_key']; + $baseUrl = $this->settings['api_type']; + $rand = uniqid(); + + + $formObjectGenerate = new Iyzico_Subscription_For_WooCommerce_FormObjectGenerate(); + $iyzicoRequest = new Iyzico_Subscription_For_WooCommerce_Request(); + $hashV2Builder = new Iyzico_Subscription_For_WooCommerce_Authorization(); + + /* V2 */ + $v2Request = new stdClass(); + $v2Request->locale = 'tr'; + + $subsUrl = $baseUrl."/v2/subscription/checkoutform/initialize?"; + + $iyzico = $formObjectGenerate->subscripotionObjectGenerate($getOrder,$customerCart); + $iyzico->customer = $formObjectGenerate->subscriptionCustomerObjectGenerate($getOrder); + $iyzico->customer->billingAddress = $formObjectGenerate->subscriptionBillingAddressGenerate($getOrder); + $iyzicoJson = json_encode($iyzico,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); + $authorizationDataV2 = $hashV2Builder->generateAuthV2Content($subsUrl,$apiKey,$secretKey,$rand,$iyzicoJson); + + $requestResponse = $iyzicoRequest->iyzicoSubscriptionRequest($subsUrl,$iyzicoJson,$authorizationDataV2); + + + $className = $this->settings['form_class']; + + if ($className == 'popup'){ + $message = __("Thank you for your order, please click the button below to pay with iyzico checkout.", 'woocommerce-iyzico-subscription') . '

'; + } + + else{ + $message = __('Thank you for your order, please enter your card information in the payment form below to pay with iyzico checkout.', 'woocommerce-iyzico-subscription') . '

'; + } + + + + echo ''; + + + if(isset($requestResponse->status)) { + if($requestResponse->status == 'success') { + echo $message; + + echo '
' . $requestResponse->checkoutFormContent . '
'; + echo ''; + } else { + echo $requestResponse->errorMessage; + } + + } else { + echo 'Not Connection...'; + } + echo $requestResponse->tokenExpireTime; + + } + + public function iyzico_response($order_id) { + + global $woocommerce; + + $token = $_POST['token']; + + $conversationId = ""; + $apiKey = $this->settings['api_key']; + $secretKey = $this->settings['secret_key']; + $baseUrl = $this->settings['api_type']; + $user = wp_get_current_user(); + $rand = rand(1,99999); + + if(!$token) { + $entityBody = file_get_contents("php://input"); + $subscriptionNotification = $this->notificationListener($entityBody,$order_id); + } + + $formObjectGenerate = new Iyzico_Subscription_For_WooCommerce_FormObjectGenerate(); + $pkiBuilder = new Iyzico_Subscription_For_WooCommerce_PkiBuilder(); + $iyzicoRequest = new Iyzico_Subscription_For_WooCommerce_Request(); + $hashV2Builder = new Iyzico_Subscription_For_WooCommerce_Authorization(); + + + $tokenDetailObject = $formObjectGenerate->generateTokenDetailObject($conversationId,$token); + $pkiString = $pkiBuilder->pkiStringGenerate($tokenDetailObject); + $authorizationData = $pkiBuilder->authorizationGenerate($pkiString,$apiKey,$secretKey,$rand); + $tokenDetailObject = json_encode($tokenDetailObject,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); + $requestResponse = $iyzicoRequest->iyzicoCheckoutFormDetailRequest($baseUrl,$tokenDetailObject,$authorizationData); + + + + + if($requestResponse->paymentStatus != 'SUCCESS' || $requestResponse->status != 'success') { + if($requestResponse->status == 'success' && $requestResponse->paymentStatus == 'FAILURE') { + throw new Exception('Kartınız için 3D güvenliği onaylanmamıştır.'); + + } + /* Redirect Error */ + $errorMessage = isset($requestResponse->errorMessage) ? $requestResponse->errorMessage : 'Failed'; + throw new \Exception($errorMessage); + } + + $paymentId = (int) $requestResponse->paymentId; + $referenceCode = esc_sql($requestResponseSubs->data->referenceCode); + $orderAwaitingPaymentId = (int) $woocommerce->session->order_awaiting_payment; + $userId = (int) $user->ID; + + $order = new WC_Order($woocommerce->session->order_awaiting_payment); + + if($baseUrl == 'https://sandbox-api.iyzipay.com') { + + $orderMessage = '

TEST SUBSCRIPTION STARTED'; + $order->add_order_note($orderMessage,0,true); + } else { + + $orderMessage = '

SUBSCRIPTION STARTED'; + $order->add_order_note($orderMessage,0,true); + + } + + $order->payment_complete(); + + /* Order Status */ + $orderStatus = $this->get_option('order_status'); + if($orderStatus != 'default' && !empty($orderStatus)) { + $order->update_status($orderStatus); + } + + + $orderMessage = 'Payment ID: '.$paymentId; + $order->add_order_note($orderMessage,0,true); + $currency = get_option('woocommerce_currency'); + + $orderMessage = __("Amount Withdrawn", 'woocommerce-iyzico-subscription').' : '.$requestResponse->price.' '.$currency.''; + $order->add_order_note($orderMessage,0,true); + + + + + + $subsRetrieveUrl = $baseUrl."/v2/subscription/checkoutform/".$token."?=locale=tr"; + $authorizationDataV2 = $hashV2Builder->generateAuthV2Content($subsRetrieveUrl,$apiKey,$secretKey,$rand,null); + $requestResponseSubs = $iyzicoRequest->iyzicoSubscriptionRetrieveRequest($subsRetrieveUrl,$tokenDetailObject,$authorizationDataV2); + + $subscriptionIyziModel = new Iyzico_Subscription_For_WooCommerce_Model(); + + $addSubsObject = new stdClass(); + $addSubsObject->referenceCode = $referenceCode; + $addSubsObject->orderId = $orderAwaitingPaymentId; + $addSubsObject->userId = $userId; + + $addSubscription = $subscriptionIyziModel->addSubscription($addSubsObject); + + $order->payment_complete(); + + $order->update_status('processing'); + + $woocommerce->cart->empty_cart(); + + $checkoutOrderUrl = $order->get_checkout_order_received_url(); + + $redirectUrl = add_query_arg(array('msg' => 'Thank You', 'type' => 'woocommerce-message'), $checkoutOrderUrl); + + wp_redirect($redirectUrl); + + } + + private function notificationListener($entityBody,$order_id) { + + $entityBody = json_decode($entityBody); + $subscriptionReferenceCode = esc_sql($entityBody->subscriptionReferenceCode); + + $subscriptionIyziModel = new Iyzico_Subscription_For_WooCommerce_Model(); + + $findSubscription = $subscriptionIyziModel->findSubscription($subscriptionReferenceCode); + + if($findSubscription->subscription_reference_code == $subscriptionReferenceCode) { + + + + echo 'SUCCESS'; + exit; + } + + echo 'FAILURE'; + exit; + } + + public static function pricingPlanMethod() { + + global $post; + $postId = (int) $post->ID; + $pricingPlanCode = 'pricing_plan_code_'.$postId; + $pricingPlanCodeOption = get_option($pricingPlanCode); + if(get_locale() == 'tr_TR') { + echo '

iyzico Abonelik

'; + ?> + + + iyzico Subscription'; + ?> + + + ID; + + if(!empty($_POST['pricingPlanReferenceCode'])) { + $pricingPlanReferenceCode = $_POST['pricingPlanReferenceCode']; + } else { + $pricingPlanReferenceCode = false; + } + + $createOrUpdateControl = false; + + + $pricingPlanReferenceCode = esc_sql($pricingPlanReferenceCode); + + $pricingPlanReferenceCodeField = 'pricing_plan_code_'.$postId; + $pricingPlanReferenceCodeOption = get_option($pricingPlanReferenceCodeField); + + /* Empty Post Control */ + if(empty($pricingPlanReferenceCode)) { + + delete_option($pricingPlanReferenceCodeField); + return; + } + + /* Sleeping Data Control */ + if($pricingPlanReferenceCode == $pricingPlanReferenceCodeOption) { + + return; + } + + if(!empty($pricingPlanReferenceCodeOption)) { + + $createOrUpdateControl = true; + } + + if(empty($createOrUpdateControl)) { + + add_option($pricingPlanReferenceCodeField,$pricingPlanReferenceCode,'','no'); + + } else { + + update_option($pricingPlanReferenceCodeField,$pricingPlanReferenceCode); + } + + return; + + } + + + private function versionCheck() { + + $phpVersion = phpversion(); + $requiredPhpVersion = 5.4; + $helper = new Iyzico_Subscription_For_WooCommerce_Helper(); + $locale = $helper->cutLocale(get_locale()); + + /* Required PHP */ + $warningMessage = 'Required PHP 5.4 and greater for iyzico WooCommerce Payment Gateway'; + if($locale == 'tr') { + $warningMessage = 'iyzico WooCommerce eklentisini çalıştırabilmek için, PHP 5.4 veya üzeri versiyonları kullanmanız gerekmektedir. '; + } + + if($phpVersion < $requiredPhpVersion) { + echo $warningMessage; + exit; + } + + /* Required WOOCOMMERCE */ + $wooCommerceVersion = WOOCOMMERCE_VERSION; + $requiredWoocommerceVersion = 3.0; + + $warningMessage = 'Required WooCommerce 3.0 and greater for iyzico WooCommerce Payment Gateway'; + + if($locale == 'tr') { + $warningMessage = 'iyzico WooCommerce eklentisini çalıştırabilmek için, WooCommerce 3.0 veya üzeri versiyonları kullanmanız gerekmektedir. '; + } + + if($wooCommerceVersion < $requiredWoocommerceVersion) { + echo $warningMessage; + exit; + } + + /* Required TLS */ + $tlsUrl = 'https://api.iyzipay.com'; + $tlsVersion = get_option('iyziTLS'); + + if(!$tlsVersion) { + + $result = $this->verifyTLS($tlsUrl); + if($result) { + add_option('iyziTLS',1.2,'','no'); + $tlsVersion = get_option('iyziTLS'); + } + + } elseif($tlsVersion != 1.2) { + + $result = $this->verifyTLS($tlsUrl); + if($result) { + update_option('iyziTLS',1.2); + $tlsVersion = get_option('iyziTLS'); + } + } + + + $requiredTlsVersion = 1.2; + + $warningMessage = 'WARNING! Minimum TLS v1.2 will be supported after March 2018. Please upgrade your openssl version to minimum 1.0.1.'; + + if($locale == 'tr') { + $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."; + } + + if($tlsVersion < $requiredTlsVersion) { + echo $warningMessage; + exit; + } + } + + private function verifyTLS($url) { + + $curl = curl_init(); + + curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $url, + )); + + $response = curl_exec($curl); + + curl_close($curl); + + return $response; + } + +} diff --git a/media/js/valid_api.js b/media/js/valid_api.js new file mode 100644 index 0000000..7b41136 --- /dev/null +++ b/media/js/valid_api.js @@ -0,0 +1 @@ +jQuery(document).ready(function(){jQuery("#mainform").submit(function(a){var e,i,r;if(e=jQuery("#woocommerce_iyzico_api_type").val(),i=jQuery("#woocommerce_iyzico_api_key").val(),r=jQuery("#woocommerce_iyzico_secret_key").val(),""!=i&&""!=r||alert("Api Key ve Secret Key Boş Bırakılamaz !"),"https://sandbox-api.iyzipay.com"==e){if("sandbox-"==i.substring(0,8))return;alert("Sandbox / Test API için Live API Anahtarları kullanılamaz !")}else if("https://api.iyzipay.com"==e){if("sandbox-"!=i.substring(0,8)&&"sandbox-"!=r.substring(0,8))return;alert("Live API için Sandbox / Test API Anahtarları kullanılamaz !")}a.preventDefault()})}); diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..726c63c --- /dev/null +++ b/readme.txt @@ -0,0 +1,72 @@ +=== iyzico Subscription WooCommerce === +Contributors: iyzico,mehmetselim,FeyzullahDemir +Tags: payment, ecommerce,credit card,checkout woocommerce,iyzico,wordpress ecommerce +Tested up to: 6.0 +Stable tag: 2.0.0 +Requires at least: 4.7 +License: LGPL v3.0 +License URI: https://www.gnu.org/licenses/lgpl-3.0.en.html + +== Description == +- This is a WooCommerce module developed by iyzico Integration team. + +- You can easily integrate iyzico WooCommerce module into your e-commerce website and start receiving payment seamlessly and securely. +Check out some of other advantages of iyzico WooCommerce Modul from below; + +- You can embed iyzico check-out form either as responsive or pop-up onto your payment screen and increase your sales conversion. + +- The module controlled by SUCURI and it is totally secure. + +- With the open source code, you can make easily make new developments on your website. + +- iyzico WooCommerce module supports SEO tools and is 100% compatible with Google. + +- You can test your website in Sandbox, one of the best test environments. + +- iyzico WooCommerce module allows you to sell with installments on your website. + +- After iyzico WooCommerce integration, with iyzico’s Buyer Protection feature you can offer your customers 24/7 live support as well as order tracking. + +- iyzico WooCommerce module is 100% compatible with WooCommerce and Wordpress systems. + +- After the integration you can offer manually created orders and payment support to your customers. + + +Requirements +PHP 5.4 and greater. +cURL +WooCommerce 3.5 requires WordPress 3.5+ + + +== Installation == +iyzico WooCommerce Plugin Download ZIP file and then Install with wordpress extension installer page + +Wordpress Marketplace in search "iyzico WooCommerce" and install + +== Screenshots == + +1. Settings Page +2. iyzico Settings Page +3. Basket Page +4. Payment Page +5. Order Result Page +6. Order List Page +7. Order Management + +== Changelog == + += 1.0.3 = + * Form Class + * On Hold + * Bug Fixed + * Wordpress update 6.0 Tested + + += 1.0.0 = + * Initial Release + + +== Upgrade Notice == + += 1.0.0 = + * Initial Release diff --git a/woocommerce-gateway-subscription-iyzico.php b/woocommerce-gateway-subscription-iyzico.php new file mode 100644 index 0000000..ccad4da --- /dev/null +++ b/woocommerce-gateway-subscription-iyzico.php @@ -0,0 +1,128 @@ +prefix . 'subscription_iyzico'; + + $charset_collate = $wpdb->get_charset_collate(); + + $sql = "CREATE TABLE $table_name ( + subscription_iyzico_id int(11) NOT NULL AUTO_INCREMENT, + subscription_reference_code varchar(45) NOT NULL, + order_id int(11) NOT NULL, + user_id int(11) NOT NULL, + created_at timestamp DEFAULT current_timestamp, + PRIMARY KEY (subscription_iyzico_id) + ) $charset_collate;"; + + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); + dbDelta($sql); + } + + public static function SubscriptionIyzicoDeactive() { + + global $wpdb; + + $table_name = $wpdb->prefix . 'subscription_iyzico'; + $charset_collate = $wpdb->get_charset_collate(); + + $sql = "DROP TABLE IF EXISTS $table_name;"; + $wpdb->query($sql); + flush_rewrite_rules(); + } + + public function init() { + + $this->InitIyzicoPaymentGateway(); + } + + + public static function installLanguage() { + + load_plugin_textdomain('woocommerce-iyzico-subscription',false,IYZICO_LANG_PATH); + + } + + public function InitIyzicoPaymentGateway() { + + if ( ! class_exists('WC_Payment_Gateway')) { + return; + } + + include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway.php'; + include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-fields.php'; + include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-formobjectgenerate.php'; + include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-helper.php'; + include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-pkibuilder.php'; + include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-authorization.php'; + include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-request.php'; + include_once IYZICO_PATH . '/library/iyzico-subscription-for-woocommerce-gateway-model.php'; + + + add_action('woocommerce_payment_gateways',array($this,'AddIyzicoSubscriptionGateway')); + + add_action('woocommerce_product_options_general_product_data', + array('Iyzico_Subscription_For_WooCommerce_Gateway', + 'pricingPlanMethod')); + + add_action('woocommerce_process_product_meta', + array('Iyzico_Subscription_For_WooCommerce_Gateway', + 'pricingPlanMethodSave')); + + } + + + public function AddIyzicoSubscriptionGateway($methods) { + + $methods[] = 'Iyzico_Subscription_For_WooCommerce_Gateway'; + return $methods; + } + + } + +Iyzico_Subscription_For_WooCommerce::get_instance(); +add_action('plugins_loaded',array('Iyzico_Subscription_For_WooCommerce','installLanguage')); +register_activation_hook(__FILE__, array('Iyzico_Subscription_For_WooCommerce','SubscriptionIyzicoActive')); +register_deactivation_hook(__FILE__,array('Iyzico_Subscription_For_WooCommerce','SubscriptionIyzicoDeactive')); +}