Retrieve shop currency later to avoid early caching in service

This commit is contained in:
Alex P. 2024-10-03 10:10:50 +03:00
parent b3d457d64a
commit f85df4718a
No known key found for this signature in database
GPG key ID: 54487A734A204D71
24 changed files with 187 additions and 136 deletions

View file

@ -17,6 +17,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentMethodTokensEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentTokensEndpoint; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentTokensEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\CardAuthenticationResult; use WooCommerce\PayPalCommerce\ApiClient\Entity\CardAuthenticationResult;
use WooCommerce\PayPalCommerce\ApiClient\Factory\CardAuthenticationResultFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\CardAuthenticationResultFactory;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
use WooCommerce\PayPalCommerce\ApiClient\Helper\FailureRegistry; use WooCommerce\PayPalCommerce\ApiClient\Helper\FailureRegistry;
use WooCommerce\PayPalCommerce\Common\Pattern\SingletonDecorator; use WooCommerce\PayPalCommerce\Common\Pattern\SingletonDecorator;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\BillingSubscriptions; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\BillingSubscriptions;
@ -370,7 +371,7 @@ return array(
}, },
'api.factory.item' => static function ( ContainerInterface $container ): ItemFactory { 'api.factory.item' => static function ( ContainerInterface $container ): ItemFactory {
return new ItemFactory( return new ItemFactory(
$container->get( 'api.shop.currency' ) $container->get( 'api.shop.currency.getter' )
); );
}, },
'api.factory.shipping' => static function ( ContainerInterface $container ): ShippingFactory { 'api.factory.shipping' => static function ( ContainerInterface $container ): ShippingFactory {
@ -392,7 +393,7 @@ return array(
return new AmountFactory( return new AmountFactory(
$item_factory, $item_factory,
$container->get( 'api.factory.money' ), $container->get( 'api.factory.money' ),
$container->get( 'api.shop.currency' ) $container->get( 'api.shop.currency.getter' )
); );
}, },
'api.factory.money' => static function ( ContainerInterface $container ): MoneyFactory { 'api.factory.money' => static function ( ContainerInterface $container ): MoneyFactory {
@ -458,10 +459,10 @@ return array(
return new ProductFactory(); return new ProductFactory();
}, },
'api.factory.billing-cycle' => static function( ContainerInterface $container ): BillingCycleFactory { 'api.factory.billing-cycle' => static function( ContainerInterface $container ): BillingCycleFactory {
return new BillingCycleFactory( $container->get( 'api.shop.currency' ) ); return new BillingCycleFactory( $container->get( 'api.shop.currency.getter' ) );
}, },
'api.factory.payment-preferences' => static function( ContainerInterface $container ):PaymentPreferencesFactory { 'api.factory.payment-preferences' => static function( ContainerInterface $container ):PaymentPreferencesFactory {
return new PaymentPreferencesFactory( $container->get( 'api.shop.currency' ) ); return new PaymentPreferencesFactory( $container->get( 'api.shop.currency.getter' ) );
}, },
'api.factory.plan' => static function( ContainerInterface $container ): PlanFactory { 'api.factory.plan' => static function( ContainerInterface $container ): PlanFactory {
return new PlanFactory( return new PlanFactory(
@ -476,23 +477,13 @@ return array(
return new DccApplies( return new DccApplies(
$container->get( 'api.dcc-supported-country-currency-matrix' ), $container->get( 'api.dcc-supported-country-currency-matrix' ),
$container->get( 'api.dcc-supported-country-card-matrix' ), $container->get( 'api.dcc-supported-country-card-matrix' ),
$container->get( 'api.shop.currency' ), $container->get( 'api.shop.currency.getter' ),
$container->get( 'api.shop.country' ) $container->get( 'api.shop.country' )
); );
}, },
'api.shop.currency' => static function ( ContainerInterface $container ) : string { 'api.shop.currency.getter' => static function ( ContainerInterface $container ) : CurrencyGetter {
$currency = get_woocommerce_currency(); return new CurrencyGetter();
if ( $currency ) {
return $currency;
}
$currency = get_option( 'woocommerce_currency' );
if ( ! $currency ) {
return 'NO_CURRENCY'; // Unlikely to happen.
}
return $currency;
}, },
'api.shop.country' => static function ( ContainerInterface $container ) : string { 'api.shop.country' => static function ( ContainerInterface $container ) : string {
$location = wc_get_base_location(); $location = wc_get_base_location();
@ -507,7 +498,7 @@ return array(
}, },
'api.shop.is-currency-supported' => static function ( ContainerInterface $container ) : bool { 'api.shop.is-currency-supported' => static function ( ContainerInterface $container ) : bool {
return in_array( return in_array(
$container->get( 'api.shop.currency' ), $container->get( 'api.shop.currency.getter' )->get(),
$container->get( 'api.supported-currencies' ), $container->get( 'api.supported-currencies' ),
true true
); );

View file

@ -14,6 +14,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\AmountBreakdown;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Item; use WooCommerce\PayPalCommerce\ApiClient\Entity\Item;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Money; use WooCommerce\PayPalCommerce\ApiClient\Entity\Money;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
use WooCommerce\PayPalCommerce\WcSubscriptions\FreeTrialHandlerTrait; use WooCommerce\PayPalCommerce\WcSubscriptions\FreeTrialHandlerTrait;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
@ -41,20 +42,24 @@ class AmountFactory {
private $money_factory; private $money_factory;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* AmountFactory constructor. * AmountFactory constructor.
* *
* @param ItemFactory $item_factory The Item factory. * @param ItemFactory $item_factory The Item factory.
* @param MoneyFactory $money_factory The Money factory. * @param MoneyFactory $money_factory The Money factory.
* @param string $currency 3-letter currency code of the shop. * @param CurrencyGetter $currency The getter of the 3-letter currency code of the shop.
*/ */
public function __construct( ItemFactory $item_factory, MoneyFactory $money_factory, string $currency ) { public function __construct(
ItemFactory $item_factory,
MoneyFactory $money_factory,
CurrencyGetter $currency
) {
$this->item_factory = $item_factory; $this->item_factory = $item_factory;
$this->money_factory = $money_factory; $this->money_factory = $money_factory;
$this->currency = $currency; $this->currency = $currency;
@ -68,25 +73,25 @@ class AmountFactory {
* @return Amount * @return Amount
*/ */
public function from_wc_cart( \WC_Cart $cart ): Amount { public function from_wc_cart( \WC_Cart $cart ): Amount {
$total = new Money( (float) $cart->get_total( 'numeric' ), $this->currency ); $total = new Money( (float) $cart->get_total( 'numeric' ), $this->currency->get() );
$item_total = (float) $cart->get_subtotal() + (float) $cart->get_fee_total(); $item_total = (float) $cart->get_subtotal() + (float) $cart->get_fee_total();
$item_total = new Money( $item_total, $this->currency ); $item_total = new Money( $item_total, $this->currency->get() );
$shipping = new Money( $shipping = new Money(
(float) $cart->get_shipping_total(), (float) $cart->get_shipping_total(),
$this->currency $this->currency->get()
); );
$taxes = new Money( $taxes = new Money(
(float) $cart->get_total_tax(), (float) $cart->get_total_tax(),
$this->currency $this->currency->get()
); );
$discount = null; $discount = null;
if ( $cart->get_discount_total() ) { if ( $cart->get_discount_total() ) {
$discount = new Money( $discount = new Money(
(float) $cart->get_discount_total(), (float) $cart->get_discount_total(),
$this->currency $this->currency->get()
); );
} }

View file

@ -12,6 +12,7 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
use stdClass; use stdClass;
use WC_Product; use WC_Product;
use WooCommerce\PayPalCommerce\ApiClient\Entity\BillingCycle; use WooCommerce\PayPalCommerce\ApiClient\Entity\BillingCycle;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
/** /**
* Class BillingCycleFactory * Class BillingCycleFactory
@ -21,16 +22,16 @@ class BillingCycleFactory {
/** /**
* The currency. * The currency.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* BillingCycleFactory constructor. * BillingCycleFactory constructor.
* *
* @param string $currency The currency. * @param CurrencyGetter $currency The currency.
*/ */
public function __construct( string $currency ) { public function __construct( CurrencyGetter $currency ) {
$this->currency = $currency; $this->currency = $currency;
} }
@ -51,7 +52,7 @@ class BillingCycleFactory {
array( array(
'fixed_price' => array( 'fixed_price' => array(
'value' => $product->get_meta( '_subscription_price' ), 'value' => $product->get_meta( '_subscription_price' ),
'currency_code' => $this->currency, 'currency_code' => $this->currency->get(),
), ),
), ),
(int) $product->get_meta( '_subscription_length' ) (int) $product->get_meta( '_subscription_length' )

View file

@ -13,6 +13,7 @@ use WC_Product;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Item; use WooCommerce\PayPalCommerce\ApiClient\Entity\Item;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Money; use WooCommerce\PayPalCommerce\ApiClient\Entity\Money;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
use WooCommerce\PayPalCommerce\ApiClient\Helper\ItemTrait; use WooCommerce\PayPalCommerce\ApiClient\Helper\ItemTrait;
/** /**
@ -23,18 +24,18 @@ class ItemFactory {
use ItemTrait; use ItemTrait;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* ItemFactory constructor. * ItemFactory constructor.
* *
* @param string $currency 3-letter currency code of the shop. * @param CurrencyGetter $currency The getter of the 3-letter currency code of the shop.
*/ */
public function __construct( string $currency ) { public function __construct( CurrencyGetter $currency ) {
$this->currency = $currency; $this->currency = $currency;
} }
@ -62,7 +63,7 @@ class ItemFactory {
$price = (float) $item['line_subtotal'] / (float) $item['quantity']; $price = (float) $item['line_subtotal'] / (float) $item['quantity'];
return new Item( return new Item(
$this->prepare_item_string( $product->get_name() ), $this->prepare_item_string( $product->get_name() ),
new Money( $price, $this->currency ), new Money( $price, $this->currency->get() ),
$quantity, $quantity,
$this->prepare_item_string( $product->get_description() ), $this->prepare_item_string( $product->get_description() ),
null, null,
@ -84,7 +85,7 @@ class ItemFactory {
function ( \stdClass $fee ): Item { function ( \stdClass $fee ): Item {
return new Item( return new Item(
$fee->name, $fee->name,
new Money( (float) $fee->amount, $this->currency ), new Money( (float) $fee->amount, $this->currency->get() ),
1, 1,
'', '',
null null

View file

@ -12,6 +12,7 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
use stdClass; use stdClass;
use WC_Product; use WC_Product;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentPreferences; use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentPreferences;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
/** /**
* Class PaymentPreferencesFactory * Class PaymentPreferencesFactory
@ -21,16 +22,16 @@ class PaymentPreferencesFactory {
/** /**
* The currency. * The currency.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private $currency;
/** /**
* PaymentPreferencesFactory constructor. * PaymentPreferencesFactory constructor.
* *
* @param string $currency The currency. * @param CurrencyGetter $currency The currency.
*/ */
public function __construct( string $currency ) { public function __construct( CurrencyGetter $currency ) {
$this->currency = $currency; $this->currency = $currency;
} }
@ -44,7 +45,7 @@ class PaymentPreferencesFactory {
return new PaymentPreferences( return new PaymentPreferences(
array( array(
'value' => $product->get_meta( '_subscription_sign_up_fee' ) ?: '0', 'value' => $product->get_meta( '_subscription_sign_up_fee' ) ?: '0',
'currency_code' => $this->currency, 'currency_code' => $this->currency->get(),
) )
); );
} }

View file

@ -0,0 +1,40 @@
<?php
/**
* The wrapper for retrieving shop currency as late as possible,
* to avoid early caching in services, e.g. before multi-currency filters were added.
*
* @package WooCommerce\PayPalCommerce\ApiClient\Helper
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\ApiClient\Helper;
/**
* Class CurrencyGetter
*/
class CurrencyGetter {
/**
* Returns the WC currency.
*/
public function get(): string {
$currency = get_woocommerce_currency();
if ( $currency ) {
return $currency;
}
$currency = get_option( 'woocommerce_currency' );
if ( ! $currency ) {
return 'NO_CURRENCY'; // Unlikely to happen.
}
return $currency;
}
/**
* Returns the WC currency.
*/
public function __toString() {
return $this->get();
}
}

View file

@ -30,11 +30,11 @@ class DccApplies {
private $country_card_matrix; private $country_card_matrix;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* 2-letter country code of the shop. * 2-letter country code of the shop.
@ -46,16 +46,16 @@ class DccApplies {
/** /**
* DccApplies constructor. * DccApplies constructor.
* *
* @param array $allowed_country_currency_matrix The matrix which countries and currency combinations can be used for DCC. * @param array $allowed_country_currency_matrix The matrix which countries and currency combinations can be used for DCC.
* @param array $country_card_matrix Which countries support which credit cards. Empty credit card arrays mean no restriction on * @param array $country_card_matrix Which countries support which credit cards. Empty credit card arrays mean no restriction on
* currency. * currency.
* @param string $currency 3-letter currency code of the shop. * @param CurrencyGetter $currency The getter of the 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.
*/ */
public function __construct( public function __construct(
array $allowed_country_currency_matrix, array $allowed_country_currency_matrix,
array $country_card_matrix, array $country_card_matrix,
string $currency, CurrencyGetter $currency,
string $country string $country
) { ) {
$this->allowed_country_currency_matrix = $allowed_country_currency_matrix; $this->allowed_country_currency_matrix = $allowed_country_currency_matrix;
@ -73,7 +73,7 @@ class DccApplies {
if ( ! in_array( $this->country, array_keys( $this->allowed_country_currency_matrix ), true ) ) { if ( ! in_array( $this->country, array_keys( $this->allowed_country_currency_matrix ), true ) ) {
return false; return false;
} }
$applies = in_array( $this->currency, $this->allowed_country_currency_matrix[ $this->country ], true ); $applies = in_array( $this->currency->get(), $this->allowed_country_currency_matrix[ $this->country ], true );
return $applies; return $applies;
} }
@ -135,6 +135,6 @@ class DccApplies {
* restrictions, which currencies are supported by a card. * restrictions, which currencies are supported by a card.
*/ */
$supported_currencies = $this->country_card_matrix[ $this->country ][ $card ]; $supported_currencies = $this->country_card_matrix[ $this->country ][ $card ];
return empty( $supported_currencies ) || in_array( $this->currency, $supported_currencies, true ); return empty( $supported_currencies ) || in_array( $this->currency->get(), $supported_currencies, true );
} }
} }

View file

@ -34,7 +34,7 @@ return array(
return new ApmApplies( return new ApmApplies(
$container->get( 'applepay.supported-countries' ), $container->get( 'applepay.supported-countries' ),
$container->get( 'applepay.supported-currencies' ), $container->get( 'applepay.supported-currencies' ),
$container->get( 'api.shop.currency' ), $container->get( 'api.shop.currency.getter' ),
$container->get( 'api.shop.country' ) $container->get( 'api.shop.country' )
); );
}, },

View file

@ -10,6 +10,8 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Applepay\Helper; namespace WooCommerce\PayPalCommerce\Applepay\Helper;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
/** /**
* Class ApmApplies * Class ApmApplies
*/ */
@ -30,11 +32,11 @@ class ApmApplies {
private $allowed_currencies; private $allowed_currencies;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* 2-letter country code of the shop. * 2-letter country code of the shop.
@ -46,15 +48,15 @@ class ApmApplies {
/** /**
* DccApplies constructor. * DccApplies constructor.
* *
* @param array $allowed_countries The list of which countries can be used for ApplePay. * @param array $allowed_countries The list of which countries can be used for ApplePay.
* @param array $allowed_currencies The list of which currencies can be used for ApplePay. * @param array $allowed_currencies The list of which currencies can be used for ApplePay.
* @param string $currency 3-letter currency code of the shop. * @param CurrencyGetter $currency The getter of the 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.
*/ */
public function __construct( public function __construct(
array $allowed_countries, array $allowed_countries,
array $allowed_currencies, array $allowed_currencies,
string $currency, CurrencyGetter $currency,
string $country string $country
) { ) {
$this->allowed_countries = $allowed_countries; $this->allowed_countries = $allowed_countries;
@ -78,7 +80,7 @@ class ApmApplies {
* @return bool * @return bool
*/ */
public function for_currency(): bool { public function for_currency(): bool {
return in_array( $this->currency, $this->allowed_currencies, true ); return in_array( $this->currency->get(), $this->allowed_currencies, true );
} }
} }

View file

@ -32,7 +32,7 @@ return array(
'axo.helpers.apm-applies' => static function ( ContainerInterface $container ) : ApmApplies { 'axo.helpers.apm-applies' => static function ( ContainerInterface $container ) : ApmApplies {
return new ApmApplies( return new ApmApplies(
$container->get( 'axo.supported-country-currency-matrix' ), $container->get( 'axo.supported-country-currency-matrix' ),
$container->get( 'api.shop.currency' ), $container->get( 'api.shop.currency.getter' ),
$container->get( 'api.shop.country' ) $container->get( 'api.shop.country' )
); );
}, },
@ -65,7 +65,7 @@ return array(
$container->get( 'wcgateway.settings' ), $container->get( 'wcgateway.settings' ),
$container->get( 'onboarding.environment' ), $container->get( 'onboarding.environment' ),
$container->get( 'wcgateway.settings.status' ), $container->get( 'wcgateway.settings.status' ),
$container->get( 'api.shop.currency' ), $container->get( 'api.shop.currency.getter' ),
$container->get( 'woocommerce.logger.woocommerce' ), $container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'wcgateway.url' ) $container->get( 'wcgateway.url' )
); );

View file

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Axo\Assets; namespace WooCommerce\PayPalCommerce\Axo\Assets;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
use WooCommerce\PayPalCommerce\Axo\FrontendLoggerEndpoint; use WooCommerce\PayPalCommerce\Axo\FrontendLoggerEndpoint;
use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Session\SessionHandler; use WooCommerce\PayPalCommerce\Session\SessionHandler;
@ -59,11 +60,11 @@ class AxoManager {
private $settings_status; private $settings_status;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* The logger. * The logger.
@ -95,7 +96,7 @@ class AxoManager {
* @param Settings $settings The Settings. * @param Settings $settings The Settings.
* @param Environment $environment The environment object. * @param Environment $environment The environment object.
* @param SettingsStatus $settings_status The Settings status helper. * @param SettingsStatus $settings_status The Settings status helper.
* @param string $currency 3-letter currency code of the shop. * @param CurrencyGetter $currency The getter of the 3-letter currency code of the shop.
* @param LoggerInterface $logger The logger. * @param LoggerInterface $logger The logger.
* @param string $wcgateway_module_url The WcGateway module URL. * @param string $wcgateway_module_url The WcGateway module URL.
*/ */
@ -106,7 +107,7 @@ class AxoManager {
Settings $settings, Settings $settings,
Environment $environment, Environment $environment,
SettingsStatus $settings_status, SettingsStatus $settings_status,
string $currency, CurrencyGetter $currency,
LoggerInterface $logger, LoggerInterface $logger,
string $wcgateway_module_url string $wcgateway_module_url
) { ) {
@ -178,7 +179,7 @@ class AxoManager {
16 16
), ),
'amount' => array( 'amount' => array(
'currency_code' => get_woocommerce_currency(), 'currency_code' => $this->currency->get(),
'value' => WC()->cart->get_total( 'numeric' ), 'value' => WC()->cart->get_total( 'numeric' ),
), ),
), ),

View file

@ -10,6 +10,8 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Axo\Helper; namespace WooCommerce\PayPalCommerce\Axo\Helper;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
/** /**
* Class ApmApplies * Class ApmApplies
*/ */
@ -23,11 +25,11 @@ class ApmApplies {
private $allowed_country_currency_matrix; private $allowed_country_currency_matrix;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* 2-letter country code of the shop. * 2-letter country code of the shop.
@ -39,13 +41,13 @@ class ApmApplies {
/** /**
* DccApplies constructor. * DccApplies constructor.
* *
* @param array $allowed_country_currency_matrix The matrix which countries and currency combinations can be used for AXO. * @param array $allowed_country_currency_matrix The matrix which countries and currency combinations can be used for AXO.
* @param string $currency 3-letter currency code of the shop. * @param CurrencyGetter $currency The getter of the 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.
*/ */
public function __construct( public function __construct(
array $allowed_country_currency_matrix, array $allowed_country_currency_matrix,
string $currency, CurrencyGetter $currency,
string $country string $country
) { ) {
$this->allowed_country_currency_matrix = $allowed_country_currency_matrix; $this->allowed_country_currency_matrix = $allowed_country_currency_matrix;
@ -62,6 +64,6 @@ class ApmApplies {
if ( ! in_array( $this->country, array_keys( $this->allowed_country_currency_matrix ), true ) ) { if ( ! in_array( $this->country, array_keys( $this->allowed_country_currency_matrix ), true ) ) {
return false; return false;
} }
return in_array( $this->currency, $this->allowed_country_currency_matrix[ $this->country ], true ); return in_array( $this->currency->get(), $this->allowed_country_currency_matrix[ $this->country ], true );
} }
} }

View file

@ -126,7 +126,6 @@ return array(
$environment = $container->get( 'onboarding.environment' ); $environment = $container->get( 'onboarding.environment' );
$payment_token_repository = $container->get( 'vaulting.repository.payment-token' ); $payment_token_repository = $container->get( 'vaulting.repository.payment-token' );
$settings_status = $container->get( 'wcgateway.settings.status' ); $settings_status = $container->get( 'wcgateway.settings.status' );
$currency = $container->get( 'api.shop.currency' );
return new SmartButton( return new SmartButton(
$container->get( 'button.url' ), $container->get( 'button.url' ),
$container->get( 'ppcp.asset-version' ), $container->get( 'ppcp.asset-version' ),
@ -141,7 +140,7 @@ return array(
$environment, $environment,
$payment_token_repository, $payment_token_repository,
$settings_status, $settings_status,
$currency, $container->get( 'api.shop.currency.getter' ),
$container->get( 'wcgateway.all-funding-sources' ), $container->get( 'wcgateway.all-funding-sources' ),
$container->get( 'button.basic-checkout-validation-enabled' ), $container->get( 'button.basic-checkout-validation-enabled' ),
$container->get( 'button.early-wc-checkout-validation-enabled' ), $container->get( 'button.early-wc-checkout-validation-enabled' ),

View file

@ -19,6 +19,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentTokensEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Money; use WooCommerce\PayPalCommerce\ApiClient\Entity\Money;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken; use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
use WooCommerce\PayPalCommerce\ApiClient\Factory\PayerFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\PayerFactory;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies; use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
use WooCommerce\PayPalCommerce\Blocks\Endpoint\UpdateShippingEndpoint; use WooCommerce\PayPalCommerce\Blocks\Endpoint\UpdateShippingEndpoint;
use WooCommerce\PayPalCommerce\Button\Endpoint\ApproveOrderEndpoint; use WooCommerce\PayPalCommerce\Button\Endpoint\ApproveOrderEndpoint;
@ -146,11 +147,11 @@ class SmartButton implements SmartButtonInterface {
private $payment_token_repository; private $payment_token_repository;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* All existing funding sources. * All existing funding sources.
@ -252,7 +253,7 @@ class SmartButton implements SmartButtonInterface {
* @param Environment $environment The environment object. * @param Environment $environment The environment object.
* @param PaymentTokenRepository $payment_token_repository The payment token repository. * @param PaymentTokenRepository $payment_token_repository The payment token repository.
* @param SettingsStatus $settings_status The Settings status helper. * @param SettingsStatus $settings_status The Settings status helper.
* @param string $currency 3-letter currency code of the shop. * @param CurrencyGetter $currency The getter of the 3-letter currency code of the shop.
* @param array $all_funding_sources All existing funding sources. * @param array $all_funding_sources All existing funding sources.
* @param bool $basic_checkout_validation_enabled Whether the basic JS validation of the form iss enabled. * @param bool $basic_checkout_validation_enabled Whether the basic JS validation of the form iss enabled.
* @param bool $early_validation_enabled Whether to execute WC validation of the checkout form. * @param bool $early_validation_enabled Whether to execute WC validation of the checkout form.
@ -278,7 +279,7 @@ class SmartButton implements SmartButtonInterface {
Environment $environment, Environment $environment,
PaymentTokenRepository $payment_token_repository, PaymentTokenRepository $payment_token_repository,
SettingsStatus $settings_status, SettingsStatus $settings_status,
string $currency, CurrencyGetter $currency,
array $all_funding_sources, array $all_funding_sources,
bool $basic_checkout_validation_enabled, bool $basic_checkout_validation_enabled,
bool $early_validation_enabled, bool $early_validation_enabled,
@ -1119,7 +1120,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
'url_params' => $url_params, 'url_params' => $url_params,
'script_attributes' => $this->attributes(), 'script_attributes' => $this->attributes(),
'client_id' => $this->client_id, 'client_id' => $this->client_id,
'currency' => $this->currency, 'currency' => $this->currency->get(),
'data_client_id' => array( 'data_client_id' => array(
'set_attribute' => ( is_checkout() && $this->dcc_is_enabled() ) || $this->can_save_vault_token(), 'set_attribute' => ( is_checkout() && $this->dcc_is_enabled() ) || $this->can_save_vault_token(),
'endpoint' => \WC_AJAX::get_endpoint( DataClientIdEndpoint::ENDPOINT ), 'endpoint' => \WC_AJAX::get_endpoint( DataClientIdEndpoint::ENDPOINT ),
@ -1393,7 +1394,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
$subscription_mode = $this->settings->has( 'subscriptions_mode' ) ? $this->settings->get( 'subscriptions_mode' ) : ''; $subscription_mode = $this->settings->has( 'subscriptions_mode' ) ? $this->settings->get( 'subscriptions_mode' ) : '';
$params = array( $params = array(
'client-id' => $this->client_id, 'client-id' => $this->client_id,
'currency' => $this->currency, 'currency' => $this->currency->get(),
'integration-date' => PAYPAL_INTEGRATION_DATE, 'integration-date' => PAYPAL_INTEGRATION_DATE,
'components' => implode( ',', $this->components() ), 'components' => implode( ',', $this->components() ),
'vault' => ( $this->can_save_vault_token() || $this->subscription_helper->need_subscription_intent( $subscription_mode ) ) ? 'true' : 'false', 'vault' => ( $this->can_save_vault_token() || $this->subscription_helper->need_subscription_intent( $subscription_mode ) ) ? 'true' : 'false',

View file

@ -36,7 +36,7 @@ return array(
return new ApmApplies( return new ApmApplies(
$container->get( 'googlepay.supported-countries' ), $container->get( 'googlepay.supported-countries' ),
$container->get( 'googlepay.supported-currencies' ), $container->get( 'googlepay.supported-currencies' ),
$container->get( 'api.shop.currency' ), $container->get( 'api.shop.currency.getter' ),
$container->get( 'api.shop.country' ) $container->get( 'api.shop.country' )
); );
}, },

View file

@ -10,6 +10,8 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Googlepay\Helper; namespace WooCommerce\PayPalCommerce\Googlepay\Helper;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
/** /**
* Class ApmApplies * Class ApmApplies
*/ */
@ -30,11 +32,11 @@ class ApmApplies {
private $allowed_currencies; private $allowed_currencies;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* 2-letter country code of the shop. * 2-letter country code of the shop.
@ -46,15 +48,15 @@ class ApmApplies {
/** /**
* DccApplies constructor. * DccApplies constructor.
* *
* @param array $allowed_countries The list of which countries can be used for GooglePay. * @param array $allowed_countries The list of which countries can be used for GooglePay.
* @param array $allowed_currencies The list of which currencies can be used for GooglePay. * @param array $allowed_currencies The list of which currencies can be used for GooglePay.
* @param string $currency 3-letter currency code of the shop. * @param CurrencyGetter $currency The getter of the 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.
*/ */
public function __construct( public function __construct(
array $allowed_countries, array $allowed_countries,
array $allowed_currencies, array $allowed_currencies,
string $currency, CurrencyGetter $currency,
string $country string $country
) { ) {
$this->allowed_countries = $allowed_countries; $this->allowed_countries = $allowed_countries;
@ -78,7 +80,7 @@ class ApmApplies {
* @return bool * @return bool
*/ */
public function for_currency(): bool { public function for_currency(): bool {
return in_array( $this->currency, $this->allowed_currencies, true ); return in_array( $this->currency->get(), $this->allowed_currencies, true );
} }
} }

View file

@ -25,7 +25,7 @@ return array(
$container->get( 'api.endpoint.billing-plans' ), $container->get( 'api.endpoint.billing-plans' ),
$container->get( 'api.factory.billing-cycle' ), $container->get( 'api.factory.billing-cycle' ),
$container->get( 'api.factory.payment-preferences' ), $container->get( 'api.factory.payment-preferences' ),
$container->get( 'api.shop.currency' ), $container->get( 'api.shop.currency.getter' ),
$container->get( 'woocommerce.logger.woocommerce' ) $container->get( 'woocommerce.logger.woocommerce' )
); );
}, },

View file

@ -19,6 +19,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Factory\BillingCycleFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\BillingCycleFactory;
use WooCommerce\PayPalCommerce\ApiClient\Factory\PaymentPreferencesFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\PaymentPreferencesFactory;
use WooCommerce\PayPalCommerce\ApiClient\Factory\ProductFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\ProductFactory;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
use WooCommerce\PayPalCommerce\ApiClient\Helper\ItemTrait; use WooCommerce\PayPalCommerce\ApiClient\Helper\ItemTrait;
/** /**
@ -66,9 +67,9 @@ class SubscriptionsApiHandler {
/** /**
* The currency. * The currency.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* The logger. * The logger.
@ -85,7 +86,7 @@ class SubscriptionsApiHandler {
* @param BillingPlans $billing_plans_endpoint Billing plans endpoint. * @param BillingPlans $billing_plans_endpoint Billing plans endpoint.
* @param BillingCycleFactory $billing_cycle_factory Billing cycle factory. * @param BillingCycleFactory $billing_cycle_factory Billing cycle factory.
* @param PaymentPreferencesFactory $payment_preferences_factory Payment preferences factory. * @param PaymentPreferencesFactory $payment_preferences_factory Payment preferences factory.
* @param string $currency The currency. * @param CurrencyGetter $currency The currency.
* @param LoggerInterface $logger The logger. * @param LoggerInterface $logger The logger.
*/ */
public function __construct( public function __construct(
@ -94,7 +95,7 @@ class SubscriptionsApiHandler {
BillingPlans $billing_plans_endpoint, BillingPlans $billing_plans_endpoint,
BillingCycleFactory $billing_cycle_factory, BillingCycleFactory $billing_cycle_factory,
PaymentPreferencesFactory $payment_preferences_factory, PaymentPreferencesFactory $payment_preferences_factory,
string $currency, CurrencyGetter $currency,
LoggerInterface $logger LoggerInterface $logger
) { ) {
$this->products_endpoint = $products_endpoint; $this->products_endpoint = $products_endpoint;
@ -253,7 +254,7 @@ class SubscriptionsApiHandler {
array( array(
'fixed_price' => array( 'fixed_price' => array(
'value' => '0', 'value' => '0',
'currency_code' => $this->currency, 'currency_code' => $this->currency->get(),
), ),
), ),
1 1
@ -272,7 +273,7 @@ class SubscriptionsApiHandler {
array( array(
'fixed_price' => array( 'fixed_price' => array(
'value' => $product->get_meta( '_subscription_price' ) ?: $product->get_price(), 'value' => $product->get_meta( '_subscription_price' ) ?: $product->get_price(),
'currency_code' => $this->currency, 'currency_code' => $this->currency->get(),
), ),
), ),
(int) $product->get_meta( '_subscription_length' ) (int) $product->get_meta( '_subscription_length' )

View file

@ -25,7 +25,7 @@ return array(
'save-payment-methods.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ) : SavePaymentMethodsApplies { 'save-payment-methods.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ) : SavePaymentMethodsApplies {
return new SavePaymentMethodsApplies( return new SavePaymentMethodsApplies(
$container->get( 'save-payment-methods.supported-country-currency-matrix' ), $container->get( 'save-payment-methods.supported-country-currency-matrix' ),
$container->get( 'api.shop.currency' ), $container->get( 'api.shop.currency.getter' ),
$container->get( 'api.shop.country' ) $container->get( 'api.shop.country' )
); );
}, },

View file

@ -9,6 +9,8 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\SavePaymentMethods\Helper; namespace WooCommerce\PayPalCommerce\SavePaymentMethods\Helper;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
/** /**
* Class SavePaymentMethodsApplies * Class SavePaymentMethodsApplies
*/ */
@ -22,11 +24,11 @@ class SavePaymentMethodsApplies {
private $allowed_country_currency_matrix; private $allowed_country_currency_matrix;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* 2-letter country code of the shop. * 2-letter country code of the shop.
@ -38,13 +40,13 @@ class SavePaymentMethodsApplies {
/** /**
* SavePaymentMethodsApplies constructor. * SavePaymentMethodsApplies constructor.
* *
* @param array $allowed_country_currency_matrix The matrix which countries and currency combinations can be used for Save Payment Methods. * @param array $allowed_country_currency_matrix The matrix which countries and currency combinations can be used for Save Payment Methods.
* @param string $currency 3-letter currency code of the shop. * @param CurrencyGetter $currency The getter of the 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.
*/ */
public function __construct( public function __construct(
array $allowed_country_currency_matrix, array $allowed_country_currency_matrix,
string $currency, CurrencyGetter $currency,
string $country string $country
) { ) {
$this->allowed_country_currency_matrix = $allowed_country_currency_matrix; $this->allowed_country_currency_matrix = $allowed_country_currency_matrix;
@ -61,6 +63,6 @@ class SavePaymentMethodsApplies {
if ( ! in_array( $this->country, array_keys( $this->allowed_country_currency_matrix ), true ) ) { if ( ! in_array( $this->country, array_keys( $this->allowed_country_currency_matrix ), true ) ) {
return false; return false;
} }
return in_array( $this->currency, $this->allowed_country_currency_matrix[ $this->country ], true ); return in_array( $this->currency->get(), $this->allowed_country_currency_matrix[ $this->country ], true );
} }
} }

View file

@ -343,7 +343,7 @@ return array(
}, },
'wcgateway.notice.currency-unsupported' => static function ( ContainerInterface $container ): UnsupportedCurrencyAdminNotice { 'wcgateway.notice.currency-unsupported' => static function ( ContainerInterface $container ): UnsupportedCurrencyAdminNotice {
$state = $container->get( 'onboarding.state' ); $state = $container->get( 'onboarding.state' );
$shop_currency = $container->get( 'api.shop.currency' ); $shop_currency = $container->get( 'api.shop.currency.getter' );
$supported_currencies = $container->get( 'api.supported-currencies' ); $supported_currencies = $container->get( 'api.supported-currencies' );
$is_wc_gateways_list_page = $container->get( 'wcgateway.is-wc-gateways-list-page' ); $is_wc_gateways_list_page = $container->get( 'wcgateway.is-wc-gateways-list-page' );
$is_ppcp_settings_page = $container->get( 'wcgateway.is-ppcp-settings-page' ); $is_ppcp_settings_page = $container->get( 'wcgateway.is-ppcp-settings-page' );

View file

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Assets; namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\BillingAgreementsEndpoint; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\BillingAgreementsEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\RefreshFeatureStatusEndpoint; use WooCommerce\PayPalCommerce\WcGateway\Endpoint\RefreshFeatureStatusEndpoint;
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper; use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
@ -48,11 +49,11 @@ class SettingsPageAssets {
private $client_id; private $client_id;
/** /**
* 3-letter currency code of the shop. * The getter of the 3-letter currency code of the shop.
* *
* @var string * @var CurrencyGetter
*/ */
private $currency; private CurrencyGetter $currency;
/** /**
* 2-letter country code of the shop. * 2-letter country code of the shop.
@ -124,7 +125,7 @@ class SettingsPageAssets {
* @param string $version The assets version. * @param string $version The assets version.
* @param SubscriptionHelper $subscription_helper The subscription helper. * @param SubscriptionHelper $subscription_helper The subscription helper.
* @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 CurrencyGetter $currency The getter of the 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 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.
@ -140,7 +141,7 @@ class SettingsPageAssets {
string $version, string $version,
SubscriptionHelper $subscription_helper, SubscriptionHelper $subscription_helper,
string $client_id, string $client_id,
string $currency, CurrencyGetter $currency,
string $country, string $country,
Environment $environment, Environment $environment,
bool $is_pay_later_button_enabled, bool $is_pay_later_button_enabled,
@ -224,7 +225,7 @@ class SettingsPageAssets {
array( array(
'is_subscriptions_plugin_active' => $this->subscription_helper->plugin_is_active(), 'is_subscriptions_plugin_active' => $this->subscription_helper->plugin_is_active(),
'client_id' => $this->client_id, 'client_id' => $this->client_id,
'currency' => $this->currency, 'currency' => $this->currency->get(),
'country' => $this->country, 'country' => $this->country,
'environment' => $this->environment->current_environment(), 'environment' => $this->environment->current_environment(),
'integration_date' => PAYPAL_INTEGRATION_DATE, 'integration_date' => PAYPAL_INTEGRATION_DATE,

View file

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Notice; namespace WooCommerce\PayPalCommerce\WcGateway\Notice;
use WooCommerce\PayPalCommerce\AdminNotices\Entity\Message; use WooCommerce\PayPalCommerce\AdminNotices\Entity\Message;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
use WooCommerce\PayPalCommerce\Onboarding\State; use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
@ -36,9 +37,9 @@ class UnsupportedCurrencyAdminNotice {
/** /**
* The shop currency. * The shop currency.
* *
* @var string * @var CurrencyGetter
*/ */
private $shop_currency; private CurrencyGetter $shop_currency;
/** /**
* Indicates if we're on the WooCommerce gateways list page. * Indicates if we're on the WooCommerce gateways list page.
@ -57,15 +58,15 @@ class UnsupportedCurrencyAdminNotice {
/** /**
* UnsupportedCurrencyAdminNotice constructor. * UnsupportedCurrencyAdminNotice constructor.
* *
* @param State $state The state. * @param State $state The state.
* @param string $shop_currency The shop currency. * @param CurrencyGetter $shop_currency The shop currency.
* @param array $supported_currencies The supported currencies. * @param array $supported_currencies The supported currencies.
* @param bool $is_wc_gateways_list_page Indicates if we're on the WooCommerce gateways list page. * @param bool $is_wc_gateways_list_page Indicates if we're on the WooCommerce gateways list page.
* @param bool $is_ppcp_settings_page Indicates if we're on a PPCP Settings page. * @param bool $is_ppcp_settings_page Indicates if we're on a PPCP Settings page.
*/ */
public function __construct( public function __construct(
State $state, State $state,
string $shop_currency, CurrencyGetter $shop_currency,
array $supported_currencies, array $supported_currencies,
bool $is_wc_gateways_list_page, bool $is_wc_gateways_list_page,
bool $is_ppcp_settings_page bool $is_ppcp_settings_page
@ -96,7 +97,7 @@ class UnsupportedCurrencyAdminNotice {
'Attention: Your current WooCommerce store currency (%1$s) is not supported by PayPal. Please update your store currency to one that is supported by PayPal to ensure smooth transactions. Visit the %2$sPayPal currency support page%3$s for more information on supported currencies.', 'Attention: Your current WooCommerce store currency (%1$s) is not supported by PayPal. Please update your store currency to one that is supported by PayPal to ensure smooth transactions. Visit the %2$sPayPal currency support page%3$s for more information on supported currencies.',
'woocommerce-paypal-payments' 'woocommerce-paypal-payments'
), ),
$this->shop_currency, $this->shop_currency->get(),
'<a href="' . esc_url( $paypal_currency_support_url ) . '">', '<a href="' . esc_url( $paypal_currency_support_url ) . '">',
'</a>' '</a>'
); );
@ -120,7 +121,7 @@ class UnsupportedCurrencyAdminNotice {
* @return bool * @return bool
*/ */
private function currency_supported(): bool { private function currency_supported(): bool {
$currency = $this->shop_currency; $currency = $this->shop_currency->get();
$supported_currencies = $this->supported_currencies; $supported_currencies = $this->supported_currencies;
return in_array( $currency, $supported_currencies, true ); return in_array( $currency, $supported_currencies, true );
} }

View file

@ -190,7 +190,7 @@ class WCGatewayModule implements ServiceModule, ExtendingModule, ExecutableModul
$c->get( 'ppcp.asset-version' ), $c->get( 'ppcp.asset-version' ),
$c->get( 'wc-subscriptions.helper' ), $c->get( 'wc-subscriptions.helper' ),
$c->get( 'button.client_id_for_admin' ), $c->get( 'button.client_id_for_admin' ),
$c->get( 'api.shop.currency' ), $c->get( 'api.shop.currency.getter' ),
$c->get( 'api.shop.country' ), $c->get( 'api.shop.country' ),
$c->get( 'onboarding.environment' ), $c->get( 'onboarding.environment' ),
$settings_status->is_pay_later_button_enabled(), $settings_status->is_pay_later_button_enabled(),