Changeset 3025245
- Timestamp:
- 01/22/2024 03:45:00 PM (2 years ago)
- Location:
- revolut-gateway-for-woocommerce/trunk
- Files:
-
- 17 edited
-
api/class-revolut-webhook-controller.php (modified) (2 diffs)
-
assets/js/revolut-payment-request.js (modified) (4 diffs)
-
assets/js/revolut.js (modified) (1 diff)
-
gateway-revolut.php (modified) (4 diffs)
-
includes/abstract/class-wc-payment-gateway-revolut.php (modified) (25 diffs)
-
includes/api/class-wc-revolut-api-client.php (modified) (12 diffs)
-
includes/class-wc-revolut-apple-pay-onboarding.php (modified) (3 diffs)
-
includes/class-wc-revolut-order-descriptor.php (modified) (1 diff)
-
includes/class-wc-revolut-payment-ajax-controller.php (modified) (10 diffs)
-
includes/class-wc-revolut-privacy.php (modified) (4 diffs)
-
includes/gateways/class-wc-gateway-revolut-cc.php (modified) (12 diffs)
-
includes/gateways/class-wc-gateway-revolut-pay.php (modified) (6 diffs)
-
includes/gateways/class-wc-gateway-revolut-payment-request.php (modified) (11 diffs)
-
includes/settings/class-wc-revolut-settings-api.php (modified) (3 diffs)
-
includes/traits/wc-revolut-express-checkout-helper-trait.php (modified) (4 diffs)
-
includes/traits/wc-revolut-helper-trait.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
revolut-gateway-for-woocommerce/trunk/api/class-revolut-webhook-controller.php
r2964057 r3025245 155 155 $wc_order_status = empty( $wc_order->get_status() ) ? '' : $wc_order->get_status(); 156 156 $check_wc_status = 'processing' === $wc_order_status || 'completed' === $wc_order_status; 157 $check_capture = isset( get_post_meta( $wc_order_id['wc_order_id'], 'revolut_capture' )[0] ) ? get_post_meta( $wc_order_id['wc_order_id'],'revolut_capture' )[0] : '';157 $check_capture = isset( $wc_order->get_meta( 'revolut_capture' )[0] ) ? $wc_order->get_meta( 'revolut_capture' )[0] : ''; 158 158 159 159 $data = array(); … … 164 164 $wc_order->add_order_note( sprintf( __( 'Payment has been successfully captured (Order ID: %s)', 'revolut-gateway-for-woocommerce' ), $order_id ) ); 165 165 $wc_order->payment_complete( $order_id ); 166 update_post_meta( $wc_order_id['wc_order_id'], 'revolut_capture', 'yes' ); 166 $wc_order->update_meta_data( 'revolut_capture', 'yes', $wc_order_id['wc_order_id'] ); 167 $wc_order->save(); 167 168 $data = array( 168 169 'status' => 'OK', -
revolut-gateway-for-woocommerce/trunk/assets/js/revolut-payment-request.js
r2974726 r3025245 15 15 16 16 sendRequest(getAjaxURL('set_error_message'), { 17 security: wc_revolut_payment_request_params.nonce.set_error_message, 17 18 revolut_payment_request_error: message, 18 19 }) … … 29 30 getAjaxURL('log_error'), 30 31 { 32 security: wc_revolut_payment_request_params.nonce.log_errors, 31 33 revolut_payment_request_error: message, 32 34 }, … … 250 252 data['revolut_gateway'] = revolut_gateway 251 253 data['revolut_public_id'] = wc_revolut_payment_request_params.revolut_public_id 254 data['security'] = wc_revolut_payment_request_params.nonce.process_payment_result 252 255 data['revolut_payment_error'] = errorMessage 253 256 data['wc_order_id'] = wc_order_id … … 279 282 payment_method: payment_method, 280 283 _wpnonce: wc_revolut_payment_request_params.nonce.checkout, 284 security: wc_revolut_payment_request_params.nonce.create_order, 281 285 shipping_method: [orderSelectedShippingOption], 282 286 payment_request_type: paymentRequestType, -
revolut-gateway-for-woocommerce/trunk/assets/js/revolut.js
r2977523 r3025245 271 271 let data = {} 272 272 data['revolut_gateway'] = currentPaymentMethod.methodId 273 data['security'] = wc_revolut.nonce.process_payment_result 273 274 data['revolut_public_id'] = currentPaymentMethod.publicId 274 275 data['revolut_payment_error'] = errorMessage -
revolut-gateway-for-woocommerce/trunk/gateway-revolut.php
r2995266 r3025245 7 7 * Author URI: https://www.revolut.com/business/online-payments 8 8 * Text Domain: revolut-gateway-for-woocommerce 9 * Version: 4.9. 59 * Version: 4.9.6 10 10 * Requires at least: 4.4 11 11 * Tested up to: 6.1 … … 16 16 defined( 'ABSPATH' ) || exit; 17 17 define( 'REVOLUT_PATH', plugin_dir_path( __FILE__ ) ); 18 define( 'WC_GATEWAY_REVOLUT_VERSION', '4.9. 5' );18 define( 'WC_GATEWAY_REVOLUT_VERSION', '4.9.6' ); 19 19 define( 'WC_GATEWAY_PUBLIC_KEY_ENDPOINT', '/public-key/latest' ); 20 20 define( 'WC_GATEWAY_REVPAY_INDEX', 'USE_REVOLUT_PAY_2_0' ); … … 53 53 add_action( 'init', 'woocommerce_revolut_load_rest_api' ); 54 54 add_action( 'wp_loaded', 'rest_api_includes' ); 55 add_action( 'before_woocommerce_init', 'declare_features_compatibility' ); 55 56 } 56 57 … … 63 64 } 64 65 66 /** 67 * Declare compatibility with plugins and features. 68 */ 69 function declare_features_compatibility() { 70 if ( class_exists( Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 71 Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 72 } 73 } 65 74 /** 66 75 * Load API function -
revolut-gateway-for-woocommerce/trunk/includes/abstract/class-wc-payment-gateway-revolut.php
r2974726 r3025245 84 84 $this->api_client = new WC_Revolut_API_Client( $this->api_settings ); 85 85 86 add_filter( 'query_vars', array( $this, 'revolut_plugin_public_query_vars' ) ); 86 87 add_filter( 'wc_revolut_settings_nav_tabs', array( $this, 'admin_nav_tab' ) ); 87 88 add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); … … 98 99 99 100 /** 101 * Init required query params 102 * 103 * @param array $qvars Query vars. 104 */ 105 public function revolut_plugin_public_query_vars( $qvars ) { 106 return array_merge( $qvars, array( 'key', 'pay_for_order', 'change_payment_method', '_rp_oid', '_rp_fr' ) ); 107 } 108 109 /** 100 110 * Validates if the WooCommerce order created successfully. 101 111 * … … 107 117 */ 108 118 public function woocommerce_checkout_revolut_order_processed( $order_id, $posted_data, $order ) { 109 if ( ! $this->check_is_post_data_submitted( 'revolut_create_wc_order' ) || $posted_data['payment_method'] !== $this->id ) { 119 $nonce_value = wc_get_var( $_REQUEST['woocommerce-process-checkout-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // phpcs:ignore 120 $revolut_create_wc_order = isset( $_POST['revolut_create_wc_order'] ) ? (bool) wc_clean( wp_unslash( $_POST['revolut_create_wc_order'] ) ) : false; 121 122 if ( ! wp_verify_nonce( $nonce_value, 'woocommerce-process_checkout' ) ) { 123 wc_add_notice( __( 'Payment was not taken. Please try again', 'revolut-gateway-for-woocommerce' ), 'error' ); 124 125 wp_send_json( 126 array( 127 'refresh-checkout' => true, 128 'result' => 'revolut_wc_order_created', 129 ) 130 ); 110 131 return; 111 132 } 112 133 134 if ( ! $revolut_create_wc_order || $posted_data['payment_method'] !== $this->id ) { 135 return; 136 } 137 113 138 try { 114 $billing_phone = $this->get_post_request_data( 'billing_phone' ); 115 $billing_email = $this->get_post_request_data( 'billing_email' ); 139 $billing_phone = isset( $_POST['billing_phone'] ) ? wc_clean( wp_unslash( $_POST['billing_phone'] ) ) : ''; 140 $billing_email = isset( $_POST['billing_email'] ) ? wc_clean( wp_unslash( $_POST['billing_email'] ) ) : ''; 141 116 142 $revolut_customer_id = $this->get_or_create_revolut_customer( $billing_phone, $billing_email ); 117 143 $this->update_revolut_customer( $revolut_customer_id, $billing_phone ); … … 122 148 WC()->session->set( 'order_awaiting_payment', $order_id ); 123 149 124 $order_total = $order->get_total(); 125 $order_currency = $order->get_currency(); 126 $public_id = $this->get_post_request_data( 'revolut_public_id' ); 127 $is_express_checkout = (bool) $this->get_post_request_data( 'is_express_checkout' ); 128 $revolut_pay_redirected = (bool) $this->get_post_request_data( 'revolut_pay_redirected' ); 150 $order_total = $order->get_total(); 151 $order_currency = $order->get_currency(); 152 153 $public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 154 $is_express_checkout = isset( $_POST['is_express_checkout'] ) ? (bool) wc_clean( wp_unslash( $_POST['is_express_checkout'] ) ) : false; 155 $revolut_pay_redirected = isset( $_POST['revolut_pay_redirected'] ) ? (bool) wc_clean( wp_unslash( $_POST['revolut_pay_redirected'] ) ) : false; 129 156 130 157 if ( ! $is_express_checkout ) { … … 153 180 $revolut_order_id = $this->get_revolut_order_by_public_id( $public_id ); 154 181 $this->save_wc_order_id( $public_id, $revolut_order_id, $order_id ); 182 183 $wc_order = wc_get_order( $order_id ); 184 $order->update_meta_data( 'revolut_payment_public_id', $public_id ); 185 $order->save(); 186 155 187 if ( ! $revolut_pay_redirected ) { 156 188 wp_send_json( … … 162 194 ); 163 195 } 196 197 $order->update_meta_data( 'revolut_pay_redirected', 1 ); 198 $order->save(); 164 199 } 165 200 … … 281 316 'promotion_banner_html' => $this->get_upsell_banner_html(), 282 317 'nonce' => array( 283 'billing_info' => wp_create_nonce( 'wc-revolut-get-billing-info' ), 284 'customer_info' => wp_create_nonce( 'wc-revolut-get-customer-info' ), 285 'get_order_public_id' => wp_create_nonce( 'wc-revolut-get-order-public-id' ), 318 'process_payment_result' => wp_create_nonce( 'wc-revolut-process-payment-result' ), 319 'billing_info' => wp_create_nonce( 'wc-revolut-get-billing-info' ), 320 'customer_info' => wp_create_nonce( 'wc-revolut-get-customer-info' ), 321 'get_order_public_id' => wp_create_nonce( 'wc-revolut-get-order-public-id' ), 286 322 ), 287 323 ) … … 402 438 */ 403 439 public function save_payment_method_requested() { 404 return false;405 }406 407 /**408 * Check if saved payment method requested for making the payment.409 *410 * @abstract411 *412 * @return bool413 */414 public function is_using_saved_payment_method() {415 440 return false; 416 441 } … … 514 539 public function add_payment_method() { 515 540 try { 541 check_ajax_referer( 'woocommerce-add-payment-method', 'woocommerce-add-payment-method-nonce' ); 542 516 543 // find public_id. 517 $revolut_payment_public_id = $this->get_post_request_data( 'revolut_public_id' ); 544 $revolut_payment_public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 545 $update_all_subscriptions_payment_method = isset( $_POST[ 'wc-' . $this->id . '-update-subs-payment-method-card' ] ) || isset( $_POST['update_all_subscriptions_payment_method'] ); 546 518 547 if ( empty( $revolut_payment_public_id ) ) { 519 548 throw new Exception( 'Missing revolut_public_id parameter' ); … … 531 560 } 532 561 533 $this->handle_add_payment_method( null, $wc_token, get_current_user_id() );562 $this->handle_add_payment_method( null, $wc_token, get_current_user_id(), $update_all_subscriptions_payment_method ); 534 563 535 564 return array( … … 549 578 * Process the payment and return the result. 550 579 * 551 * @param int $wc_order_id WooCommerce order id. 580 * @param int $wc_order_id WooCommerce order id. 581 * @param string $revolut_payment_public_id Revolut payment public id. 582 * @param bool $is_express_checkout Express checkout identifier. 583 * @param string $revolut_payment_error Payment error. 584 * @param bool $reload_checkout Indicates if the page should reloaded. 585 * @param bool $revolut_pay_redirected Indicates Revolut Pay webflow redirection. 586 * @param bool $is_using_saved_payment_method Indicates payments by payment token. 587 * @param bool $save_payment_method_requested Indicates if payment token should be saved. 588 * @param int $wc_token_id WooCommerce token id. 552 589 * 553 590 * @return array … … 555 592 * @throws Exception Exception. 556 593 */ 557 public function process_payment( $wc_order_id ) { 594 public function process_payment( 595 $wc_order_id, 596 $revolut_payment_public_id = '', 597 $is_express_checkout = false, 598 $revolut_payment_error = '', 599 $reload_checkout = false, 600 $revolut_pay_redirected = false, 601 $is_using_saved_payment_method = false, 602 $save_payment_method_requested = false, 603 $wc_token_id = 0 ) { 558 604 $wc_order = wc_get_order( $wc_order_id ); 559 605 560 606 try { 561 // find public_id. 562 $is_express_checkout = (bool) $this->get_posted_integer_data( 'is_express_checkout' ); 563 $revolut_payment_public_id = $this->get_post_request_data( 'revolut_public_id' ); 607 if ( empty( $revolut_payment_public_id ) ) { 608 $revolut_payment_public_id = $wc_order->get_meta( 'revolut_payment_public_id' ); 609 $revolut_pay_redirected = (int) $wc_order->get_meta( 'revolut_pay_redirected' ); 610 $this->log_error( 'Get public id from order: ' . $revolut_payment_public_id . ' - revolut_pay_redirected: ' . $revolut_pay_redirected ); 611 } 612 564 613 if ( empty( $revolut_payment_public_id ) ) { 565 614 throw new Exception( 'Missing revolut_public_id parameter' ); 566 615 } 567 616 568 $revolut_payment_error = $this->get_post_request_data( 'revolut_payment_error' );569 570 617 if ( empty( $revolut_payment_error ) ) { 571 $revolut_payment_error = $this->get_request_data( '_rp_fr' );618 $revolut_payment_error = get_query_var( '_rp_fr' ); 572 619 } 573 620 … … 588 635 589 636 // check if it needs to process payment with previously saved method. 590 $previously_saved_wc_token = $this->maybe_pay_by_saved_method( $revolut_order_id );637 $previously_saved_wc_token = $this->maybe_pay_by_saved_method( $revolut_order_id, $is_using_saved_payment_method, $wc_token_id ); 591 638 592 639 $this->save_wc_order_id( $revolut_payment_public_id, $revolut_order_id, $wc_order_id ); … … 601 648 $this->handle_revolut_order_result( $wc_order, $revolut_order_id ); 602 649 // check save method requested. 603 $newly_saved_wc_token = $this->maybe_save_payment_method( $revolut_order_id, $wc_order );650 $newly_saved_wc_token = $this->maybe_save_payment_method( $revolut_order_id, $wc_order, $is_using_saved_payment_method, $save_payment_method_requested ); 604 651 // check if there is any saved or used payment token. 605 652 $wc_token = null; … … 610 657 } 611 658 612 update_post_meta( $wc_order_id, 'revolut_payment_public_id', $revolut_payment_public_id );613 659 $this->save_payment_token_to_order( $wc_order, $wc_token, get_current_user_id() ); 614 660 $this->verify_order_total( $revolut_order_id, $wc_order ); 615 661 $this->update_payment_method_title( $revolut_order_id, $wc_order ); 616 662 617 return $this->checkout_return( $wc_order, $revolut_order_id );663 return $this->checkout_return( $wc_order, $revolut_order_id, $revolut_pay_redirected ); 618 664 } catch ( Exception $e ) { 619 665 $this->log_error( $e->getMessage() ); … … 626 672 627 673 // if page will be reloaded add the error message as notice, otherwise they're lost in the page reload. 628 if ( $ this->get_posted_integer_data( 'reload_checkout' ) || $this->get_posted_integer_data( 'revolut_pay_redirected' )) {674 if ( $reload_checkout || $revolut_pay_redirected ) { 629 675 unset( WC()->session->reload_checkout ); 630 676 wc_add_notice( $error_message_for_user, 'error' ); … … 827 873 if ( isset( $order['state'] ) && ! $check_wc_status ) { 828 874 if ( 'COMPLETED' === $order['state'] && 'authorize_and_capture' === $mode ) { 829 update_post_meta( $wc_order_id, 'revolut_capture', 'yes' ); 875 $wc_order->update_meta_data( 'revolut_capture', 'yes', $wc_order_id ); 876 $wc_order->save(); 830 877 $wc_order->payment_complete( $revolut_order_id ); 831 878 $wc_order->add_order_note( 'Payment has been successfully captured (Order ID: ' . $revolut_order_id . ').' ); … … 893 940 $revolut_customer_id = $this->get_or_create_revolut_customer(); 894 941 $descriptor = new WC_Revolut_Order_Descriptor( WC()->cart->get_total( '' ), get_woocommerce_currency(), $revolut_customer_id ); 895 $display_tokenization = ! empty( $revolut_customer_id ) && $this->supports( 'tokenization' ) && ( is_checkout() || $this->get_request_data( 'pay_for_order' ) ) && $this->revolut_saved_cards;942 $display_tokenization = ! empty( $revolut_customer_id ) && $this->supports( 'tokenization' ) && ( is_checkout() || get_query_var( 'pay_for_order' ) ) && $this->revolut_saved_cards; 896 943 897 944 if ( $display_tokenization ) { … … 1022 1069 * 1023 1070 * @param string $revolut_order_id Revolut order id. 1024 */ 1025 protected function maybe_pay_by_saved_method( $revolut_order_id ) { 1026 if ( $this->is_using_saved_payment_method() ) { 1027 $wc_token = $this->get_selected_payment_token(); 1071 * @param bool $is_using_saved_payment_method Indicates payments by payment token. 1072 * @param int $wc_token_id WooCommerce token id. 1073 */ 1074 protected function maybe_pay_by_saved_method( $revolut_order_id, $is_using_saved_payment_method, $wc_token_id ) { 1075 if ( $is_using_saved_payment_method ) { 1076 $wc_token = $this->get_selected_payment_token( $wc_token_id ); 1028 1077 return $this->pay_by_saved_method( $revolut_order_id, $wc_token ); 1029 1078 } … … 1054 1103 * @param string $revolut_order_id Revolut order id. 1055 1104 * @param WC_Order $wc_order WooCommerce order. 1056 */ 1057 protected function maybe_save_payment_method( $revolut_order_id, $wc_order ) { 1058 if ( $this->save_payment_method_requested() && ! $this->is_using_saved_payment_method() ) { 1105 * @param bool $is_using_saved_payment_method Indicates payments by payment token. 1106 * @param bool $save_payment_method_requested Indicates if payment token should be saved. 1107 */ 1108 protected function maybe_save_payment_method( $revolut_order_id, $wc_order, $is_using_saved_payment_method, $save_payment_method_requested ) { 1109 if ( $save_payment_method_requested && ! $is_using_saved_payment_method ) { 1059 1110 try { 1060 1111 return $this->save_payment_method( $revolut_order_id ); … … 1103 1154 foreach ( $subscriptions as $subscription ) { 1104 1155 $subscription_id = $subscription->get_id(); 1105 update_post_meta( $subscription_id, '_payment_token', $wc_token->get_token() ); 1106 update_post_meta( $subscription_id, '_payment_token_id', $id_payment_token ); 1107 update_post_meta( $subscription_id, '_wc_customer_id', $wc_customer_id ); 1156 $subscription->update_meta_data( '_payment_token', $wc_token->get_token(), $subscription_id ); 1157 $subscription->update_meta_data( '_payment_token_id', $id_payment_token, $subscription_id ); 1158 $subscription->update_meta_data( '_wc_customer_id', $wc_customer_id, $subscription_id ); 1159 $subscription->save(); 1108 1160 } 1109 1161 } … … 1113 1165 * Updates all active subscriptions payment method. 1114 1166 * 1167 * @param WC_Subscription $current_subscription WooCommerce Subscription. 1168 * @param object $wc_token WooCommerce Payment Token. 1169 * @param int $wc_customer_id WooCommerce Customer id. 1170 * @param bool $update_all_subscriptions_payment_method Indicates if payment methods should be updated for all subscriptions. 1171 * @return bool 1172 */ 1173 public function handle_add_payment_method( $current_subscription, $wc_token, $wc_customer_id, $update_all_subscriptions_payment_method ) { 1174 return false; 1175 } 1176 1177 /** 1178 * Grab selected payment token from Request 1179 * 1115 1180 * @abstract 1116 * 1117 * @param WC_Subscription $current_subscription WooCommerce Subscription. 1118 * @param object $wc_token WooCommerce Payment Token. 1119 * @param int $wc_customer_id WooCommerce Customer id. 1120 * @return bool 1121 */ 1122 public function handle_add_payment_method( $current_subscription, $wc_token, $wc_customer_id ) { 1123 return false; 1124 } 1125 1126 /** 1127 * Grab selected payment token from Request 1128 * 1129 * @abstract 1130 * 1181 * @param int $wc_token_id WooCommerce token id. 1131 1182 * @return String 1132 1183 */ 1133 public function get_selected_payment_token( ) {1184 public function get_selected_payment_token( $wc_token_id ) { 1134 1185 return ''; 1135 1186 } … … 1140 1191 * @param int $wc_order WooCommerce order id. 1141 1192 * @param String $revolut_order_id Revolut order id. 1142 * 1193 * @param bool $revolut_pay_redirected Indicates Revolut Pay webflow redirection. 1143 1194 * @return array 1144 1195 */ 1145 public function checkout_return( $wc_order, $revolut_order_id ) {1196 public function checkout_return( $wc_order, $revolut_order_id, $revolut_pay_redirected ) { 1146 1197 $this->clear_temp_session( $revolut_order_id ); 1147 1198 $this->unset_revolut_public_id(); … … 1151 1202 } 1152 1203 1153 if ( $ this->get_posted_integer_data( 'revolut_pay_redirected' )) {1204 if ( $revolut_pay_redirected ) { 1154 1205 wp_safe_redirect( $this->get_return_url( $wc_order ) ); 1155 1206 exit; … … 1225 1276 $wc_order->payment_complete( $revolut_order_id ); 1226 1277 $wc_order->add_order_note( __( 'Payment amount has been captured successfully.', 'revolut-gateway-for-woocommerce' ) ); 1227 update_post_meta( $order_id, 'revolut_capture', 'yes' ); 1278 $wc_order->update_meta_data( 'revolut_capture', 'yes', $order_id ); 1279 $wc_order->save(); 1228 1280 } else { 1229 1281 $wc_order->add_order_note( __( 'Order capture wasn\'t successful. Please try again or check your Revolut Business web portal for more information', 'revolut-gateway-for-woocommerce' ) ); -
revolut-gateway-for-woocommerce/trunk/includes/api/class-wc-revolut-api-client.php
r2976441 r3025245 47 47 48 48 /** 49 * Merchant management Api urls50 *51 * @var array52 */53 public $mgmt_api_urls = array(54 'live' => 'https://merchant-mgmt.revolut.com',55 'dev' => 'https://merchant-mgmt.revolut.codes',56 'sandbox' => 'https://sandbox-merchant-mgmt.revolut.com',57 );58 59 /**60 49 * Api mode live|sandbox|develop 61 50 * … … 91 80 */ 92 81 public $api_url; 93 94 /**95 * Public Api url96 *97 * @var string98 */99 public $mgmt_api_url;100 82 101 83 /** … … 128 110 129 111 // switch to the new api if required. 130 $this->api_url = $new_api ? $this->base_url . '/api' : $this->base_url . '/api/1.0'; 131 $this->mgmt_api_url = $this->mgmt_api_urls[ $this->mode ]; 112 $this->api_url = $new_api ? $this->base_url . '/api' : $this->base_url . '/api/1.0'; 132 113 } 133 114 … … 135 116 * Send post to API. 136 117 * 137 * @param String $path Api path.118 * @param string $path Api path. 138 119 * @param array|null $body Request body. 139 * @param bool $ is_mgmt_endpoint ManagementAPI indicator.120 * @param bool $public Public API indicator. 140 121 * @param bool $new_api New API indicator. 141 122 * … … 143 124 * @throws Exception Exception. 144 125 */ 145 public function post( $path, $body = null, $ is_mgmt_endpoint= false, $new_api = false ) {146 return $this->request( $path, 'POST', $body, $ is_mgmt_endpoint, $new_api );126 public function post( $path, $body = null, $public = false, $new_api = false ) { 127 return $this->request( $path, 'POST', $body, $public, $new_api ); 147 128 } 148 129 … … 150 131 * Send request to API 151 132 * 152 * @param String $path Api path.153 * @param String $method Request method.133 * @param string $path Api path. 134 * @param string $method Request method. 154 135 * @param array|null $body Request body. 155 * @param bool $ is_mgmt_api_endpoint Management API endpointindicator.136 * @param bool $public Public API indicator. 156 137 * @param bool $new_api New API indicator. 157 * @param bool $is_mgmt_endpoint Management endpoint indicator. 158 * 159 * @return mixed 160 * @throws Exception Exception. 161 */ 162 private function request( $path, $method, $body = null, $is_mgmt_api_endpoint = false, $new_api = false, $is_mgmt_endpoint = false ) { 138 * @return mixed 139 * @throws Exception Exception. 140 */ 141 private function request( $path, $method, $body = null, $public = false, $new_api = false ) { 163 142 global $wp_version; 164 143 global $woocommerce; … … 169 148 170 149 $api_key = $this->api_key; 171 172 if ( $is_mgmt_api_endpoint && WC_GATEWAY_PUBLIC_KEY_ENDPOINT !== $path ) { 150 $url = $this->api_url . $path; 151 152 if ( $new_api ) { 153 $url = $this->base_url . '/api' . $path; 154 } 155 156 if ( $public ) { 173 157 $api_key = $this->public_key; 158 $url = $this->base_url . '/api/public' . $path; 174 159 } 175 160 … … 188 173 } 189 174 190 $url = $this->api_url . $path;191 192 if ( $new_api ) {193 $url = $this->base_url . '/api' . $path;194 }195 196 if ( $is_mgmt_api_endpoint ) {197 $url = $this->mgmt_api_url . '/api' . $path;198 }199 200 if ( $is_mgmt_endpoint ) {201 $url = $this->mgmt_api_url . $path;202 }203 204 175 $response = wp_remote_request( $url, $request ); 205 176 $response_body = wp_remote_retrieve_body( $response ); … … 215 186 216 187 /** 217 * Send request to public API218 *219 * @param String $path Api path.220 * @param array $headers Request method.221 * @param String $method Request method.222 * @param array|null $body Request body.223 *224 * @return mixed225 * @throws Exception Exception.226 */227 public function public_request( $path, $headers, $method = 'POST', $body = null ) {228 global $wp_version;229 global $woocommerce;230 231 $headers['User-Agent'] = 'Revolut Payment Gateway/' . WC_GATEWAY_REVOLUT_VERSION . ' WooCommerce/' . $woocommerce->version . ' Wordpress/' . $wp_version . ' PHP/' . PHP_VERSION;232 $headers['Content-Type'] = 'application/json';233 234 $request = array(235 'headers' => $headers,236 'method' => $method,237 );238 239 if ( null !== $body ) {240 $request['body'] = wp_json_encode( $body );241 }242 243 $url = $this->mgmt_api_url . '/public/' . $path;244 245 $response = wp_remote_request( $url, $request );246 $response_body = wp_remote_retrieve_body( $response );247 248 if ( wp_remote_retrieve_response_code( $response ) >= 400 && wp_remote_retrieve_response_code( $response ) < 500 && 'GET' !== $method ) {249 $this->log_error( "Failed request to URL $method $url" );250 $this->log_error( $response_body );251 throw new Exception( "Something went wrong: $method $url\n" . $response_body );252 }253 254 return json_decode( $response_body, true );255 }256 257 /**258 188 * Send GET request to API 259 189 * 260 * @param String$path Request path.261 * @param Boolean $is_mgmt_api Management API endpointindicator.262 * @param Boolean $is_mgmt Management APIindicator.263 * 264 * @return mixed 265 * @throws Exception Exception. 266 */ 267 public function get( $path, $ is_mgmt_api = false, $is_mgmt= false ) {268 return $this->request( $path, 'GET', null, $ is_mgmt_api, false, $is_mgmt);190 * @param string $path Request path. 191 * @param bool $public Public API indicator. 192 * @param bool $new_api API version indicator. 193 * 194 * @return mixed 195 * @throws Exception Exception. 196 */ 197 public function get( $path, $public = false, $new_api = false ) { 198 return $this->request( $path, 'GET', null, $public, $new_api ); 269 199 } 270 200 … … 272 202 * Revolut API patch 273 203 * 274 * @param String $path Request path.204 * @param string $path Request path. 275 205 * @param array|null $body Request body. 276 206 * … … 285 215 * Revolut API delete 286 216 * 287 * @param String $path Request path.217 * @param string $path Request path. 288 218 * 289 219 * @return mixed … … 297 227 * Set Revolut Merchant Public Key 298 228 * 299 * @param String $public_key public key.229 * @param string $public_key public key. 300 230 * 301 231 * @return void -
revolut-gateway-for-woocommerce/trunk/includes/class-wc-revolut-apple-pay-onboarding.php
r2990122 r3025245 151 151 */ 152 152 public function admin_notices() { 153 $page = $this->get_request_data( 'page' );154 $section = $this->get_request_data( 'section' );153 $page = isset( $_GET['page'] ) ? wc_clean( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore 154 $section = isset( $_GET['section'] ) ? wc_clean( wp_unslash( $_GET['section'] ) ) : ''; // phpcs:ignore 155 155 156 156 if ( ! empty( $page ) && ! empty( $section ) ) { … … 233 233 */ 234 234 public function maybe_onboard_apple_pay_merchant() { 235 $action = $this->get_post_request_data( 'action' );235 $action = isset( $_POST['action'] ) ? wc_clean( wp_unslash( $_POST['action'] ) ) : ''; // phpcs:ignore 236 236 237 237 if ( ! empty( $action ) && 'wc_revolut_onboard_applepay_domain' === $action ) { … … 380 380 $this->success_messages[] = $message; 381 381 } 382 383 /**384 * Safe get posted data385 *386 * @param string $post_key request key.387 */388 public function get_post_request_data( $post_key ) {389 if ( ! isset( $_POST[ $post_key ] ) ) { // phpcs:ignore390 return null;391 }392 393 return $this->recursive_sanitize_text_field( $_POST[ $post_key ]); // phpcs:ignore394 }395 396 /**397 * Safe get request data398 *399 * @param string $get_key request key.400 */401 public function get_request_data( $get_key ) {402 if ( ! isset( $_GET[ $get_key ] ) ) { // phpcs:ignore403 return null;404 }405 406 return $this->recursive_sanitize_text_field( $_GET[ $get_key ] ); // phpcs:ignore407 }408 409 /**410 * Clear data.411 *412 * @param mixed $var data for cleaning.413 */414 public function recursive_sanitize_text_field( $var ) {415 if ( is_array( $var ) ) {416 return array_map( array( $this, 'recursive_sanitize_text_field' ), $var );417 } else {418 return sanitize_text_field( wp_unslash( $var ) );419 }420 }421 382 } -
revolut-gateway-for-woocommerce/trunk/includes/class-wc-revolut-order-descriptor.php
r2891412 r3025245 45 45 */ 46 46 public function __construct( $amount, $currency, $revolut_customer_id ) { 47 if ( $this->check_is_get_data_submitted( 'pay_for_order' ) && ! empty( $this->get_request_data( 'key' ) ) ) {47 if ( (bool) get_query_var( 'pay_for_order' ) && ! empty( get_query_var( 'key' ) ) ) { 48 48 global $wp; 49 49 $order = wc_get_order( wc_clean( $wp->query_vars['order-pay'] ) ); -
revolut-gateway-for-woocommerce/trunk/includes/class-wc-revolut-payment-ajax-controller.php
r2956658 r3025245 42 42 add_action( 'wc_ajax_revolut_payment_request_set_error_message', array( $this, 'revolut_payment_request_ajax_set_error_message' ) ); 43 43 add_action( 'wc_ajax_revolut_payment_request_log_error', array( $this, 'revolut_payment_request_ajax_log_error' ) ); 44 add_action( 'wc_ajax_revolut_payment_request_log_error', array( $this, 'revolut_payment_request_ajax_log_error' ) );45 44 46 45 if ( is_admin() ) { 47 add_action( 'wp_ajax_wc_revolut_set_webhook', array( $this, 'wc_revolut_set_webhook' ) );48 46 add_action( 'wp_ajax_wc_revolut_clear_records', array( $this, 'wc_revolut_clear_records' ) ); 49 add_action( 50 'wp_ajax_wc_revolut_onboard_applepay_domain', 51 array( $this, 'wc_revolut_onboard_applepay_domain' ) 52 ); 53 } 54 47 add_action( 'wp_ajax_wc_revolut_onboard_applepay_domain', array( $this, 'wc_revolut_onboard_applepay_domain' ) ); 48 } 55 49 } 56 50 … … 61 55 */ 62 56 public function wc_revolut_process_payment_result() { 63 try { 64 $wc_order_id = $this->get_posted_integer_data( 'wc_order_id' ); 65 $selected_gateway = $this->get_post_request_data( 'revolut_gateway' ); 66 67 if ( empty( $wc_order_id ) || empty( $selected_gateway ) || empty( $this->get_post_request_data( 'revolut_public_id' ) ) ) { 57 check_ajax_referer( 'wc-revolut-process-payment-result', 'security' ); 58 59 try { 60 $wc_order_id = isset( $_POST['wc_order_id'] ) ? (int) wc_clean( wp_unslash( $_POST['wc_order_id'] ) ) : 0; 61 $selected_gateway = isset( $_POST['revolut_gateway'] ) ? wc_clean( wp_unslash( $_POST['revolut_gateway'] ) ) : ''; 62 $is_express_checkout = isset( $_POST['is_express_checkout'] ) ? (bool) wc_clean( wp_unslash( $_POST['is_express_checkout'] ) ) : false; 63 $reload_checkout = isset( $_POST['reload_checkout'] ) ? (bool) wc_clean( wp_unslash( $_POST['reload_checkout'] ) ) : false; 64 $revolut_payment_public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 65 $revolut_payment_error = isset( $_POST['revolut_payment_error'] ) ? wc_clean( wp_unslash( $_POST['revolut_payment_error'] ) ) : ''; 66 $wc_payment_token_id = isset( $_POST[ 'wc-' . WC_Gateway_Revolut_CC::GATEWAY_ID . '-payment-token' ] ) ? wc_clean( wp_unslash( $_POST[ 'wc-' . WC_Gateway_Revolut_CC::GATEWAY_ID . '-payment-token' ] ) ) : ''; 67 $save_payment_method_requested = isset( $_POST['revolut_save_payment_method'] ) ? (bool) wc_clean( wp_unslash( $_POST['revolut_save_payment_method'] ) ) : false; 68 $is_using_saved_payment_method = ! empty( $wc_payment_token_id ) && 'new' !== $wc_payment_token_id; 69 70 if ( empty( $wc_order_id ) || empty( $selected_gateway ) || empty( $revolut_payment_public_id ) ) { 68 71 $this->log_error( 69 72 array( 70 73 'wc_order_id' => $wc_order_id, 71 74 'selected_gateway' => $selected_gateway, 72 'revolut_public_id' => $ this->get_post_request_data( 'revolut_public_id' ),75 'revolut_public_id' => $revolut_payment_public_id, 73 76 ) 74 77 ); 75 76 $revolut_payment_error = $this->get_post_request_data( 'revolut_payment_error' );77 78 78 79 if ( empty( $revolut_payment_error ) ) { … … 90 91 } 91 92 92 $result = $revolut_gateway->process_payment( $wc_order_id ); 93 93 $result = $revolut_gateway->process_payment( 94 $wc_order_id, 95 $revolut_payment_public_id, 96 $is_express_checkout, 97 $revolut_payment_error, 98 $reload_checkout, 99 false, 100 $is_using_saved_payment_method, 101 $save_payment_method_requested, 102 $wc_payment_token_id 103 ); 94 104 } catch ( Exception $e ) { 95 105 $result = array( … … 111 121 112 122 wp_send_json( $result ); 113 }114 115 /**116 * Setup webhook117 *118 * @throws Exception Exception.119 */120 public function wc_revolut_set_webhook() {121 try {122 if ( $this->check_is_post_data_submitted( 'apiKey' ) || empty( $this->get_post_request_data( 'apiKey' ) ) ) {123 wp_die( false );124 }125 126 if ( ! $this->check_is_post_data_submitted( 'mode' ) || empty( $this->get_post_request_data( 'mode' ) ) ) {127 wp_die( false );128 }129 130 $web_hook_url = get_site_url( null, '/wp-json/wc/v3/revolut', 'https' );131 132 $body = array(133 'url' => $web_hook_url,134 'events' => array(135 'ORDER_COMPLETED',136 'ORDER_AUTHORISED',137 ),138 );139 140 $mode = $this->get_post_request_data( 'mode' );141 142 if ( 'live' === $mode ) {143 $this->api_client->api_url = $this->api_client->api_url_live;144 } elseif ( 'sandbox' === $mode ) {145 $this->api_client->api_url = $this->api_client->api_url_sandbox;146 } elseif ( 'dev' === $mode ) {147 $this->api_client->api_url = $this->api_client->api_url_dev;148 }149 150 $this->api_client->api_url .= '/api/1.0';151 $this->api_client->api_key = $this->get_post_request_data( 'apiKey' );152 153 $web_hook_url_list = $this->api_client->get( '/webhooks' );154 if ( ! empty( $web_hook_url_list ) ) {155 $web_hook_url_list = array_column( $web_hook_url_list, 'url' );156 157 if ( in_array( $web_hook_url, $web_hook_url_list, true ) ) {158 wp_send_json(159 array(160 'success' => true,161 )162 );163 }164 }165 166 $response = $this->api_client->post( '/webhooks', $body );167 168 if ( isset( $response['id'] ) && ! empty( $response['id'] ) ) {169 wp_send_json(170 array(171 'success' => true,172 )173 );174 }175 } catch ( Exception $e ) {176 $this->log_error( $e->getMessage() );177 wp_send_json(178 array(179 'success' => false,180 'message' => $e->getMessage(),181 )182 );183 }184 185 wp_send_json(186 array(187 'success' => true,188 )189 );190 123 } 191 124 … … 328 261 public function wc_revolut_validate_order_pay_form() { 329 262 try { 330 $nonce_value = wc_get_var( $ this->get_post_request_data( 'woocommerce-pay-nonce' ), $this->get_post_request_data( '_wpnonce' ) );263 $nonce_value = wc_get_var( $_REQUEST['woocommerce-pay-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // phpcs:ignore 331 264 332 265 if ( ! wp_verify_nonce( $nonce_value, 'woocommerce-pay' ) ) { … … 334 267 } 335 268 336 $order_key = $this->get_post_request_data( 'wc_order_key' ); 337 $order_id = $this->get_posted_integer_data( 'wc_order_id' ); 338 $order = wc_get_order( $order_id ); 269 $order_id = isset( $_POST['wc_order_id'] ) ? (int) wc_clean( wp_unslash( $_POST['wc_order_id'] ) ) : 0; 270 $terms_field = isset( $_POST['terms-field'] ) ? (int) wc_clean( wp_unslash( $_POST['terms-field'] ) ) : 0; 271 $order_key = isset( $_POST['wc_order_key'] ) ? wc_clean( wp_unslash( $_POST['wc_order_key'] ) ) : ''; 272 $terms = isset( $_POST['terms'] ) ? wc_clean( wp_unslash( $_POST['terms'] ) ) : ''; 273 $order = wc_get_order( $order_id ); 339 274 340 275 if ( $order_id === $order->get_id() && hash_equals( $order->get_order_key(), $order_key ) && $order->needs_payment() ) { 341 276 do_action( 'woocommerce_before_pay_action', $order ); 342 if ( ! empty( $t his->get_posted_integer_data( 'terms-field' ) && empty( $this->get_post_request_data( 'terms' ) )) ) {277 if ( ! empty( $terms_field ) && empty( $terms ) ) { 343 278 throw new Exception( __( 'Please read and accept the terms and conditions to proceed with your order.', 'woocommerce' ) ); 344 279 } … … 372 307 check_ajax_referer( 'wc-revolut-get-billing-info', 'security' ); 373 308 374 $order_id = $this->get_posted_integer_data( 'order_id' ); 375 $order_key = $this->get_post_request_data( 'order_key' ); 376 $order = wc_get_order( $order_id ); 309 $order_id = isset( $_POST['order_id'] ) ? (int) wc_clean( wp_unslash( $_POST['order_id'] ) ) : 0; 310 $order_key = isset( $_POST['order_key'] ) ? wc_clean( wp_unslash( $_POST['order_key'] ) ) : ''; 311 312 $order = wc_get_order( $order_id ); 377 313 // validate order key. 378 314 if ( $order && $order_key === $order->get_order_key() ) { … … 428 364 public function revolut_payment_request_ajax_cancel_order() { 429 365 check_ajax_referer( 'wc-revolut-cancel-order', 'security' ); 430 $revolut_public_id = $this->get_post_request_data( 'revolut_public_id' ); 431 $revolut_order_id = $this->get_revolut_order_by_public_id( $revolut_public_id ); 366 $revolut_public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 367 368 $revolut_order_id = $this->get_revolut_order_by_public_id( $revolut_public_id ); 432 369 433 370 try { … … 453 390 */ 454 391 public function revolut_payment_request_ajax_set_error_message() { 455 $error_message = $this->get_post_request_data( 'revolut_payment_request_error' ); 392 check_ajax_referer( 'wc-revolut-set-error-message', 'security' ); 393 $error_message = isset( $_POST['revolut_payment_request_error'] ) ? wc_clean( wp_unslash( $_POST['revolut_payment_request_error'] ) ) : ''; 456 394 457 395 if ( empty( $error_message ) ) { … … 466 404 */ 467 405 public function revolut_payment_request_ajax_log_error() { 468 $error_message = $this->get_post_request_data( 'revolut_payment_request_error' ); 406 check_ajax_referer( 'wc-revolut-log-errors', 'security' ); 407 $error_message = isset( $_POST['revolut_payment_request_error'] ) ? wc_clean( wp_unslash( $_POST['revolut_payment_request_error'] ) ) : ''; 469 408 $this->log_error( $error_message ); 470 409 } -
revolut-gateway-for-woocommerce/trunk/includes/class-wc-revolut-privacy.php
r2680985 r3025245 97 97 if ( 0 < count( $orders ) ) { 98 98 foreach ( $orders as $order ) { 99 $wc_order = $this->wc_get_order( $order->get_id() ); 99 100 $data_to_export[] = array( 100 101 'group_id' => 'woocommerce_orders', … … 104 105 array( 105 106 'name' => __( 'Revolut token', 'revolut-gateway-for-woocommerce' ), 106 'value' => get_post_meta( $order->get_id(),'_revolut_pre_order_token', true ),107 'value' => $wc_order->get_meta( '_revolut_pre_order_token', true ), 107 108 ), 108 109 ), … … 157 158 * Handle eraser of data tied to Orders 158 159 * 159 * @param WC_Order $ order WooCommerce Order.160 * @param WC_Order $wc_order WooCommerce Order. 160 161 * 161 162 * @return array 162 163 */ 163 protected function maybe_handle_order( $ order ) {164 $order_id = $ order->get_id();165 $revolut_token = get_post_meta( $order_id,'_revolut_pre_order_token', true );164 protected function maybe_handle_order( $wc_order ) { 165 $order_id = $wc_order->get_id(); 166 $revolut_token = $wc_order->get_meta( '_revolut_pre_order_token', true ); 166 167 167 168 if ( empty( $revolut_token ) ) { … … 169 170 } 170 171 171 delete_post_meta( $order_id,'_revolut_pre_order_token' );172 $wc_order->delete_meta_data( '_revolut_pre_order_token' ); 172 173 173 174 return array( true, false, array( __( 'Revolut Order Data Erased.', 'revolut-gateway-for-woocommerce' ) ) ); -
revolut-gateway-for-woocommerce/trunk/includes/gateways/class-wc-gateway-revolut-cc.php
r2976441 r3025245 257 257 * Process the payment and return the result. 258 258 * 259 * @param int $wc_order_id WooCommerce Order order id. 259 * @param int $wc_order_id WooCommerce order id. 260 * @param string $revolut_payment_public_id Revolut payment public id. 261 * @param bool $is_express_checkout Express checkout identifier. 262 * @param string $revolut_payment_error Payment error. 263 * @param bool $reload_checkout Indicates if the page should reloaded. 264 * @param bool $revolut_pay_redirected Indicates Revolut Pay webflow redirection. 265 * @param bool $is_using_saved_payment_method Indicates payments by payment token. 266 * @param bool $save_payment_method_requested Indicates if payment token should be saved. 267 * @param int $wc_token_id WooCommerce token id. 260 268 * 261 269 * @throws Exception Exception. 262 270 */ 263 public function process_payment( $wc_order_id ) {271 public function process_payment( $wc_order_id, $revolut_payment_public_id = '', $is_express_checkout = false, $revolut_payment_error = '', $reload_checkout = false, $revolut_pay_redirected = false, $is_using_saved_payment_method = false, $save_payment_method_requested = false, $wc_token_id = 0 ) { 264 272 if ( $this->has_subscription( $wc_order_id ) ) { 265 if ( $this->is_subs_change_payment() ) { 266 return $this->change_subs_payment_method( $wc_order_id ); 267 } 268 269 // Regular payment with force customer enabled. 270 return parent::process_payment( $wc_order_id ); 271 } else { 272 return parent::process_payment( $wc_order_id ); 273 } 273 if ( isset( $_POST['_wcsnonce'] ) && wp_verify_nonce( wc_clean( wp_unslash( $_POST['_wcsnonce'] ) ), 'wcs_change_payment_method' ) ) { 274 if ( isset( $_POST['woocommerce_change_payment'] ) ) { 275 return $this->change_subs_payment_method( $wc_order_id ); 276 } 277 } 278 } 279 280 return parent::process_payment( $wc_order_id, $revolut_payment_public_id, $is_express_checkout, $revolut_payment_error, $reload_checkout, $revolut_pay_redirected, $is_using_saved_payment_method, $save_payment_method_requested, $wc_token_id ); 274 281 } 275 282 … … 304 311 public function change_subs_payment_method( $wc_order_id ) { 305 312 try { 306 $subscription = wc_get_order( $wc_order_id ); 307 $revolut_payment_public_id = $this->get_post_request_data( 'revolut_public_id' ); 313 if ( ! isset( $_POST['_wcsnonce'] ) || ! wp_verify_nonce( wc_clean( wp_unslash( $_POST['_wcsnonce'] ) ), 'wcs_change_payment_method' ) ) { 314 return; 315 } 316 317 $subscription = wc_get_order( $wc_order_id ); 318 319 $revolut_payment_public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 320 $wc_payment_token_id = isset( $_POST[ 'wc-' . $this->id . '-payment-token' ] ) ? wc_clean( wp_unslash( $_POST[ 'wc-' . $this->id . '-payment-token' ] ) ) : ''; 321 $is_using_saved_payment_method = ! empty( $wc_payment_token_id ) && 'new' !== $wc_payment_token_id; 322 $update_all_subscriptions_payment_method = isset( $_POST[ 'wc-' . $this->id . '-update-subs-payment-method-card' ] ) || isset( $_POST['update_all_subscriptions_payment_method'] ); 308 323 309 324 if ( empty( $revolut_payment_public_id ) ) { … … 318 333 } 319 334 320 if ( $ this->is_using_saved_payment_method()) {321 $wc_token = $this->get_selected_payment_token( );335 if ( $is_using_saved_payment_method ) { 336 $wc_token = $this->get_selected_payment_token( $wc_payment_token_id ); 322 337 } else { 323 338 $wc_token = $this->save_payment_method( $revolut_order_id ); … … 328 343 329 344 $this->save_payment_token_to_order( $subscription, $wc_token, get_current_user_id() ); 330 $this->handle_add_payment_method( $subscription, $wc_token, get_current_user_id() );345 $this->handle_add_payment_method( $subscription, $wc_token, get_current_user_id(), $update_all_subscriptions_payment_method ); 331 346 332 347 return array( … … 345 360 * Updates all active subscriptions payment method. 346 361 * 347 * @param WC_Subscription $current_subscription WooCommerce Subscription. 348 * @param object $wc_token WooCommerce Payment Token. 349 * @param int $wc_customer_id WooCommerce Customer id. 362 * @param WC_Subscription $current_subscription WooCommerce Subscription. 363 * @param object $wc_token WooCommerce Payment Token. 364 * @param int $wc_customer_id WooCommerce Customer id. 365 * @param bool $update_all_subscriptions_payment_method Indicates if payment methods should be updated for all subscriptions. 350 366 * @return bool 351 367 */ 352 public function handle_add_payment_method( $current_subscription, $wc_token, $wc_customer_id ) {368 public function handle_add_payment_method( $current_subscription, $wc_token, $wc_customer_id, $update_all_subscriptions_payment_method ) { 353 369 // remove public ID after saving the card. 354 370 $this->unset_revolut_public_id(); 355 371 356 if ( $ this->update_all_subscriptions_payment_method()) {372 if ( $update_all_subscriptions_payment_method ) { 357 373 $all_subs = wcs_get_users_subscriptions(); 358 374 … … 416 432 */ 417 433 public function delete_resubscribe_meta( $resubscribe_order ) { 418 delete_post_meta( $resubscribe_order->get_id(), '_payment_token' );419 delete_post_meta( $resubscribe_order->get_id(), '_payment_token_id' );420 delete_post_meta( $resubscribe_order->get_id(), '_wc_customer_id' );434 $resubscribe_order->delete_meta_data( $resubscribe_order->get_id(), '_payment_token' ); 435 $resubscribe_order->delete_meta_data( $resubscribe_order->get_id(), '_payment_token_id' ); 436 $resubscribe_order->delete_meta_data( $resubscribe_order->get_id(), '_wc_customer_id' ); 421 437 } 422 438 … … 457 473 */ 458 474 public function update_failing_payment_method( $subscription, $renewal_order ) { 459 update_post_meta( $subscription->get_id(), '_payment_token', $renewal_order->get_meta( '_payment_token' ) ); 460 update_post_meta( $subscription->get_id(), '_payment_token_id', $renewal_order->get_meta( '_payment_token_id' ) ); 461 update_post_meta( $subscription->get_id(), '_wc_customer_id', $renewal_order->get_meta( '_wc_customer_id' ) ); 475 $subscription->update_meta_data( '_payment_token', $renewal_order->get_meta( '_payment_token' ), $subscription->get_id() ); 476 $subscription->update_meta_data( '_payment_token_id', $renewal_order->get_meta( '_payment_token_id' ), $subscription->get_id() ); 477 $subscription->update_meta_data( '_wc_customer_id', $renewal_order->get_meta( '_wc_customer_id' ), $subscription->get_id() ); 478 $subscription->save(); 462 479 } 463 480 … … 471 488 public function update_changed_subscription_token( $subscription, $new_token ) { 472 489 if ( $new_token->get_gateway_id() === $this->id ) { 473 update_post_meta( $subscription->get_id(), '_payment_token', $new_token->get_token() ); 474 update_post_meta( $subscription->get_id(), '_payment_token_id', $new_token->get_id() ); 490 $subscription_id = $subscription->get_id(); 491 $subscription->update_meta_data( '_payment_token', $new_token->get_token(), $subscription_id ); 492 $subscription->update_meta_data( '_payment_token_id', $new_token->get_id(), $subscription_id ); 493 $subscription->save(); 475 494 } 476 495 } … … 489 508 490 509 /** 491 * Update all subscriptions payment methods492 *493 * @return bool494 */495 public function update_all_subscriptions_payment_method() {496 return $this->check_is_post_data_submitted( 'wc-' . $this->id . '-update-subs-payment-method-card' ) || $this->check_is_post_data_submitted( 'update_all_subscriptions_payment_method' );497 }498 499 /**500 * Check if it is using saved payment method501 *502 * @return bool503 */504 public function is_using_saved_payment_method() {505 return ( $this->check_is_post_data_submitted( 'wc-' . $this->id . '-payment-token' ) && ! empty( $this->get_post_request_data( 'wc-' . $this->id . '-payment-token' ) && 'new' !== $this->get_post_request_data( 'wc-' . $this->id . '-payment-token' ) ) );506 }507 508 /**509 510 * Grab selected payment token from Request 510 511 * 512 * @param int $wc_token_id WooCommerce payment token id. 511 513 * @return string 512 514 * @throws Exception Exception. 513 515 */ 514 public function get_selected_payment_token() { 515 $wc_token_id = $this->get_posted_integer_data( 'wc-' . $this->id . '-payment-token' ); 516 public function get_selected_payment_token( $wc_token_id ) { 516 517 $wc_token = WC_Payment_Tokens::get( $wc_token_id ); 517 518 $payment_method_id = $wc_token->get_token(); … … 522 523 523 524 return $wc_token; 524 }525 526 /**527 * Check if save payment method requested528 */529 public function save_payment_method_requested() {530 return $this->get_posted_integer_data( 'revolut_save_payment_method' );531 525 } 532 526 … … 549 543 $total = $this->get_revolut_order_total( $total, $currency ); 550 544 $mode = $this->api_settings->get_option( 'mode' ); 551 $hide_fieldset = $this->get_option( 'card_widget_type' ) === 'popup' || $this->get_request_data( 'pay_for_order' ) ? 'height:0px;padding:0' : '';545 $hide_fieldset = $this->get_option( 'card_widget_type' ) === 'popup' || get_query_var( 'pay_for_order' ) ? 'height:0px;padding:0' : ''; 552 546 $shipping_total = $this->get_cart_total_shipping(); 553 547 $hide_payment_method = ! empty( $hide_fieldset ) && ! $display_tokenization ? true : false; … … 615 609 } 616 610 617 return $this->check_is_get_data_submitted( 'change_payment_method' ) || $this->cart_contains_subscription();611 return get_query_var( 'change_payment_method' ) || $this->cart_contains_subscription(); 618 612 } 619 613 -
revolut-gateway-for-woocommerce/trunk/includes/gateways/class-wc-gateway-revolut-pay.php
r2976441 r3025245 44 44 } 45 45 46 add_action( 'wp _loaded', array( $this, 'check_revolut_pay_payment_result' ) );46 add_action( 'wp', array( $this, 'check_revolut_pay_payment_result' ) ); 47 47 add_filter( 'wc_revolut_settings_nav_tabs', array( $this, 'admin_nav_tab' ), 3 ); 48 48 add_action( 'wp_enqueue_scripts', array( $this, 'wc_revolut_pay_enqueue_scripts' ) ); … … 57 57 */ 58 58 public function check_revolut_pay_payment_result() { 59 if ( empty( $this->get_request_data( '_rp_oid' ) ) ) {59 if ( empty( get_query_var( '_rp_oid' ) ) ) { 60 60 return; 61 61 } 62 62 63 $public_id = $this->get_request_data( '_rp_oid' );63 $public_id = get_query_var( '_rp_oid' ); 64 64 65 65 global $wpdb; … … 95 95 $this->log_error( 'order processing - public_id: ' . $public_id . ' - wc_order_id: ' . $wc_order_id ); 96 96 97 $_POST['revolut_public_id'] = $public_id; 98 $_POST['revolut_pay_redirected'] = 1; 99 $this->process_payment( $wc_order_id ); 97 $this->process_payment( $wc_order_id, $public_id, false, '', false, true ); 100 98 } 101 99 … … 108 106 public function process_revolut_pay_fc_payment( $revolut_public_id ) { 109 107 try { 110 if ( ! empty( $this->get_request_data( '_rp_fr' ) ) ) {111 wc_add_notice( $this->get_request_data( '_rp_fr' ), 'error' );108 if ( ! empty( get_query_var( '_rp_fr' ) ) ) { 109 wc_add_notice( get_query_var( '_rp_fr' ), 'error' ); 112 110 return; 113 111 } … … 245 243 check_ajax_referer( 'wc-revolut-load-order-data', 'security' ); 246 244 247 $revolut_public_id = $this->get_post_request_data( 'revolut_public_id' );245 $revolut_public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 248 246 249 247 wp_send_json( … … 442 440 $total = WC()->cart->get_total( '' ); 443 441 444 if ( $this->check_is_get_data_submitted( 'pay_for_order' ) && ! empty( $this->get_request_data( 'key' ) ) ) {442 if ( get_query_var( 'pay_for_order' ) && ! empty( get_query_var( 'key' ) ) ) { 445 443 global $wp; 446 444 $order = wc_get_order( wc_clean( $wp->query_vars['order-pay'] ) ); -
revolut-gateway-for-woocommerce/trunk/includes/gateways/class-wc-gateway-revolut-payment-request.php
r2976441 r3025245 170 170 */ 171 171 public function is_available() { 172 if ( ( 'yes' === $this->enabled && is_product() ) || ( $this->check_is_post_data_submitted( 'payment_method' ) && $this->get_post_request_data( 'payment_method' ) === $this->id ) ) { 172 $payment_method = isset( $_POST['payment_method'] ) ? wc_clean( wp_unslash( $_POST['payment_method'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing 173 174 if ( ( 'yes' === $this->enabled && is_product() ) || $payment_method === $this->id ) { 173 175 return true; 174 176 } … … 283 285 ); 284 286 285 if ( $this->get_option( 'apple_pay_merchant_onboarded' ) === 'no' ) {287 if ( $this->get_option( 'apple_pay_merchant_onboarded' ) !== 'yes' ) { 286 288 $this->form_fields['onboard_applepay'] = array( 287 289 'title' => __( 'Onboard shop domain for Apple Pay', 'revolut-gateway-for-woocommerce' ), … … 332 334 /** 333 335 * Ajax endpoint in order to create WooCommerce order 336 * 337 * @throws Exception Exception. 334 338 */ 335 339 public function revolut_payment_request_ajax_create_order() { 340 check_ajax_referer( 'wc-revolut-create-order', 'security' ); 336 341 337 342 if ( WC()->cart->is_empty() ) { … … 346 351 347 352 try { 348 $wc_order_data = $this->get_wc_order_details(); 353 $public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 354 355 if ( empty( $public_id ) ) { 356 throw new Exception( 'Public ID is missing for the session' ); 357 } 358 359 $order_id = $this->get_revolut_order_by_public_id( $public_id ); 360 361 if ( empty( $order_id ) ) { 362 throw new Exception( 'Can not find revolut order id' ); 363 } 364 365 $address_info = isset( $_POST['address_info'] ) ? wc_clean( wp_unslash( $_POST['address_info'] ) ) : ''; 366 $shipping_required = isset( $_POST['shipping_required'] ) ? wc_clean( wp_unslash( $_POST['shipping_required'] ) ) : ''; 367 $revolut_gateway = isset( $_POST['revolut_gateway'] ) ? wc_clean( wp_unslash( $_POST['address_info'] ) ) : ''; 368 $revolut_payment_error = isset( $_POST['revolut_payment_error'] ) ? wc_clean( wp_unslash( $_POST['revolut_payment_error'] ) ) : ''; 369 370 if ( empty( $address_info ) ) { 371 throw new Exception( 'Address information is missing' ); 372 } 373 374 $wc_order_data = $this->format_wc_order_details( 375 $address_info, 376 $shipping_required, 377 $revolut_gateway 378 ); 379 380 foreach ( $errors->errors as $code => $messages ) { 381 $data = $errors->get_error_data( $code ); 382 foreach ( $messages as $message ) { 383 wc_add_notice( $message, 'error', $data ); 384 } 385 } 386 387 if ( 0 === wc_notice_count( 'error' ) ) { 388 $_POST = array_merge( $_POST, $wc_order_data ); 389 unset( $_POST['address_info'] ); 390 $_POST['_wpnonce'] = wp_create_nonce( 'woocommerce-process_checkout' ); 391 WC()->checkout()->process_checkout(); 392 } 393 394 $messages = wc_print_notices( true ); 395 396 $this->log_error( '->>> start messages - ' . $messages ); 397 398 wp_send_json( 399 array( 400 'result' => 'failure', 401 'messages' => $messages, 402 ) 403 ); 349 404 } catch ( Exception $e ) { 350 $this->log_error( $e->getMessage() );351 405 $errors->add( 'payment', __( 'Something went wrong', 'woocommerce' ) ); 352 if ( ! empty( $this->get_post_request_data( 'revolut_payment_error' ) ) ) { 353 $errors->add( 'payment', $this->get_post_request_data( 'revolut_payment_error' ) ); 354 $this->log_error( $this->get_post_request_data( 'revolut_payment_error' ) ); 355 } 356 } 357 358 foreach ( $errors->errors as $code => $messages ) { 359 $data = $errors->get_error_data( $code ); 360 foreach ( $messages as $message ) { 361 wc_add_notice( $message, 'error', $data ); 362 } 363 } 364 365 if ( 0 === wc_notice_count( 'error' ) ) { 366 $_POST = array_merge( $_POST, $wc_order_data ); // phpcs:ignore 367 unset( $_POST['address_info'] ); // phpcs:ignore 368 $_POST['_wpnonce'] = wp_create_nonce( 'woocommerce-process_checkout' ); 369 WC()->checkout()->process_checkout(); 370 } 371 372 $messages = wc_print_notices( true ); 373 374 wp_send_json( 375 array( 376 'result' => 'failure', 377 'messages' => $messages, 378 ) 379 ); 380 } 381 382 /** 383 * Get order details 384 * 385 * @throws Exception Exception. 386 */ 387 public function get_wc_order_details() { 388 $public_id = $this->get_post_request_data( 'revolut_public_id' ); 389 390 if ( empty( $public_id ) ) { 391 throw new Exception( 'Public ID is missing for the session' ); 392 } 393 394 $order_id = $this->get_revolut_order_by_public_id( $public_id ); 395 396 if ( empty( $order_id ) ) { 397 throw new Exception( 'Can not find revolut order id' ); 398 } 399 400 $address_info = $this->get_post_request_data( 'address_info' ); 401 402 if ( empty( $address_info ) ) { 403 throw new Exception( 'Address information is missing' ); 404 } 405 406 return $this->format_wc_order_details( 407 $this->get_post_request_data( 'address_info' ), 408 $this->get_posted_integer_data( 'shipping_required' ), 409 $this->get_post_request_data( 'revolut_gateway' ) 410 ); 406 if ( ! empty( $revolut_payment_error ) ) { 407 $errors->add( 'payment', $revolut_payment_error ); 408 $this->log_error( 'revolut_payment_request_ajax_create_order: ' . $revolut_payment_error ); 409 } 410 } 411 411 } 412 412 … … 420 420 check_ajax_referer( 'wc-revolut-pr-add-to-cart', 'security' ); 421 421 422 $revolut_public_id = $this->get_post_request_data( 'revolut_public_id' );422 $revolut_public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 423 423 424 424 if ( empty( $revolut_public_id ) ) { … … 432 432 WC()->shipping->reset_shipping(); 433 433 434 $product_id = $this->get_posted_integer_data( 'product_id' ); 435 $is_revolut_pay = $this->get_posted_integer_data( 'is_revolut_pay' ); 436 $qty = ! $this->check_is_post_data_submitted( 'qty' ) ? 1 : $this->get_posted_integer_data( 'qty' ); 437 $product = wc_get_product( $product_id ); 438 $product_type = $product->get_type(); 439 $global_cart = WC()->cart; 440 441 if ( ! $this->get_posted_integer_data( 'add_to_cart' ) ) { 434 $product_id = isset( $_POST['product_id'] ) ? wc_clean( wp_unslash( $_POST['product_id'] ) ) : 0; 435 $is_revolut_pay = isset( $_POST['is_revolut_pay'] ) ? wc_clean( wp_unslash( $_POST['is_revolut_pay'] ) ) : 0; 436 $qty = isset( $_POST['qty'] ) ? wc_clean( wp_unslash( $_POST['qty'] ) ) : 0; 437 $is_add_to_cart_action = isset( $_POST['add_to_cart'] ) ? wc_clean( wp_unslash( $_POST['add_to_cart'] ) ) : 0; 438 $attributes = isset( $_POST['attributes'] ) ? wc_clean( wp_unslash( $_POST['attributes'] ) ) : ''; 439 $product = wc_get_product( $product_id ); 440 $product_type = $product->get_type(); 441 $global_cart = WC()->cart; 442 443 if ( ! $is_add_to_cart_action ) { 442 444 WC()->cart = clone WC()->cart; 443 445 } … … 447 449 if ( 'simple' === $product_type || 'subscription' === $product_type ) { 448 450 WC()->cart->add_to_cart( $product->get_id(), $qty ); 449 } elseif ( $this->check_is_post_data_submitted( 'attributes' ) && ( 'variable' === $product_type || 'variable-subscription' === $product_type ) ) { 450 $attributes = $this->get_post_request_data( 'attributes' ); 451 } elseif ( $attributes && ( 'variable' === $product_type || 'variable-subscription' === $product_type ) ) { 451 452 $data_store = WC_Data_Store::load( 'product' ); 452 453 $variation_id = $data_store->find_matching_product_variation( $product, $attributes ); … … 460 461 $is_cart_empty = ! WC()->cart->is_empty(); 461 462 462 if ( ! $ this->get_posted_integer_data( 'add_to_cart' )) {463 if ( ! $is_add_to_cart_action ) { 463 464 WC()->cart = $global_cart; 464 465 } … … 487 488 try { 488 489 489 $revolut_public_id = $this->get_post_request_data( 'revolut_public_id' );490 $revolut_public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 490 491 491 492 if ( empty( $revolut_public_id ) ) { … … 542 543 } 543 544 544 $revolut_public_id = $this->get_post_request_data( 'revolut_public_id' );545 $revolut_public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 545 546 546 547 if ( empty( $revolut_public_id ) ) { … … 577 578 578 579 try { 579 $revolut_public_id = $this->get_post_request_data( 'revolut_public_id' );580 $revolut_public_id = isset( $_POST['revolut_public_id'] ) ? wc_clean( wp_unslash( $_POST['revolut_public_id'] ) ) : ''; 580 581 581 582 if ( empty( $revolut_public_id ) ) { -
revolut-gateway-for-woocommerce/trunk/includes/settings/class-wc-revolut-settings-api.php
r2977523 r3025245 394 394 395 395 if ( $this->get_option( 'revolut_pay_synchronous_webhook_domain_' . $mode . '_' . $location_id ) === $web_hook_url ) { 396 $this->update_option( 'revolut_' . $mode . '_location_id', $location_id ); 396 397 return true; 397 398 } 399 398 400 $body = array( 399 401 'url' => $web_hook_url, … … 453 455 */ 454 456 public function check_is_get_data_submitted( $submit ) { 455 return isset( $_GET[ $submit ] ); // phpcs:ignore 457 return isset( $_GET[ $submit ] ); // phpcs:ignore 456 458 } 457 459 … … 462 464 */ 463 465 public function get_request_data( $get_key ) { 464 if ( ! isset( $_GET[ $get_key ] ) ) { // phpcs:ignore 465 return null; 466 } 467 468 return $this->recursive_sanitize_text_field( $_GET[ $get_key ] ); // phpcs:ignore 469 } 470 471 /** 472 * Clear data. 473 * 474 * @param mixed $var data for cleaning. 475 */ 476 public function recursive_sanitize_text_field( $var ) { 477 if ( is_array( $var ) ) { 478 return array_map( array( $this, 'recursive_sanitize_text_field' ), $var ); 479 } else { 480 return sanitize_text_field( wp_unslash( $var ) ); 481 } 466 return isset( $_GET[ $get_key ] ) ? wc_clean( wp_unslash( $_GET[ $get_key ] ) ) : ''; // phpcs:ignore 482 467 } 483 468 } -
revolut-gateway-for-woocommerce/trunk/includes/traits/wc-revolut-express-checkout-helper-trait.php
r2964057 r3025245 219 219 $attribute_key = 'attribute_' . sanitize_title( $attribute_name ); 220 220 221 if ( $this->check_is_get_data_submitted( $attribute_key ) ) {221 if ( isset( $_GET[ $attribute_key ] ) ) { // phpcs:ignore 222 222 $attributes[ $attribute_key ] = sanitize_text_field( wp_unslash( $_GET[ $attribute_key ] ) ); // phpcs:ignore 223 223 } else { … … 336 336 'update_order_total' => wp_create_nonce( 'wc-revolut-update-order-total' ), 337 337 'load_order_data' => wp_create_nonce( 'wc-revolut-load-order-data' ), 338 'create_order' => wp_create_nonce( 'wc-revolut-create-order' ), 338 339 'cancel_order' => wp_create_nonce( 'wc-revolut-cancel-order' ), 339 340 'get_express_checkout_params' => wp_create_nonce( 'wc-revolut-get-express-checkout-params' ), … … 343 344 'get_selected_product_data' => wp_create_nonce( 'wc-revolut-get-selected-product-data' ), 344 345 'log_errors' => wp_create_nonce( 'wc-revolut-log-errors' ), 346 'set_error_message' => wp_create_nonce( 'wc-revolut-set-error-message' ), 345 347 'clear_cart' => wp_create_nonce( 'wc-revolut-clear-cart' ), 348 'process_payment_result' => wp_create_nonce( 'wc-revolut-process-payment-result' ), 346 349 ), 347 350 'is_product_page' => $this->is_product(), … … 357 360 ); 358 361 } catch ( Exception $e ) { 359 $this->log_error( $e->getMessage() );362 $this->log_error( 'get_wc_revolut_payment_request_params : ' . $e->getMessage() ); 360 363 } 361 364 } -
revolut-gateway-for-woocommerce/trunk/includes/traits/wc-revolut-helper-trait.php
r2995266 r3025245 595 595 } 596 596 597 $merchant_public_key = $this->api_client->get( WC_GATEWAY_PUBLIC_KEY_ENDPOINT, true );597 $merchant_public_key = $this->api_client->get( WC_GATEWAY_PUBLIC_KEY_ENDPOINT, false, true ); 598 598 $merchant_public_key = isset( $merchant_public_key['public_key'] ) ? $merchant_public_key['public_key'] : ''; 599 599 … … 635 635 */ 636 636 public function is_subs_change_payment() { 637 return ( isset( $_GET['pay_for_order'] ) && isset( $_GET['change_payment_method'] ) ); // phpcs:ignore637 return get_query_var( 'pay_for_order' ) && get_query_var( 'change_payment_method' ); 638 638 } 639 639 … … 828 828 829 829 /** 830 * Check is data submitted for GET request.831 *832 * @param string $submit request key.833 */834 public function check_is_get_data_submitted( $submit ) {835 return isset( $_GET[ $submit ] ); // phpcs:ignore836 }837 838 /**839 * Check is data submitted for POST request.840 *841 * @param string $submit request key.842 */843 public function check_is_post_data_submitted( $submit ) {844 return isset( $_POST[ $submit ] ); // phpcs:ignore845 }846 847 /**848 * Safe get posted integer data849 *850 * @param string $post_key request key.851 */852 public function get_posted_integer_data( $post_key ) {853 if ( ! isset( $_POST[ $post_key ] ) ) { // phpcs:ignore854 return 0;855 }856 857 return (int) $_POST[ $post_key ]; // phpcs:ignore858 }859 860 /**861 * Safe get posted data862 *863 * @param string $post_key request key.864 */865 public function get_post_request_data( $post_key ) {866 if ( ! isset( $_POST[ $post_key ] ) ) { // phpcs:ignore867 return null;868 }869 870 return $this->recursive_sanitize_text_field( $_POST[ $post_key ]); // phpcs:ignore871 }872 873 /**874 * Safe get request data875 *876 * @param string $get_key request key.877 */878 public function get_request_data( $get_key ) {879 if ( ! isset( $_GET[ $get_key ] ) ) { // phpcs:ignore880 return null;881 }882 883 return $this->recursive_sanitize_text_field( $_GET[ $get_key ] ); // phpcs:ignore884 }885 886 /**887 * Clear data.888 *889 * @param mixed $var data for cleaning.890 */891 public function recursive_sanitize_text_field( $var ) {892 if ( is_array( $var ) ) {893 return array_map( array( $this, 'recursive_sanitize_text_field' ), $var );894 } else {895 return sanitize_text_field( wp_unslash( $var ) );896 }897 }898 899 /**900 830 * Get two-digit language iso code. 901 831 */ … … 936 866 public function get_available_card_brands( $public_id ) { 937 867 try { 938 $order_details = $this->api_client->get( "/orders/token/{$public_id}", false, true );939 if ( ! isset( $order_details['available CardBrands'] ) || empty( $order_details['availableCardBrands'] ) ) {868 $order_details = $this->api_client->get( '/available-payment-methods', true ); 869 if ( ! isset( $order_details['available_card_brands'] ) || empty( $order_details['available_card_brands'] ) ) { 940 870 return ''; 941 871 } 942 943 return implode( ',', array_map( 'strtolower', $order_details['availableCardBrands'] ) ); 872 return implode( ',', array_map( 'strtolower', $order_details['available_card_brands'] ) ); 944 873 } catch ( Exception $e ) { 945 874 $this->log_error( 'get_available_card_brands: ' . $e->getMessage() ); -
revolut-gateway-for-woocommerce/trunk/readme.txt
r2995266 r3025245 4 4 Requires at least: 4.4 5 5 Tested up to: 6.3 6 Stable tag: 4.9. 56 Stable tag: 4.9.6 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 98 98 99 99 == Changelog == 100 = 4.9.6 = 101 * Added Woocommerce High-Performance Order Storage (HPOS) compatibility. 102 * Added additional security improvements. 103 100 104 = 4.9.5 = 101 105 * Fixed creating customer objects
Note: See TracChangeset
for help on using the changeset viewer.