diff --git a/.gitignore b/.gitignore index 3d0dbe4..c681cbd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -tests/ \ No newline at end of file +tests/ +.DS_Store diff --git a/MAINTAINING.md b/MAINTAINING.md new file mode 100644 index 0000000..0a7c301 --- /dev/null +++ b/MAINTAINING.md @@ -0,0 +1,120 @@ +### Overview of Code Structures +- /abstract: contains abstract/interface class + - abstract.midtrans-gateway.php: refer to that file comments. Main blueprint implementation for the main gateway + - abstract.midtrans-gateway-sub.php: refer to that file comments. main blueprint implementation for the Separated Payment Buttons gateway, see below section. +- /class: the concrete class implementations for each of +- /midtrans-gateway.php: refer to that file comments. +- /lib: Midtrans API PHP library, commited dependency, need be manually updated to latest Midtrans PHP library on github/composer +- /js: folder for JS file asset on PG config page on WP admin panel +- /public: public asset folder for images, css, js on customer facing UI + - /images/payment-methods: folder of payment method icons + - all image directly used should not be prefixed with `alt_` + - if filename is prefixed with `alt_`, it is not directly used, and only there as alternative image. +- /resources: like library or helper folder, which may no longer be used? @TODO: remove this? +- /readme: required file, act as WP plugin manifest, see [this reference](https://wordpress.org/plugins/readme.txt). + +Other: +- WC/WP have hook functions that will be auto called when certain action are triggered on WC system, e.g: when payment is initiated, when refund occurs, when thank you page showed, etc. + - see ref of "docs WC Payment Gateway" below, to know which functions are built-in function from WC. If not defined there, likely it is our own custom/helper function. + - so most of functions implemented in the code are to implement those built-in functions. + +#### References: +- WC PG development guide: https://docs.woocommerce.com/document/payment-gateway-api/ +- docs WC Order: https://woocommerce.github.io/code-reference/classes/WC-Order.html +- docs WC Payment Gateway: https://woocommerce.github.io/code-reference/classes/WC-Payment-Gateway.html +- WC hooks guide: https://woocommerce.github.io/code-reference/hooks/hooks.html +- official WP plugin dev guide: https://developer.wordpress.org/plugins/intro/ +- sample [PG plugin implementation](https://github.com/woocommerce/woocommerce-gateway-stripe/) from official WC team. [Some other](https://github.com/woocommerce?q=gateway&type=&language=&sort=). +- External WC PG dev guide: https://www.skyverge.com/blog/how-to-create-a-simple-woocommerce-payment-gateway/ +- WP get_options() functions: https://developer.wordpress.org/reference/functions/get_option/ + +### Separted Payment Buttons +To implement separated payment buttons (separate WC payment gateway) for each of Midtrans' supported payment methods, the following implementations are made: +- within `/class/sub-specific-buttons` those are the class files + - these class extends abstract `/abstract/abstract.midtrans-gateway-sub.php` + - which extends main gateway/button `/class/abstract.midtrans-gateway.php`, and most of the core logic are using the logic in implemented in this file. Like: Snap API calling, Notif handling, etc. + - which extends main abstract `/abstract/abstract.midtrans-gateway.php` + - so becareful when modifying these chain of files, as it may impact many other files. +- each of them is imported into `/midtrans-gateway.php` to register the buttons into WC + +Quick guide to add new separate button for future payment methods: +- copy one of the file at `/class/sub-specific-buttons`, e.g: `class.midtrans-gateway-sub-gopay.php` as template. Rename the new file into e.g: `class.midtrans-gateway-sub-bni-va.php` +- within the file, replace all the `gopay` keyword with the new payment method's keyword e.g: `bni_va` + - mind the upper/lower case +- within file `/midtrans-gateway.php`: + - add code to import ` +require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-bni-va.php';` + - add code to register WC gateway ` + $methods[] = 'WC_Gateway_Midtrans_Sub_BNI_VA';` +- add new image files (for the payment method's icon) into `/public/images/payment-methods`. e.g: `bni_va.png` +- also change the image file names values, you can refer to the file's code comments. + +Alternatively, you can also refer to commit history of when a separate button is added, for example one commit w/ msg: `add basic separate button gateway: card`. + +Note: this section may not be frequently updated and may become outdated. In the case the code itself is more updated than this section, please refer to the code itself. + +### User Guide +- Some of specific featues of this plugins are documented on Github wiki: https://github.com/veritrans/SNAP-Woocommerce/wiki. @TODO: need to centralize this to Midtrans tech docs? +- Some are in [README.md](./README.md) +- Some are in [Midtrans tech docs](https://docs.midtrans.com/en/snap/with-plugins?id=wordpress-woocommerce) + +### Releasing / Publishing Plugins to Wordpress +Plugin WP Hosted url: https://wordpress.org/plugins/midtrans-woocommerce/ + +**HOW TO:** + +#### Prepare: Clone svn repo from Wordpress to local +- This step only required once, to make sure you have the svn cloned on local folder +- Prepare a separated folder from this github repo folder on your local +- Clone the SVN Repo URL: https://plugins.svn.wordpress.org/midtrans-woocommerce/ + - Ref on SVN guidelines: + - https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/ + - https://developer.wordpress.org/plugins/wordpress-org/how-to-use-subversion/ + - https://developer.wordpress.org/plugins/wordpress-org/plugin-developer-faq/ + - https://wordpress.org/plugins/about/readme.txt + - https://wordpress.org/plugins/about/validator/ + - https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/ +- Run `svn update` to get update from remote repo to local repo + +#### Update plugin +- On Github repo folder, update version compatibility & tested up to in these files: + - `midtrans-gateway.php`: + - `Version:` {current plugin version: x.x.x} + - `WC tested up to:` {latest WC version: x.x.x} + - `readme.txt`: + - `Requires at least:` {min version of WP, rarely changes: x.x.x} + - `Tested up to:` {latest WP version: x.x.x} + - `Stable tag:` {latest/stable version of this plugin (must have its own /trunk folder): x.x.x} +- Copy contents of Github root folder `Snap-Woocommerce` into your SVN folder, under `/trunk` folder +- Create new folder under `/tags` folder, name it with the plugin version. e.g: `2.6.3` +- Ensure `Stable tag` value within `readme.txt` in folder `trunk` have the same value as above e.g: `2.6.3` + - values that need to be consistent: + - stable tag in readme.txt `/trunk` + - stable tag in readme.txt `/tags/[new version folder]` + - version in `midtrans-gateway.php` + +Note, alternatively can also: +- First, svn push the `/tags/[new version folder]`, ensure have been pushed on WP svn. +- Then, edit the readme / trunks version value to match the new version, then push svn again. + +Note, if you are deleting commited files: +- SVN will not auto remove files commited in repo, removing commited files in SVN need to be 1by1, here is helper script to bulk remove commited files: + - run script in terminal from your svn repo: `svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )` + - src: https://stackoverflow.com/a/9600437 + +#### Push to SVN +Run terminal command: +- `svn add tags/*` +- `svn add trunk/*` +- `svn add assets/*` +- `svn ci -m '' --username --password ` + +Alternatively, can also create helper script `update_and_push_to_wp.sh` file: +``` +#!/usr/bin/env bash +svn add tags/* --force; +svn add trunk/* --force; +svn add assets/* --force; +# svn up; +svn ci -m 'update' --password ; +``` \ No newline at end of file diff --git a/README.md b/README.md index c67c293..7b4816b 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,17 @@ Additional payment options (radio button) can be activated: - Offline Installment - Promo / specific payment +#### Customize Payment Icons + +You can customize icon that will be shown on payment buttons, from the plugin configuration page on your WooCommerce portal, under `Button Icons` config field. + +All available values for the field: +``` +credit_card.png, gopay.png, shopeepay.png, qris.png, other_va.png, bni_va.png, bri_va.png, bca_va.png, permata_va.png, echannel.png, alfamart.png, indomaret.png, akulaku.png, bca_klikpay.png, cimb_clicks.png, danamon_online.png, midtrans.png +``` + +Or refer to [payment-methods folder](/public/images/payment-methods) to see the list of all available file names. The image file will be loaded from that folder. + #### BCA Klikpay Specific
Click to expand info @@ -110,6 +121,55 @@ If required to change API endpoint/url, these are where you need to change: - Replace any Snap API domain: https://app.sandbox.midtrans.com with UAT API domain
+#### Available Custom Hooks + +
Click to expand info +
+ +If you are a developer or know how to customize Wordpress, this section may be useful for you in case you want to customize some code/behaviour of this plugin. + +This plugin have few available [WP hooks](ttps://developer.wordpress.org/plugins/hooks/): +- filter: `midtrans_snap_params_main_before_charge` (1 params) + - For if you want to modify Snap API JSON param on the main gateway, before transaction is created on Midtrans side. +- action: `midtrans_after_notification_payment_complete` (2 params) + - For if you want to perform action/update WC Order object when the payment is declared as complete upon Midtrans notification received. +- action: `midtrans_on_notification_received` (2 params) + - For if you want to perform action/update WC Order object upon Midtrans notification received. + +Example implementation: +```php +// Custom filter hook to modify Snap params +add_filter( 'midtrans_snap_params_main_before_charge', 'my_midtrans_snap_param_hook' ); +function my_midtrans_snap_param_hook( $params ) { + // example: modify Snap params to add additional item with 0 price + $params['item_details'][] = array( + "name" => "My Custom Additional Item", + "id" => "my-item-01", + "price" => 0, + "quantity" => 3, + ); + // don't forget to return the $params + return $params; +} + +// Custom action hook to modify WC Order object after payment marked as complete +add_action( 'midtrans_after_notification_payment_complete', 'my_midtrans_complete_hook',$priority = 10, $accepted_args = 2 ); +function my_midtrans_complete_hook( $order, $midtrans_notification ) { + // example: update order status to directly `completed`, instead of default `processing`. + $order->update_status('completed',__('Completed payment via my custom hook: Midtrans-'.$midtrans_notification->payment_type,'midtrans-woocommerce')); +} + +// Custom action hook to modify WC Order object when midtrans notification is received +add_action( 'midtrans_on_notification_received', 'my_midtrans_on_notif_hook',$priority = 10, $accepted_args = 2 ); +function my_midtrans_on_notif_hook( $order, $midtrans_notification ) { + // do as you wish here +} +``` + +For reference on where/which file to apply that code example, [refer here](https://blog.nexcess.net/the-right-way-to-add-custom-functions-to-your-wordpress-site/). + +
+ #### Customizing Snap API parameters
Click to expand info diff --git a/abstract/abstract.midtrans-gateway-sub.php b/abstract/abstract.midtrans-gateway-sub.php new file mode 100644 index 0000000..ead1132 --- /dev/null +++ b/abstract/abstract.midtrans-gateway-sub.php @@ -0,0 +1,148 @@ +id = ''; // override me. sample: 'midtrans_sub_other_va'; + // $this->sub_payment_method_params = []; // override me. sample: ['other_va']; + // $this->sub_payment_method_image_file_names_str_final = []; // override me. sample: 'other_va.png,other_va_2.png'; + // override above values when extending this class + + $this->method_title = __( $this->pluginTitle(), 'midtrans-woocommerce' ); + $this->method_description = __( $this->getSettingsDescription(), 'midtrans-woocommerce'); + $this->main_gateway = false; + + parent::__construct(); + add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); + // maybe replace $this->id with main gateway id? + add_action( 'woocommerce_receipt_' . $this->id, array( $this, 'receipt_page' ) );// Payment page hook + } + + /** + * Hook function that will be auto-called by WC, this determine what will be shown on Gateway config page on WP panel + * Admin Panel Options + * - Options for bits like 'title' and availability on a country-by-country basis + * @access public + * @return void + */ + public function admin_options() { ?> +

pluginTitle(), 'midtrans-woocommerce' ); ?>

