diff --git a/.gitignore b/.gitignore index 85e49ae..003c634 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea -*.zip \ No newline at end of file +*.zip +.DS_Store \ No newline at end of file diff --git a/woo-doku-jokul/Block/DokuCheckoutBlock.php b/woo-doku-jokul/Block/DokuCheckoutBlock.php index c75efda..53b08a4 100644 --- a/woo-doku-jokul/Block/DokuCheckoutBlock.php +++ b/woo-doku-jokul/Block/DokuCheckoutBlock.php @@ -46,4 +46,3 @@ public function get_payment_method_data() { } } -?> \ No newline at end of file diff --git a/woo-doku-jokul/Common/JokulConfig.php b/woo-doku-jokul/Common/JokulConfig.php index 7c626ee..6ca75d1 100644 --- a/woo-doku-jokul/Common/JokulConfig.php +++ b/woo-doku-jokul/Common/JokulConfig.php @@ -1,5 +1,7 @@ diff --git a/woo-doku-jokul/Common/JokulDb.php b/woo-doku-jokul/Common/JokulDb.php index 3cf7820..1763d26 100644 --- a/woo-doku-jokul/Common/JokulDb.php +++ b/woo-doku-jokul/Common/JokulDb.php @@ -1,20 +1,29 @@ $field_data ) - { - $SQL .= " $field_name = '$field_data',"; - } - $SQL = substr( $SQL, 0, -1 ); - - $wpdb->query("INSERT INTO ".$wpdb->prefix."jokuldb SET $SQL"); - } + $table = $wpdb->prefix . "jokuldb"; + + $columns = array_keys($datainsert); + $placeholders = array_map(function ($value) { + return is_numeric($value) ? '%d' : '%s'; + }, $datainsert); + + $columns_str = implode(', ', $columns); + $placeholders_str = implode(', ', $placeholders); + + $query = $wpdb->prepare( + "INSERT INTO $table ($columns_str) VALUES ($placeholders_str)", + array_values($datainsert) + ); + + $result = $wpdb->query($query); + } function updateData($invoice, $status) { @@ -25,10 +34,15 @@ function updateData($invoice, $status) function checkTrx($order_id, $amount, $vaNumber) { global $wpdb; - $db_prefix = $wpdb->prefix; + $table = $wpdb->prefix . "jokuldb"; - $query="SELECT * FROM ".$db_prefix."jokuldb where invoice_number='".$order_id."' and amount='".$amount."' ORDER BY trx_id DESC LIMIT 1"; - $result = $wpdb->get_var($query); + $query = $wpdb->prepare( + "SELECT * FROM $table WHERE invoice_number = %s AND amount = %d ORDER BY trx_id DESC LIMIT 1", + $order_id, + $amount + ); + + $result = $wpdb->get_row($query); return $result; } @@ -36,10 +50,17 @@ function checkTrx($order_id, $amount, $vaNumber) function checkStatusTrx($order_id, $amount, $vaNumber, $processType) { global $wpdb; - $db_prefix = $wpdb->prefix; - $query="SELECT payment_code FROM ".$db_prefix."jokuldb where invoice_number='".$order_id."' and amount='".$amount."' and process_type = 'PAYMENT_COMPLETED' ORDER BY trx_id DESC LIMIT 1"; + $table = $wpdb->prefix . "jokuldb"; + + $query = $wpdb->prepare( + "SELECT payment_code FROM $table WHERE invoice_number = %s AND amount = %d AND process_type = %s ORDER BY trx_id DESC LIMIT 1", + $order_id, + $amount, + $processType + ); + $result = $wpdb->get_var($query); return $result; } } -?> + diff --git a/woo-doku-jokul/Common/JokulListModule.php b/woo-doku-jokul/Common/JokulListModule.php index 4e86675..31f233f 100644 --- a/woo-doku-jokul/Common/JokulListModule.php +++ b/woo-doku-jokul/Common/JokulListModule.php @@ -1,5 +1,7 @@ = 5.2.1 required'); @@ -15,11 +17,10 @@ } // Modules -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulMainModule.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Module/JokulCheckoutModule.php'); +require_once(DOKU_PAYMENT_PLUGIN_PATH . '/Module/JokulMainModule.php'); +require_once(DOKU_PAYMENT_PLUGIN_PATH . '/Module/JokulCheckoutModule.php'); //API End Point -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Service/JokulNotificationService.php'); -require_once(DOKU_JOKUL_PLUGIN_PATH . '/Service/JokulQrisNotificationService.php'); +require_once(DOKU_PAYMENT_PLUGIN_PATH . '/Service/JokulNotificationService.php'); +require_once(DOKU_PAYMENT_PLUGIN_PATH . '/Service/JokulQrisNotificationService.php'); -?> diff --git a/woo-doku-jokul/Common/JokulUtils.php b/woo-doku-jokul/Common/JokulUtils.php index 4df3899..c5f7b79 100644 --- a/woo-doku-jokul/Common/JokulUtils.php +++ b/woo-doku-jokul/Common/JokulUtils.php @@ -1,4 +1,7 @@ ' . $invoice_number . " : "; + $log_header = gmdate(DATE_ATOM) . ' ' . '---> ' . $invoice_number . " : "; if (!file_exists($log_filename)) { - // create directory/folder uploads. mkdir($log_filename, 0777, true); } - $log_file_data = $log_filename . '/log_' . date('d-M-Y') . '.log'; - // if you don't add `FILE_APPEND`, the file will be erased each time you add a log + $log_file_data = $log_filename . '/log_' . gmdate('d-M-Y') . '.log'; file_put_contents($log_file_data, $log_header . $log_msg . "\n", FILE_APPEND); } @@ -90,7 +106,12 @@ public function send_email($order, $emailParams, $howToPayUrl) //format the email $recipient = $emailParams['customerEmail']; - $subject = __("Hi " . $emailParams['customerName']. ", here is your payment instructions for order number " . $order->get_order_number() . "!", 'theme_name'); + $subject = sprintf( + /* translators: %1$s: Customer name, %2$s: Order number */ + __("Hi %1$s, here is your payment instructions for order number %2$s!", 'doku-payment'), + $emailParams['customerName'], + $order->get_order_number() + ); $content = $this->get_custom_email_html($order, $this->getEmailMessage($howToPayUrl), $mailer, $subject); $headers = "Content-Type: text/html\r\n"; @@ -111,27 +132,52 @@ function get_custom_email_html($order, $instructions, $mailer, $heading = false) )); } + // function getEmailMessage($url) + // { + // $ch = curl_init(); + // $headers = array( + // 'Accept: application/json', + // 'Content-Type: application/json', + + // ); + // curl_setopt($ch, CURLOPT_URL, $url); + // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + // curl_setopt($ch, CURLOPT_HEADER, 0); + + // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); + // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + // // Timeout in seconds + // curl_setopt($ch, CURLOPT_TIMEOUT, 30); + + // $response = curl_exec($ch); + // $responseJson = json_decode($response, true); + // return $responseJson['payment_instruction']; + // } function getEmailMessage($url) { - $ch = curl_init(); $headers = array( - 'Accept: application/json', - 'Content-Type: application/json', + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ); + $args = array( + 'headers' => $headers, + 'timeout' => 30, ); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = wp_remote_get($url, $args); + + if (is_wp_error($response)) { + $error_message = $response->get_error_message(); + return "Error fetching payment instructions: $error_message"; + } - // Timeout in seconds - curl_setopt($ch, CURLOPT_TIMEOUT, 30); + // Ambil isi body dari respons + $response_body = wp_remote_retrieve_body($response); + $responseJson = json_decode($response_body, true); - $response = curl_exec($ch); - $responseJson = json_decode($response, true); - return $responseJson['payment_instruction']; + return $responseJson['payment_instruction'] ?? null; } function formatPhoneNumber($phoneNumber) { diff --git a/woo-doku-jokul/Form/JokulAlfaO2OSetting.php b/woo-doku-jokul/Form/JokulAlfaO2OSetting.php index 8c66fe3..73768c8 100644 --- a/woo-doku-jokul/Form/JokulAlfaO2OSetting.php +++ b/woo-doku-jokul/Form/JokulAlfaO2OSetting.php @@ -1,25 +1,27 @@ array( - 'title' => __('Payment Channel Display Name', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Channel Display Name', 'doku-payment'), 'type' => 'text', - 'description' => __('Default : Alfamart', 'woocommerce-gateway-jokul'), + 'description' => __('Default : Alfamart', 'doku-payment'), 'placeholder' => 'Alfamart', ), 'payment_description' => array( - 'title' => __('Payment Description', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Description', 'doku-payment'), 'type' => 'textarea', 'css' => 'width: 400px;', - 'description' => __('Change your payment description for payment using Alfamart', 'woocommerce-gateway-jokul'), + 'description' => __('Change your payment description for payment using Alfamart', 'doku-payment'), 'placeholder' => 'Bayar pesanan dengan transfer melalui Alfamart', ), 'footer_message' => array( - 'title' => __('Footer Message', 'woocommerce-gateway-jokul'), + 'title' => __('Footer Message', 'doku-payment'), 'type' => 'text', - 'description' => __('Change your footer message for payment using Alfamart', 'woocommerce-gateway-jokul'), + 'description' => __('Change your footer message for payment using Alfamart', 'doku-payment'), 'placeholder' => 'ex: Call Center 021 555-0525', ) ) diff --git a/woo-doku-jokul/Form/JokulBcaVaSetting.php b/woo-doku-jokul/Form/JokulBcaVaSetting.php index 605f25d..dfe8520 100644 --- a/woo-doku-jokul/Form/JokulBcaVaSetting.php +++ b/woo-doku-jokul/Form/JokulBcaVaSetting.php @@ -1,22 +1,22 @@ array( - 'title' => __('Payment Channel Display Name', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Channel Display Name', 'doku-payment'), 'type' => 'text', - 'description' => __('Default : BCA VA', 'woocommerce-gateway-jokul'), + 'description' => __('Default : BCA VA', 'doku-payment'), 'placeholder' => 'BCA VA', ), 'payment_description' => array( - 'title' => __('Payment Description', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Description', 'doku-payment'), 'type' => 'textarea', 'css' => 'width: 400px;', - 'description' => __('Change your payment description for BCA VA', 'woocommerce-gateway-jokul'), + 'description' => __('Change your payment description for BCA VA', 'doku-payment'), 'placeholder' => 'Bayar pesanan dengan transfer dari BCA', ) ) ); - -?> diff --git a/woo-doku-jokul/Form/JokulBriVaSetting.php b/woo-doku-jokul/Form/JokulBriVaSetting.php index df8243d..c100ea6 100644 --- a/woo-doku-jokul/Form/JokulBriVaSetting.php +++ b/woo-doku-jokul/Form/JokulBriVaSetting.php @@ -1,22 +1,22 @@ array( - 'title' => __('Payment Channel Display Name', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Channel Display Name', 'doku-payment'), 'type' => 'text', - 'description' => __('Default : Bank Rakyat Indonesia VA', 'woocommerce-gateway-jokul'), + 'description' => __('Default : Bank Rakyat Indonesia VA', 'doku-payment'), 'placeholder' => 'Bank Rakyat Indonesia VA', ), 'payment_description' => array( - 'title' => __('Payment Description', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Description', 'doku-payment'), 'type' => 'textarea', 'css' => 'width: 400px;', - 'description' => __('Change your payment description for Bank Rakyat Indonesia VA', 'woocommerce-gateway-jokul'), + 'description' => __('Change your payment description for Bank Rakyat Indonesia VA', 'doku-payment'), 'placeholder' => 'Bayar pesanan dengan transfer Bank Rakyat Indonesia VA', ) ) ); - -?> diff --git a/woo-doku-jokul/Form/JokulBsmVaSetting.php b/woo-doku-jokul/Form/JokulBsmVaSetting.php index c58b56a..be7858a 100644 --- a/woo-doku-jokul/Form/JokulBsmVaSetting.php +++ b/woo-doku-jokul/Form/JokulBsmVaSetting.php @@ -1,22 +1,22 @@ array( - 'title' => __('Payment Channel Display Name', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Channel Display Name', 'doku-payment'), 'type' => 'text', - 'description' => __('Default : Bank Syariah Indonesia VA', 'woocommerce-gateway-jokul'), + 'description' => __('Default : Bank Syariah Indonesia VA', 'doku-payment'), 'placeholder' => 'Bank Syariah Indonesia VA', ), 'payment_description' => array( - 'title' => __('Payment Description', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Description', 'doku-payment'), 'type' => 'textarea', 'css' => 'width: 400px;', - 'description' => __('Change your payment description for Bank Syariah Indonesia VA', 'woocommerce-gateway-jokul'), + 'description' => __('Change your payment description for Bank Syariah Indonesia VA', 'doku-payment'), 'placeholder' => 'Bayar pesanan dengan transfer Bank Syariah Indonesia VA', ) ) ); - -?> diff --git a/woo-doku-jokul/Form/JokulCheckoutSetting.php b/woo-doku-jokul/Form/JokulCheckoutSetting.php index 0593a09..eb3ace6 100644 --- a/woo-doku-jokul/Form/JokulCheckoutSetting.php +++ b/woo-doku-jokul/Form/JokulCheckoutSetting.php @@ -1,55 +1,56 @@ array( - 'title' => __('Payment Channel Display Name', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Channel Display Name', 'doku-payment'), 'type' => 'text', - 'description' => __('Default: Checkout', 'woocommerce-gateway-jokul'), + 'description' => __('Default: Checkout', 'doku-payment'), 'placeholder' => 'DOKU Checkout', ), 'payment_description' => array( - 'title' => __('Payment Description', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Description', 'doku-payment'), 'type' => 'textarea', 'css' => 'width: 400px;', - 'description' => __('Change your payment description for DOKU Checkout', 'woocommerce-gateway-jokul'), + 'description' => __('Change your payment description for DOKU Checkout', 'doku-payment'), 'placeholder' => 'Bayar pesanan dengan DOKU Checkout', ), 'QRIS_Credential' => array( - 'title' => __('QRIS Credential', 'woocommerce-gateway-jokul'), + 'title' => __('QRIS Credential', 'doku-payment'), 'type' => 'text', 'custom_attributes' => array('readonly' => 'readonly'), 'placeholder' => 'Below field is QRIS credential section', ), 'payment_client_id' => array( - 'title' => __('Client-ID', 'woocommerce-gateway-jokul'), + 'title' => __('Client-ID', 'doku-payment'), 'type' => 'text', - 'description' => __('Default: Client ID', 'woocommerce-gateway-jokul'), + 'description' => __('Default: Client ID', 'doku-payment'), 'placeholder' => '0', ), 'payment_shared_key' => array( - 'title' => __('Shared Key', 'woocommerce-gateway-jokul'), + 'title' => __('Shared Key', 'doku-payment'), 'type' => 'text', - 'description' => __('Default: Shared Key', 'woocommerce-gateway-jokul'), + 'description' => __('Default: Shared Key', 'doku-payment'), 'placeholder' => '0', ), 'payment_mpan' => array( - 'title' => __('Merchant PAN', 'woocommerce-gateway-jokul'), + 'title' => __('Merchant PAN', 'doku-payment'), 'type' => 'text', - 'description' => __('Default: Merchant PAN', 'woocommerce-gateway-jokul'), + 'description' => __('Default: Merchant PAN', 'doku-payment'), 'placeholder' => '0', ), 'auto_redirect_jokul' => array( - 'title' => __('Auto Redirect', 'woocommerce-gateway-jokul'), + 'title' => __('Auto Redirect', 'doku-payment'), 'type' => 'select', 'default' => 'false', 'options' => array( - 'false' => __('FALSE', 'woocommerce-gateway-jokul'), - 'true' => __('TRUE', 'woocommerce-gateway-jokul'), + 'false' => __('FALSE', 'doku-payment'), + 'true' => __('TRUE', 'doku-payment'), ), ) ) ); -?> diff --git a/woo-doku-jokul/Form/JokulCreditCardSetting.php b/woo-doku-jokul/Form/JokulCreditCardSetting.php index 3c56514..19eed63 100644 --- a/woo-doku-jokul/Form/JokulCreditCardSetting.php +++ b/woo-doku-jokul/Form/JokulCreditCardSetting.php @@ -1,55 +1,55 @@ array( - 'title' => __('Payment Channel Display Name', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Channel Display Name', 'doku-payment'), 'type' => 'text', - 'description' => __('Default: Credit Card', 'woocommerce-gateway-jokul'), + 'description' => __('Default: Credit Card', 'doku-payment'), 'placeholder' => 'Credit Card', ), 'payment_description' => array( - 'title' => __('Payment Description', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Description', 'doku-payment'), 'type' => 'textarea', 'css' => 'width: 400px;', - 'description' => __('Change your payment description for Credit Card', 'woocommerce-gateway-jokul'), + 'description' => __('Change your payment description for Credit Card', 'doku-payment'), 'placeholder' => 'Bayar pesanan dengan Credit Card', ), 'language_payment_jokul' => array( - 'title' => __('Language :', 'jokul'), + 'title' => __('Language :', 'doku-payment'), 'type' => 'select', 'default' => 'ID', 'options' => array( - 'ID' => __('ID', 'jokul'), - 'EN' => __('EN', 'jokul'), + 'ID' => __('ID', 'doku-payment'), + 'EN' => __('EN', 'doku-payment'), ), ), 'payment_background_color' => array( - 'title' => __('Background Color', 'woocommerce-gateway-jokul'), + 'title' => __('Background Color', 'doku-payment'), 'type' => 'text', - 'description' => __('Default: F5F8FB', 'woocommerce-gateway-jokul'), + 'description' => __('Default: F5F8FB', 'doku-payment'), 'placeholder' => 'Background Color', ), 'payment_font_color' => array( - 'title' => __('Font Color', 'woocommerce-gateway-jokul'), + 'title' => __('Font Color', 'doku-payment'), 'type' => 'text', - 'description' => __('Default: 1A1A1A', 'woocommerce-gateway-jokul'), + 'description' => __('Default: 1A1A1A', 'doku-payment'), 'placeholder' => 'Font Color', ), 'payment_button_background_color' => array( - 'title' => __('Button Background Color', 'woocommerce-gateway-jokul'), + 'title' => __('Button Background Color', 'doku-payment'), 'type' => 'text', - 'description' => __('Default: E1251B', 'woocommerce-gateway-jokul'), + 'description' => __('Default: E1251B', 'doku-payment'), 'placeholder' => 'Button Background Color', ), 'payment_button_font_color' => array( - 'title' => __('Button Font Color', 'woocommerce-gateway-jokul'), + 'title' => __('Button Font Color', 'doku-payment'), 'type' => 'text', - 'description' => __('Default: FFFFFF', 'woocommerce-gateway-jokul'), + 'description' => __('Default: FFFFFF', 'doku-payment'), 'placeholder' => 'Button Font Color', ) ) ); - -?> diff --git a/woo-doku-jokul/Form/JokulDokuVaSetting.php b/woo-doku-jokul/Form/JokulDokuVaSetting.php index 07e8823..a7b22bf 100644 --- a/woo-doku-jokul/Form/JokulDokuVaSetting.php +++ b/woo-doku-jokul/Form/JokulDokuVaSetting.php @@ -1,22 +1,23 @@ array( - 'title' => __('Payment Channel Display Name', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Channel Display Name', 'doku-payment'), 'type' => 'text', - 'description' => __('Default : Other Banks (VA by DOKU)', 'woocommerce-gateway-jokul'), + 'description' => __('Default : Other Banks (VA by DOKU)', 'doku-payment'), 'placeholder' => 'Other Banks (VA by DOKU)', ), 'payment_description' => array( - 'title' => __('Payment Description', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Description', 'doku-payment'), 'type' => 'textarea', 'css' => 'width: 400px;', - 'description' => __('Change your payment description for DOKU VA', 'woocommerce-gateway-jokul'), + 'description' => __('Change your payment description for DOKU VA', 'doku-payment'), 'placeholder' => 'Bayar pesanan dengan transfer dari bank lain', ) ) ); -?> diff --git a/woo-doku-jokul/Form/JokulMandiriVaSetting.php b/woo-doku-jokul/Form/JokulMandiriVaSetting.php index c64fe8c..02656b9 100644 --- a/woo-doku-jokul/Form/JokulMandiriVaSetting.php +++ b/woo-doku-jokul/Form/JokulMandiriVaSetting.php @@ -1,22 +1,22 @@ array( - 'title' => __('Payment Channel Display Name', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Channel Display Name', 'doku-payment'), 'type' => 'text', - 'description' => __('Default : Bank Mandiri VA', 'woocommerce-gateway-jokul'), + 'description' => __('Default : Bank Mandiri VA', 'doku-payment'), 'placeholder' => 'Bank Mandiri VA', ), 'payment_description' => array( - 'title' => __('Payment Description', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Description', 'doku-payment'), 'type' => 'textarea', 'css' => 'width: 400px;', - 'description' => __('Change your payment description for Bank Mandiri VA', 'woocommerce-gateway-jokul'), + 'description' => __('Change your payment description for Bank Mandiri VA', 'doku-payment'), 'placeholder' => 'Bayar pesanan dengan transfer dari Bank Mandiri', ) ) ); - -?> diff --git a/woo-doku-jokul/Form/JokulPermataVaSetting.php b/woo-doku-jokul/Form/JokulPermataVaSetting.php index cbf00de..30ed7ca 100644 --- a/woo-doku-jokul/Form/JokulPermataVaSetting.php +++ b/woo-doku-jokul/Form/JokulPermataVaSetting.php @@ -1,22 +1,22 @@ array( - 'title' => __('Payment Channel Display Name', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Channel Display Name', 'doku-payment'), 'type' => 'text', - 'description' => __('Default : Bank Permata VA', 'woocommerce-gateway-jokul'), + 'description' => __('Default : Bank Permata VA', 'doku-payment'), 'placeholder' => 'Bank Permata VA', ), 'payment_description' => array( - 'title' => __('Payment Description', 'woocommerce-gateway-jokul'), + 'title' => __('Payment Description', 'doku-payment'), 'type' => 'textarea', 'css' => 'width: 400px;', - 'description' => __('Change your payment description for Bank Permata VA', 'woocommerce-gateway-jokul'), + 'description' => __('Change your payment description for Bank Permata VA', 'doku-payment'), 'placeholder' => 'Bayar pesanan dengan transfer dari Bank Permata', ) ) ); - -?> diff --git a/woo-doku-jokul/Form/JokulPgSetting.php b/woo-doku-jokul/Form/JokulPgSetting.php index c21e2ad..f6c2853 100644 --- a/woo-doku-jokul/Form/JokulPgSetting.php +++ b/woo-doku-jokul/Form/JokulPgSetting.php @@ -1,107 +1,108 @@ array( - 'title' => __('Enable :', 'jokul'), + 'title' => __('Enable :', 'doku-payment'), 'type' => 'checkbox', - 'label' => __('Enable DOKU', 'jokul'), + 'label' => __('Enable DOKU', 'doku-payment'), 'default' => 'no', ), 'environment_payment_jokul' => array( - 'title' => __('Environment :', 'jokul'), + 'title' => __('Environment :', 'doku-payment'), 'type' => 'select', 'default' => 'false', 'options' => array( - 'false' => __('Sandbox', 'jokul'), - 'true' => __('Production', 'jokul'), + 'false' => __('Sandbox', 'doku-payment'), + 'true' => __('Production', 'doku-payment'), ), ), 'sandbox_client_id' => array( 'style' => '', - 'title' => __('Sandbox Client ID:', 'jokul'), + 'title' => __('Sandbox Client ID:', 'doku-payment'), 'type' => 'text', - 'description' => __('Sandbox Client ID you retrieved from DOKU Back Office', 'jokul'), - 'default' => __('', 'jokul'), + 'description' => __('Sandbox Client ID you retrieved from DOKU Back Office', 'doku-payment'), + 'default' => __('', 'doku-payment'), ), 'sandbox_shared_key' => array( 'style' => '', - 'title' => __('Sandbox Secret Key:', 'jokul'), + 'title' => __('Sandbox Secret Key:', 'doku-payment'), 'type' => 'text', - 'description' => __('Sandbox Secret Key you retrieved from DOKU Back Office', 'jokul'), - 'default' => __('', 'jokul'), + 'description' => __('Sandbox Secret Key you retrieved from DOKU Back Office', 'doku-payment'), + 'default' => '', ), 'prod_client_id' => array( 'style' => '', - 'title' => __('Production Client ID:', 'jokul'), + 'title' => __('Production Client ID:', 'doku-payment'), 'type' => 'text', - 'description' => __('Production Client ID you retrieved from DOKU Back Office', 'jokul'), - 'default' => __('', 'jokul'), + 'description' => __('Production Client ID you retrieved from DOKU Back Office', 'doku-payment'), + 'default' => '', ), 'prod_shared_key' => array( 'style' => '', - 'title' => __('Production Secret Key:', 'jokul'), + 'title' => __('Production Secret Key:', 'doku-payment'), 'type' => 'text', - 'description' => __('Unique Production Secret Key Id you retrieved from DOKU Back Office', 'jokul'), - 'default' => __('', 'jokul'), + 'description' => __('Unique Production Secret Key Id you retrieved from DOKU Back Office', 'doku-payment'), + 'default' => '', ), 'expired_time' => array( - 'title' => __('Expired Time:', 'jokul'), + 'title' => __('Expired Time:', 'doku-payment'), 'type' => 'number', - 'description' => __('Order will be cancelled if customer do not pay an invoice (Virtual Account and O2O) past the expiry time', 'jokul'), - 'default' => __('60', 'jokul'), + 'description' => __('Order will be cancelled if customer do not pay an invoice (Virtual Account and O2O) past the expiry time', 'doku-payment'), + 'default' => __('60', 'doku-payment'), ), 'notif_url' => array( 'style' => '', - 'title' => __('Notification URL:', 'jokul'), + 'title' => __('Notification URL:', 'doku-payment'), 'type' => 'text', 'custom_attributes' => array('readonly' => 'readonly'), - 'description' => __('Set this URL to your DOKU Back Office', 'jokul'), - 'default' => __(get_bloginfo('url').'/wp-json/doku/notification', 'jokul'), + 'description' => __('Set this URL to your DOKU Back Office', 'doku-payment'), + 'default' => sprintf( __( '%s/wp-json/doku/notification', 'doku-payment' ), get_bloginfo('url') ) + ), 'notif_url_qris' => array( 'style' => '', - 'title' => __('QRIS Notification URL:', 'jokul'), + 'title' => __('QRIS Notification URL:', 'doku-payment'), 'type' => 'text', 'custom_attributes' => array('readonly' => 'readonly'), - 'description' => __('Set this URL to your DOKU Back Office', 'jokul'), - 'default' => __(get_bloginfo('url').'/wp-json/doku/qrisnotification', 'jokul'), + 'description' => __('Set this URL to your DOKU Back Office', 'doku-payment'), + 'default' => sprintf( __( '%s/wp-json/doku/qrisnotification', 'doku-payment' ), get_bloginfo('url') ), ), 'email_notifications' => array( - 'title' => __('Email Notifications :', 'jokul'), + 'title' => __('Email Notifications :', 'doku-payment'), 'type' => 'checkbox', - 'label' => __('Send email instruction to customer for virtual account and convenience store', 'jokul'), + 'label' => __('Send email instruction to customer for virtual account and convenience store', 'doku-payment'), 'default' => 'yes' ), 'sac_check' => array( - 'title' => __('Enabling Sub Account :', 'jokul'), + 'title' => __('Enabling Sub Account :', 'doku-payment'), 'type' => 'checkbox', - 'label' => __('Enable Your Sub Account in Woocomerce', 'jokul'), - 'description' => __( 'Enable Your Sub Account in Woocomerce', 'jokul' ), + 'label' => __('Enable Your Sub Account in Woocomerce', 'doku-payment'), + 'description' => __( 'Enable Your Sub Account in Woocomerce', 'doku-payment' ), 'desc_tip' => true, 'default' => 'no' ), 'sac_textbox' => array( 'style' => '', 'class' => array('jokul_class'), - 'title' => __('On Behalf Of:', 'jokul'), + 'title' => __('On Behalf Of:', 'doku-payment'), 'type' => 'text', - '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'), + 'description' => __('Route to your DOKU Sub Account ID. All transactions will be linked to this account', 'doku-payment'), + 'placeholder' => _x('e.g. SAC-Xxxxxx', 'placeholder', 'doku-payment'), + 'default' => '', 'required' => true ), ) ); - -?> diff --git a/woo-doku-jokul/Module/JokulCheckoutModule.php b/woo-doku-jokul/Module/JokulCheckoutModule.php index b09c5eb..408d467 100644 --- a/woo-doku-jokul/Module/JokulCheckoutModule.php +++ b/woo-doku-jokul/Module/JokulCheckoutModule.php @@ -1,9 +1,11 @@ method_name = 'DOKU Checkout'; $this->method_code = 'JOKUL_CHECKOUT'; $this->title = !empty($this->get_option('channel_name')) ? $this->get_option('channel_name') : $this->method_name; - $this->method_title = __('DOKU', 'woocommerce-gateway-jokul'); - $this->method_description = sprintf(__('Accept payment through various payment channels with DOKU. Make it easy for your customers to purchase on your store.', 'woocommerce')); + $this->method_title = __('DOKU', 'doku-payment'); + $this->method_description = sprintf(__('Accept payment through various payment channels with DOKU. Make it easy for your customers to purchase on your store.', 'doku-payment')); $this->checkout_msg = 'This your payment on DOKU Checkout : '; $this->init_settings(); @@ -47,17 +49,15 @@ public function __construct() add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); - $haystack = explode("&", $_SERVER['QUERY_STRING']); - if( WC()->session != null ){ - $chosen_payment_method = WC()->session->get('chosen_payment_method'); + $queryArray = explode("&", sanitize_text_field($_SERVER['QUERY_STRING'])); + if (WC()->session != null) { + $chosen_payment_method = WC()->session->get('chosen_payment_method'); if ($this->id == 'jokul_checkout') { - if (strpos($_SERVER['QUERY_STRING'], "jokul=show") !== false) { - - add_filter('the_title', array($this, 'woo_title_order_pending')); + if (in_array("jokul=show", $queryArray)) { + add_filter('the_title', array($this, 'woo_title_order_pending')); add_action('woocommerce_thankyou_' . $this->id, array($this, 'thank_you_page_pending'), 1, 10); } else { - - add_filter('the_title', array($this, 'woo_title_order_received')); + add_filter('the_title', array($this, 'woo_title_order_received')); } } } @@ -256,7 +256,7 @@ public function process_payment($order_id) public function init_form_fields() { - $this->form_fields = require(DOKU_JOKUL_PLUGIN_PATH . '/Form/JokulCheckoutSetting.php'); + $this->form_fields = require(DOKU_PAYMENT_PLUGIN_PATH . '/Form/JokulCheckoutSetting.php'); } public function process_admin_options() @@ -346,7 +346,7 @@ public function addDb($response, $amount) $trx['invoice_number'] = $response['response']['order']['invoice_number']; $trx['result_msg'] = null; $trx['process_type'] = 'PAYMENT_PENDING'; - $trx['raw_post_data'] = file_get_contents('php://input'); + $trx['raw_post_data'] = json_encode($response); $trx['ip_address'] = $getIp; $trx['amount'] = $amount; $trx['payment_channel'] = $this->method_code; @@ -361,19 +361,30 @@ public function addDb($response, $amount) } public function thank_you_page_pending($order_id) -{ + { + $jokulCheckoutURL = get_post_meta($order_id, 'checkoutUrl', true); + if (!$jokulCheckoutURL) { + return; + } - $jokulCheckoutURL = get_post_meta($order_id, 'checkoutUrl', true); -?> - - + diff --git a/woo-doku-jokul/Module/JokulMainModule.php b/woo-doku-jokul/Module/JokulMainModule.php index c51a69f..383223e 100644 --- a/woo-doku-jokul/Module/JokulMainModule.php +++ b/woo-doku-jokul/Module/JokulMainModule.php @@ -1,5 +1,7 @@ has_fields = true; $this->method_name = 'General Configuration'; $this->title = !empty($this->get_option('channel_name')) ? $this->get_option('channel_name') : $this->method_name; - $this->method_title = __('DOKU', 'woocommerce-gateway-jokul'); - $this->method_description = sprintf(__('Accept payment through various payment channels with DOKU. Make it easy for your customers to purchase on your store.', 'woocommerce')); + $this->method_title = __('DOKU', 'doku-payment'); + $this->method_description = sprintf(__('Accept payment through various payment channels with DOKU. Make it easy for your customers to purchase on your store.', 'doku-payment')); $this->init_settings(); $this->enabled = $this->get_option('enabled'); @@ -30,7 +32,7 @@ public function __construct() public function init_form_fields() { - $this->form_fields = require(DOKU_JOKUL_PLUGIN_PATH . '/Form/JokulPgSetting.php'); + $this->form_fields = require(DOKU_PAYMENT_PLUGIN_PATH . '/Form/JokulPgSetting.php'); } public function process_admin_options() diff --git a/woo-doku-jokul/Service/JokulCheckStatusService.php b/woo-doku-jokul/Service/JokulCheckStatusService.php index f22ec27..328aad3 100644 --- a/woo-doku-jokul/Service/JokulCheckStatusService.php +++ b/woo-doku-jokul/Service/JokulCheckStatusService.php @@ -1,7 +1,9 @@ jokulUtils = new JokulUtils(); $requestId = $this->jokulUtils->guidv4(); - $targetPath= "/orders/v1/status/".$params['invoiceNumber']; + $targetPath = "/orders/v1/status/" . $params['invoiceNumber']; $dateTime = gmdate("Y-m-d H:i:s"); $dateTime = date(DATE_ISO8601, strtotime($dateTime)); - $dateTimeFinal = substr($dateTime,0,19)."Z"; + $dateTimeFinal = substr($dateTime, 0, 19) . "Z"; $this->jokulConfig = new JokulConfig(); - $valueEnv = $config['environment'] === 'true'? true: false; - $getUrl = $this->jokulConfig -> getBaseUrl($valueEnv); - $url = $getUrl.$targetPath; + $valueEnv = $config['environment'] === 'true' ? true : false; + $getUrl = $this->jokulConfig->getBaseUrl($valueEnv); + $url = $getUrl . $targetPath; $header['Client-Id'] = $config['client_id']; $header['Request-Id'] = $requestId; @@ -28,31 +30,32 @@ public function generated($config, $params) $signature = $this->jokulUtils->generateSignatureCheckStatus($header, $config['shared_key']); - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - 'Signature:'.$signature, - 'Request-Id:'.$requestId, - 'Client-Id:'.$config['client_id'], - 'Request-Timestamp:'.$dateTimeFinal, - 'Request-Target:'.$targetPath - )); - - $responseJson = curl_exec($ch); + $args = array( + 'headers' => array( + 'Content-Type' => 'application/json', + 'Signature' => $signature, + 'Request-Id' => $requestId, + 'Client-Id' => $config['client_id'], + 'Request-Timestamp' => $dateTimeFinal, + 'Request-Target' => $targetPath, + ), + 'timeout' => 45 + ); + + $response = wp_remote_get($url, $args); + + if (is_wp_error($response)) { + $error_message = $response->get_error_message(); + $this->jokulUtils->doku_log($this, 'Jokul Check Status ERROR: ' . $error_message, $params['invoiceNumber']); + return null; + } - curl_close($ch); + $responseBody = wp_remote_retrieve_body($response); - $this->jokulUtils->doku_log($this, 'Jokul Check Status REQUEST URL : ' . $url, $params['invoiceNumber']); - $this->jokulUtils->doku_log($this, 'Jokul Check Status RESPONSE : ' . json_encode($responseJson, JSON_PRETTY_PRINT), $params['invoiceNumber']); + $this->jokulUtils->doku_log($this, 'Jokul Check Status REQUEST URL: ' . $url, $params['invoiceNumber']); + $this->jokulUtils->doku_log($this, 'Jokul Check Status RESPONSE: ' . json_encode($responseBody, JSON_PRETTY_PRINT), $params['invoiceNumber']); - if (is_string($responseJson)) { - return json_decode($responseJson, true); - } else { - print_r($responseJson); - } + return json_decode($responseBody, true); } } diff --git a/woo-doku-jokul/Service/JokulCheckoutService.php b/woo-doku-jokul/Service/JokulCheckoutService.php index 0ad4440..35d7349 100644 --- a/woo-doku-jokul/Service/JokulCheckoutService.php +++ b/woo-doku-jokul/Service/JokulCheckoutService.php @@ -1,7 +1,9 @@ jokulUtils->guidv4(); $formattedPhoneNumber = $this->jokulUtils->formatPhoneNumber($params['phone']); $targetPath= "/checkout/v1/payment"; - $dateTime = gmdate("Y-m-d H:i:s"); - $dateTime = date(DATE_ISO8601, strtotime($dateTime)); - $dateTimeFinal = substr($dateTime,0,19)."Z"; + $dateTime = gmdate(DATE_ISO8601); + $dateTimeFinal = substr($dateTime, 0, 19) . "Z"; $data = $params['sac_check'] === 'yes' ? array( "order" => $params['auto_redirect'] === 'true' ? array( @@ -71,7 +72,7 @@ public function generated($config, $params) "additional_info" => array ( "integration" => array ( "name" => "woocommerce-plugin", - "version" => "1.3.15", + "version" => "1.3.16", "cms_version" => $params['woo_version'] ), "account" => array( @@ -134,7 +135,7 @@ public function generated($config, $params) "additional_info" => array ( "integration" => array ( "name" => "woocommerce-plugin", - "version" => "1.3.15", + "version" => "1.3.16", "cms_version" => $params['woo_version'] ), "method" => "Jokul Checkout", @@ -151,36 +152,29 @@ public function generated($config, $params) $header['Request-Id'] = $requestId; $header['Request-Timestamp'] = $dateTimeFinal; $header['Request-Target'] = $targetPath; + $header['Content-Type'] = "application/json"; $signature = $this->jokulUtils->generateSignature($header, json_encode($data), $config['shared_key']); + $header['Signature'] = $signature; - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - 'Signature:'.$signature, - 'Request-Id:'.$requestId, - 'Client-Id:'.$config['client_id'], - 'Request-Timestamp:'.$dateTimeFinal, - - )); - - $responseJson = curl_exec($ch); - - curl_close($ch); + $body = json_encode($data); + $args = array( + 'body' => $body, + 'headers' => $header, + 'method' => 'POST', + 'timeout' => 45, + ); + $response = wp_remote_post($url, $args); + $response_body = wp_remote_retrieve_body($response); $this->jokulUtils->doku_log($this, 'Jokul Checkout REQUEST : ' . json_encode($data), $params['invoiceNumber']); + $this->jokulUtils->doku_log($this, 'Jokul Checkout REQUEST Header: ' . json_encode($header), $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']); + $this->jokulUtils->doku_log($this, 'Jokul Checkout RESPONSE : ' . json_encode($response, JSON_PRETTY_PRINT), $params['invoiceNumber']); + $this->jokulUtils->doku_log($this, 'Jokul Checkout RESPONSE Body: ' . json_encode($response_body, JSON_PRETTY_PRINT), $params['invoiceNumber']); + - if (is_string($responseJson)) { - return json_decode($responseJson, true); - } else { - print_r($responseJson); - } + return json_decode($response_body, true); } } diff --git a/woo-doku-jokul/Service/JokulNotificationService.php b/woo-doku-jokul/Service/JokulNotificationService.php index bdc14e5..3babc0f 100644 --- a/woo-doku-jokul/Service/JokulNotificationService.php +++ b/woo-doku-jokul/Service/JokulNotificationService.php @@ -1,8 +1,10 @@ &$value) { + if (is_array($value)) { + $value = $this->sanitize_array($value); + } else { + if (is_string($value)) { + $value = sanitize_text_field($value); + } elseif (is_int($value)) { + $value = intval($value); + } elseif (is_float($value)) { + $value = floatval($value); + } + } + } + return $array; + } public function getNotification($path) { $jokulUtils = new JokulUtils(); - $raw_notification = json_decode(file_get_contents('php://input'), true); + $raw_input = file_get_contents('php://input'); + $raw_notification = json_decode($raw_input, true); $mainSettings = get_option('woocommerce_jokul_gateway_settings'); $headerData = $this->getallheaders(); + if (json_last_error() !== JSON_ERROR_NONE) { + $jokulUtils->doku_log($jokulUtils, 'INVALID JSON INPUT: ' . json_last_error_msg(), null); + http_response_code(400); + echo esc_html(http_response_code()); + return new WP_REST_Response('Invalid JSON input', 400); + } + + $raw_notification = $this->sanitize_array($raw_notification); + $jokulUtils->doku_log($jokulUtils, 'NOTIFICATION : ' . json_encode($raw_notification, JSON_PRETTY_PRINT), $raw_notification['order']['invoice_number']); $jokulUtils->doku_log($jokulUtils, 'NOTIFICATION HEADER : ' . json_encode($headerData, JSON_PRETTY_PRINT), $raw_notification['order']['invoice_number']); @@ -51,9 +80,9 @@ public function getNotification($path) $transaction = $jokulDb->checkTrx($invoiceNumber, $amount, $paymentCode); - if ($transaction != '') { + if (!empty($transaction)){ - $signature = $jokulUtils->generateSignatureNotification($headerData, file_get_contents('php://input'), $sharedKey, $requestTarget); + $signature = $jokulUtils->generateSignatureNotification($headerData, $raw_input, $sharedKey, $requestTarget); if ($signature == $headerData['Signature']) { $jokulUtils->doku_log($jokulUtils, 'TRANSACTION SIGNATURE VALID', $raw_notification['order']['invoice_number']); @@ -81,12 +110,12 @@ public function getNotification($path) } else { $jokulUtils->doku_log($jokulUtils, 'SIGNATURE NOT MATCH!', $raw_notification['order']['invoice_number']); http_response_code(400); - echo http_response_code(); + echo esc_html(http_response_code()); return new WP_REST_Response(null, 400); } } else { http_response_code(404); - echo http_response_code(); + echo esc_html(http_response_code()); return new WP_REST_Response(null, 404); } } diff --git a/woo-doku-jokul/Service/JokulQrisNotificationService.php b/woo-doku-jokul/Service/JokulQrisNotificationService.php index ef56876..a83c1b4 100644 --- a/woo-doku-jokul/Service/JokulQrisNotificationService.php +++ b/woo-doku-jokul/Service/JokulQrisNotificationService.php @@ -1,7 +1,9 @@ doku_log($jokulUtils, 'Qris Notify : ' .'Jokul - Notification Controller Notification Raw Request: '.$raw_notification); - $jokulUtils->doku_log('Qris Notify','Jokul - Notification Controller Qris Notification Request : ' . $_POST['ACQUIRER']); + $jokulUtils->doku_log('Qris Notify','Jokul - Notification Controller Qris Notification Request : ' . sanitize_text_field($_POST['ACQUIRER'])); - $order = wc_get_order($_POST['TRANSACTIONID']); + $order = wc_get_order(sanitize_text_field($_POST['TRANSACTIONID'])); $mainSettings = get_option('woocommerce_jokul_checkout_settings'); $sharedKey = $mainSettings['payment_shared_key']; - $words = $_POST['ISSUERID'] . $_POST['TXNDATE'] . $_POST['MERCHANTPAN'] . $_POST['INVOICE'] . $sharedKey; + $words = sanitize_text_field($_POST['ISSUERID']) . sanitize_text_field($_POST['TXNDATE']) . sanitize_text_field($_POST['MERCHANTPAN']) . sanitize_text_field($_POST['INVOICE']) . $sharedKey; $jokulUtils->doku_log('Qris Notify','Component Words Qris Current : ' . $words); $validateWord = sha1($words); $jokulUtils->doku_log('Qris Notify','Validated Words Qris Current : ' . $validateWord); - $jokulUtils->doku_log('Qris Notify','Words Qris Expected : ' . $_POST['WORDS']); + $jokulUtils->doku_log('Qris Notify','Words Qris Expected : ' . sanitize_text_field($_POST['WORDS'])); if ($validateWord == $_POST['WORDS']) { if (strtolower($_POST['TXNSTATUS']) == strtolower('S')) { - $order = wc_get_order($_POST['TRANSACTIONID']); + $order = wc_get_order(sanitize_text_field($_POST['TRANSACTIONID'])); $order->update_status('processing'); $order->payment_complete(); - $jokulUtils->doku_log('Qris Notify','Jokul - Update transaction to Processing '.$_POST['TRANSACTIONID']); + $jokulUtils->doku_log('Qris Notify','Jokul - Update transaction to Processing '.sanitize_text_field($_POST['TRANSACTIONID'])); echo "SUCCESS"; } else { - $order = wc_get_order($_POST['TRANSACTIONID']); + $order = wc_get_order(sanitize_text_field($_POST['TRANSACTIONID'])); $order->update_status('failed'); - $jokulUtils->doku_log('Qris Notify','Jokul - Update transaction to FAILED '. $_POST['TRANSACTIONID']); + $jokulUtils->doku_log('Qris Notify','Jokul - Update transaction to FAILED '. sanitize_text_field($_POST['TRANSACTIONID'])); echo "SUCCESS"; } } else { - $jokulUtils->doku_log('Qris Notify','Words Not Match '. $_POST['TRANSACTIONID']); + $jokulUtils->doku_log('Qris Notify','Words Not Match '. sanitize_text_field($_POST['TRANSACTIONID'])); } } } diff --git a/woo-doku-jokul/JokulMainPg.php b/woo-doku-jokul/doku-payment.php similarity index 81% rename from woo-doku-jokul/JokulMainPg.php rename to woo-doku-jokul/doku-payment.php index fab0c81..b103f10 100644 --- a/woo-doku-jokul/JokulMainPg.php +++ b/woo-doku-jokul/doku-payment.php @@ -1,9 +1,12 @@ 'POST', 'callback' => function ($request) { - return order_update_status('doku'); + return doku_payment_order_update_status('doku'); }, 'permission_callback' => '__return_true' )); @@ -130,37 +133,37 @@ function installDb() register_rest_route('jokul', 'notification', array( 'methods' => 'POST', 'callback' => function ($request) { - return order_update_status('jokul'); + return doku_payment_order_update_status('jokul'); }, 'permission_callback' => '__return_true' )); }); -function order_update_status($path) +function doku_payment_order_update_status($path) { $notificationService = new JokulNotificationService(); $response = $notificationService->getNotification($path); return $response; } -add_action('rest_api_init', 'qris_register_route'); -function qris_register_route() +add_action('rest_api_init', 'doku_payment_qris_register_route'); +function doku_payment_qris_register_route() { register_rest_route('doku', 'qrisnotification', array( 'methods' => 'POST', - 'callback' => 'order_update_status_qris', + 'callback' => 'doku_payment_order_update_status_qris', 'permission_callback' => '__return_true' )); } -function order_update_status_qris() +function doku_payment_order_update_status_qris() { $qrisNotificationService = new JokulQrisNotificationService(); $response = $qrisNotificationService->getQrisNotification(); } -add_action('woocommerce_thankyou', 'thank_you_page_credit_card', 1, 10); -function thank_you_page_credit_card($order_id) +add_action('woocommerce_thankyou', 'doku_payment_thank_you_page_credit_card', 1, 10); +function doku_payment_thank_you_page_credit_card($order_id) { $chosen_payment_method = WC()->session->get('chosen_payment_method'); if ($chosen_payment_method == 'jokul_creditcard') { @@ -172,8 +175,8 @@ function thank_you_page_credit_card($order_id)

