Skip to content

Commit

Permalink
Merge pull request #20 from mehmetselim/master
Browse files Browse the repository at this point in the history
Plug-In Update
  • Loading branch information
mehmetselim authored Feb 13, 2019
2 parents ea36174 + 375f02c commit 1eba12c
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 37 deletions.
Binary file modified i18n/languages/woocommerce-iyzico-en_US.mo
Binary file not shown.
90 changes: 69 additions & 21 deletions i18n/languages/woocommerce-iyzico-en_US.po
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
msgid ""
msgsen ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
Expand All @@ -10,65 +10,113 @@ msgsen ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.11\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"Language: en_US\n"
"Language: tr_TR\n"

# This file is distributed under the GNU General Public License v2 or later.
msgid "Api Type"
msgsen "Api Type"
msgstr "Api Type"

msgid "Api Key"
msgsen "Api Key"
msgstr "Api Key"

msgid "Secret Key"
msgsen "Secret Key"
msgstr "Secret Key"

msgid "Payment Value"
msgsen "Payment Value"
msgstr "Payment Value""

msgid "Payment Value Message"
msgstr "Online Payment"
msgstr "Payment Value Message"

msgid "Payment Form Description Value"
msgsen "Payment Form Description Value"
msgstr "Payment Form Description Value""

msgid "Enable/Disable"
msgsen "Enable/Disable"
msgstr "Enable/Disable"

msgid "Enable iyzico checkout"
msgsen "Enable iyzico checkout"
msgstr "Enable iyzico checkout"

msgid "Payment Form Design"
msgsen "Payment Form Design"
msgstr "Payment Form Design"


msgid "Left"
msgsen "Bottom Left"
msgstr "Bottom Left"

msgid "Right"
msgsen "Bottom Right"
msgstr "Bottom Right"

msgid "Hide"
msgsen "Hide"
msgstr "Hide"

msgid "Overlay Script"
msgsen "Overlay Script"
msgstr "Overlay Script"


msgid "Installment"
msgsen "Installment"
msgstr "Installment"

msgid "Installment Fee"
msgsen "Installment Fee"
msgstr "Installment Fee"

msgid "This message will show to the user during checkout."
msgsen "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."
msgsen "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."
msgsen "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"
msgsen "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"
Binary file modified i18n/languages/woocommerce-iyzico-tr_TR.mo
Binary file not shown.
18 changes: 16 additions & 2 deletions i18n/languages/woocommerce-iyzico-tr_TR.po
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ msgstr "iyzico ile ödemeyi etkinleştir"
msgid "Payment Form Design"
msgstr "Ödeme Formu Görünümü"


msgid "Left"
msgstr "Alt Sol"

Expand Down Expand Up @@ -104,4 +103,19 @@ msgid "Refunded"
msgstr "İade Edildi"

msgid "Failed"
msgstr "Başarısız"
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ı"
152 changes: 149 additions & 3 deletions library/iyzico-for-woocommerce-buyer-protection.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,157 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit;
}