+

getSettingsDescription(), 'midtrans-woocommerce' ); ?>

+ + generate_settings_html(); + ?> +
+ form_fields = + apply_filters( + 'wc_midtrans_settings', + array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'midtrans-woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable this specific payment methods', 'midtrans-woocommerce' ), + 'default' => 'no' + ), + 'title' => array( + 'title' => __( 'Payment Title', 'midtrans-woocommerce' ), + 'type' => 'text', + 'description' => __( 'This controls the payment label title which the user sees during checkout. This support HTML tags like <img> tag, if you want to include images.', 'midtrans-woocommerce' ), + 'placeholder' => $this->getDefaultTitle(), + 'default' => $this->getDefaultTitle(), + // 'desc_tip' => true, + ), + 'description' => array( + 'title' => __( 'Payment Description', 'midtrans-woocommerce' ), + 'type' => 'textarea', + 'description' => __( 'You can customize here the expanded description which the user sees during checkout when they choose this payment. This support HTML tags like <img> tag, if you want to include images.', 'midtrans-woocommerce' ), + 'placeholder' => $this->getDefaultDescription(), + 'default' => $this->getDefaultDescription(), + ), + 'advanced_config_separator' => array( + 'title' => __( 'Note:', 'midtrans-woocommerce' ), + 'type' => 'title', + 'description' => __( 'Other configurations by default will follow main Midtrans Payment plugin config'), + ), + ) + ); + } + /** + * Override Hook function that will be auto-called by WC on customer initiate payment + * act as entry point when payment process is initated + * @param string $order_id generated from WC + * @return array contains redirect_url of payment for customer + */ + function process_payment( $order_id ) { + $main_gateway = $this->getMainGatewayObject(); + // pass through the real function from main gateway implementation, with options params + return $main_gateway->process_payment_helper( + $order_id, + array('sub_payment_method_params' => $this->sub_payment_method_params) + ); + } + + /** + * Hook function that will be auto-called by WC on receipt page + * Output HTML for Snap payment page. Including `snap.pay()` part + * @param string $order_id generated by WC + * @return string HTML + */ + function receipt_page( $order_id ) { + // pass through the real function from main gateway implementation + $main_gateway = $this->getMainGatewayObject(); + return $main_gateway->receipt_page($order_id); + } + + /** + * @return string Title for plugin config page + */ + abstract public function pluginTitle (); + + /** + * @return string Description for plugin config page + */ + abstract public function getSettingsDescription (); + + /** + * @return string Config field: Title for pay button label for customer + */ + abstract protected function getDefaultTitle (); + + /** + * @return string Config field: Description for pay button label for customer + */ + abstract protected function getDefaultDescription (); + + /** + * @return WC_Gateway_Midtrans + */ + protected function getMainGatewayObject(){ + if ($this->main_gateway && $this->main_gateway->id) { + // main gateway exist, do nothing + } else { + $this->main_gateway = new WC_Gateway_Midtrans(); + } + return $this->main_gateway; + } + +} \ No newline at end of file diff --git a/abstract/abstract.midtrans-gateway.php b/abstract/abstract.midtrans-gateway.php index a007800..67da586 100644 --- a/abstract/abstract.midtrans-gateway.php +++ b/abstract/abstract.midtrans-gateway.php @@ -5,7 +5,10 @@ /** * WC_Gateway_Midtrans_Abstract class. - * + * This class is made as a main blueprint that will be extended by each of the + * payment gateway/buttons. Because Midtrans WC plugin contains multiple separate buttons + * with each of its own config and functionality + * * @extends WC_Payment_Gateway */ abstract class WC_Gateway_Midtrans_Abstract extends WC_Payment_Gateway { @@ -25,6 +28,7 @@ public function __construct() { // Get Settings $this->title = $this->get_option( 'title' ); $this->description = $this->get_option( 'description' ); + $this->sub_payment_method_image_file_names_str = $this->get_option( 'sub_payment_method_image_file_names_str' ); $this->environment = $this->get_option( 'select_midtrans_environment' ); $this->client_key = ($this->environment == 'production') ? $this->get_option( 'client_key_v2_production' ) : $this->get_option( 'client_key_v2_sandbox' ); $this->server_key = ($this->environment == 'production') ? $this->get_option( 'server_key_v2_production' ) : $this->get_option( 'server_key_v2_sandbox' ); @@ -87,7 +91,7 @@ public function init_form_fields() { } /** - * Hook function that will be called on thank you page + * Hook function that will be auto-called by WC on thank you page * Output HTML for payment/instruction URL * @param string $order_id generated by WC * @return string HTML @@ -98,6 +102,7 @@ public function view_order_and_thankyou_page( $order_id ) { /** * Refund a charge + * Hook function that will be auto-called by WC on refund action by admin * @param int $order_id * @param float $amount * @return bool @@ -115,6 +120,7 @@ public function process_refund($order_id, $amount = null, $reason = '') { /** * Process a payment object refund + * Custom helper function to initiate refund to Midtrans * * @param WC_Order $order * @param int $order_id @@ -147,7 +153,7 @@ public function refund( $order, $order_id, $amount, $reason ) { /** * Plugin config and cart/order properties are used as params - * + * Custom helper function to generate Midtrans Snap API params/payload * @param $order_id * @return object $params */ @@ -320,7 +326,7 @@ public function getResponseTemplate( $order ) { } /** - * Handle Midtrans Refund, when refund trigger not from woocommerce + * Helper function to handle Midtrans Refund, when refund trigger not from WC but from Midtrans * @param [int] $order_id * @param [int] $refund_amount * @param [string] $refund_reason @@ -380,10 +386,47 @@ public function midtrans_refund( $order_id, $refund_amount, $refund_reason, $isF return $refund; } + /** + * Custom helper function to write messages to WP/WC error log. + * @TODO: refactor name to make it more descriptive? + * @param string $message the error message that will be recorded + */ public function setLogError( $message ) { WC_Midtrans_Logger::log( $message, 'midtrans-error', $this->id, current_time( 'timestamp' ) ); } + /** + * Hook function that will be auto-called by WC on payment page to show button's icon for this payment gateway button + * @return string Gateway payment button html tag to render icon images. + */ + public function get_icon() + { + $image_file_name_str = false; + if(isset($this->sub_payment_method_image_file_names_str_final)){ + $image_file_name_str = $this->sub_payment_method_image_file_names_str_final; + } else if (isset($this->sub_payment_method_image_file_names_str)){ + $image_file_name_str = $this->sub_payment_method_image_file_names_str; + } + + $image_tag = ''; + if( isset($image_file_name_str) && is_string($image_file_name_str) ){ + $image_file_names = explode(',', $image_file_name_str); + foreach ($image_file_names as $image_file_name) { + if(strlen($image_file_name)<=0){ continue; } + // remove whitespaces + $image_file_name = str_replace(' ', '', $image_file_name); + // prefix with internal image url + $image_url = MIDTRANS_PLUGIN_DIR_URL.'public/images/payment-methods/'.$image_file_name; + if(strpos($image_file_name, '://') !== false){ + // image is absolute url, external, don't prefix. + $image_url = $image_file_name; + } + $image_tag .= 'Midtrans '; + } + } + return apply_filters('woocommerce_gateway_icon', $image_tag, $this->id); + } + /** * @return string */ @@ -393,4 +436,10 @@ abstract protected function getDefaultTitle (); * @return string */ abstract protected function getDefaultDescription (); + /** + * @return string The main gateway plugin's Notification URL that will be displayed to config page + */ + public function get_main_notification_url(){ + return add_query_arg( 'wc-api', 'WC_Gateway_Midtrans', home_url( '/' ) ); + } } \ No newline at end of file diff --git a/class/class.midtrans-gateway-api.php b/class/class.midtrans-gateway-api.php index 7289254..cb44afd 100644 --- a/class/class.midtrans-gateway-api.php +++ b/class/class.midtrans-gateway-api.php @@ -45,6 +45,7 @@ public static function set_environment( $environment ) { self::$environment = $environment; } + // @TODO: maybe handle when $plugin_id is invalid (e.g: `all`), it result in invalid $plugin_options, then empty serverKey, then it will cause failure on getStatusFromMidtransNotif. Make $plugin_options default value to `midtrans` plugin when serverKey not found?. /** * Fetch Plugin Options and Set as self/private vars * @param string $plugin_id diff --git a/class/class.midtrans-gateway-installment.php b/class/class.midtrans-gateway-installment.php index 25b7569..864450c 100755 --- a/class/class.midtrans-gateway-installment.php +++ b/class/class.midtrans-gateway-installment.php @@ -13,7 +13,7 @@ class WC_Gateway_Midtrans_Installment extends WC_Gateway_Midtrans_Abstract { function __construct() { $this->id = 'midtrans_installment'; $this->method_title = __( $this->pluginTitle(), 'midtrans-woocommerce' ); - $this->notify_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'WC_Gateway_Midtrans_Installment', home_url( '/' ) ) ); + $this->method_description = $this->getSettingsDescription(); parent::__construct(); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); @@ -22,7 +22,7 @@ function __construct() { public function admin_options() { ?>

pluginTitle(), 'midtrans-woocommerce' ); ?>

