| @@ -31,8 +31,15 @@ | ||
| 31 | 31 | $data['supports'] = $this->get_supported_features(); |
| 32 | 32 | $data['showSaveOption'] = !empty($this->gateway->save_card) ? $this->gateway->save_card : false; |
| 33 | 33 | $configuration = $this->get_service('configuration'); |
| 34 | 34 | $embedded_mode = $configuration->get_option('payment_methods.configuration.payplug.embedded_mode'); |
| 35 | + // Order-pay always has a real, existing order (the one being repaid) - a regular | |
| 36 | + // checkout's order isn't created until the place-order submission itself (see | |
| 37 | + // wc-payplug-integratedPayment-blocks.js / wc-payplug-popup-blocks.js for why that | |
| 38 | + // matters here). Used by both the 'integrated' and 'popup' embedded modes below. | |
| 39 | + $data['is_order_pay'] = is_wc_endpoint_url('order-pay'); | |
| 40 | + $data['order_pay_id'] = $data['is_order_pay'] ? (int) get_query_var('order-pay') : 0; | |
| 41 | + $data['order_pay_key'] = $data['is_order_pay'] ? wc_clean(wp_unslash($_GET['key'] ?? '')) : ''; | |
| 35 | 42 | switch ($embedded_mode) { |
| 36 | 43 | case 'integrated': |
| 37 | 44 | $data['payplug_integrated_payment_cardHolder_error'] = __('payplug_integrated_payment_cardHolder_error', 'payplug'); |
| 38 | 45 | $data['payplug_integrated_payment_empty'] = __('payplug_integrated_payment_empty', 'payplug'); |
| @@ -55,8 +62,9 @@ | ||
| 55 | 62 | $data['payplug_integrated_payment_check_payment_url'] = \WC_AJAX::get_endpoint('payplug_check_payment'); |
| 56 | 63 | $data['payplug_integrated_payment_nonce_field'] = wp_nonce_field('woocommerce-process_checkout', 'woocommerce-process-checkout-nonce'); |
| 57 | 64 | $data['wp_nonce'] = wp_create_nonce('woocommerce-process_checkout'); |
| 58 | 65 | $data['mode'] = PayplugWoocommerceHelper::check_mode(); |
| 66 | + $data['secureDomain'] = PayplugWoocommerceHelper::get_secure_domain(); | |
| 59 | 67 | $data['IP'] = true; |
| 60 | 68 | break; |
| 61 | 69 | case 'popup': |
| 62 | 70 | $data['popup'] = true; |
| @@ -90,9 +98,9 @@ | ||
| 90 | 98 | |
| 91 | 99 | return parent::get_payment_method_script_handles(); |
| 92 | 100 | } |
| 93 | 101 | |
| 94 | - private function ip_scripts() | |
| 102 | + private function ip_scripts(): void | |
| 95 | 103 | { |
| 96 | 104 | wp_enqueue_style('payplugIP', PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/css/payplug-integrated-payments.css', [], PAYPLUG_GATEWAY_VERSION); |
| 97 | 105 | wp_register_script( |
| 98 | 106 | 'payplug-integrated-payments-api', |
| @@ -107,9 +115,9 @@ | ||
| 107 | 115 | |
| 108 | 116 | wp_enqueue_script('payplug-integrated-payments-api'); |
| 109 | 117 | } |
| 110 | 118 | |
| 111 | - private function popup_scripts() | |
| 119 | + private function popup_scripts(): void | |
| 112 | 120 | { |
| 113 | 121 | wp_register_script('payplug-popup', 'https://api.payplug.com/js/1/form.latest.js', [], null, true); |
| 114 | 122 | if (isset($_GET['pay_for_order'])) { |
| 115 | 123 | wp_register_script('payplug-checkout', PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/js/payplug-checkout.js', [ |