diff --git a/woo-doku-jokul/Common/JokulListModule.php b/woo-doku-jokul/Common/JokulListModule.php index 0190f31..4e86675 100644 --- a/woo-doku-jokul/Common/JokulListModule.php +++ b/woo-doku-jokul/Common/JokulListModule.php @@ -16,14 +16,6 @@ // Modules require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulMainModule.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulDokuVaModule.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulBsmVaModule.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulMandiriVaModule.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulBcaVaModule.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulPermataVaModule.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulAlfaO2OModule.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulCreditCardModule.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulBriVaModule.php'); require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulCheckoutModule.php'); //API End Point diff --git a/woo-doku-jokul/Form/JokulCheckoutSetting.php b/woo-doku-jokul/Form/JokulCheckoutSetting.php index 808a12f..347cdd4 100644 --- a/woo-doku-jokul/Form/JokulCheckoutSetting.php +++ b/woo-doku-jokul/Form/JokulCheckoutSetting.php @@ -39,6 +39,15 @@ 'type' => 'text', 'description' => __('Default: Merchant PAN', 'woocommerce-gateway-jokul'), 'placeholder' => '0', + ), + 'auto_redirect_jokul' => array( + 'title' => __('Auto Redirect', 'woocommerce-gateway-jokul'), + 'type' => 'select', + 'default' => 'false', + 'options' => array( + 'false' => __('FALSE', 'woocommerce-gateway-jokul'), + 'true' => __('TRUE', 'woocommerce-gateway-jokul'), + ), ) ) ); diff --git a/woo-doku-jokul/JokulMainPg.php b/woo-doku-jokul/JokulMainPg.php index b6043f4..4cdce05 100644 --- a/woo-doku-jokul/JokulMainPg.php +++ b/woo-doku-jokul/JokulMainPg.php @@ -3,7 +3,7 @@ * Plugin Name: Jokul - WooCommerce * Plugin URI: http://www.doku.com * Description: Accept payment through various payment channels with Jokul. Make it easy for your customers to purchase on your store. - * Version: 1.3.8 + * Version: 1.3.9 * Author: DOKU * Author URI: http://www.doku.com * WC requires at least: 2.2 @@ -59,14 +59,6 @@ function addJokulGateway($methods) { $mainSettings = get_option('woocommerce_jokul_gateway_settings'); $methods[] = 'JokulMainModule'; - $methods[] = 'JokulDokuVaModule'; - $methods[] = 'JokulBsmVaModule'; - $methods[] = 'JokulMandiriVaModule'; - $methods[] = 'JokulBcaVaModule'; - $methods[] = 'JokulPermataVaModule'; - $methods[] = 'JokulAlfaO2OModule'; - $methods[] = 'JokulCreditCardModule'; - $methods[] = 'JokulBriVaModule'; $methods[] = 'JokulCheckoutModule'; return $methods; diff --git a/woo-doku-jokul/Module/JokulCheckoutModule.php b/woo-doku-jokul/Module/JokulCheckoutModule.php index b8db3d2..1541e00 100644 --- a/woo-doku-jokul/Module/JokulCheckoutModule.php +++ b/woo-doku-jokul/Module/JokulCheckoutModule.php @@ -34,6 +34,7 @@ public function __construct() $paymentDescription = $this->get_option('payment_description'); $this->payment_method = $this->get_option('payment_method'); + $this->auto_redirect_jokul = $this->get_option('auto_redirect_jokul'); $this->sac_check = $mainSettings['sac_check' ]; $this->sac_textbox = $mainSettings['sac_textbox']; @@ -84,32 +85,32 @@ public function get_order_data($order) foreach ($meta->get_formatted(null) as $meta_key => $formatted_meta) { $item_meta[] = array('key' => $meta_key, 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']); } - $order_data[] = array('price' => wc_format_decimal($order->get_item_total($item, false, false), $dp), 'quantity' => wc_stock_amount($item['qty']), 'name' => preg_replace($pattern, "", $item['name']), 'sku' => $product_sku, 'category' => $categories_string); + $order_data[] = array('price' => wc_format_decimal($order->get_item_total($item, false, false), $dp), 'quantity' => wc_stock_amount($item['qty']), 'name' => preg_replace($pattern, "", $item['name']), 'sku' => $product_sku, 'category' => $categories_string, 'url' => 'https://www.doku.com/'); } // Add shipping. foreach ($order->get_shipping_methods() as $shipping_item_id => $shipping_item) { if (wc_format_decimal($shipping_item['cost'], $dp) > 0) { - $order_data[] = array('name' => preg_replace($pattern, "", $shipping_item['name']), 'price' => wc_format_decimal($shipping_item['cost'], $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized'); + $order_data[] = array('name' => preg_replace($pattern, "", $shipping_item['name']), 'price' => wc_format_decimal($shipping_item['cost'], $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized', 'url' => 'https://www.doku.com/'); } } // Add taxes. foreach ($order->get_tax_totals() as $tax_code => $tax) { if (wc_format_decimal($tax->amount, $dp) > 0) { - $order_data[] = array('name' => preg_replace($pattern, "", $tax->label), 'price' => wc_format_decimal($tax->amount, $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized'); + $order_data[] = array('name' => preg_replace($pattern, "", $tax->label), 'price' => wc_format_decimal($tax->amount, $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized', 'url' => 'https://www.doku.com/'); } } // Add fees. foreach ($order->get_fees() as $fee_item_id => $fee_item) { if (wc_format_decimal($order->get_line_total($fee_item), $dp) > 0) { - $order_data[] = array('name' => preg_replace($pattern, "", $fee_item['name']), 'price' => wc_format_decimal($order->get_line_total($fee_item), $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized'); + $order_data[] = array('name' => preg_replace($pattern, "", $fee_item['name']), 'price' => wc_format_decimal($order->get_line_total($fee_item), $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized', 'url' => 'https://www.doku.com/'); } } // Add coupons. foreach ($order->get_items('coupon') as $coupon_item_id => $coupon_item) { if (wc_format_decimal($coupon_item['discount_amount'], $dp) > 0) { - $order_data[] = array('name' => preg_replace($pattern, "", $coupon_item['name']), 'price' => wc_format_decimal($coupon_item['discount_amount'], $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized'); + $order_data[] = array('name' => preg_replace($pattern, "", $coupon_item['name']), 'price' => wc_format_decimal($coupon_item['discount_amount'], $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized', 'url' => 'https://www.doku.com/'); } } $order_data = apply_filters('woocommerce_cli_order_data', $order_data); @@ -126,19 +127,19 @@ public function process_payment($order_id) $order_data = $order->get_data(); $params = array( - 'customerId' => 0 !== $order->get_customer_id() ? $order->get_customer_id() : preg_replace('/[^0-9]/', '', $order->billing_phone), + 'customerId' => 0 !== $order->get_customer_id() ? $order->get_customer_id() : null, 'customerEmail' => $order->get_billing_email(), 'customerName' => $order->get_billing_first_name() . " " . $order->get_billing_last_name(), 'amount' => $amount, 'invoiceNumber' => $order->get_order_number(), 'expiryTime' => $this->expiredTime, - 'phone' => preg_replace('/[^0-9]/', '', $order->billing_phone), + 'phone' => $order->billing_phone, 'country' => $order->billing_country, 'address' => preg_replace($pattern, "", $order->shipping_address_1), 'itemQty' => $this->get_order_data($order), 'payment_method' => $this->payment_method, 'postcode' => $order_data['billing']['postcode'], - 'state' => $order_data['billing']['state'] !== null ? $order_data['billing']['state'] : "", + 'state' => $order_data['billing']['state'], 'city' => $order_data['billing']['city'], 'info1' => '', 'info2' => '', @@ -147,7 +148,12 @@ public function process_payment($order_id) 'reusableStatus' => false, 'callback_url' => $this->get_return_url($order) . '&' . $order_id, 'sac_check' => $this->sac_check, + 'auto_redirect' => $this->auto_redirect_jokul, 'sac_textbox' => $this->sac_textbox, + 'first_name_shipping' => $order->shipping_first_name, + 'address_shipping' => preg_replace($pattern, "",$order->shipping_address_1), + 'city_shipping' => $order->shipping_city, + 'postal_code_shipping' => $order->shipping_postcode ); if ($this->environmentPaymentJokul == 'false') { @@ -177,7 +183,6 @@ public function process_payment($order_id) return array( 'result' => 'success', 'redirect' => $this->get_return_url($order) . "&jokul=show&" . $order_id - // 'redirect' => wc_get_page_permalink('checkout')."?jokul=show" ); } else { wc_add_notice('There is something wrong. Please try again.', 'error'); @@ -326,8 +331,8 @@ function woo_title_order_received($title) global $woocommerce; if (function_exists('is_order_received_page') && is_order_received_page() && $title === 'Order received') { - $haystack = explode("&", $_SERVER['QUERY_STRING']); - $order = wc_get_order($haystack[1]); + $haystack = explode('/', $_SERVER['REQUEST_URI']); + $order = wc_get_order($haystack[4]); $woocommerce->cart->empty_cart(); wc_reduce_stock_levels($order->get_id()); diff --git a/woo-doku-jokul/Module/JokulCreditCardModule.php b/woo-doku-jokul/Module/JokulCreditCardModule.php index 6d9d4c8..af1e0e5 100644 --- a/woo-doku-jokul/Module/JokulCreditCardModule.php +++ b/woo-doku-jokul/Module/JokulCreditCardModule.php @@ -79,7 +79,7 @@ function my_disruptive_filter($content) { return $url; } - + public function get_order_data($order) { $pattern = "/[^A-Za-z0-9? .,_-]/"; @@ -142,6 +142,7 @@ public function process_payment($order_id) $order = wc_get_order($order_id); $amount = $order->order_total; + $itemQty = array(); $params = array( 'customerId' => 0 !== $order->get_customer_id() ? $order->get_customer_id() : null, diff --git a/woo-doku-jokul/Service/JokulAlfaO2OService.php b/woo-doku-jokul/Service/JokulAlfaO2OService.php index d636b00..52cdfcb 100644 --- a/woo-doku-jokul/Service/JokulAlfaO2OService.php +++ b/woo-doku-jokul/Service/JokulAlfaO2OService.php @@ -34,7 +34,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "account" => array( @@ -66,7 +66,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "method" => "Jokul Direct" diff --git a/woo-doku-jokul/Service/JokulBcaVaService.php b/woo-doku-jokul/Service/JokulBcaVaService.php index 99dbe18..76ef743 100644 --- a/woo-doku-jokul/Service/JokulBcaVaService.php +++ b/woo-doku-jokul/Service/JokulBcaVaService.php @@ -28,7 +28,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "account" => array( @@ -55,7 +55,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "method" => "Jokul Direct" diff --git a/woo-doku-jokul/Service/JokulBriVaService.php b/woo-doku-jokul/Service/JokulBriVaService.php index 78fbbf3..137d00f 100644 --- a/woo-doku-jokul/Service/JokulBriVaService.php +++ b/woo-doku-jokul/Service/JokulBriVaService.php @@ -28,7 +28,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "account" => array( @@ -55,7 +55,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "method" => "Jokul Direct" diff --git a/woo-doku-jokul/Service/JokulBsmVaService.php b/woo-doku-jokul/Service/JokulBsmVaService.php index d6aea9f..49444b0 100644 --- a/woo-doku-jokul/Service/JokulBsmVaService.php +++ b/woo-doku-jokul/Service/JokulBsmVaService.php @@ -28,7 +28,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "account" => array( @@ -55,7 +55,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "method" => "Jokul Direct" diff --git a/woo-doku-jokul/Service/JokulCheckoutService.php b/woo-doku-jokul/Service/JokulCheckoutService.php index 9c027ec..08ab452 100644 --- a/woo-doku-jokul/Service/JokulCheckoutService.php +++ b/woo-doku-jokul/Service/JokulCheckoutService.php @@ -17,7 +17,15 @@ public function generated($config, $params) $dateTimeFinal = substr($dateTime,0,19)."Z"; $data = $params['sac_check'] === 'yes' ? array( - "order" => array( + "order" => $params['auto_redirect'] === 'true' ? array( + "invoice_number" => $params['invoiceNumber'], + "line_items" => $params['itemQty'], + "amount" => $params['amount'], + "callback_url" => $params['callback_url'], + "currency" => "IDR", + "auto_redirect" => true, + "disable_retry_payment" => true + ): array( "invoice_number" => $params['invoiceNumber'], "line_items" => $params['itemQty'], "amount" => $params['amount'], @@ -38,19 +46,36 @@ public function generated($config, $params) "city" => $params['city'], "address" => $params['address'] ), + "shipping_address" => array( + "first_name" => $params['first_name_shipping'], + "address" => trim($params['address_shipping']), + "city" => $params['city_shipping'], + "postal_code" => $params['postal_code_shipping'], + "phone" => $params['phone'], + "country_code" => "ID" + ), "additional_info" => array ( "integration" => array ( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "account" => array( "id" => $params['sac_textbox'] ), - "method" => "Jokul Checkout" + "method" => "Jokul Checkout", + "doku_wallet_notify_url" => "" ) ) : array( - "order" => array( + "order" => $params['auto_redirect'] === 'true' ? array( + "invoice_number" => $params['invoiceNumber'], + "line_items" => $params['itemQty'], + "amount" => $params['amount'], + "callback_url" => $params['callback_url'], + "currency" => "IDR", + "auto_redirect" => true, + "disable_retry_payment" => true + ): array( "invoice_number" => $params['invoiceNumber'], "line_items" => $params['itemQty'], "amount" => $params['amount'], @@ -71,13 +96,22 @@ public function generated($config, $params) "city" => $params['city'], "address" => $params['address'] ), + "shipping_address" => array( + "first_name" => $params['first_name_shipping'], + "address" => trim($params['address_shipping']), + "city" => $params['city_shipping'], + "postal_code" => $params['postal_code_shipping'], + "phone" => $params['phone'], + "country_code" => "ID" + ), "additional_info" => array ( "integration" => array ( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), - "method" => "Jokul Checkout" + "method" => "Jokul Checkout", + "doku_wallet_notify_url" => "" ) ); @@ -104,13 +138,13 @@ public function generated($config, $params) 'Request-Id:'.$requestId, 'Client-Id:'.$config['client_id'], 'Request-Timestamp:'.$dateTimeFinal, - + )); $responseJson = curl_exec($ch); curl_close($ch); - + $this->jokulUtils->doku_log($this, 'Jokul Checkout REQUEST : ' . json_encode($data), $params['invoiceNumber']); $this->jokulUtils->doku_log($this, 'Jokul Checkout REQUEST URL : ' . $url, $params['invoiceNumber']); $this->jokulUtils->doku_log($this, 'Jokul Checkout RESPONSE : ' . json_encode($responseJson, JSON_PRETTY_PRINT), $params['invoiceNumber']); diff --git a/woo-doku-jokul/Service/JokulCreditCardService.php b/woo-doku-jokul/Service/JokulCreditCardService.php index 2c7eed2..baa6ffa 100644 --- a/woo-doku-jokul/Service/JokulCreditCardService.php +++ b/woo-doku-jokul/Service/JokulCreditCardService.php @@ -44,7 +44,7 @@ public function generated($config, $params) "additional_info" => array ( "integration" => array ( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "account" => array( @@ -80,7 +80,7 @@ public function generated($config, $params) "additional_info" => array ( "integration" => array ( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "method" => "Jokul Direct" diff --git a/woo-doku-jokul/Service/JokulDokuVaService.php b/woo-doku-jokul/Service/JokulDokuVaService.php index a5c9cfb..5aec70f 100644 --- a/woo-doku-jokul/Service/JokulDokuVaService.php +++ b/woo-doku-jokul/Service/JokulDokuVaService.php @@ -28,7 +28,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "account" => array( @@ -55,7 +55,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "method" => "Jokul Direct" diff --git a/woo-doku-jokul/Service/JokulMandiriVaService.php b/woo-doku-jokul/Service/JokulMandiriVaService.php index 1033b5c..e652979 100644 --- a/woo-doku-jokul/Service/JokulMandiriVaService.php +++ b/woo-doku-jokul/Service/JokulMandiriVaService.php @@ -27,7 +27,7 @@ public function generated($config, $params) "additional_info" => array ( "integration" => array ( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "account" => array( @@ -54,7 +54,7 @@ public function generated($config, $params) "additional_info" => array ( "integration" => array ( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "method" => "Jokul Direct" diff --git a/woo-doku-jokul/Service/JokulNotificationService.php b/woo-doku-jokul/Service/JokulNotificationService.php index 6562bf5..f7773cb 100644 --- a/woo-doku-jokul/Service/JokulNotificationService.php +++ b/woo-doku-jokul/Service/JokulNotificationService.php @@ -55,6 +55,8 @@ public function getNotification() $signature = $jokulUtils->generateSignatureNotification($headerData, file_get_contents('php://input'), $sharedKey); if ($signature == $headerData['Signature']) { + $jokulUtils->doku_log($jokulUtils, 'TRANSACTION SIGNATURE VALID', $raw_notification['order']['invoice_number']); + if (strtolower($raw_notification['transaction']['status']) == strtolower('SUCCESS')) { $checkTrxStatus = $jokulDb->checkStatusTrx($invoiceNumber, $amount, $paymentCode == "" ? "" : $paymentCode, 'PAYMENT_COMPLETED'); diff --git a/woo-doku-jokul/Service/JokulPermataVaService.php b/woo-doku-jokul/Service/JokulPermataVaService.php index a5f3fc7..b5185a8 100644 --- a/woo-doku-jokul/Service/JokulPermataVaService.php +++ b/woo-doku-jokul/Service/JokulPermataVaService.php @@ -24,7 +24,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "account" => array( @@ -48,7 +48,7 @@ public function generated($config, $params) "additional_info" => array( "integration" => array( "name" => "woocommerce-plugin", - "version" => "1.3.8", + "version" => "1.3.9", "cms_version" => $params['woo_version'] ), "method" => "Jokul Direct"