-

+

getSettingsDescription(), 'midtrans-woocommerce' ); ?>

Installment(Cicilan) feature, only used if you already have agreement with bank (leave it disabled if not sure).', 'midtrans-woocommerce'); + } + /** * @return string */ diff --git a/class/class.midtrans-gateway-installmentoff.php b/class/class.midtrans-gateway-installmentoff.php index 91cede2..9f9e3d6 100755 --- a/class/class.midtrans-gateway-installmentoff.php +++ b/class/class.midtrans-gateway-installmentoff.php @@ -12,7 +12,7 @@ class WC_Gateway_Midtrans_InstallmentOff extends WC_Gateway_Midtrans_Abstract { function __construct() { $this->id = 'midtrans_installment_offline'; $this->method_title = __( $this->pluginTitle(), 'midtrans-woocommerce' ); - $this->notify_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'WC_Gateway_Midtrans_InstallmentOff', home_url( '/' ) ) ); + $this->method_description = $this->getSettingsDescription(); parent::__construct(); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); @@ -22,7 +22,7 @@ function __construct() { public function admin_options() { ?>

pluginTitle(), 'midtrans-woocommerce' ); ?>

-

+

getSettingsDescription(), 'midtrans-woocommerce' ); ?>

Installment(Cicilan) feature, only used if you already have agreement with bank (leave it disabled if not sure).', 'midtrans-woocommerce'); } /** diff --git a/class/class.midtrans-gateway-notif-handler.php b/class/class.midtrans-gateway-notif-handler.php index de13e25..1ecbb2d 100644 --- a/class/class.midtrans-gateway-notif-handler.php +++ b/class/class.midtrans-gateway-notif-handler.php @@ -32,7 +32,7 @@ public function __construct() { */ public function doEarlyAckResponse() { if ( $_SERVER['REQUEST_METHOD'] == 'GET' ) { - die('This endpoint should not be opened using browser (HTTP GET). This endpoint is for Midtrans notification URL (HTTP POST)'); + die('This endpoint is for Midtrans notification URL (HTTP POST). This message will be shown if opened using browser (HTTP GET). You can copy this current URL on your browser address bar and paste it to: "Midtrans Dashboard > Settings > Configuration > Notification Url". This will allow your WooCommerce to receive Midtrans payment status, which will auto sync the payment status.'); exit(); } @@ -90,8 +90,6 @@ public function handleMidtransNotificationRequest() { if(empty($sanitized['order_id']) && empty($sanitizedPost['id']) && empty($sanitized['id']) && empty($sanitizedPost['response'])) { // Request is POST, proceed to create new notification, then update the payment status $raw_notification = $this->doEarlyAckResponse(); - // Handle pdf url update - $this->handlePendingPaymentPdfUrlUpdate(); // Get WooCommerce order $wcorder = wc_get_order( $raw_notification['order_id'] ); // exit if the order id doesn't exist in WooCommerce dashboard @@ -101,6 +99,10 @@ public function handleMidtransNotificationRequest() { } // Get current plugin id else $plugin_id = $wcorder->get_payment_method(); + if(strpos($plugin_id, 'midtrans_sub') !== false){ + // for sub separated gateway buttons, use main gateway plugin id instead + $plugin_id = 'midtrans'; + } // Verify Midtrans notification $midtrans_notification = WC_Midtrans_API::getStatusFromMidtransNotif( $plugin_id ); // If notification verified, handle it @@ -193,51 +195,6 @@ public function handleMidtransNotificationRequest() { } } - /** - * UNUSED - * @TODO: Evaluate if this still required/used - * Handle API call from payment page to update order with PDF instruction Url - * @return void - */ - public function handlePendingPaymentPdfUrlUpdate(){ - try { - global $woocommerce; - $requestObj = json_decode(file_get_contents("php://input"), true); - if( !isset($requestObj['pdf_url_update']) || - !isset($requestObj['snap_token_id']) ){ - return; - } - // @FIXME: $this is broken, it doesn't refer to plugin class - $snapApiBaseUrl = ($this->environment) ? 'https://app.midtrans.com' : 'https://app.sandbox.midtrans.com'; - $tokenStatusUrl = $snapApiBaseUrl.'/snap/v1/transactions/'.$requestObj['snap_token_id'].'/status'; - $tokenStatusResponse = wp_remote_get( $tokenStatusUrl); - $tokenStatus = json_decode($tokenStatusResponse['body'], true); - $paymentStatus = $tokenStatus['transaction_status']; - $order = new WC_Order( $tokenStatus['order_id'] ); - $orderStatus = $order->get_status(); - - // update order status to on-hold if current status is "pending payment" - if($orderStatus == 'pending' && $paymentStatus == 'pending'){ - $order->update_status('on-hold',__('Midtrans onPending Callback received','midtrans-woocommerce')); - - } - if( !isset($tokenStatus['pdf_url']) ){ - return; - } - - // store Url as $Order metadata - $order->update_meta_data('_mt_payment_pdf_url',$tokenStatus['pdf_url']); - $order->save(); - - echo esc_html("OK"); - // immediately terminate notif handling, not a notification. - exit(); - } catch (Exception $e) { - // var_dump($e); - // exit(); - } - } - /** * Handle Midtrans Notification Object, after payment status changes on Midtrans * Will update WC payment status accordingly @@ -251,6 +208,9 @@ public function handleMidtransValidNotificationRequest( $midtrans_notification, $order = new WC_Order( $midtrans_notification->order_id ); $order->add_order_note(__('Midtrans HTTP notification received: '.$midtrans_notification->transaction_status.'. Midtrans-'.$midtrans_notification->payment_type,'midtrans-woocommerce')); $order_id = $midtrans_notification->order_id; + + // allow merchant-defined custom action function to perform action on $order upon notif handling + do_action( 'midtrans_on_notification_received', $order, $midtrans_notification ); if ($midtrans_notification->transaction_status == 'capture') { if ($midtrans_notification->fraud_status == 'accept') { @@ -258,9 +218,11 @@ public function handleMidtransValidNotificationRequest( $midtrans_notification, if( class_exists( 'WC_Subscriptions' ) ){ $this->checkAndHandleWCSubscriptionTxnNotif( $midtrans_notification, $order ); } - $order->payment_complete(); + $order->payment_complete($midtrans_notification->transaction_id); $order->add_order_note(__('Midtrans payment completed: capture. Midtrans-'.$midtrans_notification->payment_type,'midtrans-woocommerce')); - + // allow merchant-defined custom action function to perform action on $order + do_action( 'midtrans_after_notification_payment_complete', + $order, $midtrans_notification ); } else if ($midtrans_notification->fraud_status == 'challenge') { $order->update_status('on-hold',__('Challanged payment: Midtrans-'.$midtrans_notification->payment_type,'midtrans-woocommerce')); @@ -278,8 +240,11 @@ public function handleMidtransValidNotificationRequest( $midtrans_notification, } else if ($midtrans_notification->transaction_status == 'settlement') { if($midtrans_notification->payment_type != 'credit_card'){ - $order->payment_complete(); + $order->payment_complete($midtrans_notification->transaction_id); $order->add_order_note(__('Midtrans payment completed: settlement. Midtrans-'.$midtrans_notification->payment_type,'midtrans-woocommerce')); + // allow merchant-defined custom action function to perform action on $order + do_action( 'midtrans_after_notification_payment_complete', + $order, $midtrans_notification ); } } else if ($midtrans_notification->transaction_status == 'pending') { @@ -294,7 +259,6 @@ public function handleMidtransValidNotificationRequest( $midtrans_notification, exit; } $order->update_status('on-hold',__('Awaiting payment: Midtrans-'.$midtrans_notification->payment_type,'midtrans-woocommerce')); - error_log($plugin_options['ignore_pending_status']); } else if ($midtrans_notification->transaction_status == 'refund' || $midtrans_notification->transaction_status == 'partial_refund') { $refund_request = $this->validateRefundNotif( $midtrans_notification ); diff --git a/class/class.midtrans-gateway-paymentrequest.php b/class/class.midtrans-gateway-paymentrequest.php index 3541a5d..afb6288 100755 --- a/class/class.midtrans-gateway-paymentrequest.php +++ b/class/class.midtrans-gateway-paymentrequest.php @@ -17,7 +17,6 @@ function __construct() { $this->id = 'midtrans_paymentrequest'; $this->method_title = __( $this->pluginTitle(), 'midtrans-woocommerce' ); $this->method_description = $this->getSettingsDescription(); - $this->notify_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'WC_Gateway_Midtrans_Paymentrequest', home_url( '/' ) ) ); parent::__construct(); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); @@ -119,7 +118,7 @@ function receipt_page( $order_id ) { * @return string */ public function pluginTitle() { - return "Midtrans Optional Card in-Browser Payment UI"; + return "Midtrans Adv: Card in-Browser Payment UI"; } /** diff --git a/class/class.midtrans-gateway-promo.php b/class/class.midtrans-gateway-promo.php index 6f47018..6ffc717 100755 --- a/class/class.midtrans-gateway-promo.php +++ b/class/class.midtrans-gateway-promo.php @@ -16,7 +16,7 @@ class WC_Gateway_Midtrans_Promo extends WC_Gateway_Midtrans_Abstract { function __construct() { $this->id = 'midtrans_promo'; $this->method_title = __( $this->pluginTitle(), 'midtrans-woocommerce' ); - $this->notify_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'WC_Gateway_Midtrans_Promo', home_url( '/' ) ) ); + $this->method_description = $this->getSettingsDescription(); parent::__construct(); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); @@ -32,7 +32,7 @@ function __construct() { */ public function admin_options() { ?>