class Iyzico_Checkout_For_WooCommerce_Buyer_Protection {

public function getOverlayScript() {
public static function iyziCargoTracking($order) {

$orderId = (int) $order->get_id();

$cargoCodeValue = 'iyzico_cargo_no_'.$orderId;
$cargoNameValue = 'iyzico_cargo_name_'.$orderId;

$cargoTrackingNumber = get_option($cargoCodeValue);
$cargoNumber = get_option($cargoNameValue);
$currentOrderStatus = $order->get_status();
$orderStatusArray = array('processing','on-hold','completed');
$orderStatus = in_array($currentOrderStatus,$orderStatusArray);
$paymentMethod = $order->get_payment_method();
$protectedControl = get_option('iyzico_overlay_token');

/* Payment Gateways */
$gateway_controller = WC_Payment_Gateways::instance();
$all_gateways = $gateway_controller->payment_gateways();
$iyzico = $all_gateways['iyzico']->settings;
$apiType = $iyzico['api_type'];

if($apiType == 'https://sandbox-api.iyzipay.com') {
$protectedControl = true;
}

/* Cargo Object */
$cargoArray = array(array('name' => 'MNG Kargo', 'value' => 1),
array('name' => 'Aras Kargo', 'value' => 4),
array('name' => 'Yurtiçi Kargo', 'value' => 6),
array('name' => 'UPS Kargo', 'value' => 10),
array('name' => 'Sürat Kargo', 'value' => 15)
);


foreach ($cargoArray as $key => $cargo) {

$cargoObject[$key] = new stdClass();
$cargoObject[$key]->name = $cargo['name'];
$cargoObject[$key]->value = $cargo['value'];
}

$pluginUrl = plugins_url().IYZICO_PLUGIN_NAME;
?>
<?php if($protectedControl && $orderStatus && $paymentMethod == 'iyzico'): ?>


<h3><?php echo __('iyzico Protected Shopping, Shipping Tracking', 'woocommerce-iyzico'); ?></h3>
<p><?php echo __('By entering the shipping tracking number of this order, you can ensure your customer have real time order tracking.', 'woocommerce-iyzico'); ?></p>
<p style="font-weight:bold;margin-bottom:0px !important;"><?php echo __('Shipping Company', 'woocommerce-iyzico'); ?></p>
<select name="cargoNumber" style="width: 80%;">
<option value=""><?php echo __('Select', 'woocommerce-iyzico'); ?></option>
<?php foreach ($cargoObject as $key => $cargo): ?>
<option value="<?php echo $cargo->value; ?>" <?php if($cargo->value == (int) $cargoNumber) { echo 'selected';}?>>
<?php echo $cargo->name; ?>
</option>
<?php endforeach; ?>
</select>
<p style="font-weight:bold;margin-bottom:0px !important;"><?php echo __('Shipping Tracking Number', 'woocommerce-iyzico'); ?></p>
<input type="text" style="width: 80%;" name="cargoTrackingNumber" value="<?php echo $cargoTrackingNumber; ?>" placeholder="<?php echo __('Shipping Tracking Number', 'woocommerce-iyzico'); ?>" />
<?php endif; ?>
<?php
}

public static function iyziCargoTrackingSave($order_id) {

$orderId = (int) $order_id;

$cargoNumber = esc_sql($_POST['cargoNumber']);
$cargoTrackingNumber = esc_sql($_POST['cargoTrackingNumber']);
$createOrUpdateControl = false;

/* Empty Post Control */
if(empty($cargoNumber) || empty($cargoTrackingNumber)) {

return;
}

$cargoTrackingField = 'iyzico_cargo_no_'.$orderId;
$cargoNumberField = 'iyzico_cargo_name_'.$orderId;
$cargoTrackingOption = get_option($cargoTrackingField);
$cargoNumberOption = get_option($cargoNumberField);


/* Sleeping Data Control */
if($cargoNumber == $cargoNumberOption && $cargoTrackingNumber == $cargoTrackingOption) {

return;
}

if(!empty($cargoNumberOption) && !empty($cargoTrackingOption)) {

$createOrUpdateControl = true;
}

$gateway_controller = WC_Payment_Gateways::instance();
$all_gateways = $gateway_controller->payment_gateways();
$iyzico = $all_gateways['iyzico']->settings;

$apiKey = $iyzico['api_key'];
$secretKey = $iyzico['secret_key'];
$randNumer = rand(1,99999);

$iyziModel = new Iyzico_Checkout_For_WooCommerce_Model();
$paymentId = $iyziModel->findPaymentId($orderId);

/* Post iyzico */
$formObjectGenerate = new Iyzico_Checkout_For_WooCommerce_FormObjectGenerate();
$pkiBuilder = new Iyzico_Checkout_For_WooCommerce_PkiBuilder();
$iyzicoRequest = new Iyzico_Checkout_For_WooCommerce_iyzicoRequest();
$baseUrl = $iyzico['api_type'];

if($baseUrl == 'https://api.iyzipay.com') {
$baseUrl = 'https://iyziup.iyzipay.com';
}

$cargoObject = $formObjectGenerate->generateCargoTracking($cargoTrackingNumber,$paymentId,$cargoNumber);
$pkiString = $pkiBuilder->pkiStringGenerate($cargoObject);
$authorizationData = $pkiBuilder->authorizationGenerate($pkiString,$apiKey,$secretKey,$randNumer);


$iyzicoJson = json_encode($cargoObject,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
$requestResponse = $iyzicoRequest->iyzicoCargoTracking($baseUrl,$iyzicoJson,$authorizationData);

if(isset($requestResponse->status)) {

if($requestResponse->status == 'success') {

if(empty($createOrUpdateControl)) {

add_option($cargoNumberField,$cargoNumber,'','yes');
add_option($cargoTrackingField,$cargoTrackingNumber,'','yes');

} else {

update_option($cargoNumberField,$cargoNumber);
update_option($cargoTrackingField,$cargoTrackingNumber);
}

} else {

return;
}
}

}

public static function getOverlayScript() {

$token = get_option('iyzico_overlay_token');
$position = get_option('iyzico_overlay_position');
Expand All @@ -24,4 +170,4 @@ public function getOverlayScript() {
echo $overlayScript;
}

}
}
2 changes: 1 addition & 1 deletion library/iyzico-for-woocommerce-gateway-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function iyzicoAdminFields() {
'default' => 'popup',
'options' =>
array(
'https://api.iyzipay.com' => __('Live', 'iyzico-checkout-for-woocommerce'),
'https://api.iyzipay.com' => __('Live', 'woocommerce-iyzico'),
'https://sandbox-api.iyzipay.com' => __('Sandbox / Test', 'woocommerce-iyzico')
)),
'api_key' => array(
Expand Down
13 changes: 12 additions & 1 deletion library/iyzico-for-woocommerce-gateway-formobjectgenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function generateOption($items,$data,$apiKey) {
$iyzico->forceThreeDS = "0";
$iyzico->callbackUrl = add_query_arg('wc-api', 'WC_Gateway_Iyzico', $data->get_checkout_order_received_url());
$iyzico->cardUserKey = $iyziModel->findUserCardKey($user->ID,$apiKey);
$iyzico->paymentSource = 'WOOCOMMERCE|'.WOOCOMMERCE_VERSION.'|CARRERA-1.1.1';
$iyzico->paymentSource = 'WOOCOMMERCE|'.WOOCOMMERCE_VERSION.'|CARRERA-1.1.3';


return $iyzico;
Expand Down Expand Up @@ -158,4 +158,15 @@ public function oneProductCalc($order) {

return $basketItems;
}

public function generateCargoTracking($trackingNumber,$paymentId,$shippingCompanyId) {

$cargoObject = new stdClass();

$cargoObject->trackingNumber = $trackingNumber;
$cargoObject->paymentId = $paymentId;
$cargoObject->shippingCompanyId = $shippingCompanyId;

return $cargoObject;
}
}
Loading

0 comments on commit 1eba12c

Please sign in to comment.