Changeset 3331857
- Timestamp:
- 07/22/2025 05:05:19 AM (9 months ago)
- Location:
- omise
- Files:
-
- 4 added
- 20 edited
- 1 copied
-
tags/6.2.2 (copied) (copied from omise/trunk)
-
tags/6.2.2/CHANGELOG.md (modified) (1 diff)
-
tags/6.2.2/assets/css/omise-css.css (modified) (1 diff)
-
tags/6.2.2/includes/class-omise-rest-webhooks-controller.php (modified) (4 diffs)
-
tags/6.2.2/includes/gateway/abstract-omise-payment-offline.php (modified) (1 diff)
-
tags/6.2.2/includes/gateway/class-omise-payment-paynow.php (modified) (4 diffs)
-
tags/6.2.2/omise-woocommerce.php (modified) (2 diffs)
-
tags/6.2.2/phpcs.xml (modified) (2 diffs)
-
tags/6.2.2/readme.txt (modified) (2 diffs)
-
tags/6.2.2/tests/unit/includes/class-omise-rest-webhooks-controller-test.php (added)
-
tags/6.2.2/tests/unit/includes/gateway/bootstrap-test-setup.php (modified) (2 diffs)
-
tags/6.2.2/tests/unit/includes/gateway/class-omise-payment-paynow-test.php (added)
-
tags/6.2.2/tests/unit/includes/gateway/class-omise-payment-test.php (modified) (1 diff)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/assets/css/omise-css.css (modified) (1 diff)
-
trunk/includes/class-omise-rest-webhooks-controller.php (modified) (4 diffs)
-
trunk/includes/gateway/abstract-omise-payment-offline.php (modified) (1 diff)
-
trunk/includes/gateway/class-omise-payment-paynow.php (modified) (4 diffs)
-
trunk/omise-woocommerce.php (modified) (2 diffs)
-
trunk/phpcs.xml (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/tests/unit/includes/class-omise-rest-webhooks-controller-test.php (added)
-
trunk/tests/unit/includes/gateway/bootstrap-test-setup.php (modified) (2 diffs)
-
trunk/tests/unit/includes/gateway/class-omise-payment-paynow-test.php (added)
-
trunk/tests/unit/includes/gateway/class-omise-payment-test.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
omise/tags/6.2.2/CHANGELOG.md
r3312403 r3331857 1 1 # CHANGELOG 2 3 ## [v6.2.2 _(Jul 22, 2025)_](https://github.com/omise/omise-woocommerce/releases/tag/v6.2.2) 4 5 - Add authentication to Paynow status endpoint. (PR: [#530](https://github.com/omise/omise-woocommerce/issues/530)) 2 6 3 7 ## [v6.2.1 _(Jun 16, 2025)_](https://github.com/omise/omise-woocommerce/releases/tag/v6.2.1) -
omise/tags/6.2.2/assets/css/omise-css.css
r3182037 r3331857 122 122 .omise-paynow-payment-status .green-check { 123 123 background: url('../images/green-check.svg') no-repeat; 124 height: 150px; 125 width: 116px; 126 margin: auto; 124 background-size: contain; 125 background-position: center; 126 height: 50px; 127 margin: 10px auto; 127 128 } 128 129 -
omise/tags/6.2.2/includes/class-omise-rest-webhooks-controller.php
r3083045 r3331857 1 1 <?php 2 defined( 'ABSPATH' ) ordie( 'No direct script access allowed.' );2 defined( 'ABSPATH' ) || die( 'No direct script access allowed.' ); 3 3 4 4 if ( class_exists( 'Omise_Rest_Webhooks_Controller' ) ) { … … 22 22 * @var string 23 23 */ 24 const PAYNOW_CHARGE_STATUS_ENDPOINT = 'paynow-payment-status';24 const ENDPOINT_ORDER_STATUS = 'order-status'; 25 25 26 26 /** … … 45 45 register_rest_route( 46 46 self::ENDPOINT_NAMESPACE, 47 '/' . self:: PAYNOW_CHARGE_STATUS_ENDPOINT,47 '/' . self::ENDPOINT_ORDER_STATUS, 48 48 array( 49 49 'methods' => WP_REST_Server::READABLE, 50 'callback' => array( $this, 'callback_ paynow_payment_status' ),51 'permission_callback' => self::RETURN_TRUE 50 'callback' => array( $this, 'callback_get_order_status' ), 51 'permission_callback' => self::RETURN_TRUE, 52 52 ) 53 53 ); … … 81 81 * @return WP_Error|WP_REST_Response 82 82 */ 83 public function callback_paynow_payment_status($request) { 84 $order_id = $request->get_param('order_id'); 85 $data['status'] = false; 86 if(isset( $order_id )) { 87 $order = new WC_Order( $order_id ); 88 if(isset($order)) { 89 $data['status'] = $order->get_status(); 90 } 83 public function callback_get_order_status( $request ) { 84 $nonce = $request->get_param( '_nonce' ); 85 $order_key = $request->get_param( 'key' ); 86 87 if ( ! wp_verify_nonce( $nonce, 'get_order_status_' . $order_key ) ) { 88 return new WP_Error( 'omise_rest_invalid_nonce', __( 'Invalid nonce.', 'omise' ), [ 'status' => 403 ] ); 91 89 } 92 return rest_ensure_response( $data ); 90 91 $order_id = wc_get_order_id_by_order_key( $order_key ); 92 $order = wc_get_order( $order_id ); 93 94 if ( ! $order ) { 95 return new WP_Error( 'omise_rest_order_not_found', __( 'Order not found.', 'omise' ), [ 'status' => 404 ] ); 96 } 97 98 return rest_ensure_response( [ 'status' => $order->get_status() ] ); 93 99 } 94 100 } -
omise/tags/6.2.2/includes/gateway/abstract-omise-payment-offline.php
r3308831 r3331857 13 13 14 14 protected $enabled_processing_notification = true; 15 16 public function __construct() 17 { 18 parent::__construct(); 19 } 15 20 16 21 /** -
omise/tags/6.2.2/includes/gateway/class-omise-payment-paynow.php
r3256918 r3331857 95 95 96 96 if ( 'view' === $context ) : ?> 97 <?php 98 $order_key = $order->get_order_key(); 99 $get_order_status_url = add_query_arg( 100 [ 101 'key' => $order_key, 102 '_nonce' => wp_create_nonce( 'get_order_status_' . $order_key ), 103 '_wpnonce' => wp_create_nonce('wp_rest'), 104 ], 105 get_rest_url( null, 'omise/order-status') 106 ); 107 ?> 97 108 <div class="omise omise-paynow-details" <?php echo 'email' === $context ? 'style="margin-bottom: 4em; text-align:center;"' : ''; ?>> 98 109 <div class="omise omise-paynow-logo"></div> … … 117 128 </div> 118 129 <script type="text/javascript"> 119 var xhr_param_name = "?order_id="+"<?php echo $this->order->get_id() ?>"; 120 refresh_status_url = "<?php echo get_rest_url( null, 'omise/paynow-payment-status' ); ?>"+xhr_param_name; 121 class_payment_pending = document.getElementsByClassName("pending"); 122 class_payment_completed = document.getElementsByClassName("completed"); 123 class_payment_timeout = document.getElementsByClassName("timeout"); 124 class_qr_image = document.querySelector(".omise.omise-paynow-qrcode > img"); 130 <!-- 131 var classPaymentPending = document.getElementsByClassName("pending"); 132 var classPaymentCompleted = document.getElementsByClassName("completed"); 133 var classPaymentTimeout = document.getElementsByClassName("timeout"); 134 var classQrImage = document.querySelector(".omise.omise-paynow-qrcode > img"); 125 135 126 var refresh _payment_status = function(intervalIterator) {136 var refreshPaymentStatus = function(intervalIterator) { 127 137 var xmlhttp = new XMLHttpRequest(); 128 138 xmlhttp.addEventListener("load", function() { 129 139 if (this.status == 200) { 130 140 var chargeState = JSON.parse(this.responseText); 131 if (chargeState.status == "processing") {132 class _qr_image.style.display = "none";133 class _payment_pending[0].style.display = "none";134 class _payment_completed[0].style.display = "block";141 if (chargeState.status == "processing") { 142 classQrImage.style.display = "none"; 143 classPaymentPending[0].style.display = "none"; 144 classPaymentCompleted[0].style.display = "block"; 135 145 clearInterval(intervalIterator); 136 146 } 147 } else if (this.status == 403) { 148 clearInterval(intervalIterator); 137 149 } 138 150 }); 139 xmlhttp.open( "GET", refresh_status_url, true);151 xmlhttp.open('GET', '<?php echo $get_order_status_url ?>', true); 140 152 xmlhttp.send(); 141 153 }, … … 152 164 } 153 165 if((timer % 5) == 0 && timer >= 5) { 154 refresh _payment_status(intervalIterator);166 refreshPaymentStatus(intervalIterator); 155 167 } 156 168 if(timer == 0) { 157 class _payment_pending[0].style.display = "none";158 class _payment_timeout[0].style.display = "block";159 class _qr_image.style.display = "none";169 classPaymentPending[0].style.display = "none"; 170 classPaymentTimeout[0].style.display = "block"; 171 classQrImage.style.display = "none"; 160 172 clearInterval(intervalIterator); 161 173 } … … 168 180 intervalTime(duration, display); 169 181 }; 182 //--> 170 183 </script> 171 184 <?php elseif ( 'email' === $context && !$order->has_status('failed')) : ?> -
omise/tags/6.2.2/omise-woocommerce.php
r3312403 r3331857 5 5 * Plugin URI: https://www.omise.co/woocommerce 6 6 * Description: Omise Payments is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Omise Payment Gateway's payment methods to WooCommerce. 7 * Version: 6.2. 17 * Version: 6.2.2 8 8 * Author: Omise and contributors 9 9 * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors … … 24 24 * @var string 25 25 */ 26 public $version = '6.2. 1';26 public $version = '6.2.2'; 27 27 28 28 /** -
omise/tags/6.2.2/phpcs.xml
r3312403 r3331857 19 19 <exclude name="Squiz.Commenting.FileComment.Missing" /> 20 20 <exclude name="Squiz.Commenting.FunctionComment.Missing" /> 21 <exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" /> 21 22 <exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" /> 23 <exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" /> 22 24 <exclude name="Squiz.Commenting.VariableComment.Missing" /> 23 25 … … 36 38 </properties> 37 39 </rule> 40 41 <rule ref="WordPress.Security.ValidatedSanitizedInput.InputNotSanitized"> 42 <type>warning</type> 43 </rule> 44 <rule ref="WordPress.Security.ValidatedSanitizedInput.MissingUnslash"> 45 <type>warning</type> 46 </rule> 38 47 </ruleset> -
omise/tags/6.2.2/readme.txt
r3312403 r3331857 4 4 Requires at least: 4.3.1 5 5 Tested up to: 6.8.1 6 Stable tag: 6.2. 16 Stable tag: 6.2.2 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 34 34 35 35 == Changelog == 36 37 = 6.2.2 = 38 39 - Add authentication to Paynow status endpoint. (PR: [#530](https://github.com/omise/omise-woocommerce/issues/530)) 36 40 37 41 = 6.2.1 = -
omise/tags/6.2.2/tests/unit/includes/gateway/bootstrap-test-setup.php
r3312403 r3331857 16 16 return self::$is_available; 17 17 } 18 } 19 20 /** 21 * Temporary mock for WP_* class 22 * In the future, we should move to use WP_UnitTestCase 23 */ 24 class WP_Error 25 { 26 public function __construct( 27 public $code = '', 28 public $message = '', 29 public $data = '' 30 ) { 31 } 32 } 33 class WP_REST_Server_Stub 34 { 35 const EDITABLE = 'POST'; 36 const READABLE = 'GET'; 18 37 } 19 38 … … 119 138 $omiseSettingMock = Mockery::mock('alias:Omise_Setting'); 120 139 121 $omiseSettingMock->shouldReceive('instance')->andReturn($omiseSettingMock); 122 $omiseSettingMock->shouldReceive('public_key')->andReturn($pkey); 123 $omiseSettingMock->shouldReceive('secret_key')->andReturn($skey); 140 $omiseSettingMock->allows([ 141 'instance' => $omiseSettingMock, 142 'public_key' => $pkey, 143 'secret_key' => $skey, 144 ]); 145 $omiseSettingMock->shouldReceive('get_settings')->andReturn([])->byDefault(); 124 146 125 147 return $omiseSettingMock; -
omise/tags/6.2.2/tests/unit/includes/gateway/class-omise-payment-test.php
r3308831 r3331857 204 204 } 205 205 206 protected function mockOmiseSetting($pkey, $skey)207 {208 $omiseSettingMock = parent::mockOmiseSetting($pkey, $skey);209 $omiseSettingMock->shouldReceive('get_settings')->andReturn([])->byDefault();210 211 return $omiseSettingMock;212 }213 214 206 private function omisePaymentImpl($sourceType) 215 207 { -
omise/trunk/CHANGELOG.md
r3312403 r3331857 1 1 # CHANGELOG 2 3 ## [v6.2.2 _(Jul 22, 2025)_](https://github.com/omise/omise-woocommerce/releases/tag/v6.2.2) 4 5 - Add authentication to Paynow status endpoint. (PR: [#530](https://github.com/omise/omise-woocommerce/issues/530)) 2 6 3 7 ## [v6.2.1 _(Jun 16, 2025)_](https://github.com/omise/omise-woocommerce/releases/tag/v6.2.1) -
omise/trunk/assets/css/omise-css.css
r3182037 r3331857 122 122 .omise-paynow-payment-status .green-check { 123 123 background: url('../images/green-check.svg') no-repeat; 124 height: 150px; 125 width: 116px; 126 margin: auto; 124 background-size: contain; 125 background-position: center; 126 height: 50px; 127 margin: 10px auto; 127 128 } 128 129 -
omise/trunk/includes/class-omise-rest-webhooks-controller.php
r3083045 r3331857 1 1 <?php 2 defined( 'ABSPATH' ) ordie( 'No direct script access allowed.' );2 defined( 'ABSPATH' ) || die( 'No direct script access allowed.' ); 3 3 4 4 if ( class_exists( 'Omise_Rest_Webhooks_Controller' ) ) { … … 22 22 * @var string 23 23 */ 24 const PAYNOW_CHARGE_STATUS_ENDPOINT = 'paynow-payment-status';24 const ENDPOINT_ORDER_STATUS = 'order-status'; 25 25 26 26 /** … … 45 45 register_rest_route( 46 46 self::ENDPOINT_NAMESPACE, 47 '/' . self:: PAYNOW_CHARGE_STATUS_ENDPOINT,47 '/' . self::ENDPOINT_ORDER_STATUS, 48 48 array( 49 49 'methods' => WP_REST_Server::READABLE, 50 'callback' => array( $this, 'callback_ paynow_payment_status' ),51 'permission_callback' => self::RETURN_TRUE 50 'callback' => array( $this, 'callback_get_order_status' ), 51 'permission_callback' => self::RETURN_TRUE, 52 52 ) 53 53 ); … … 81 81 * @return WP_Error|WP_REST_Response 82 82 */ 83 public function callback_paynow_payment_status($request) { 84 $order_id = $request->get_param('order_id'); 85 $data['status'] = false; 86 if(isset( $order_id )) { 87 $order = new WC_Order( $order_id ); 88 if(isset($order)) { 89 $data['status'] = $order->get_status(); 90 } 83 public function callback_get_order_status( $request ) { 84 $nonce = $request->get_param( '_nonce' ); 85 $order_key = $request->get_param( 'key' ); 86 87 if ( ! wp_verify_nonce( $nonce, 'get_order_status_' . $order_key ) ) { 88 return new WP_Error( 'omise_rest_invalid_nonce', __( 'Invalid nonce.', 'omise' ), [ 'status' => 403 ] ); 91 89 } 92 return rest_ensure_response( $data ); 90 91 $order_id = wc_get_order_id_by_order_key( $order_key ); 92 $order = wc_get_order( $order_id ); 93 94 if ( ! $order ) { 95 return new WP_Error( 'omise_rest_order_not_found', __( 'Order not found.', 'omise' ), [ 'status' => 404 ] ); 96 } 97 98 return rest_ensure_response( [ 'status' => $order->get_status() ] ); 93 99 } 94 100 } -
omise/trunk/includes/gateway/abstract-omise-payment-offline.php
r3308831 r3331857 13 13 14 14 protected $enabled_processing_notification = true; 15 16 public function __construct() 17 { 18 parent::__construct(); 19 } 15 20 16 21 /** -
omise/trunk/includes/gateway/class-omise-payment-paynow.php
r3256918 r3331857 95 95 96 96 if ( 'view' === $context ) : ?> 97 <?php 98 $order_key = $order->get_order_key(); 99 $get_order_status_url = add_query_arg( 100 [ 101 'key' => $order_key, 102 '_nonce' => wp_create_nonce( 'get_order_status_' . $order_key ), 103 '_wpnonce' => wp_create_nonce('wp_rest'), 104 ], 105 get_rest_url( null, 'omise/order-status') 106 ); 107 ?> 97 108 <div class="omise omise-paynow-details" <?php echo 'email' === $context ? 'style="margin-bottom: 4em; text-align:center;"' : ''; ?>> 98 109 <div class="omise omise-paynow-logo"></div> … … 117 128 </div> 118 129 <script type="text/javascript"> 119 var xhr_param_name = "?order_id="+"<?php echo $this->order->get_id() ?>"; 120 refresh_status_url = "<?php echo get_rest_url( null, 'omise/paynow-payment-status' ); ?>"+xhr_param_name; 121 class_payment_pending = document.getElementsByClassName("pending"); 122 class_payment_completed = document.getElementsByClassName("completed"); 123 class_payment_timeout = document.getElementsByClassName("timeout"); 124 class_qr_image = document.querySelector(".omise.omise-paynow-qrcode > img"); 130 <!-- 131 var classPaymentPending = document.getElementsByClassName("pending"); 132 var classPaymentCompleted = document.getElementsByClassName("completed"); 133 var classPaymentTimeout = document.getElementsByClassName("timeout"); 134 var classQrImage = document.querySelector(".omise.omise-paynow-qrcode > img"); 125 135 126 var refresh _payment_status = function(intervalIterator) {136 var refreshPaymentStatus = function(intervalIterator) { 127 137 var xmlhttp = new XMLHttpRequest(); 128 138 xmlhttp.addEventListener("load", function() { 129 139 if (this.status == 200) { 130 140 var chargeState = JSON.parse(this.responseText); 131 if (chargeState.status == "processing") {132 class _qr_image.style.display = "none";133 class _payment_pending[0].style.display = "none";134 class _payment_completed[0].style.display = "block";141 if (chargeState.status == "processing") { 142 classQrImage.style.display = "none"; 143 classPaymentPending[0].style.display = "none"; 144 classPaymentCompleted[0].style.display = "block"; 135 145 clearInterval(intervalIterator); 136 146 } 147 } else if (this.status == 403) { 148 clearInterval(intervalIterator); 137 149 } 138 150 }); 139 xmlhttp.open( "GET", refresh_status_url, true);151 xmlhttp.open('GET', '<?php echo $get_order_status_url ?>', true); 140 152 xmlhttp.send(); 141 153 }, … … 152 164 } 153 165 if((timer % 5) == 0 && timer >= 5) { 154 refresh _payment_status(intervalIterator);166 refreshPaymentStatus(intervalIterator); 155 167 } 156 168 if(timer == 0) { 157 class _payment_pending[0].style.display = "none";158 class _payment_timeout[0].style.display = "block";159 class _qr_image.style.display = "none";169 classPaymentPending[0].style.display = "none"; 170 classPaymentTimeout[0].style.display = "block"; 171 classQrImage.style.display = "none"; 160 172 clearInterval(intervalIterator); 161 173 } … … 168 180 intervalTime(duration, display); 169 181 }; 182 //--> 170 183 </script> 171 184 <?php elseif ( 'email' === $context && !$order->has_status('failed')) : ?> -
omise/trunk/omise-woocommerce.php
r3312403 r3331857 5 5 * Plugin URI: https://www.omise.co/woocommerce 6 6 * Description: Omise Payments is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Omise Payment Gateway's payment methods to WooCommerce. 7 * Version: 6.2. 17 * Version: 6.2.2 8 8 * Author: Omise and contributors 9 9 * Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors … … 24 24 * @var string 25 25 */ 26 public $version = '6.2. 1';26 public $version = '6.2.2'; 27 27 28 28 /** -
omise/trunk/phpcs.xml
r3312403 r3331857 19 19 <exclude name="Squiz.Commenting.FileComment.Missing" /> 20 20 <exclude name="Squiz.Commenting.FunctionComment.Missing" /> 21 <exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" /> 21 22 <exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" /> 23 <exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" /> 22 24 <exclude name="Squiz.Commenting.VariableComment.Missing" /> 23 25 … … 36 38 </properties> 37 39 </rule> 40 41 <rule ref="WordPress.Security.ValidatedSanitizedInput.InputNotSanitized"> 42 <type>warning</type> 43 </rule> 44 <rule ref="WordPress.Security.ValidatedSanitizedInput.MissingUnslash"> 45 <type>warning</type> 46 </rule> 38 47 </ruleset> -
omise/trunk/readme.txt
r3312403 r3331857 4 4 Requires at least: 4.3.1 5 5 Tested up to: 6.8.1 6 Stable tag: 6.2. 16 Stable tag: 6.2.2 7 7 License: MIT 8 8 License URI: https://opensource.org/licenses/MIT … … 34 34 35 35 == Changelog == 36 37 = 6.2.2 = 38 39 - Add authentication to Paynow status endpoint. (PR: [#530](https://github.com/omise/omise-woocommerce/issues/530)) 36 40 37 41 = 6.2.1 = -
omise/trunk/tests/unit/includes/gateway/bootstrap-test-setup.php
r3312403 r3331857 16 16 return self::$is_available; 17 17 } 18 } 19 20 /** 21 * Temporary mock for WP_* class 22 * In the future, we should move to use WP_UnitTestCase 23 */ 24 class WP_Error 25 { 26 public function __construct( 27 public $code = '', 28 public $message = '', 29 public $data = '' 30 ) { 31 } 32 } 33 class WP_REST_Server_Stub 34 { 35 const EDITABLE = 'POST'; 36 const READABLE = 'GET'; 18 37 } 19 38 … … 119 138 $omiseSettingMock = Mockery::mock('alias:Omise_Setting'); 120 139 121 $omiseSettingMock->shouldReceive('instance')->andReturn($omiseSettingMock); 122 $omiseSettingMock->shouldReceive('public_key')->andReturn($pkey); 123 $omiseSettingMock->shouldReceive('secret_key')->andReturn($skey); 140 $omiseSettingMock->allows([ 141 'instance' => $omiseSettingMock, 142 'public_key' => $pkey, 143 'secret_key' => $skey, 144 ]); 145 $omiseSettingMock->shouldReceive('get_settings')->andReturn([])->byDefault(); 124 146 125 147 return $omiseSettingMock; -
omise/trunk/tests/unit/includes/gateway/class-omise-payment-test.php
r3308831 r3331857 204 204 } 205 205 206 protected function mockOmiseSetting($pkey, $skey)207 {208 $omiseSettingMock = parent::mockOmiseSetting($pkey, $skey);209 $omiseSettingMock->shouldReceive('get_settings')->andReturn([])->byDefault();210 211 return $omiseSettingMock;212 }213 214 206 private function omisePaymentImpl($sourceType) 215 207 {
Note: See TracChangeset
for help on using the changeset viewer.