pluginTitle(), 'midtrans-woocommerce' ); ?>

-

+

getSettingsDescription(), 'midtrans-woocommerce' ); ?>

payment-method based promo, usually only used if you have promo agreement with bank/payment provider (leave it disabled if not sure).', 'midtrans-woocommerce'); + } + /** * @return string */ diff --git a/class/class.midtrans-gateway-subscription.php b/class/class.midtrans-gateway-subscription.php index 7cc5f27..4941837 100644 --- a/class/class.midtrans-gateway-subscription.php +++ b/class/class.midtrans-gateway-subscription.php @@ -11,7 +11,6 @@ function __construct() { $this->id = 'midtrans_subscription'; $this->method_title = __( $this->pluginTitle(), 'midtrans-woocommerce' ); $this->method_description = $this->getSettingsDescription(); - $this->notify_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'WC_Gateway_Midtrans_Subscription', home_url( '/' ) ) ); parent::__construct(); $this->supports = array( 'refunds', diff --git a/class/class.midtrans-gateway.php b/class/class.midtrans-gateway.php index c32427e..1f8ed6d 100755 --- a/class/class.midtrans-gateway.php +++ b/class/class.midtrans-gateway.php @@ -26,6 +26,7 @@ /** * Midtrans Payment Gateway Class + * extend implementation from main blueprint of abstract class */ class WC_Gateway_Midtrans extends WC_Gateway_Midtrans_Abstract { @@ -40,7 +41,6 @@ function __construct() { $this->method_title = __( $this->pluginTitle(), 'midtrans-woocommerce' ); $this->method_description = $this->getSettingsDescription(); $this->has_fields = true; - $this->notify_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'WC_Gateway_Midtrans', home_url( '/' ) ) ); parent::__construct(); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); @@ -50,13 +50,13 @@ function __construct() { /** * Admin Panel Options - * HTML that will be displayed on Admin Panel + * See definition on the extended abstract class * @access public * @return void */ public function admin_options() { ?>