Your payment with Credit Card is success!

diff --git a/woo-doku-jokul/readme.txt b/woo-doku-jokul/readme.txt index 202c905..2d6cb97 100644 --- a/woo-doku-jokul/readme.txt +++ b/woo-doku-jokul/readme.txt @@ -4,10 +4,11 @@ Donate link: https://doku.com/ Tags: Payment Gateway, Payment Requires at least: 2.2 Tested up to: 6.6 -Stable tag: 1.3.14 +Stable tag: 1.3.16 Requires PHP: 5.6 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html +DOKU plugin offers a secure payment with DOKU Checkout, letting customers choose from various payment methods and complete transactions seamlessly. == Description == @@ -29,13 +30,26 @@ Note that the `readme.txt` value of stable tag is the one that is the defining o If you develop in trunk, you can update the trunk `readme.txt` to reflect changes in your in-development version, without having that information incorrectly disclosed about the current stable version that lacks those changes -- as long as the trunk's `readme.txt` points to the correct stable tag. If no stable tag is provided, your users may not get the correct version of your code. - + == Upgrade Notice == -= 1.3.14 = += 1.3.16 = +Fixing minor bug and adjust code to wordpress standards. + +== Change Log == += 1.3.16 = +Fixing minor bug and adjust code to wordpress standards. + +1.3.15 - +DOKU Payment Support Tax and Fee for indodana. + +1.3.14 - DOKU Payment compatible with WooCommerce Checkout Block. -== A brief Markdown Example == +== External services == +This plugin connects to DOKU Checkout to facilitate customer payments by enabling them to select a payment method and complete transactions through DOKU Checkout. For testing, it connects to the sandbox environment at https://api-sandbox.doku.com, while live transactions are processed through the production environment at https://api.doku.com. During payment initiation and processing, the plugin transmits transaction details and customer payment preferences to these endpoints. +Additionally, the plugin uses JokulNotificationService to update payment statuses via a notification endpoint that incorporates the merchant's name as a data. This endpoint is triggered each time an event initiates a status change, ensuring that transaction updates are accurately reflected. +For more information, please refer to DOKU’s Checkout Document https://developers.doku.com/accept-payment/doku-checkout ## Requirements @@ -102,4 +116,52 @@ Blockquotes are email style: And Backticks for code: -`` \ No newline at end of file +`` + +== Frequently Asked Questions == +1. Do I need to have a DOKU Merchant account to use the plugin? +Yes. You can sign up for a merchant account on DOKU Business Account Registration page (https://dashboard.doku.com/register) and obtain your API credentials (Merchant ID and Secret Key). +2. How do I get my API credentials? +To get your API credentials, log in to DOKU Dashboard. Once logged in, follow the steps below +Log in to DOKU Dashboard, and then access the side navigation bar +Select Settings from the menu +Settings page will appear. Under Account section, select API Keys +Your credentials containing Brand ID/Client ID and Secret Key are found on this page +Enter these credentials into the WooCommerce DOKU Checkout settings to enable payment processing +Refer to the following link for the complete guide: +https://docs.doku.com/accept-payments/integration-tools/e-commerce-and-plugins/woocommerce-wordpress +3. What payment methods are supported by DOKU? + 1. Bank Transfer (Virtual Account) + 2. Cards + 3. e-Wallet + 4. QR payment + 5. PayLater + 6. Direct Debit + 7. Digital Banking + 8. Internet banking +Refer to https://docs.doku.com/accept-payments/payment-methods for the complete list +4. Can I add more payment methods? +Yes, you can add more payment methods in DOKU Dashboard by following the steps below: +Log in to DOKU Dashboard, and then access the side navigation bar +Select Settings from the menu +Settings page will appear. Under Account section, select Service +On Service page, click ADD SERVICE button +Select the payment method you would like to activate +Click ACTIVATE button. +Notes: +Some payment methods require our Sales Team's assistance to activate +If payment methods are disabled, that means your account type is limited from activating those payment methods. +5. Can you configure how your checkout page appears? +Yes. DOKU provides configuration settings to customize how your checkout page appears by customizing colors, fonts, store logo, as well as the payment methods you would like to show/hide on the checkout page. +Log in to DOKU Dashboard, and then access the side navigation bar +Select Settings from the menu +Settings page will appear. Under Accept Payments section, select Checkout Appearance +Checkout Page Configuration page will appear, then click Interface Settings tab where you will find several options for customizing the look and feel of your checkout page, including the ability to add your logo and change the background color that fits your brand +Click Save button to save your configuration +6. Is DOKU WooCommerce plugin secure? +Yes, DOKU WooCommerce plugin is secured. It uses industry-standard security protocols, including SSL encryption, to ensure that sensitive customer data (like payment details) is protected during transactions. DOKU complies with PCI-DSS security standards to handle payment card information securely. + +== Screenshots == +1. Customizable Checkout page +2. Various payment channel +3. Configuration Page \ No newline at end of file