Skip to content

Commit

Permalink
Add currency restriction pill on Amazon Pay (#3856)
Browse files Browse the repository at this point in the history
* Add currency restriction pill on Amazon Pay

* Add changelog entry

---------

Co-authored-by: Diego Curbelo <diego@curbelo.com>
  • Loading branch information
hsingyuc and diegocurbelo authored Feb 7, 2025
1 parent 38e94a5 commit 344996f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* Tweak - Improve slow query for legacy SEPA subscriptions on WC status tools page by caching the data.
* Tweak - Improve settings page load by delaying oauth URL generation.
* Tweak - Update the Woo logo in the Configure connection modal
* Add - Add currency restriction pill on Amazon Pay.

= 9.1.1 - 2025-01-10 =
* Fix - Fixes the webhook order retrieval by intent charges. The processed event is an object, not an array.
Expand Down
8 changes: 8 additions & 0 deletions client/settings/payment-request-section/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '../../data';
import './styles.scss';
import AmazonPayIcon from '../../payment-method-icons/amazon-pay';
import PaymentMethodMissingCurrencyPill from '../../components/payment-method-missing-currency-pill';
import {
PAYMENT_METHOD_CARD,
PAYMENT_METHOD_LINK,
Expand Down Expand Up @@ -259,6 +260,13 @@ const PaymentRequestSection = () => {
'Amazon Pay',
'woocommerce-gateway-stripe'
) }
<PaymentMethodMissingCurrencyPill
id="amazon_pay"
label={ __(
'Amazon Pay',
'woocommerce-gateway-stripe'
) }
/>
</div>
<div className="express-checkout__description">
{
Expand Down
13 changes: 13 additions & 0 deletions client/utils/use-payment-method-currencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
PAYMENT_METHOD_ALIPAY,
PAYMENT_METHOD_KLARNA,
PAYMENT_METHOD_WECHAT_PAY,
PAYMENT_METHOD_AMAZON_PAY,
} from 'wcstripe/stripe-utils/constants';

const accountCountry =
Expand Down Expand Up @@ -152,6 +153,7 @@ const getWechatPayCurrencies = () => {
'PT',
'ES',
];

if ( EuroSupportedCountries.includes( accountCountry ) ) {
upeCurrencies = [ 'EUR', 'CNY' ];
}
Expand Down Expand Up @@ -206,6 +208,15 @@ const getKlarnaCurrencies = () => {
);
};

const getAmazonPayCurrencies = () => {
switch ( accountCountry ) {
case 'US':
return [ 'USD' ];
default:
return [ 'USD' ];
}
};

export const usePaymentMethodCurrencies = ( paymentMethodId ) => {
const { isUpeEnabled } = useContext( UpeToggleContext );

Expand All @@ -216,6 +227,8 @@ export const usePaymentMethodCurrencies = ( paymentMethodId ) => {
return getWechatPayCurrencies();
case PAYMENT_METHOD_KLARNA:
return getKlarnaCurrencies();
case PAYMENT_METHOD_AMAZON_PAY:
return getAmazonPayCurrencies();
default:
return PaymentMethodsMap[ paymentMethodId ]?.currencies || [];
}
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
* Tweak - Improve slow query for legacy SEPA subscriptions on WC status tools page by caching the data.
* Tweak - Improve settings page load by delaying oauth URL generation.
* Tweak - Update the Woo logo in the Configure connection modal
* Add - Add currency restriction pill on Amazon Pay.

[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

0 comments on commit 344996f

Please sign in to comment.