pluginTitle(), 'midtrans-woocommerce' ); ?>

-

+

getSettingsDescription(), 'midtrans-woocommerce' ); ?>

/** * Initialise Gateway Settings Form Fields - * Method ini digunakan untuk mengatur halaman konfigurasi admin + * See definition on the extended abstract class */ function init_form_fields() { - /** - * Build array of configurations that will be displayed on Admin Panel - */ + // Build array of configuration fieldss that will be displayed on Admin Panel + // Use config fields template from abstract class parent::init_form_fields(); + // Specific config fields for this main gateway goes below WC_Midtrans_Utils::array_insert( $this->form_fields, 'enable_3d_secure', array( 'acquring_bank' => array( 'title' => __( 'Acquiring Bank', 'midtrans-woocommerce'), @@ -84,17 +84,31 @@ function init_form_fields() { 'default' => '' ) )); - // Make this payment method enabled by default + // Make this payment method enabled-checkbox 'yes' by default $this->form_fields['enabled']['default'] = 'yes'; + // Set icons config field specific placeholder + $this->form_fields['sub_payment_method_image_file_names_str']['placeholder'] = 'midtrans.png,credit_card.png'; + $this->form_fields['sub_payment_method_image_file_names_str']['default'] = 'midtrans.png'; } /** - * This function auto-triggered by WC when payment process initiated - * Serves as WC payment entry point - * @param [String] $order_id auto generated by WC - * @return [array] contains redirect_url of payment for customer + * Hook function that will be auto-called by WC on customer initiate payment + * act as entry point when payment process is initated + * @param string $order_id generated from WC + * @return array contains redirect_url of payment for customer */ function process_payment( $order_id ) { + // pass through the real function handling the logic + return $this->process_payment_helper($order_id); + } + + /** + * Helper function to handle additional params from sub separated gateway buttons + * @param string $order_id auto generated by WC + * @param array mixed array opts, used by sub separated gateway buttons classes + * @return array contains redirect_url of payment for customer + */ + public function process_payment_helper( $order_id, $options = false ) { global $woocommerce; // Create the order object @@ -107,8 +121,16 @@ function process_payment( $order_id ) { if (strlen($this->get_option('acquring_bank')) > 0) $params['credit_card']['bank'] = strtoupper ($this->get_option('acquring_bank')); + // if coming from sub separated gateway buttons + if($options && $options['sub_payment_method_params']){ + $params['enabled_payments'] = $options['sub_payment_method_params']; + } + // @TODO: add order thank you page as snap finish url + // Empty the cart because payment is initiated. $woocommerce->cart->empty_cart(); + // allow merchant-defined custom filter function to modify snap $params + $params = apply_filters( 'midtrans_snap_params_main_before_charge', $params ); try { $snapResponse = WC_Midtrans_API::createSnapTransaction( $params, $this->id ); } catch (Exception $e) { @@ -129,8 +151,11 @@ function process_payment( $order_id ) { $order->update_meta_data('_mt_payment_url',$snapResponse->redirect_url); $order->save(); + // @TODO: default to yes or remove this options: enable_immediate_reduce_stock if(property_exists($this,'enable_immediate_reduce_stock') && $this->enable_immediate_reduce_stock == 'yes'){ // Reduce item stock on WC, item also auto reduced on order `pending` status changes + // @NOTE: unable to replace with this code: `$order->update_status('on-hold',__('Customer proceed to Midtrans Payment page','midtrans-woocommerce'));` + // because of `This order’s status is “On hold”—it cannot be paid for.` wc_reduce_stock_levels($order); } @@ -141,8 +166,9 @@ function process_payment( $order_id ) { /** * Hook function that will be called on receipt page * Output HTML for Snap payment page. Including `snap.pay()` part - * @param [String] $order_id generated by WC - * @return [String] HTML + * See definition on the extended abstract class + * @param string $order_id generated by WC + * @return string HTML */ function receipt_page( $order_id ) { global $woocommerce; @@ -163,21 +189,21 @@ public function pluginTitle() { * @return string */ protected function getDefaultTitle () { - return __('Online Payment via Midtrans', 'midtrans-woocommerce'); + return __('All Supported Payment', 'midtrans-woocommerce'); } /** * @return string */ protected function getSettingsDescription() { - return __('Secure payment via Midtrans that accept various payment methods, with mobile friendly built-in interface, or (optionally) redirection.', 'midtrans-woocommerce'); + return __('Secure payment via Midtrans that accept various payment methods, with mobile friendly built-in interface, or (optionally) redirection. This is the main payment button, 1 single button for multiple available payments methods', 'midtrans-woocommerce'); } /** * @return string */ protected function getDefaultDescription () { - return __('Pay via Midtrans', 'midtrans-woocommerce'); + return __('Accept all various supported payment methods. Choose your preferred payment on the next page. Secure payment via Midtrans.', 'midtrans-woocommerce'); } } diff --git a/class/midtrans-admin-settings.php b/class/midtrans-admin-settings.php index a52f539..9a8c07f 100644 --- a/class/midtrans-admin-settings.php +++ b/class/midtrans-admin-settings.php @@ -61,21 +61,37 @@ 'default' => '', 'class' => 'production_settings toggle-midtrans' ), + 'notification_url_display' => array( + 'title' => __( 'Notification URL value', 'midtrans-woocommerce' ), + 'type' => 'title', + 'description' => __( 'After you have filled required config above, don\'t forget to scroll to bottom and click Save Changes button.

Copy and use this recommended Notification URL '.$this->get_main_notification_url().' into "Midtrans Dashboard > Settings > Configuration > Notification Url". This will allow your WooCommerce to receive Midtrans payment status, which auto sync the payment status.','midtrans-woocommerce'), + ), + 'label_config_separator' => array( + 'title' => __( 'II. Payment Buttons Appereance Section - Optional', 'midtrans-woocommerce' ), + 'type' => 'title', + 'description' => __( '-- Configure how the payment button will appear to customer, you can leave them default.','midtrans-woocommerce'), + ), 'title' => array( - 'title' => __( 'Payment Title', 'midtrans-woocommerce' ), + 'title' => __( 'Button Title', 'midtrans-woocommerce' ), 'type' => 'text', 'description' => __( 'This controls the payment label title which the user sees during checkout. This support HTML tags like <img> tag, if you want to include images.', 'midtrans-woocommerce' ), 'default' => $this->getDefaultTitle(), // 'desc_tip' => true, ), 'description' => array( - 'title' => __( 'Payment Description', 'midtrans-woocommerce' ), + 'title' => __( 'Button Description', 'midtrans-woocommerce' ), 'type' => 'textarea', 'description' => __( 'You can customize here the expanded description which the user sees during checkout when they choose this payment. This support HTML tags like <img> tag, if you want to include images.', 'midtrans-woocommerce' ), 'default' => $this->getDefaultDescription(), ), + 'sub_payment_method_image_file_names_str' => array( + 'title' => __( 'Button Icons', 'midtrans-woocommerce' ), + 'type' => 'text', + 'description' => __( 'You can input multiple payment method names separated by coma (,).
See all available values here, you can copy paste the value, and adjust as needed. Also support https:// url to external image.', 'midtrans-woocommerce' ), + 'placeholder' => 'midtrans.png,credit_card.png', + ), 'advanced_config_separator' => array( - 'title' => __( 'Advanced Config Section - Optional, you can leave them default.', 'midtrans-woocommerce' ), + 'title' => __( 'III. Advanced Config Section - Optional', 'midtrans-woocommerce' ), 'type' => 'title', 'description' => __( '-- Configurations below is optional and don\'t need to be changed, you can leave them default. Unless you know you want advanced configuration --','midtrans-woocommerce'), ), @@ -133,7 +149,7 @@ 'type' => 'checkbox', 'label' => 'Immediately reduce item stock on Midtrans payment pop-up?', 'description' => __( 'By default, item stock only reduced if payment status on Midtrans reach pending/success (customer choose payment channel and click pay on payment pop-up). Enable this if you want to immediately reduce item stock when payment pop-up generated/displayed.', 'midtrans-woocommerce' ), - 'default' => 'no' + 'default' => 'yes' ), // @Note: only main plugin class config will be applied on notif handler, sub plugin class config will not affect it, check gateway-notif-handler.php class to fix 'ignore_pending_status' => array( diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-akulaku.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-akulaku.php new file mode 100644 index 0000000..cee0a66 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-akulaku.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_akulaku'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['akulaku']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'akulaku.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Akulaku"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Akulaku', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('Pay with Akulaku Account/Installment', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-alfamart.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-alfamart.php new file mode 100644 index 0000000..5b338dc --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-alfamart.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_alfamart'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['alfamart']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'alfamart_1.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Alfamart Group"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Alfamart Group (Alfamart, Alfamidi, Dan+Dan)', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('Pay from Alfamart Group, Alfamidi, Dan+Dan outlet', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-bca-klikpay.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-bca-klikpay.php new file mode 100644 index 0000000..ca940e5 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-bca-klikpay.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_bca_klikpay'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['bca_klikpay']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'bca_klikpay.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: BCA KlikPay"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('BCA KlikPay', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-bca-va.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-bca-va.php new file mode 100644 index 0000000..0a9e889 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-bca-va.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_bca_va'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['bca_va']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'bca_va.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Bank Transfer BCA VA"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Bank Transfer - BCA VA', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('Only accept transfer from BCA account.', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-bni-va.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-bni-va.php new file mode 100644 index 0000000..75d07a6 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-bni-va.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_bni_va'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['bni_va']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'bni_va.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Bank Transfer BNI VA"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Bank Transfer - BNI VA', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('Accept transfer from any bank, and BNI account.', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-bri-epay.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-bri-epay.php new file mode 100644 index 0000000..00ac17d --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-bri-epay.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_bri_epay'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['bri_epay']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'bri_epay.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: e-Pay BRI"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('e-Pay BRI', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-bri-va.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-bri-va.php new file mode 100644 index 0000000..37ea2b3 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-bri-va.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_bri_va'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['bri_va']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'bri_va.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Bank Transfer BRI VA"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Bank Transfer - BRI VA', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('Accept transfer from any bank, and BRI account.', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-card.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-card.php new file mode 100644 index 0000000..8fc9ba8 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-card.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_card'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['credit_card']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'cc_amex.png,cc_jcb.png,cc_master.png,cc_visa.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Card Payment"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Credit/Debit Card', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-cimb-clicks.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-cimb-clicks.php new file mode 100644 index 0000000..4d45f53 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-cimb-clicks.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_cimb_clicks'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['cimb_clicks']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'cimb_clicks.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: CIMB OCTO Clicks"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('OCTO Clicks', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-danamon-online.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-danamon-online.php new file mode 100644 index 0000000..60b2640 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-danamon-online.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_danamon_online'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['danamon_online']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'danamon_online.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Danamon Online Banking"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Danamon Online Banking', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-echannel.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-echannel.php new file mode 100644 index 0000000..7f405fb --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-echannel.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_echannel'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['echannel']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'echannel.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Bank Transfer Mandiri Bill Payment"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Bank Transfer - Mandiri Bill Payment', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('Only accept Bill Payment from Mandiri account.', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-gopay.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-gopay.php new file mode 100644 index 0000000..7c0c8af --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-gopay.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_gopay'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['gopay']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'qris.png,gopay.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: GoPay & QRIS"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('GoPay', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-indomaret.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-indomaret.php new file mode 100644 index 0000000..f2296eb --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-indomaret.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_indomaret'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['indomaret']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'indomaret.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Indomaret"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Indomaret', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-other-va.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-other-va.php new file mode 100644 index 0000000..eac55d3 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-other-va.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_other_va'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['other_va']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'other_va_3.png,other_va_2.png,other_va_1.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Bank Transfer Other"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Bank Transfer - Other', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('Bank Transfer for other banks', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-permata-va.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-permata-va.php new file mode 100644 index 0000000..98fefea --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-permata-va.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_permata_va'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['permata_va']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'permata_va.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: Bank Transfer Permata VA"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('Bank Transfer - Permata VA', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('Accept transfer from any bank, and Permata account.', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-qris.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-qris.php new file mode 100644 index 0000000..c391bda --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-qris.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_qris'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['gopay']; // via gopay, since Snap don't have 'qris' standalone method + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'qris.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: QRIS"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('QRIS', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('Pay with any QRIS compatible e-wallets or banking app (GoPay, ShopeePay, OVO, DANA, LinkAja, and other e-wallets).', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/class.midtrans-gateway-sub-shopeepay.php b/class/sub-specific-buttons/class.midtrans-gateway-sub-shopeepay.php new file mode 100644 index 0000000..2ee9738 --- /dev/null +++ b/class/sub-specific-buttons/class.midtrans-gateway-sub-shopeepay.php @@ -0,0 +1,30 @@ +id = 'midtrans_sub_shopeepay'; + // used as Snap enabled_payments params. + $this->sub_payment_method_params = ['shopeepay']; + // used to display icons on customer side's payment buttons. + $this->sub_payment_method_image_file_names_str_final = 'qris.png,shopeepay.png'; + + parent::__construct(); + } + + public function pluginTitle() { + return "Midtrans Specific: ShopeePay & QRIS"; + } + public function getSettingsDescription() { + return "Separated payment buttons for this specific the payment methods with its own icons"; + } + protected function getDefaultTitle () { + return __('ShopeePay', 'midtrans-woocommerce'); + } + protected function getDefaultDescription () { + return __('', 'midtrans-woocommerce'); + } +} \ No newline at end of file diff --git a/class/sub-specific-buttons/index.php b/class/sub-specific-buttons/index.php new file mode 100644 index 0000000..6220032 --- /dev/null +++ b/class/sub-specific-buttons/index.php @@ -0,0 +1,2 @@ +Midtrans -Version: 2.22.0 +Version: 2.30.0 Author: Midtrans Author URI: http://midtrans.co.id License: GPLv2 or later WC requires at least: 2.0.0 -WC tested up to: 5.7 +WC tested up to: 5.5.1 */ /* @@ -37,6 +37,10 @@ * @link http://docs.midtrans.com * (This plugin is made based on Payment Plugin Template by WooCommerce) */ + + /** + * This file is the WP/WC plugin main entry point, all other files are imported and registered from within this file. + */ // Make sure we don't expose any info if called directly add_action( 'plugins_loaded', 'midtrans_gateway_init', 0 ); @@ -53,40 +57,85 @@ function midtrans_gateway_init() { if(!class_exists("Midtrans\Config")){ include_once dirname( __FILE__ ) . '/lib/midtrans/Midtrans.php'; } + // shared imports require_once dirname( __FILE__ ) . '/abstract/abstract.midtrans-gateway.php'; require_once dirname( __FILE__ ) . '/class/class.midtrans-gateway-notif-handler.php'; require_once dirname( __FILE__ ) . '/class/class.midtrans-gateway-api.php'; - + // utils imports require_once dirname( __FILE__ ) . '/class/class.midtrans-utils.php'; require_once dirname( __FILE__ ) . '/class/class.midtrans-logger.php'; - + // main gateway imports require_once dirname( __FILE__ ) . '/class/class.midtrans-gateway.php'; - require_once dirname( __FILE__ ) . '/class/class.midtrans-gateway-paymentrequest.php'; + // sub gateway imports require_once dirname( __FILE__ ) . '/class/class.midtrans-gateway-installment.php'; require_once dirname( __FILE__ ) . '/class/class.midtrans-gateway-installmentoff.php'; require_once dirname( __FILE__ ) . '/class/class.midtrans-gateway-promo.php'; + require_once dirname( __FILE__ ) . '/class/class.midtrans-gateway-paymentrequest.php'; + // shared abstract import for sub separated gateway buttons + require_once dirname( __FILE__ ) . '/abstract/abstract.midtrans-gateway-sub.php'; + // sub separated gateway buttons imports, add new methods under here + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-card.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-gopay.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-shopeepay.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-qris.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-bca-va.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-bni-va.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-bri-va.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-permata-va.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-echannel.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-other-va.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-akulaku.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-bca-klikpay.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-bri-epay.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-cimb-clicks.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-danamon-online.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-alfamart.php'; + require_once dirname( __FILE__ ) . '/class/sub-specific-buttons/class.midtrans-gateway-sub-indomaret.php'; + // Add this payment method if WooCommerce Subscriptions plugin activated if( class_exists( 'WC_Subscriptions' ) ) { require_once dirname( __FILE__ ) . '/class/class.midtrans-gateway-subscription.php'; } - add_filter( 'woocommerce_payment_gateways', 'add_midtrans_payment_gateway' ); + add_filter( 'woocommerce_payment_gateways', 'midtrans_add_payment_gateway' ); add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'midtrans_plugin_action_links' ); } -function add_midtrans_payment_gateway( $methods ) { +function midtrans_add_payment_gateway( $methods ) { /** * Payment methods are separated as different method/class so it will be separated * as different payment button. This is needed because each of 'feature' like Promo, * require special backend treatment (i.e. applying discount and locking payment channel). * Especially Offline Installment, it requires `whitelist_bins` so it should not be combined * with other payment feature. + * Order of these will determine the order of gateway/button shown on WC payment config page */ + // main gateways $methods[] = 'WC_Gateway_Midtrans'; - $methods[] = 'WC_Gateway_Midtrans_Paymentrequest'; + // sub separated gateway buttons, add new methods under here + $methods[] = 'WC_Gateway_Midtrans_Sub_Card'; + $methods[] = 'WC_Gateway_Midtrans_Sub_Gopay'; + $methods[] = 'WC_Gateway_Midtrans_Sub_Shopeepay'; + $methods[] = 'WC_Gateway_Midtrans_Sub_QRIS'; + $methods[] = 'WC_Gateway_Midtrans_Sub_BCA_VA'; + $methods[] = 'WC_Gateway_Midtrans_Sub_BNI_VA'; + $methods[] = 'WC_Gateway_Midtrans_Sub_BRI_VA'; + $methods[] = 'WC_Gateway_Midtrans_Sub_Permata_VA'; + $methods[] = 'WC_Gateway_Midtrans_Sub_Echannel'; + $methods[] = 'WC_Gateway_Midtrans_Sub_Other_VA'; + $methods[] = 'WC_Gateway_Midtrans_Sub_Akulaku'; + $methods[] = 'WC_Gateway_Midtrans_Sub_BCA_Klikpay'; + $methods[] = 'WC_Gateway_Midtrans_Sub_BRI_Epay'; + $methods[] = 'WC_Gateway_Midtrans_Sub_CIMB_Clicks'; + $methods[] = 'WC_Gateway_Midtrans_Sub_Danamon_Online'; + $methods[] = 'WC_Gateway_Midtrans_Sub_Alfamart'; + $methods[] = 'WC_Gateway_Midtrans_Sub_Indomaret'; + // additional gateways $methods[] = 'WC_Gateway_Midtrans_Installment'; $methods[] = 'WC_Gateway_Midtrans_InstallmentOff'; $methods[] = 'WC_Gateway_Midtrans_Promo'; + $methods[] = 'WC_Gateway_Midtrans_Paymentrequest'; + // Add this payment method if WooCommerce Subscriptions plugin activated if( class_exists( 'WC_Subscriptions' ) ) { $methods[] = 'WC_Gateway_Midtrans_Subscription'; diff --git a/public/images/payment-methods/akulaku.png b/public/images/payment-methods/akulaku.png new file mode 100644 index 0000000..335dac5 Binary files /dev/null and b/public/images/payment-methods/akulaku.png differ diff --git a/public/images/payment-methods/alfamart.png b/public/images/payment-methods/alfamart.png new file mode 100644 index 0000000..cb51f4c Binary files /dev/null and b/public/images/payment-methods/alfamart.png differ diff --git a/public/images/payment-methods/alfamart_1.png b/public/images/payment-methods/alfamart_1.png new file mode 100644 index 0000000..fba7816 Binary files /dev/null and b/public/images/payment-methods/alfamart_1.png differ diff --git a/public/images/payment-methods/alt_alfamart_2.png b/public/images/payment-methods/alt_alfamart_2.png new file mode 100644 index 0000000..faa250f Binary files /dev/null and b/public/images/payment-methods/alt_alfamart_2.png differ diff --git a/public/images/payment-methods/alt_alfamart_3.png b/public/images/payment-methods/alt_alfamart_3.png new file mode 100644 index 0000000..e79d99e Binary files /dev/null and b/public/images/payment-methods/alt_alfamart_3.png differ diff --git a/public/images/payment-methods/alt_cc_visa_master.png b/public/images/payment-methods/alt_cc_visa_master.png new file mode 100644 index 0000000..f9b0cff Binary files /dev/null and b/public/images/payment-methods/alt_cc_visa_master.png differ diff --git a/public/images/payment-methods/alt_cc_visa_master_amex.png b/public/images/payment-methods/alt_cc_visa_master_amex.png new file mode 100644 index 0000000..851a697 Binary files /dev/null and b/public/images/payment-methods/alt_cc_visa_master_amex.png differ diff --git a/public/images/payment-methods/alt_cc_visa_master_jcb.png b/public/images/payment-methods/alt_cc_visa_master_jcb.png new file mode 100644 index 0000000..a8056b0 Binary files /dev/null and b/public/images/payment-methods/alt_cc_visa_master_jcb.png differ diff --git a/public/images/payment-methods/alt_credit_card.png b/public/images/payment-methods/alt_credit_card.png new file mode 100644 index 0000000..8e71faa Binary files /dev/null and b/public/images/payment-methods/alt_credit_card.png differ diff --git a/public/images/payment-methods/alt_gopay_qris.png b/public/images/payment-methods/alt_gopay_qris.png new file mode 100644 index 0000000..fd97d00 Binary files /dev/null and b/public/images/payment-methods/alt_gopay_qris.png differ diff --git a/public/images/payment-methods/alt_mandiri_clickpay.png b/public/images/payment-methods/alt_mandiri_clickpay.png new file mode 100644 index 0000000..05fc3e3 Binary files /dev/null and b/public/images/payment-methods/alt_mandiri_clickpay.png differ diff --git a/public/images/payment-methods/alt_mandiri_ecash.png b/public/images/payment-methods/alt_mandiri_ecash.png new file mode 100644 index 0000000..2de4b98 Binary files /dev/null and b/public/images/payment-methods/alt_mandiri_ecash.png differ diff --git a/public/images/payment-methods/alt_other_va.png b/public/images/payment-methods/alt_other_va.png new file mode 100644 index 0000000..0882fd4 Binary files /dev/null and b/public/images/payment-methods/alt_other_va.png differ diff --git a/public/images/payment-methods/alt_shopeepay_qris.png b/public/images/payment-methods/alt_shopeepay_qris.png new file mode 100644 index 0000000..4d29204 Binary files /dev/null and b/public/images/payment-methods/alt_shopeepay_qris.png differ diff --git a/public/images/payment-methods/alt_uob.png b/public/images/payment-methods/alt_uob.png new file mode 100644 index 0000000..487b523 Binary files /dev/null and b/public/images/payment-methods/alt_uob.png differ diff --git a/public/images/payment-methods/bca_klikpay.png b/public/images/payment-methods/bca_klikpay.png new file mode 100644 index 0000000..a1ffaf3 Binary files /dev/null and b/public/images/payment-methods/bca_klikpay.png differ diff --git a/public/images/payment-methods/bca_va.png b/public/images/payment-methods/bca_va.png new file mode 100644 index 0000000..97f7f6e Binary files /dev/null and b/public/images/payment-methods/bca_va.png differ diff --git a/public/images/payment-methods/bni_va.png b/public/images/payment-methods/bni_va.png new file mode 100644 index 0000000..043240f Binary files /dev/null and b/public/images/payment-methods/bni_va.png differ diff --git a/public/images/payment-methods/bri_epay.png b/public/images/payment-methods/bri_epay.png new file mode 100644 index 0000000..849954a Binary files /dev/null and b/public/images/payment-methods/bri_epay.png differ diff --git a/public/images/payment-methods/bri_va.png b/public/images/payment-methods/bri_va.png new file mode 100644 index 0000000..95a3e57 Binary files /dev/null and b/public/images/payment-methods/bri_va.png differ diff --git a/public/images/payment-methods/cc_amex.png b/public/images/payment-methods/cc_amex.png new file mode 100644 index 0000000..ab50b27 Binary files /dev/null and b/public/images/payment-methods/cc_amex.png differ diff --git a/public/images/payment-methods/cc_jcb.png b/public/images/payment-methods/cc_jcb.png new file mode 100644 index 0000000..a0598d8 Binary files /dev/null and b/public/images/payment-methods/cc_jcb.png differ diff --git a/public/images/payment-methods/cc_master.png b/public/images/payment-methods/cc_master.png new file mode 100644 index 0000000..a43ac0c Binary files /dev/null and b/public/images/payment-methods/cc_master.png differ diff --git a/public/images/payment-methods/cc_visa.png b/public/images/payment-methods/cc_visa.png new file mode 100644 index 0000000..e571144 Binary files /dev/null and b/public/images/payment-methods/cc_visa.png differ diff --git a/public/images/payment-methods/cimb_clicks.png b/public/images/payment-methods/cimb_clicks.png new file mode 100644 index 0000000..b3fd820 Binary files /dev/null and b/public/images/payment-methods/cimb_clicks.png differ diff --git a/public/images/payment-methods/credit_card.png b/public/images/payment-methods/credit_card.png new file mode 100644 index 0000000..73922f7 Binary files /dev/null and b/public/images/payment-methods/credit_card.png differ diff --git a/public/images/payment-methods/danamon_online.png b/public/images/payment-methods/danamon_online.png new file mode 100644 index 0000000..968e6a7 Binary files /dev/null and b/public/images/payment-methods/danamon_online.png differ diff --git a/public/images/payment-methods/echannel.png b/public/images/payment-methods/echannel.png new file mode 100644 index 0000000..f05678b Binary files /dev/null and b/public/images/payment-methods/echannel.png differ diff --git a/public/images/payment-methods/gopay.png b/public/images/payment-methods/gopay.png new file mode 100644 index 0000000..714bea0 Binary files /dev/null and b/public/images/payment-methods/gopay.png differ diff --git a/public/images/payment-methods/indomaret.png b/public/images/payment-methods/indomaret.png new file mode 100644 index 0000000..0af364d Binary files /dev/null and b/public/images/payment-methods/indomaret.png differ diff --git a/public/images/payment-methods/midtrans.png b/public/images/payment-methods/midtrans.png new file mode 100644 index 0000000..0acf9e8 Binary files /dev/null and b/public/images/payment-methods/midtrans.png differ diff --git a/public/images/payment-methods/midtrans_1.png b/public/images/payment-methods/midtrans_1.png new file mode 100644 index 0000000..030fa18 Binary files /dev/null and b/public/images/payment-methods/midtrans_1.png differ diff --git a/public/images/payment-methods/other_va_0.png b/public/images/payment-methods/other_va_0.png new file mode 100644 index 0000000..1c007d9 Binary files /dev/null and b/public/images/payment-methods/other_va_0.png differ diff --git a/public/images/payment-methods/other_va_1.png b/public/images/payment-methods/other_va_1.png new file mode 100644 index 0000000..8f350cb Binary files /dev/null and b/public/images/payment-methods/other_va_1.png differ diff --git a/public/images/payment-methods/other_va_2.png b/public/images/payment-methods/other_va_2.png new file mode 100644 index 0000000..bf89145 Binary files /dev/null and b/public/images/payment-methods/other_va_2.png differ diff --git a/public/images/payment-methods/other_va_3.png b/public/images/payment-methods/other_va_3.png new file mode 100644 index 0000000..c2ee723 Binary files /dev/null and b/public/images/payment-methods/other_va_3.png differ diff --git a/public/images/payment-methods/permata_va.png b/public/images/payment-methods/permata_va.png new file mode 100644 index 0000000..5ff3820 Binary files /dev/null and b/public/images/payment-methods/permata_va.png differ diff --git a/public/images/payment-methods/qris.png b/public/images/payment-methods/qris.png new file mode 100644 index 0000000..a7356ae Binary files /dev/null and b/public/images/payment-methods/qris.png differ diff --git a/public/images/payment-methods/qris_1.png b/public/images/payment-methods/qris_1.png new file mode 100644 index 0000000..6b66c6d Binary files /dev/null and b/public/images/payment-methods/qris_1.png differ diff --git a/public/images/payment-methods/shopeepay.png b/public/images/payment-methods/shopeepay.png new file mode 100644 index 0000000..5358127 Binary files /dev/null and b/public/images/payment-methods/shopeepay.png differ diff --git a/public/js/midtrans-payment-page-main.js b/public/js/midtrans-payment-page-main.js index deaa3ec..739d9de 100644 --- a/public/js/midtrans-payment-page-main.js +++ b/public/js/midtrans-payment-page-main.js @@ -101,21 +101,6 @@ // if no pdf instruction, hide the btn document.getElementById('payment-instruction-btn').style.display = "none"; } - return 0; - // Below code is UNUSED - // Update order with PDF url to backend - try{ - result['pdf_url_update'] = true; - result['snap_token_id'] = SNAP_TOKEN; - fetch(wc_midtrans.plugin_backend_url, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(result) - }); - }catch(e){ console.log(e); } }, onError: function(result){ MixpanelTrackResult(SNAP_TOKEN, MERCHANT_ID, CMS_NAME, CMS_VERSION, PLUGIN_NAME, PLUGIN_VERSION, 'error', result); diff --git a/readme.txt b/readme.txt index 263f7f8..ca543b7 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: yocki, rizdaprasetya Tags: midtrans, snap, payment, payment-gateway, credit-card, commerce, e-commerce, woocommerce, veritrans Requires at least: 3.9.1 -Tested up to: 5.7 -Stable tag: 2.22.0 +Tested up to: 5.8 +Stable tag: 2.30.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -70,6 +70,17 @@ The best way please email to support@midtrans.com, but bugs can be reported in o == Changelog == += 2.30.0 - 2021-08-06 = +* major feature: sub [specific gateway buttons for each](https://docs.midtrans.com/en/snap/with-plugins?id=advanced-specific-payment-buttons) supported payment methods +* improve config page UI section separation +* add notif url config value recommendation on config page UI +* immediate-reduce-stock enabled by default +* improve gateway payment button naming +* add config field to allow customize payment button icons +* add built in payment icon assets +* improve UI, messaging clarity, and order of advanced config +* added some custom [wp hooks](https://github.com/veritrans/SNAP-Woocommerce/#available-custom-hooks) + = 2.22.0 - 2021-04-27 = * prevent issue of 3rd party Cloudflare plugin breaking payment page (reload repetitively) * improve configuration page structure and description @@ -237,6 +248,17 @@ The best way please email to support@midtrans.com, but bugs can be reported in o == Upgrade Notice == += 2.30.0 - 2021-08-06 = +* major feature: sub [specific gateway buttons for each](https://docs.midtrans.com/en/snap/with-plugins?id=advanced-specific-payment-buttons) supported payment methods +* improve config page UI section separation +* add notif url config value recommendation on config page UI +* immediate-reduce-stock enabled by default +* improve gateway payment button naming +* add config field to allow customize payment button icons +* add built in payment icon assets +* improve UI, messaging clarity, and order of advanced config +* added some custom [wp hooks](https://github.com/veritrans/SNAP-Woocommerce/#available-custom-hooks) + = 2.22.0 - 2021-04-27 = * prevent issue of 3rd party Cloudflare plugin breaking payment page (reload repetitively) * improve configuration page structure and description