mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge pull request #1186 from woocommerce/PCP-1447-fix-preview-country
Do not send buyer-country for previews in live mode to avoid error
This commit is contained in:
commit
018ef8603a
4 changed files with 20 additions and 2 deletions
|
@ -114,10 +114,13 @@ import {setVisibleByClass, isVisible} from "../../../ppcp-button/resources/js/mo
|
||||||
'integration-date': PayPalCommerceGatewaySettings.integration_date,
|
'integration-date': PayPalCommerceGatewaySettings.integration_date,
|
||||||
'components': ['buttons', 'funding-eligibility', 'messages'],
|
'components': ['buttons', 'funding-eligibility', 'messages'],
|
||||||
'enable-funding': ['venmo', 'paylater'],
|
'enable-funding': ['venmo', 'paylater'],
|
||||||
'buyer-country': PayPalCommerceGatewaySettings.country,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if(payLaterButtonPreview?.length) {
|
if (PayPalCommerceGatewaySettings.environment === 'sandbox') {
|
||||||
|
settings['buyer-country'] = PayPalCommerceGatewaySettings.country;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payLaterButtonPreview?.length) {
|
||||||
disabledSources = Object.keys(PayPalCommerceGatewaySettings.all_funding_sources);
|
disabledSources = Object.keys(PayPalCommerceGatewaySettings.all_funding_sources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
|
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
|
||||||
|
|
||||||
|
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,6 +59,13 @@ class SettingsPageAssets {
|
||||||
*/
|
*/
|
||||||
private $country;
|
private $country;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The environment object.
|
||||||
|
*
|
||||||
|
* @var Environment
|
||||||
|
*/
|
||||||
|
private $environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether Pay Later button is enabled either for checkout, cart or product page.
|
* Whether Pay Later button is enabled either for checkout, cart or product page.
|
||||||
*
|
*
|
||||||
|
@ -88,6 +96,7 @@ class SettingsPageAssets {
|
||||||
* @param string $client_id The PayPal SDK client ID.
|
* @param string $client_id The PayPal SDK client ID.
|
||||||
* @param string $currency 3-letter currency code of the shop.
|
* @param string $currency 3-letter currency code of the shop.
|
||||||
* @param string $country 2-letter country code of the shop.
|
* @param string $country 2-letter country code of the shop.
|
||||||
|
* @param Environment $environment The environment object.
|
||||||
* @param bool $is_pay_later_button_enabled Whether Pay Later button is enabled either for checkout, cart or product page.
|
* @param bool $is_pay_later_button_enabled Whether Pay Later button is enabled either for checkout, cart or product page.
|
||||||
* @param array $disabled_sources The list of disabled funding sources.
|
* @param array $disabled_sources The list of disabled funding sources.
|
||||||
* @param array $all_funding_sources The list of all existing funding sources.
|
* @param array $all_funding_sources The list of all existing funding sources.
|
||||||
|
@ -99,6 +108,7 @@ class SettingsPageAssets {
|
||||||
string $client_id,
|
string $client_id,
|
||||||
string $currency,
|
string $currency,
|
||||||
string $country,
|
string $country,
|
||||||
|
Environment $environment,
|
||||||
bool $is_pay_later_button_enabled,
|
bool $is_pay_later_button_enabled,
|
||||||
array $disabled_sources,
|
array $disabled_sources,
|
||||||
array $all_funding_sources
|
array $all_funding_sources
|
||||||
|
@ -109,6 +119,7 @@ class SettingsPageAssets {
|
||||||
$this->client_id = $client_id;
|
$this->client_id = $client_id;
|
||||||
$this->currency = $currency;
|
$this->currency = $currency;
|
||||||
$this->country = $country;
|
$this->country = $country;
|
||||||
|
$this->environment = $environment;
|
||||||
$this->is_pay_later_button_enabled = $is_pay_later_button_enabled;
|
$this->is_pay_later_button_enabled = $is_pay_later_button_enabled;
|
||||||
$this->disabled_sources = $disabled_sources;
|
$this->disabled_sources = $disabled_sources;
|
||||||
$this->all_funding_sources = $all_funding_sources;
|
$this->all_funding_sources = $all_funding_sources;
|
||||||
|
@ -191,6 +202,7 @@ class SettingsPageAssets {
|
||||||
'client_id' => $this->client_id,
|
'client_id' => $this->client_id,
|
||||||
'currency' => $this->currency,
|
'currency' => $this->currency,
|
||||||
'country' => $this->country,
|
'country' => $this->country,
|
||||||
|
'environment' => $this->environment->current_environment(),
|
||||||
'integration_date' => PAYPAL_INTEGRATION_DATE,
|
'integration_date' => PAYPAL_INTEGRATION_DATE,
|
||||||
'is_pay_later_button_enabled' => $this->is_pay_later_button_enabled,
|
'is_pay_later_button_enabled' => $this->is_pay_later_button_enabled,
|
||||||
'disabled_sources' => $this->disabled_sources,
|
'disabled_sources' => $this->disabled_sources,
|
||||||
|
|
|
@ -174,6 +174,7 @@ class WCGatewayModule implements ModuleInterface {
|
||||||
$c->get( 'button.client_id_for_admin' ),
|
$c->get( 'button.client_id_for_admin' ),
|
||||||
$c->get( 'api.shop.currency' ),
|
$c->get( 'api.shop.currency' ),
|
||||||
$c->get( 'api.shop.country' ),
|
$c->get( 'api.shop.country' ),
|
||||||
|
$c->get( 'onboarding.environment' ),
|
||||||
$settings_status->is_pay_later_button_enabled(),
|
$settings_status->is_pay_later_button_enabled(),
|
||||||
$settings->has( 'disable_funding' ) ? $settings->get( 'disable_funding' ) : array(),
|
$settings->has( 'disable_funding' ) ? $settings->get( 'disable_funding' ) : array(),
|
||||||
$c->get( 'wcgateway.all-funding-sources' )
|
$c->get( 'wcgateway.all-funding-sources' )
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
|
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
|
||||||
|
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
||||||
|
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||||
use WooCommerce\PayPalCommerce\TestCase;
|
use WooCommerce\PayPalCommerce\TestCase;
|
||||||
use function Brain\Monkey\Functions\when;
|
use function Brain\Monkey\Functions\when;
|
||||||
|
@ -23,6 +24,7 @@ class SettingsPagesAssetsTest extends TestCase
|
||||||
'123',
|
'123',
|
||||||
'EUR',
|
'EUR',
|
||||||
'DE',
|
'DE',
|
||||||
|
Mockery::mock(Environment::class),
|
||||||
true,
|
true,
|
||||||
array(),
|
array(),
|
||||||
array()
|
array()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue