@@ -266,24 +266,15 @@ public function get_payment_fields_js_config() {
266266 return $ payment_fields ; // nosemgrep: audit.php.wp.security.xss.query-arg -- server generated url is passed in.
267267 }
268268
269- $ payment_fields ['isOrderPay ' ] = true ;
270- $ order_id = absint ( get_query_var ( 'order-pay ' ) );
271- $ payment_fields ['orderId ' ] = $ order_id ;
272- $ order = wc_get_order ( $ order_id );
273-
274- if ( is_a ( $ order , 'WC_Order ' ) ) {
275- $ order_currency = $ order ->get_currency ();
276- $ payment_fields ['currency ' ] = $ order_currency ;
277- $ payment_fields ['cartTotal ' ] = WC_Payments_Utils::prepare_amount ( $ order ->get_total (), $ order_currency );
278- $ payment_fields ['orderReturnURL ' ] = esc_url_raw (
279- add_query_arg (
280- [
281- 'wc_payment_method ' => WC_Payment_Gateway_WCPay::GATEWAY_ID ,
282- '_wpnonce ' => wp_create_nonce ( 'wcpay_process_redirect_order_nonce ' ),
283- ],
284- $ this ->gateway ->get_return_url ( $ order )
285- )
286- );
269+ $ order_id = absint ( get_query_var ( 'order-pay ' ) );
270+ $ order = wc_get_order ( $ order_id );
271+
272+ if ( is_a ( $ order , 'WC_Order ' ) && get_current_user_id () === $ order ->get_user_id () ) {
273+ $ payment_fields ['isOrderPay ' ] = true ;
274+ $ payment_fields ['orderId ' ] = $ order_id ;
275+ $ order_currency = $ order ->get_currency ();
276+ $ payment_fields ['currency ' ] = $ order_currency ;
277+ $ payment_fields ['cartTotal ' ] = WC_Payments_Utils::prepare_amount ( $ order ->get_total (), $ order_currency );
287278 }
288279 }
289280
0 commit comments