Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add currency restriction pill on Amazon Pay #3856

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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).
Loading