Changeset 2876857
- Timestamp:
- 03/09/2023 02:03:23 AM (3 years ago)
- Location:
- omise
- Files:
-
- 6 added
- 36 edited
- 1 copied
-
tags/4.29.0 (copied) (copied from omise/trunk)
-
tags/4.29.0/CHANGELOG.md (modified) (1 diff)
-
tags/4.29.0/assets/css/omise-css.css (modified) (1 diff)
-
tags/4.29.0/assets/images/ktb-m.png (added)
-
tags/4.29.0/includes/admin/class-omise-admin-page.php (modified) (1 diff)
-
tags/4.29.0/includes/admin/views/omise-page-settings.php (modified) (1 diff)
-
tags/4.29.0/includes/backends/class-omise-backend-mobile-banking.php (modified) (1 diff)
-
tags/4.29.0/includes/class-omise-callback.php (modified) (1 diff)
-
tags/4.29.0/includes/class-omise-money.php (modified) (1 diff)
-
tags/4.29.0/includes/class-omise-rest-webhooks-controller.php (modified) (4 diffs)
-
tags/4.29.0/includes/events/class-omise-event-charge-capture.php (modified) (1 diff)
-
tags/4.29.0/includes/events/class-omise-event-charge-complete.php (modified) (6 diffs)
-
tags/4.29.0/includes/gateway/abstract-omise-payment-base-card.php (modified) (1 diff)
-
tags/4.29.0/includes/gateway/class-omise-payment-touch-n-go.php (modified) (4 diffs)
-
tags/4.29.0/includes/gateway/class-omise-payment.php (modified) (5 diffs)
-
tags/4.29.0/includes/gateway/traits (added)
-
tags/4.29.0/includes/gateway/traits/sync-order-trait.php (added)
-
tags/4.29.0/includes/libraries/omise-plugin/helpers/charge.php (modified) (2 diffs)
-
tags/4.29.0/includes/libraries/omise-plugin/helpers/mailer.php (modified) (1 diff)
-
tags/4.29.0/omise-woocommerce.php (modified) (3 diffs)
-
tags/4.29.0/readme.txt (modified) (2 diffs)
-
tags/4.29.0/templates/payment/form-fpx.php (modified) (1 diff)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/assets/css/omise-css.css (modified) (1 diff)
-
trunk/assets/images/ktb-m.png (added)
-
trunk/includes/admin/class-omise-admin-page.php (modified) (1 diff)
-
trunk/includes/admin/views/omise-page-settings.php (modified) (1 diff)
-
trunk/includes/backends/class-omise-backend-mobile-banking.php (modified) (1 diff)
-
trunk/includes/class-omise-callback.php (modified) (1 diff)
-
trunk/includes/class-omise-money.php (modified) (1 diff)
-
trunk/includes/class-omise-rest-webhooks-controller.php (modified) (4 diffs)
-
trunk/includes/events/class-omise-event-charge-capture.php (modified) (1 diff)
-
trunk/includes/events/class-omise-event-charge-complete.php (modified) (6 diffs)
-
trunk/includes/gateway/abstract-omise-payment-base-card.php (modified) (1 diff)
-
trunk/includes/gateway/class-omise-payment-touch-n-go.php (modified) (4 diffs)
-
trunk/includes/gateway/class-omise-payment.php (modified) (5 diffs)
-
trunk/includes/gateway/traits (added)
-
trunk/includes/gateway/traits/sync-order-trait.php (added)
-
trunk/includes/libraries/omise-plugin/helpers/charge.php (modified) (2 diffs)
-
trunk/includes/libraries/omise-plugin/helpers/mailer.php (modified) (1 diff)
-
trunk/omise-woocommerce.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/templates/payment/form-fpx.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
omise/tags/4.29.0/CHANGELOG.md
r2854110 r2876857 1 1 # CHANGELOG 2 3 ### [v4.29.0 _(Mar 8, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v4.29.0) 4 - Added Krungthai NEXT mobile banking (PR [#347](https://github.com/omise/omise-woocommerce/pull/347)) 2 5 3 6 ### [v4.28.1 _(Jan 25, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v4.28.1) -
omise/tags/4.29.0/assets/css/omise-css.css
r2852769 r2876857 437 437 } 438 438 439 /** KTB **/ 440 .mobile-banking-logo.ktb { 441 background: url('../images/ktb-m.png'); 442 background-size: cover; 443 } 439 444 440 445 /** -
omise/tags/4.29.0/includes/admin/class-omise-admin-page.php
r2501457 r2876857 26 26 $this->errors[] = $message; 27 27 break; 28 29 case 'message': 28 default: 30 29 $this->messages[] = $message; 31 30 break; -
omise/tags/4.29.0/includes/admin/views/omise-page-settings.php
r2852769 r2876857 196 196 </td>'; 197 197 break; 198 199 default: 200 break; 198 201 } 199 202 endforeach; -
omise/tags/4.29.0/includes/backends/class-omise-backend-mobile-banking.php
r2783685 r2876857 27 27 'title' => __( 'Bualuang mBanking', 'omise' ), 28 28 'logo' => 'bbl', 29 ), 30 'mobile_banking_ktb' => array( 31 'title' => __( 'Krungthai NEXT', 'omise' ), 32 'logo' => 'ktb', 29 33 ) 30 34 ); -
omise/tags/4.29.0/includes/class-omise-callback.php
r2832733 r2876857 22 22 public function __construct( $order ) { 23 23 $this->order = $order; 24 if ( ! $this->order || ! $this->order instanceof WC_Abstract_Order ) $this->invalid_result(); 24 if ( ! $this->order || ! $this->order instanceof WC_Abstract_Order ) { 25 $this->invalid_result(); 26 } 25 27 } 26 28 -
omise/tags/4.29.0/includes/class-omise-money.php
r2501457 r2876857 50 50 51 51 /** 52 * convert omise amount to human readable amount. 53 */ 54 public static function convert_currency_unit( $amount, $currency ) { 55 $amount = self::purify_amount( $amount ); 56 $currency = strtoupper( $currency ); 57 58 if ( ! isset( self::$subunit_multiplier[ $currency ] ) ) { 59 throw new Exception( __( 'We do not support the currency you are using.', 'omise' ) ); 60 } 61 62 return $amount / self::$subunit_multiplier[ $currency ]; 63 } 64 65 /** 52 66 * @param int|float $amount 53 67 * -
omise/tags/4.29.0/includes/class-omise-rest-webhooks-controller.php
r2720994 r2876857 30 30 31 31 /** 32 * @var string 33 */ 34 const RETURN_TRUE = '__return_true'; 35 36 /** 32 37 * Register the routes for webhooks. 33 38 */ … … 39 44 'methods' => WP_REST_Server::EDITABLE, 40 45 'callback' => array( $this, 'callback' ), 41 'permission_callback' => '__return_true'46 'permission_callback' => self::RETURN_TRUE 42 47 ) 43 48 ); … … 49 54 'methods' => WP_REST_Server::READABLE, 50 55 'callback' => array( $this, 'callback_paynow_payment_status' ), 51 'permission_callback' => '__return_true'56 'permission_callback' => self::RETURN_TRUE 52 57 ) 53 58 ); … … 59 64 'methods' => WP_REST_Server::READABLE, 60 65 'callback' => array( $this, 'callback_ocbc_pao_callback' ), 61 'permission_callback' => '__return_true'66 'permission_callback' => self::RETURN_TRUE 62 67 ) 63 68 ); -
omise/tags/4.29.0/includes/events/class-omise-event-charge-capture.php
r2832733 r2876857 79 79 $this->order->update_status( 'processing' ); 80 80 } 81 break; 81 break; 82 83 default: 84 throw new Exception('invalid charge status'); 85 break; 82 86 } 83 87 -
omise/tags/4.29.0/includes/events/class-omise-event-charge-complete.php
r2832733 r2876857 1 1 <?php 2 2 3 defined( 'ABSPATH') || exit;3 defined('ABSPATH') || exit; 4 4 5 class Omise_Event_Charge_Complete extends Omise_Event { 5 class Omise_Event_Charge_Complete extends Omise_Event 6 { 6 7 /** 7 8 * @var string of an event name. … … 12 13 * @inheritdoc 13 14 */ 14 public function validate() { 15 if ( 'charge' !== $this->data['object'] || ! isset( $this->data['metadata']['order_id'] ) ) { 15 public function validate() 16 { 17 if ('charge' !== $this->data['object'] || !isset($this->data['metadata']['order_id'])) { 16 18 return false; 17 19 } 18 20 19 if ( ! $this->order = wc_get_order( $this->data['metadata']['order_id'] )) {21 if (!$this->order = wc_get_order($this->data['metadata']['order_id'])) { 20 22 return false; 21 23 } 22 24 23 25 // Making sure that an event's charge id is identical with an order transaction id. 24 if ( $this->order->get_transaction_id() !== $this->data['id']) {26 if ($this->order->get_transaction_id() !== $this->data['id']) { 25 27 return false; 26 28 } … … 29 31 } 30 32 31 public function is_resolvable() { 32 if ( 'yes' === $this->order->get_meta( 'is_omise_payment_resolved' ) || $this->is_attempt_limit_exceeded() ) { 33 public function is_resolvable() 34 { 35 if ('yes' === $this->order->get_meta('is_omise_payment_resolved') || $this->is_attempt_limit_exceeded()) { 33 36 return true; 34 37 } … … 36 39 $schedule_action = 'omise_async_webhook_event_handler'; 37 40 $schedule_group = 'omise_async_webhook'; 38 $data = array( 'key' => self::EVENT_NAME, 'data' => serialize( $this->data ));39 $this->schedule_single( $schedule_action, $data, $schedule_group);41 $data = array('key' => self::EVENT_NAME, 'data' => serialize($this->data)); 42 $this->schedule_single($schedule_action, $data, $schedule_group); 40 43 return false; 41 44 } … … 73 76 * @return void 74 77 */ 75 public function resolve() { 76 if ( ! $this->is_resolvable() ) return; 78 public function resolve() 79 { 80 if (!$this->is_resolvable()) { 81 return; 82 } 77 83 78 $this->order->add_order_note( __( 'Opn Payments: Received charge.complete webhook event.', 'omise' ) ); 84 $this->order->add_order_note( 85 $this->allow_br('Opn Payments: Received charge.complete webhook event.')); 79 86 80 switch ( $this->data['status']) {87 switch ($this->data['status']) { 81 88 case 'failed': 82 if ( $this->order->has_status( 'failed' ) ) { 83 return; 84 } 85 86 $message = __( 'Opn Payments: Payment failed.<br/>%s', 'omise' ); 87 $failure_message = Omise()->translate( $this->data['failure_message'] ) . ' (code: ' . $this->data['failure_code'] . ')'; 88 $this->order->add_order_note( 89 sprintf( 90 wp_kses( $message, array( 'br' => array() ) ), 91 $failure_message 92 ) 93 ); 94 $this->order->update_status( 'failed' ); 89 $this->handle_failed_charge(); 95 90 break; 96 97 91 case 'successful': 98 if ( $this->order->has_status( 'processing' ) ) { 99 return; 100 } 101 102 $message = __( 'Opn Payments: Payment successful.<br/>An amount %1$s %2$s has been paid', 'omise' ); 103 104 $this->order->add_order_note( 105 sprintf( 106 wp_kses( $message, array( 'br' => array() ) ), 107 $this->order->get_total(), 108 $this->order->get_currency() 109 ) 110 ); 111 $this->order->payment_complete(); 92 $this->handle_successful_charge(); 112 93 break; 113 114 94 case 'pending': 115 if ( $this->order->has_status( 'processing' ) ) { 116 return; 117 } 118 119 // Credit Card 3-D Secure with 'authorize only' payment action case. 120 if ( $this->data['authorized'] ) { 121 $this->order->update_meta_data( 'is_awaiting_capture', 'yes' ); 122 $this->order->update_status( 'processing' ); 123 $this->order->save(); 124 } 95 $this->handle_pending_charge(); 96 break; 97 default: 125 98 break; 126 99 } … … 128 101 return; 129 102 } 103 104 /** 105 * handler failed charge 106 */ 107 private function handle_failed_charge() 108 { 109 if ($this->order->has_status('failed')) { 110 return; 111 } 112 113 $failure_message = sprintf( 114 '%s (code: %s)', 115 Omise()->translate($this->data['failure_message']), 116 $this->data['failure_code'] 117 ); 118 119 $this->order->add_order_note( 120 sprintf( 121 $this->allow_br('Opn Payments: Payment failed.<br/>%s'), 122 $failure_message 123 ) 124 ); 125 126 $this->order->update_status(Omise_Payment::STATUS_FAILED); 127 } 128 129 /** 130 * handler successful charge 131 */ 132 private function handle_successful_charge() 133 { 134 if ($this->order->has_status('processing')) { 135 return; 136 } 137 $this->order->add_order_note( 138 sprintf( 139 $this->allow_br('Opn Payments: Payment successful.<br/>An amount %1$s %2$s has been paid'), 140 $this->order->get_total(), 141 $this->order->get_currency() 142 ) 143 ); 144 $this->order->payment_complete(); 145 } 146 147 /** 148 * handler pending charge 149 */ 150 private function handle_pending_charge() 151 { 152 if ($this->order->has_status('processing')) { 153 return; 154 } 155 // Credit Card 3-D Secure with 'authorize only' payment action case. 156 if ($this->data['authorized']) { 157 $this->order->update_meta_data('is_awaiting_capture', 'yes'); 158 $this->order->update_status('processing'); 159 $this->order->save(); 160 } 161 } 162 163 /** 164 * allow br from the message. 165 */ 166 private function allow_br($message) 167 { 168 return wp_kses(__($message, 'omise'), ['br' => []]); 169 } 130 170 } -
omise/tags/4.29.0/includes/gateway/abstract-omise-payment-base-card.php
r2832733 r2876857 205 205 206 206 // Then, check is authorized after if the first condition is false. 207 if ( ! $success ) 207 if ( ! $success ) { 208 208 $success = Omise_Charge::is_authorized( $charge ); 209 209 } 210 210 211 break; 211 212 } -
omise/tags/4.29.0/includes/gateway/class-omise-payment-touch-n-go.php
r2832733 r2876857 3 3 4 4 class Omise_Payment_TouchNGo extends Omise_Payment_Offsite { 5 6 private $touch_and_go_wallet_title = 'Touch \'n Go eWallet'; 7 5 8 public function __construct() { 6 9 parent::__construct(); … … 31 34 */ 32 35 public function init_form_fields() { 33 $method_title = 'Touch \'n Go eWallet';34 $default_title = 'Touch \'n Go eWallet';36 $method_title = $this->touch_and_go_wallet_title; 37 $default_title = $this->touch_and_go_wallet_title; 35 38 36 39 if ($this->provider === 'Alipay_plus') { … … 67 70 } 68 71 69 return 'Touch \'n Go eWallet';72 return $this->touch_and_go_wallet_title; 70 73 } 71 74 … … 94 97 $icon = Omise_Image::get_image([ 95 98 'file' => 'touch-n-go.png', 96 'alternate_text' => 'Touch \'n Go eWallet',99 'alternate_text' => $this->touch_and_go_wallet_title, 97 100 ]); 98 101 return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id ); -
omise/tags/4.29.0/includes/gateway/class-omise-payment.php
r2832733 r2876857 11 11 12 12 abstract class Omise_Payment extends WC_Payment_Gateway { 13 use Sync_Order; 14 15 const WC_VERSION3 = '3.0.0'; 16 13 17 /** Omise charge id post meta key. */ 14 18 const CHARGE_ID = 'omise_charge_id'; … … 420 424 421 425 /** 422 * Retrieve a charge by a given charge id (that attach to an order).423 * Find some diff, then merge it back to WooCommerce system.424 *425 * @param WC_Order $order WooCommerce's order object426 *427 * @return void428 *429 * @see WC_Meta_Box_Order_Actions::save( $post_id, $post )430 * @see woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php431 */432 public function sync_payment( $order ) {433 $this->load_order( $order );434 435 try {436 $charge = OmiseCharge::retrieve( $this->get_charge_id_from_order() );437 438 /**439 * Backward compatible with WooCommerce v2.x series440 * This case is likely not going to happen anymore as this was provided back then441 * when Omise-WooCommerce was introducing of adding charge.id into WC Order transaction id.442 **/443 if ( ! $this->order()->get_transaction_id() ) {444 $this->set_order_transaction_id( $charge['id'] );445 }446 447 switch ( $charge['status'] ) {448 case self::STATUS_SUCCESSFUL:449 $this->delete_capture_metadata();450 451 // Omise API 2017-11-02 uses `refunded`, Omise API 2019-05-29 uses `refunded_amount`.452 $refunded_amount = isset( $charge['refunded_amount'] ) ? $charge['refunded_amount'] : $charge['refunded'];453 if ( $charge['funding_amount'] == $refunded_amount ) {454 if ( ! $this->order()->has_status( self::STATUS_REFUNDED ) ) {455 $this->order()->update_status( self::STATUS_REFUNDED );456 }457 458 $message = wp_kses( __(459 'Opn Payments: Payment refunded.<br/>An amount %1$s %2$s has been refunded (manual sync).', 'omise' ),460 array( 'br' => array() )461 );462 $this->order()->add_order_note( sprintf( $message, $this->order()->get_total(), $this->order()->get_currency() ) );463 } else {464 $message = wp_kses( __(465 'Opn Payments: Payment successful.<br/>An amount %1$s %2$s has been paid (manual sync).', 'omise' ),466 array( 'br' => array() )467 );468 $this->order()->add_order_note( sprintf( $message, $this->order()->get_total(), $this->order()->get_currency() ) );469 470 if ( ! $this->order()->is_paid() ) {471 $this->order()->payment_complete();472 }473 }474 break;475 476 case self::STATUS_FAILED:477 $this->delete_capture_metadata();478 479 $message = wp_kses(480 __( 'Opn Payments: Payment failed.<br/>%s (code: %s) (manual sync).', 'omise' ),481 array( 'br' => array() )482 );483 $this->order()->add_order_note( sprintf( $message, Omise()->translate( $charge['failure_message'] ), $charge['failure_code'] ) );484 485 if ( ! $this->order()->has_status( self::STATUS_FAILED ) ) {486 $this->order()->update_status( self::STATUS_FAILED );487 }488 break;489 490 case self::STATUS_PENDING:491 $message = wp_kses( __(492 'Opn Payments: Payment is still in progress.<br/>493 You might wait for a moment before click sync the status again or contact Opn Payments support team at [email protected] if you have any questions (manual sync).',494 'omise'495 ), array( 'br' => array() ) );496 497 $this->order()->add_order_note( $message );498 break;499 500 case self::STATUS_EXPIRED:501 $this->delete_capture_metadata();502 503 $message = wp_kses( __( 'Opn Payments: Payment expired. (manual sync).', 'omise' ), array( 'br' => array() ) );504 $this->order()->add_order_note( $message );505 506 if ( ! $this->order()->has_status( self::STATUS_CANCELLED ) ) {507 $this->order()->update_status( self::STATUS_CANCELLED );508 }509 break;510 511 case self::STATUS_REVERSED:512 $this->delete_capture_metadata();513 514 $message = wp_kses( __( 'Opn Payments: Payment reversed. (manual sync).', 'omise' ), array( 'br' => array() ) );515 $this->order()->add_order_note( $message );516 517 if ( ! $this->order()->has_status( self::STATUS_CANCELLED ) ) {518 $this->order()->update_status( self::STATUS_CANCELLED );519 }520 break;521 522 default:523 throw new Exception(524 __( 'Cannot read the payment status. Please try sync again or contact Opn Payments support team at [email protected] if you have any questions.', 'omise' )525 );526 break;527 }528 } catch ( Exception $e ) {529 $message = wp_kses(530 __( 'Opn Payments: Sync failed (manual sync).<br/>%s.', 'omise' ),531 array( 'br' => array() )532 );533 534 $order->add_order_note( sprintf( $message, $e->getMessage() ) );535 }536 }537 538 /**539 426 * Set an order transaction id 540 427 * … … 543 430 protected function set_order_transaction_id( $transaction_id ) { 544 431 /** backward compatible with WooCommerce v2.x series **/ 545 if ( version_compare( WC()->version, '3.0.0', '>=' ) ) {432 if ( version_compare( WC()->version, self::WC_VERSION3, '>=' ) ) { 546 433 $this->order()->set_transaction_id( $transaction_id ); 547 434 $this->order()->save(); … … 599 486 */ 600 487 // Backward compatible for Omise v3.0 - v3.3 601 $order_id = version_compare( WC()->version, '3.0.0', '>=' ) ? $this->order()->get_id() : $this->order()->id;488 $order_id = version_compare( WC()->version, self::WC_VERSION3, '>=' ) ? $this->order()->get_id() : $this->order()->id; 602 489 $charge_id = get_post_meta( $order_id, self::CHARGE_ID, true ); 603 490 … … 632 519 protected function deprecated_get_charge_id_from_post() { 633 520 /** backward compatible with WooCommerce v2.x series **/ 634 $order_id = version_compare( WC()->version, '3.0.0', '>=' ) ? $this->order()->get_id() : $this->order()->id;521 $order_id = version_compare( WC()->version, self::WC_VERSION3, '>=' ) ? $this->order()->get_id() : $this->order()->id; 635 522 636 523 $posts = get_posts( -
omise/tags/4.29.0/includes/libraries/omise-plugin/helpers/charge.php
r2501457 r2876857 9 9 public static function isChargeObject($charge) 10 10 { 11 if (! isset($charge['object']) || $charge['object'] !== 'charge') 11 if (! isset($charge['object']) || $charge['object'] !== 'charge') { 12 12 return false; 13 13 } 14 14 return true; 15 15 } … … 39 39 public static function isFailed($charge) 40 40 { 41 if (! self::isChargeObject($charge)) 41 if (! self::isChargeObject($charge)) { 42 42 return true; 43 } 44 45 if ((! is_null($charge['failure_code']) && $charge['failure_code'] !== "") 46 || (! is_null($charge['failure_message']) && $charge['failure_message'] !== "")) { 47 return true; 48 } 43 49 44 if ((! is_null($charge['failure_code']) && $charge['failure_code'] !== "") 45 || (! is_null($charge['failure_message']) && $charge['failure_message'] !== "")) 50 if (strtoupper($charge['status']) === 'FAILED') { 46 51 return true; 47 48 if (strtoupper($charge['status']) === 'FAILED') 49 return true; 52 } 50 53 51 54 return false; -
omise/tags/4.29.0/includes/libraries/omise-plugin/helpers/mailer.php
r2737840 r2876857 23 23 public static function disable_merchant_order_on_hold( $recipient, $order ) { 24 24 $payment_gateway = wc_get_payment_gateway_by_order( $order ); 25 if (is_a($order, 'WC_Order') && is_a( $payment_gateway, 'Omise_Payment' ) && 26 $order->get_status() == 'on-hold' ) $recipient = ''; 25 if (is_a($order, 'WC_Order') && 26 is_a( $payment_gateway, 'Omise_Payment' ) && 27 $order->get_status() == 'on-hold' 28 ) { 29 $recipient = ''; 30 } 27 31 return $recipient; 28 32 } -
omise/tags/4.29.0/omise-woocommerce.php
r2854110 r2876857 5 5 * Plugin URI: https://www.omise.co/woocommerce 6 6 * Description: Opn Payments is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Opn Payments Payment Gateway's payment methods to WooCommerce. 7 * Version: 4.2 8.17 * Version: 4.29.0 8 8 * Author: Opn Payments and contributors 9 9 * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors … … 23 23 * @var string 24 24 */ 25 public $version = '4.2 8.1';25 public $version = '4.29.0'; 26 26 27 27 /** … … 149 149 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/events/class-omise-event-charge-complete.php'; 150 150 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/events/class-omise-event-charge-create.php'; 151 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/traits/sync-order-trait.php'; 151 152 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/abstract-omise-payment-offline.php'; 152 153 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/abstract-omise-payment-offsite.php'; -
omise/tags/4.29.0/readme.txt
r2854110 r2876857 4 4 Requires at least: 4.3.1 5 5 Tested up to: 6.0.2 6 Stable tag: 4.2 8.16 Stable tag: 4.29.0 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 34 34 35 35 == Changelog == 36 37 = 4.29.0 = 38 39 - Added Krungthai NEXT mobile banking (PR [#347](https://github.com/omise/omise-woocommerce/pull/347)) 36 40 37 41 = 4.28.1 = -
omise/tags/4.29.0/templates/payment/form-fpx.php
r2783685 r2876857 9 9 class="<?php echo $bank["code"];?>" 10 10 value="<?php echo $bank["code"]; ?>" 11 <? =$bank['active'] ?: "disabled" ?>11 <?php $bank['active'] ?: "disabled" ?> 12 12 > 13 13 <?php echo $bank["name"]; ?> 14 <?php if (!$bank['active']) echo " (offline)" ;?>14 <?php if (!$bank['active']) { echo " (offline)"; } ?> 15 15 </option> 16 16 <?php endforeach; ?> -
omise/trunk/CHANGELOG.md
r2854110 r2876857 1 1 # CHANGELOG 2 3 ### [v4.29.0 _(Mar 8, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v4.29.0) 4 - Added Krungthai NEXT mobile banking (PR [#347](https://github.com/omise/omise-woocommerce/pull/347)) 2 5 3 6 ### [v4.28.1 _(Jan 25, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v4.28.1) -
omise/trunk/assets/css/omise-css.css
r2852769 r2876857 437 437 } 438 438 439 /** KTB **/ 440 .mobile-banking-logo.ktb { 441 background: url('../images/ktb-m.png'); 442 background-size: cover; 443 } 439 444 440 445 /** -
omise/trunk/includes/admin/class-omise-admin-page.php
r2501457 r2876857 26 26 $this->errors[] = $message; 27 27 break; 28 29 case 'message': 28 default: 30 29 $this->messages[] = $message; 31 30 break; -
omise/trunk/includes/admin/views/omise-page-settings.php
r2852769 r2876857 196 196 </td>'; 197 197 break; 198 199 default: 200 break; 198 201 } 199 202 endforeach; -
omise/trunk/includes/backends/class-omise-backend-mobile-banking.php
r2783685 r2876857 27 27 'title' => __( 'Bualuang mBanking', 'omise' ), 28 28 'logo' => 'bbl', 29 ), 30 'mobile_banking_ktb' => array( 31 'title' => __( 'Krungthai NEXT', 'omise' ), 32 'logo' => 'ktb', 29 33 ) 30 34 ); -
omise/trunk/includes/class-omise-callback.php
r2832733 r2876857 22 22 public function __construct( $order ) { 23 23 $this->order = $order; 24 if ( ! $this->order || ! $this->order instanceof WC_Abstract_Order ) $this->invalid_result(); 24 if ( ! $this->order || ! $this->order instanceof WC_Abstract_Order ) { 25 $this->invalid_result(); 26 } 25 27 } 26 28 -
omise/trunk/includes/class-omise-money.php
r2501457 r2876857 50 50 51 51 /** 52 * convert omise amount to human readable amount. 53 */ 54 public static function convert_currency_unit( $amount, $currency ) { 55 $amount = self::purify_amount( $amount ); 56 $currency = strtoupper( $currency ); 57 58 if ( ! isset( self::$subunit_multiplier[ $currency ] ) ) { 59 throw new Exception( __( 'We do not support the currency you are using.', 'omise' ) ); 60 } 61 62 return $amount / self::$subunit_multiplier[ $currency ]; 63 } 64 65 /** 52 66 * @param int|float $amount 53 67 * -
omise/trunk/includes/class-omise-rest-webhooks-controller.php
r2720994 r2876857 30 30 31 31 /** 32 * @var string 33 */ 34 const RETURN_TRUE = '__return_true'; 35 36 /** 32 37 * Register the routes for webhooks. 33 38 */ … … 39 44 'methods' => WP_REST_Server::EDITABLE, 40 45 'callback' => array( $this, 'callback' ), 41 'permission_callback' => '__return_true'46 'permission_callback' => self::RETURN_TRUE 42 47 ) 43 48 ); … … 49 54 'methods' => WP_REST_Server::READABLE, 50 55 'callback' => array( $this, 'callback_paynow_payment_status' ), 51 'permission_callback' => '__return_true'56 'permission_callback' => self::RETURN_TRUE 52 57 ) 53 58 ); … … 59 64 'methods' => WP_REST_Server::READABLE, 60 65 'callback' => array( $this, 'callback_ocbc_pao_callback' ), 61 'permission_callback' => '__return_true'66 'permission_callback' => self::RETURN_TRUE 62 67 ) 63 68 ); -
omise/trunk/includes/events/class-omise-event-charge-capture.php
r2832733 r2876857 79 79 $this->order->update_status( 'processing' ); 80 80 } 81 break; 81 break; 82 83 default: 84 throw new Exception('invalid charge status'); 85 break; 82 86 } 83 87 -
omise/trunk/includes/events/class-omise-event-charge-complete.php
r2832733 r2876857 1 1 <?php 2 2 3 defined( 'ABSPATH') || exit;3 defined('ABSPATH') || exit; 4 4 5 class Omise_Event_Charge_Complete extends Omise_Event { 5 class Omise_Event_Charge_Complete extends Omise_Event 6 { 6 7 /** 7 8 * @var string of an event name. … … 12 13 * @inheritdoc 13 14 */ 14 public function validate() { 15 if ( 'charge' !== $this->data['object'] || ! isset( $this->data['metadata']['order_id'] ) ) { 15 public function validate() 16 { 17 if ('charge' !== $this->data['object'] || !isset($this->data['metadata']['order_id'])) { 16 18 return false; 17 19 } 18 20 19 if ( ! $this->order = wc_get_order( $this->data['metadata']['order_id'] )) {21 if (!$this->order = wc_get_order($this->data['metadata']['order_id'])) { 20 22 return false; 21 23 } 22 24 23 25 // Making sure that an event's charge id is identical with an order transaction id. 24 if ( $this->order->get_transaction_id() !== $this->data['id']) {26 if ($this->order->get_transaction_id() !== $this->data['id']) { 25 27 return false; 26 28 } … … 29 31 } 30 32 31 public function is_resolvable() { 32 if ( 'yes' === $this->order->get_meta( 'is_omise_payment_resolved' ) || $this->is_attempt_limit_exceeded() ) { 33 public function is_resolvable() 34 { 35 if ('yes' === $this->order->get_meta('is_omise_payment_resolved') || $this->is_attempt_limit_exceeded()) { 33 36 return true; 34 37 } … … 36 39 $schedule_action = 'omise_async_webhook_event_handler'; 37 40 $schedule_group = 'omise_async_webhook'; 38 $data = array( 'key' => self::EVENT_NAME, 'data' => serialize( $this->data ));39 $this->schedule_single( $schedule_action, $data, $schedule_group);41 $data = array('key' => self::EVENT_NAME, 'data' => serialize($this->data)); 42 $this->schedule_single($schedule_action, $data, $schedule_group); 40 43 return false; 41 44 } … … 73 76 * @return void 74 77 */ 75 public function resolve() { 76 if ( ! $this->is_resolvable() ) return; 78 public function resolve() 79 { 80 if (!$this->is_resolvable()) { 81 return; 82 } 77 83 78 $this->order->add_order_note( __( 'Opn Payments: Received charge.complete webhook event.', 'omise' ) ); 84 $this->order->add_order_note( 85 $this->allow_br('Opn Payments: Received charge.complete webhook event.')); 79 86 80 switch ( $this->data['status']) {87 switch ($this->data['status']) { 81 88 case 'failed': 82 if ( $this->order->has_status( 'failed' ) ) { 83 return; 84 } 85 86 $message = __( 'Opn Payments: Payment failed.<br/>%s', 'omise' ); 87 $failure_message = Omise()->translate( $this->data['failure_message'] ) . ' (code: ' . $this->data['failure_code'] . ')'; 88 $this->order->add_order_note( 89 sprintf( 90 wp_kses( $message, array( 'br' => array() ) ), 91 $failure_message 92 ) 93 ); 94 $this->order->update_status( 'failed' ); 89 $this->handle_failed_charge(); 95 90 break; 96 97 91 case 'successful': 98 if ( $this->order->has_status( 'processing' ) ) { 99 return; 100 } 101 102 $message = __( 'Opn Payments: Payment successful.<br/>An amount %1$s %2$s has been paid', 'omise' ); 103 104 $this->order->add_order_note( 105 sprintf( 106 wp_kses( $message, array( 'br' => array() ) ), 107 $this->order->get_total(), 108 $this->order->get_currency() 109 ) 110 ); 111 $this->order->payment_complete(); 92 $this->handle_successful_charge(); 112 93 break; 113 114 94 case 'pending': 115 if ( $this->order->has_status( 'processing' ) ) { 116 return; 117 } 118 119 // Credit Card 3-D Secure with 'authorize only' payment action case. 120 if ( $this->data['authorized'] ) { 121 $this->order->update_meta_data( 'is_awaiting_capture', 'yes' ); 122 $this->order->update_status( 'processing' ); 123 $this->order->save(); 124 } 95 $this->handle_pending_charge(); 96 break; 97 default: 125 98 break; 126 99 } … … 128 101 return; 129 102 } 103 104 /** 105 * handler failed charge 106 */ 107 private function handle_failed_charge() 108 { 109 if ($this->order->has_status('failed')) { 110 return; 111 } 112 113 $failure_message = sprintf( 114 '%s (code: %s)', 115 Omise()->translate($this->data['failure_message']), 116 $this->data['failure_code'] 117 ); 118 119 $this->order->add_order_note( 120 sprintf( 121 $this->allow_br('Opn Payments: Payment failed.<br/>%s'), 122 $failure_message 123 ) 124 ); 125 126 $this->order->update_status(Omise_Payment::STATUS_FAILED); 127 } 128 129 /** 130 * handler successful charge 131 */ 132 private function handle_successful_charge() 133 { 134 if ($this->order->has_status('processing')) { 135 return; 136 } 137 $this->order->add_order_note( 138 sprintf( 139 $this->allow_br('Opn Payments: Payment successful.<br/>An amount %1$s %2$s has been paid'), 140 $this->order->get_total(), 141 $this->order->get_currency() 142 ) 143 ); 144 $this->order->payment_complete(); 145 } 146 147 /** 148 * handler pending charge 149 */ 150 private function handle_pending_charge() 151 { 152 if ($this->order->has_status('processing')) { 153 return; 154 } 155 // Credit Card 3-D Secure with 'authorize only' payment action case. 156 if ($this->data['authorized']) { 157 $this->order->update_meta_data('is_awaiting_capture', 'yes'); 158 $this->order->update_status('processing'); 159 $this->order->save(); 160 } 161 } 162 163 /** 164 * allow br from the message. 165 */ 166 private function allow_br($message) 167 { 168 return wp_kses(__($message, 'omise'), ['br' => []]); 169 } 130 170 } -
omise/trunk/includes/gateway/abstract-omise-payment-base-card.php
r2832733 r2876857 205 205 206 206 // Then, check is authorized after if the first condition is false. 207 if ( ! $success ) 207 if ( ! $success ) { 208 208 $success = Omise_Charge::is_authorized( $charge ); 209 209 } 210 210 211 break; 211 212 } -
omise/trunk/includes/gateway/class-omise-payment-touch-n-go.php
r2832733 r2876857 3 3 4 4 class Omise_Payment_TouchNGo extends Omise_Payment_Offsite { 5 6 private $touch_and_go_wallet_title = 'Touch \'n Go eWallet'; 7 5 8 public function __construct() { 6 9 parent::__construct(); … … 31 34 */ 32 35 public function init_form_fields() { 33 $method_title = 'Touch \'n Go eWallet';34 $default_title = 'Touch \'n Go eWallet';36 $method_title = $this->touch_and_go_wallet_title; 37 $default_title = $this->touch_and_go_wallet_title; 35 38 36 39 if ($this->provider === 'Alipay_plus') { … … 67 70 } 68 71 69 return 'Touch \'n Go eWallet';72 return $this->touch_and_go_wallet_title; 70 73 } 71 74 … … 94 97 $icon = Omise_Image::get_image([ 95 98 'file' => 'touch-n-go.png', 96 'alternate_text' => 'Touch \'n Go eWallet',99 'alternate_text' => $this->touch_and_go_wallet_title, 97 100 ]); 98 101 return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id ); -
omise/trunk/includes/gateway/class-omise-payment.php
r2832733 r2876857 11 11 12 12 abstract class Omise_Payment extends WC_Payment_Gateway { 13 use Sync_Order; 14 15 const WC_VERSION3 = '3.0.0'; 16 13 17 /** Omise charge id post meta key. */ 14 18 const CHARGE_ID = 'omise_charge_id'; … … 420 424 421 425 /** 422 * Retrieve a charge by a given charge id (that attach to an order).423 * Find some diff, then merge it back to WooCommerce system.424 *425 * @param WC_Order $order WooCommerce's order object426 *427 * @return void428 *429 * @see WC_Meta_Box_Order_Actions::save( $post_id, $post )430 * @see woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php431 */432 public function sync_payment( $order ) {433 $this->load_order( $order );434 435 try {436 $charge = OmiseCharge::retrieve( $this->get_charge_id_from_order() );437 438 /**439 * Backward compatible with WooCommerce v2.x series440 * This case is likely not going to happen anymore as this was provided back then441 * when Omise-WooCommerce was introducing of adding charge.id into WC Order transaction id.442 **/443 if ( ! $this->order()->get_transaction_id() ) {444 $this->set_order_transaction_id( $charge['id'] );445 }446 447 switch ( $charge['status'] ) {448 case self::STATUS_SUCCESSFUL:449 $this->delete_capture_metadata();450 451 // Omise API 2017-11-02 uses `refunded`, Omise API 2019-05-29 uses `refunded_amount`.452 $refunded_amount = isset( $charge['refunded_amount'] ) ? $charge['refunded_amount'] : $charge['refunded'];453 if ( $charge['funding_amount'] == $refunded_amount ) {454 if ( ! $this->order()->has_status( self::STATUS_REFUNDED ) ) {455 $this->order()->update_status( self::STATUS_REFUNDED );456 }457 458 $message = wp_kses( __(459 'Opn Payments: Payment refunded.<br/>An amount %1$s %2$s has been refunded (manual sync).', 'omise' ),460 array( 'br' => array() )461 );462 $this->order()->add_order_note( sprintf( $message, $this->order()->get_total(), $this->order()->get_currency() ) );463 } else {464 $message = wp_kses( __(465 'Opn Payments: Payment successful.<br/>An amount %1$s %2$s has been paid (manual sync).', 'omise' ),466 array( 'br' => array() )467 );468 $this->order()->add_order_note( sprintf( $message, $this->order()->get_total(), $this->order()->get_currency() ) );469 470 if ( ! $this->order()->is_paid() ) {471 $this->order()->payment_complete();472 }473 }474 break;475 476 case self::STATUS_FAILED:477 $this->delete_capture_metadata();478 479 $message = wp_kses(480 __( 'Opn Payments: Payment failed.<br/>%s (code: %s) (manual sync).', 'omise' ),481 array( 'br' => array() )482 );483 $this->order()->add_order_note( sprintf( $message, Omise()->translate( $charge['failure_message'] ), $charge['failure_code'] ) );484 485 if ( ! $this->order()->has_status( self::STATUS_FAILED ) ) {486 $this->order()->update_status( self::STATUS_FAILED );487 }488 break;489 490 case self::STATUS_PENDING:491 $message = wp_kses( __(492 'Opn Payments: Payment is still in progress.<br/>493 You might wait for a moment before click sync the status again or contact Opn Payments support team at [email protected] if you have any questions (manual sync).',494 'omise'495 ), array( 'br' => array() ) );496 497 $this->order()->add_order_note( $message );498 break;499 500 case self::STATUS_EXPIRED:501 $this->delete_capture_metadata();502 503 $message = wp_kses( __( 'Opn Payments: Payment expired. (manual sync).', 'omise' ), array( 'br' => array() ) );504 $this->order()->add_order_note( $message );505 506 if ( ! $this->order()->has_status( self::STATUS_CANCELLED ) ) {507 $this->order()->update_status( self::STATUS_CANCELLED );508 }509 break;510 511 case self::STATUS_REVERSED:512 $this->delete_capture_metadata();513 514 $message = wp_kses( __( 'Opn Payments: Payment reversed. (manual sync).', 'omise' ), array( 'br' => array() ) );515 $this->order()->add_order_note( $message );516 517 if ( ! $this->order()->has_status( self::STATUS_CANCELLED ) ) {518 $this->order()->update_status( self::STATUS_CANCELLED );519 }520 break;521 522 default:523 throw new Exception(524 __( 'Cannot read the payment status. Please try sync again or contact Opn Payments support team at [email protected] if you have any questions.', 'omise' )525 );526 break;527 }528 } catch ( Exception $e ) {529 $message = wp_kses(530 __( 'Opn Payments: Sync failed (manual sync).<br/>%s.', 'omise' ),531 array( 'br' => array() )532 );533 534 $order->add_order_note( sprintf( $message, $e->getMessage() ) );535 }536 }537 538 /**539 426 * Set an order transaction id 540 427 * … … 543 430 protected function set_order_transaction_id( $transaction_id ) { 544 431 /** backward compatible with WooCommerce v2.x series **/ 545 if ( version_compare( WC()->version, '3.0.0', '>=' ) ) {432 if ( version_compare( WC()->version, self::WC_VERSION3, '>=' ) ) { 546 433 $this->order()->set_transaction_id( $transaction_id ); 547 434 $this->order()->save(); … … 599 486 */ 600 487 // Backward compatible for Omise v3.0 - v3.3 601 $order_id = version_compare( WC()->version, '3.0.0', '>=' ) ? $this->order()->get_id() : $this->order()->id;488 $order_id = version_compare( WC()->version, self::WC_VERSION3, '>=' ) ? $this->order()->get_id() : $this->order()->id; 602 489 $charge_id = get_post_meta( $order_id, self::CHARGE_ID, true ); 603 490 … … 632 519 protected function deprecated_get_charge_id_from_post() { 633 520 /** backward compatible with WooCommerce v2.x series **/ 634 $order_id = version_compare( WC()->version, '3.0.0', '>=' ) ? $this->order()->get_id() : $this->order()->id;521 $order_id = version_compare( WC()->version, self::WC_VERSION3, '>=' ) ? $this->order()->get_id() : $this->order()->id; 635 522 636 523 $posts = get_posts( -
omise/trunk/includes/libraries/omise-plugin/helpers/charge.php
r2501457 r2876857 9 9 public static function isChargeObject($charge) 10 10 { 11 if (! isset($charge['object']) || $charge['object'] !== 'charge') 11 if (! isset($charge['object']) || $charge['object'] !== 'charge') { 12 12 return false; 13 13 } 14 14 return true; 15 15 } … … 39 39 public static function isFailed($charge) 40 40 { 41 if (! self::isChargeObject($charge)) 41 if (! self::isChargeObject($charge)) { 42 42 return true; 43 } 44 45 if ((! is_null($charge['failure_code']) && $charge['failure_code'] !== "") 46 || (! is_null($charge['failure_message']) && $charge['failure_message'] !== "")) { 47 return true; 48 } 43 49 44 if ((! is_null($charge['failure_code']) && $charge['failure_code'] !== "") 45 || (! is_null($charge['failure_message']) && $charge['failure_message'] !== "")) 50 if (strtoupper($charge['status']) === 'FAILED') { 46 51 return true; 47 48 if (strtoupper($charge['status']) === 'FAILED') 49 return true; 52 } 50 53 51 54 return false; -
omise/trunk/includes/libraries/omise-plugin/helpers/mailer.php
r2737840 r2876857 23 23 public static function disable_merchant_order_on_hold( $recipient, $order ) { 24 24 $payment_gateway = wc_get_payment_gateway_by_order( $order ); 25 if (is_a($order, 'WC_Order') && is_a( $payment_gateway, 'Omise_Payment' ) && 26 $order->get_status() == 'on-hold' ) $recipient = ''; 25 if (is_a($order, 'WC_Order') && 26 is_a( $payment_gateway, 'Omise_Payment' ) && 27 $order->get_status() == 'on-hold' 28 ) { 29 $recipient = ''; 30 } 27 31 return $recipient; 28 32 } -
omise/trunk/omise-woocommerce.php
r2854110 r2876857 5 5 * Plugin URI: https://www.omise.co/woocommerce 6 6 * Description: Opn Payments is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Opn Payments Payment Gateway's payment methods to WooCommerce. 7 * Version: 4.2 8.17 * Version: 4.29.0 8 8 * Author: Opn Payments and contributors 9 9 * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors … … 23 23 * @var string 24 24 */ 25 public $version = '4.2 8.1';25 public $version = '4.29.0'; 26 26 27 27 /** … … 149 149 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/events/class-omise-event-charge-complete.php'; 150 150 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/events/class-omise-event-charge-create.php'; 151 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/traits/sync-order-trait.php'; 151 152 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/abstract-omise-payment-offline.php'; 152 153 require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/abstract-omise-payment-offsite.php'; -
omise/trunk/readme.txt
r2854110 r2876857 4 4 Requires at least: 4.3.1 5 5 Tested up to: 6.0.2 6 Stable tag: 4.2 8.16 Stable tag: 4.29.0 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 34 34 35 35 == Changelog == 36 37 = 4.29.0 = 38 39 - Added Krungthai NEXT mobile banking (PR [#347](https://github.com/omise/omise-woocommerce/pull/347)) 36 40 37 41 = 4.28.1 = -
omise/trunk/templates/payment/form-fpx.php
r2783685 r2876857 9 9 class="<?php echo $bank["code"];?>" 10 10 value="<?php echo $bank["code"]; ?>" 11 <? =$bank['active'] ?: "disabled" ?>11 <?php $bank['active'] ?: "disabled" ?> 12 12 > 13 13 <?php echo $bank["name"]; ?> 14 <?php if (!$bank['active']) echo " (offline)" ;?>14 <?php if (!$bank['active']) { echo " (offline)"; } ?> 15 15 </option> 16 16 <?php endforeach; ?>
Note: See TracChangeset
for help on using the changeset viewer.