Skip to content

Commit

Permalink
Merchant only receive payment through DOKU Checkout V2
Browse files Browse the repository at this point in the history
  • Loading branch information
dedyeirawan committed Feb 10, 2023
1 parent d4885e8 commit 06ff6da
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 60 deletions.
8 changes: 0 additions & 8 deletions woo-doku-jokul/Common/JokulListModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions woo-doku-jokul/Form/JokulCheckoutSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
),
)
)
);
Expand Down
14 changes: 7 additions & 7 deletions woo-doku-jokul/Form/JokulPgSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'enabled' => array(
'title' => __('Enable :', 'jokul'),
'type' => 'checkbox',
'label' => __('Enable Jokul', 'jokul'),
'label' => __('Enable DOKU', 'jokul'),
'default' => 'no',
),

Expand All @@ -24,23 +24,23 @@
'style' => '',
'title' => __('Sandbox Client ID:', 'jokul'),
'type' => 'text',
'description' => __('Sandbox Client ID you retrieved from Jokul Back Office', 'jokul'),
'description' => __('Sandbox Client ID you retrieved from DOKU Back Office', 'jokul'),
'default' => __('', 'jokul'),
),

'sandbox_shared_key' => array(
'style' => '',
'title' => __('Sandbox Secret Key:', 'jokul'),
'type' => 'text',
'description' => __('Sandbox Secret Key you retrieved from Jokul Back Office', 'jokul'),
'description' => __('Sandbox Secret Key you retrieved from DOKU Back Office', 'jokul'),
'default' => __('', 'jokul'),
),

'prod_client_id' => array(
'style' => '',
'title' => __('Production Client ID:', 'jokul'),
'type' => 'text',
'description' => __('Production Client ID you retrieved from Jokul Back Office', 'jokul'),
'description' => __('Production Client ID you retrieved from DOKU Back Office', 'jokul'),
'default' => __('', 'jokul'),
),

Expand All @@ -64,7 +64,7 @@
'title' => __('Notification URL:', 'jokul'),
'type' => 'text',
'custom_attributes' => array('readonly' => 'readonly'),
'description' => __('Set this URL to your Jokul Back Office', 'jokul'),
'description' => __('Set this URL to your DOKU Back Office', 'jokul'),
'default' => __(get_bloginfo('url').'/wp-json/jokul/notification', 'jokul'),
),

Expand All @@ -73,7 +73,7 @@
'title' => __('QRIS Notification URL:', 'jokul'),
'type' => 'text',
'custom_attributes' => array('readonly' => 'readonly'),
'description' => __('Set this URL to your Jokul Back Office', 'jokul'),
'description' => __('Set this URL to your DOKU Back Office', 'jokul'),
'default' => __(get_bloginfo('url').'/wp-json/jokul/qrisnotification', 'jokul'),
),

Expand All @@ -96,7 +96,7 @@
'class' => array('jokul_class'),
'title' => __('On Behalf Of:', 'jokul'),
'type' => 'text',
'description' => __('Route to yout Jokul Sub Account ID. All transactions will be linked to this account', 'jokul'),
'description' => __('Route to your DOKU Sub Account ID. All transactions will be linked to this account', 'jokul'),
'placeholder' => _x('e.g. SAC-Xxxxxx', 'placeholder', 'jokul'),
'default' => __('', 'jokul'),
'required' => true
Expand Down
10 changes: 1 addition & 9 deletions woo-doku-jokul/JokulMainPg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
27 changes: 16 additions & 11 deletions woo-doku-jokul/Module/JokulCheckoutModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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);
Expand All @@ -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' => '',
Expand All @@ -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') {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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());

Expand Down
3 changes: 2 additions & 1 deletion woo-doku-jokul/Module/JokulCreditCardModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function my_disruptive_filter($content) {

return $url;
}

public function get_order_data($order)
{
$pattern = "/[^A-Za-z0-9? .,_-]/";
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions woo-doku-jokul/Service/JokulAlfaO2OService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions woo-doku-jokul/Service/JokulBcaVaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions woo-doku-jokul/Service/JokulBriVaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions woo-doku-jokul/Service/JokulBsmVaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"
Expand Down
Loading

0 comments on commit 06ff6da

Please sign in to comment.