From 8c15c9fea9675e2d4ce7d09c86fa9ec222b73ed5 Mon Sep 17 00:00:00 2001 From: Ravinder Kumar Date: Fri, 18 Aug 2023 21:41:13 +0530 Subject: [PATCH] refactor: reuse paypal sdk options --- .../PayPalCommerce/ScriptLoader.php | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/PaymentGateways/PayPalCommerce/ScriptLoader.php b/src/PaymentGateways/PayPalCommerce/ScriptLoader.php index b13569ff75..8dafdbfb6d 100644 --- a/src/PaymentGateways/PayPalCommerce/ScriptLoader.php +++ b/src/PaymentGateways/PayPalCommerce/ScriptLoader.php @@ -148,6 +148,9 @@ public function loadPublicAssets() try { $formSettings = $this->payPalCommerceGateway->formSettings(FrontendFormTemplateUtils::getFormId()); $paypalSDKOptions = $formSettings['sdkOptions']; + + // Remove v3 donation form related param. + unset($paypalSDKOptions['data-namespace']); } catch (\Exception $e) { give_set_error( 'give-paypal-commerce-client-token-error', @@ -165,23 +168,6 @@ public function loadPublicAssets() /* @var MerchantDetail $merchant */ $merchant = give(MerchantDetail::class); - /** - * @since 2.27.1 Removed locale query parameter. - */ - $payPalSdkQueryParameters = [ - 'client-id' => $paypalSDKOptions['client-id'], - 'merchant-id' => $paypalSDKOptions['merchant-id'], - 'components' => $paypalSDKOptions['components'], - 'disable-funding' => 'credit', - 'vault' => true, - 'data-partner-attribution-id' => give('PAYPAL_COMMERCE_ATTRIBUTION_ID'), - 'data-client-token' => $paypalSDKOptions['data-client-token'], - ]; - - if (array_key_exists('enable-funding', $paypalSDKOptions) && $paypalSDKOptions['enable-funding']) { - $payPalSdkQueryParameters['enable-funding'] = $paypalSDKOptions['enable-funding']; - } - $scriptId = 'give-paypal-commerce-js'; wp_enqueue_script( @@ -219,7 +205,7 @@ public function loadPublicAssets() 'hostedCardFieldStyles' => apply_filters('give_paypal_commerce_hosted_field_style', []), 'supportsCustomPayments' => $merchant->supportsCustomPayments ? 1 : '', 'separatorLabel' => esc_html__('Or pay with card', 'give'), - 'payPalSdkQueryParameters' => $payPalSdkQueryParameters, + 'payPalSdkQueryParameters' => $paypalSDKOptions, 'textForOverlayScreen' => sprintf( '

%1$s

%2$s

%3$s

', esc_html__('Donation Processing...', 'give'),