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

Release branch for 6.6.0 #7435

Merged
merged 100 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
224288c
Fix issues when the Stripe Billing `is_migrating()` function would re…
james-allan Sep 17, 2023
1664440
Disable automatic currency switching and switcher widgets on pay_for_…
jessepearson Sep 18, 2023
e355f04
Add Transaction Details dispute footer for disputes not awaiting a re…
Jinksi Sep 19, 2023
f797789
Fix modal header alignment on safari (#7181)
KarlisJ Sep 19, 2023
4192de6
Prevent WooPay from modifying non-WooPay Webhooks (#7235)
timur27 Sep 19, 2023
e902b23
Revert "Redirect back to the pay-for-order page when it's pay-for-ord…
hsingyuc Sep 19, 2023
ae45522
Add Dispute Challenge and Accept buttons to Transaction Details (#7093)
Jinksi Sep 19, 2023
30503da
Expand WooPayments SSR entries to cover real HEs needs (#7236)
vladolaru Sep 20, 2023
4f668be
Enable deferred intent creation UPE for SEPA (#7232)
timur27 Sep 20, 2023
07c7ba0
fix: save platform checkout info on blocks (#7204)
frosso Sep 20, 2023
b88b01f
Update Transaction Details breakdown: rename labels and add fee break…
Jinksi Sep 20, 2023
eb0434b
In-Person Payments: Prevent double-charging of terminal orders (#6670)
mordeth Sep 21, 2023
56e4cc4
Squashed merge of improve block attribute escaping
rafaelzaleski Sep 19, 2023
11655aa
Increase GBP transaction limit for Afterpay (#7234)
mgascam Sep 21, 2023
fe233b7
Merge trunk v6.5.0 into develop
botwoo Sep 21, 2023
04cf873
Show dispute details on the transaction details screen when a dispute…
Jinksi Sep 21, 2023
16f322f
Add dispute steps to resolve to the transaction details page. (#7206)
shendy-a8c Sep 21, 2023
5fbe6eb
Transaction Details → Show resolution status footer for inquiries (#7…
Jinksi Sep 25, 2023
b090f6d
fix: WooPay billing phone fallback (#7251)
frosso Sep 25, 2023
ae1bcee
Fix WooPay Multiple Redirects (#7215)
bborman22 Sep 25, 2023
8c1558b
Fix WooPay express checkout behavior with product bundles on product …
alefesouza Sep 25, 2023
237ebf4
Pass pay for order param to init WooPay session (#7253)
hsingyuc Sep 26, 2023
815d12f
Merge trunk v6.5.1 into develop
botwoo Sep 26, 2023
ee35b76
Add correct inquiry docs link to active dispute/inquiry notice in tra…
haszari Sep 26, 2023
8416f1f
Add different PO congrats message when account is not complete (#7293)
vladolaru Sep 27, 2023
a806944
Add the feature flag check for pay-for-order flow (#7296)
hsingyuc Sep 27, 2023
07dc42b
Transaction Details → Dispute Details – show dispute amount in store/…
Jinksi Sep 27, 2023
32e8bd0
Remove the redundant network requests in `capture_charge` (#6408)
mordeth Sep 28, 2023
995374d
Fix Apple Pay and Google Pay if card payments are disabled (#7250)
dpaun1985 Sep 28, 2023
af41db7
Fix invalid value error for paymentMethodMessaging in product details…
mgascam Sep 28, 2023
2eb4de5
Added docs for cancel_authorization endpoint. (#7079)
zmaglica Sep 28, 2023
e5e7f69
RPP: Container Exceptions (#7316)
RadoslavGeorgiev Sep 29, 2023
ed2a18f
Remove passing filter hook name from send() method in request classes…
zmaglica Sep 29, 2023
e6ce748
Store the customer currencies data as an option (#7143)
eduardoumpierre Sep 29, 2023
d265ddb
Preload checkout data in WooPay (#7199)
lovo-h Sep 29, 2023
d71f409
Add DisallowHooksInConstructor sniff and migrate some classes to use …
marcinbot Oct 2, 2023
9b72d3d
Fraud Services - Remove hooks from constructor (#7308)
allie500 Oct 2, 2023
557b7d9
Hide tooltip related to Storefront theme in Multi-Currency settings w…
jessepearson Oct 2, 2023
7354671
Revert "Hide tooltip related to Storefront theme in Multi-Currency se…
jessepearson Oct 2, 2023
1eadff7
Update tracking conditions (#7244)
malithsen Oct 2, 2023
587e9a8
Enables deferred intent UPE for existing legacy UPE stores (#7306)
timur27 Oct 3, 2023
8d4d614
Fix variable virtual products require a shipping address for Apple Pa…
mordeth Oct 3, 2023
666d8c1
Move hooks out of MultiCurrency class constructors into own init_hook…
jessepearson Oct 3, 2023
a10f4c0
Add tests for set_payment_method_title_for_email function (#7331)
mdmoore Oct 3, 2023
1e696f8
add a new page component for redirecting disputes => details: (#7310)
haszari Oct 3, 2023
e8da918
Update the WooPayments and Woo Subscriptions deactivate plugin warnin…
james-allan Oct 4, 2023
281c2a0
Add JCB capability request notice (#7224)
mordeth Oct 4, 2023
a6830ce
HACK week: Display server error messages on Settings save (#7140)
mordeth Oct 4, 2023
3db129e
Add helper function/method for raw amount conversion (#7202)
jessepearson Oct 4, 2023
972c07e
Update Name Your Price compatibility to use new Compatibility methods…
jessepearson Oct 4, 2023
2066971
API endpoint to fetch customer's saved payment methods. (#7344)
zmaglica Oct 4, 2023
02b5f3a
Redirect back to the pay-for-order page when it's pay-for-order order…
hsingyuc Oct 4, 2023
2ad0101
Send current user fingerprint data on onboarding init (#7356)
vladolaru Oct 4, 2023
e7915bb
Endpoint for creating a payment intent (#6791)
jessy-p Oct 4, 2023
7e05e5d
Default WooPay first party feature flag to on (#7351)
bborman22 Oct 4, 2023
5448262
Update URL to connect with WooPay (#7362)
lovo-h Oct 4, 2023
c001813
Fix Mix and Match Products on product WooPay Express Checkout Button …
alefesouza Oct 4, 2023
e1b3b62
Disputes: Allow merchant to respond to inquiries from transaction det…
brucealdridge Oct 4, 2023
1ab3115
Transaction Details → Show steps to resolve for inquiries (#7292)
Jinksi Oct 4, 2023
471f56f
Fix error when disabling WCPay with core disabled (#7312)
alefesouza Oct 5, 2023
6a5f1fb
Enable transaction dispute details feature for all merchants (remove …
Jinksi Oct 5, 2023
728218b
Remove 'View dispute' link in Transaction Timeline (#7088)
Jinksi Oct 5, 2023
1d52a33
Moving hook initialisation functions out of constructors (#7355)
dmallory42 Oct 5, 2023
95125fd
RPP: Payments skeleton (#7318)
RadoslavGeorgiev Oct 5, 2023
2c6d231
Introduce Klarna PM (#7282)
KarlisJ Oct 5, 2023
540f2b5
Restrict PMs to location in deferred UPE implementation (#7315)
KarlisJ Oct 5, 2023
81f1dea
RPP: Working Data (#7324)
RadoslavGeorgiev Oct 5, 2023
1efe3a7
Hide helper text related to Storefront theme in Multi-Currency settin…
jessepearson Oct 5, 2023
42910c6
Fix payment method section missing for Affirm and Afterpay on transac…
mgascam Oct 5, 2023
a09f17f
RPP: Extract gateway methods (#7333)
RadoslavGeorgiev Oct 5, 2023
f8b1b2b
Added documentation for payment methods API (#7369)
zmaglica Oct 5, 2023
4247328
Add documentation for create payment intent api endpoint (#7384)
zmaglica Oct 5, 2023
cda6a74
Prevent onboarding flow access without server connection (#7386)
ismaeldcom Oct 5, 2023
b57f91b
Add e2e tests for progressive onboarding (#7309)
oaratovskyi Oct 5, 2023
a2d7454
Fix MultiCurrency onboarding settings page on Woo Express (#7361)
eduardoumpierre Oct 5, 2023
87b0675
Added missing API docs sidebar links (#7389)
zmaglica Oct 5, 2023
81b6bf9
Load MultiCurrency class on Multi-currency setup page (#7205)
eduardoumpierre Oct 5, 2023
f5aa7cd
Add multi-currency enablement check to WooPay session handler (#7390)
c-shultz Oct 5, 2023
3dc4627
Transaction Details → show dispute amount in shopper currency (#7379)
Jinksi Oct 5, 2023
5603143
Only request WooPay session once on Blocks pages (#7393)
cesarcosta99 Oct 5, 2023
145496e
Disputes: wording for disputes implying that fee has not yet been de…
brucealdridge Oct 5, 2023
1fbcd97
Disputes: Prevent errors crashing the payment details page (#7378)
brucealdridge Oct 6, 2023
671b39b
Gate dispute issuer evidence behind a feature flag. (#7394)
shendy-a8c Oct 6, 2023
59e8b2f
Change `Dispute → Details` links to `Transaction → Details` (#7087)
Jinksi Oct 6, 2023
42d58a5
Update Subscriptions with WooPayments eligibility as we move to depre…
james-allan Oct 6, 2023
b3c40cf
Update steps to resolve wording in dispute details on transaction det…
shendy-a8c Oct 6, 2023
faba5fb
Use consistent colors on transaction page when disputed. (#7398)
brucealdridge Oct 6, 2023
34a37c2
Update Subscriptions Core to 6.3.0 (#7403)
mattallan Oct 6, 2023
467b5ea
Bump minimum PHP version to 7.4 for WooCommerce beta matrix only. (#7…
c-shultz Oct 6, 2023
c95ef55
RPP: Minimal Checkout (#7332)
RadoslavGeorgiev Oct 6, 2023
7176d57
Update JCB request capability docs link and capitalize it on the tran…
mordeth Oct 6, 2023
74c9136
Enhance design of bnpl payment methods status in settings screen (#7406)
mgascam Oct 6, 2023
c605942
Point Klarna documentation to correct url from 'Contact WooCommerce S…
KarlisJ Oct 6, 2023
74d9de8
Implement loading state to WooPay express checkout button (#7366)
ricardo Oct 6, 2023
193d409
Add backup loading spinner style from WC blocks to WooPay button (#7432)
ricardo Oct 6, 2023
c1f7b63
Show survey for merchants that disable WooPay (#7401)
alefesouza Oct 7, 2023
703835a
Disputes: Use existing tracks events where possible (#7402)
brucealdridge Oct 8, 2023
91d6dd8
Update version and add changelog entries for release 6.6.0
github-actions[bot] Oct 8, 2023
bf327ed
Fix for issue during plugin update (#7447)
jessy-p Oct 10, 2023
5f471fb
Amend changelog entries for release 6.6.0
botwoo Oct 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: "Generate matrix"
id: generate_matrix
run: |
PHP_VERSIONS=$( echo "[\"$PHP_MIN_SUPPORTED_VERSION\", \"8.0\", \"8.1\"]" )
PHP_VERSIONS=$( echo "[\"7.4\", \"8.0\", \"8.1\"]" )
echo "matrix={\"woocommerce\":[\"beta\"],\"wordpress\":[\"latest\"],\"gutenberg\":[\"latest\"],\"php\":$PHP_VERSIONS}" >> $GITHUB_OUTPUT

# a dedicated job, as allowed to fail
Expand Down
4 changes: 4 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
background-image: url( '../images/payment-methods/affirm-icon.svg' );
}

.payment-method__brand--klarna {
background-image: url( '../images/payment-methods/klarna.svg' );
}

.wc_gateways tr[data-gateway_id='woocommerce_payments'] .payment-method__icon {
border: 1px solid #ddd;
border-radius: 2px;
Expand Down
11 changes: 11 additions & 0 deletions assets/images/payment-methods/klarna.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,83 @@
*** WooPayments Changelog ***

= 6.6.0 - 2023-10-11 =
* Add - Add a notice on the Settings page to request JCB capability for Japanese customers.
* Add - Add current user data to the onboarding init request payload. This data is used for fraud prevention.
* Add - Added API endpoint to fetch customer's saved payment methods.
* Add - Added docs for cancel_authorization endpoint
* Add - Added documentation for create payment intent API endpoint.
* Add - Added documentation for payment methods API endpoint
* Add - Add functionality to enable WooPay first party auth behind feature flag.
* Add - Add helper function/method for raw currency amount conversion.
* Add - Add Klarna payment method
* Add - Add loading state to WooPay button
* Add - Add payment intent creation endpoint
* Add - Add the feature flag check for pay-for-order flow
* Add - Add WC blocks spinner to the WooPay checkout styles.
* Add - Behind a feature flag: dispute message added to transactions screen for disputes not needing a response.
* Add - Display dispute information, recommended resolution steps, and actions directly on the transaction details screen to help merchants with dispute resolution.
* Add - Display server error messages on Settings save
* Add - Expand the data points added to the WooCommerce SSR to include all the main WooPayments features.
* Add - Handle server-side feature flag for new UPE type enablement.
* Add - Introduce the "Subscription Relationship" column under the Orders list admin page when HPOS is enabled.
* Add - Show survey for merchants that disable WooPay.
* Fix - Add Mix and Match Products support on WooPay.
* Fix - Add multi-currency enablement check in WooPay session handling.
* Fix - Comment: Behind a feature flag: Update documentation links (new/changed docs content) when notifying merchant that a dispute needs response.
* Fix - Disable automatic currency switching and switcher widgets on pay_for_order page.
* Fix - Ensure renewal orders paid via the Block Checkout are correctly linked to their subscription.
* Fix - Ensure the order needs processing transient is deleted when a subscription order (eg renewal) is created. Fixes issues with renewal orders going straight to a completed status.
* Fix - fix: save platform checkout info on blocks
* Fix - Fix Apple Pay and Google Pay if card payments are disabled.
* Fix - Fix error when disabling WCPay with core disabled.
* Fix - Fix init WooPay and empty cart error
* Fix - Fix modal header alignment on safari browser
* Fix - Fix onboarding section on MultiCurrency settings page.
* Fix - Fix WooPay express checkout button with product bundles on product page.
* Fix - Hide tooltip related to Storefront theme in Multi-Currency settings when Storefront is not the active theme
* Fix - Improved product details script with enhanced price calculation, and fallbacks for potential undefined values.
* Fix - Improve escaping around attributes.
* Fix - Load multi-currency class on setup page.
* Fix - Missing styles on the Edit Subscription page when HPOS is enabled.
* Fix - Only request WooPay session data once on blocks pages.
* Fix - Payment method section missing for Affirm and Afterpay on transaction details page
* Fix - Prevent charging completed or processing orders with a new payment intent ID
* Fix - Prevent WooPay-related implementation to modify non-WooPay-specific webhooks by changing their data.
* Fix - Prevent WooPay multiple redirect requests.
* Fix - Redirect back to the connect page when attempting to access the new onboarding flow without a server connection.
* Fix - Redirect back to the pay-for-order page when it's pay-for-order order
* Fix - Resolved an issue that caused paying for failed/pending parent orders that include Product Add-ons to not calculate the correct total.
* Fix - Speed up capturing terminal and authorized payments.
* Fix - Store the correct subscription start date in postmeta and ordermeta when HPOS and data syncing is being used.
* Fix - Tracking conditions
* Fix - Virtual variable products no longer require shipping details when checking out with Apple Pay and Google Pay
* Fix - When HPOS is enabled, deleting a customer will now delete their subscriptions.
* Fix - When HPOS is enabled, make the orders_by_type_query filter box work in the WooCommerce orders screen.
* Fix - WooPay save my info phone number fallback for virtual products
* Update - Adapt the PO congratulations card copy for pending account status.
* Update - Allow deferred intent creation UPE to support SEPA payments.
* Update - Enhance design of bnpl payment methods status in settings screen
* Update - Increase GBP transaction limit for Afterpay
* Update - Only display the WCPay Subscriptions setting to existing users as part of deprecating this feature.
* Update - Set WooPay First Party Authentication feature flag to default on.
* Update - Store customer currencies as an option to avoid expensive calculation.
* Update - Updated Transaction Details summary with added fee breakdown tooltip for disputed transactions.
* Update - Update links that pointed to the dispute details screen to point to the transaction details screen
* Update - Update Name Your Price compatibility to use new Compatibility methods.
* Update - Update the content of modals that are displayed when deactivating the WooPayments or Woo Subscriptions plugins when the store has active Stripe Billing subscriptions.
* Update - Update URL used to communicate with WooPay from the iFrame in the merchant site.
* Dev - Added missing API docs links for payment intents and payment methods API endpoints
* Dev - Capitalize the JCB label on transactions details page.
* Dev - e2e tests for progressive onboarding
* Dev - Extracting payment metadata and level 3 data generation into services.
* Dev - Migrate away from hooking into actions in certain classes
* Dev - Move fraud related service hooks out of class constructors and into new init_hooks methods.
* Dev - Move hooks out of MultiCurrency constructor into own init_hooks method.
* Dev - Refactored request class send() method
* Dev - Refactor to move hook initialisation out of constructors.
* Dev - This work is part of a UI improvements to increase disputes response that is behind a feature flag. A changelog entry will be added to represent the work as a whole.
* Dev - Update subscriptions-core to 6.3.0.

= 6.5.1 - 2023-09-26 =
* Fix - fix incorrect payment method title for non-WooPayments gateways

Expand Down
1 change: 1 addition & 0 deletions client/additional-methods-setup/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const upeMethods = [
'affirm',
'afterpay_clearpay',
'jcb',
'klarna',
];

export const upeCapabilityStatuses = {
Expand Down
27 changes: 16 additions & 11 deletions client/checkout/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class WCPayAPI {
this.stripe = null;
this.stripePlatform = null;
this.request = request;
this.isWooPayRequesting = false;
}

createStripe( publishableKey, locale, accountId = '', betas = [] ) {
Expand Down Expand Up @@ -688,17 +689,21 @@ export default class WCPayAPI {
}

initWooPay( userEmail, woopayUserSession ) {
const wcAjaxUrl = getConfig( 'wcAjaxUrl' );
const nonce = getConfig( 'initWooPayNonce' );

return this.request( buildAjaxURL( wcAjaxUrl, 'init_woopay' ), {
_wpnonce: nonce,
email: userEmail,
user_session: woopayUserSession,
order_id: getConfig( 'order_id' ),
key: getConfig( 'key' ),
billing_email: getConfig( 'billing_email' ),
} );
if ( ! this.isWooPayRequesting ) {
this.isWooPayRequesting = true;
const wcAjaxUrl = getConfig( 'wcAjaxUrl' );
const nonce = getConfig( 'initWooPayNonce' );
return this.request( buildAjaxURL( wcAjaxUrl, 'init_woopay' ), {
_wpnonce: nonce,
email: userEmail,
user_session: woopayUserSession,
order_id: getConfig( 'order_id' ),
key: getConfig( 'key' ),
billing_email: getConfig( 'billing_email' ),
} ).finally( () => {
this.isWooPayRequesting = false;
} );
}
}

expressCheckoutAddToCart( productData ) {
Expand Down
29 changes: 26 additions & 3 deletions client/checkout/api/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import request from 'wcpay/checkout/utils/request';
import { buildAjaxURL } from 'wcpay/payment-request/utils';
import { getConfig } from 'wcpay/utils/checkout';

jest.mock( 'wcpay/checkout/utils/request', () => jest.fn() );
jest.mock( 'wcpay/checkout/utils/request', () =>
jest.fn( () => Promise.resolve( {} ).finally( () => {} ) )
);
jest.mock( 'wcpay/payment-request/utils', () => ( {
buildAjaxURL: jest.fn(),
} ) );
Expand All @@ -15,7 +17,7 @@ jest.mock( 'wcpay/utils/checkout', () => ( {
} ) );

describe( 'WCPayAPI', () => {
test( 'initializes woopay using config params', () => {
test( 'does not initialize woopay if already requesting', async () => {
buildAjaxURL.mockReturnValue( 'https://example.org/' );
getConfig.mockImplementation( ( key ) => {
const mockProperties = {
Expand All @@ -28,7 +30,27 @@ describe( 'WCPayAPI', () => {
} );

const api = new WCPayAPI( {}, request );
api.initWooPay( '[email protected]', 'qwerty123' );
api.isWooPayRequesting = true;
await api.initWooPay( '[email protected]', 'qwerty123' );

expect( request ).not.toHaveBeenCalled();
expect( api.isWooPayRequesting ).toBe( true );
} );

test( 'initializes woopay using config params', async () => {
buildAjaxURL.mockReturnValue( 'https://example.org/' );
getConfig.mockImplementation( ( key ) => {
const mockProperties = {
initWooPayNonce: 'foo',
order_id: 1,
key: 'testkey',
billing_email: '[email protected]',
};
return mockProperties[ key ];
} );

const api = new WCPayAPI( {}, request );
await api.initWooPay( '[email protected]', 'qwerty123' );

expect( request ).toHaveBeenLastCalledWith( 'https://example.org/', {
_wpnonce: 'foo',
Expand All @@ -38,5 +60,6 @@ describe( 'WCPayAPI', () => {
key: 'testkey',
billing_email: '[email protected]',
} );
expect( api.isWooPayRequesting ).toBe( false );
} );
} );
2 changes: 2 additions & 0 deletions client/checkout/blocks/upe-split.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
PAYMENT_METHOD_NAME_SOFORT,
PAYMENT_METHOD_NAME_AFFIRM,
PAYMENT_METHOD_NAME_AFTERPAY,
PAYMENT_METHOD_NAME_KLARNA,
} from '../constants.js';
import { getSplitUPEFields } from './upe-split-fields';
import { getDeferredIntentCreationUPEFields } from './upe-deferred-intent-creation/payment-elements';
Expand All @@ -46,6 +47,7 @@ const upeMethods = {
sofort: PAYMENT_METHOD_NAME_SOFORT,
affirm: PAYMENT_METHOD_NAME_AFFIRM,
afterpay_clearpay: PAYMENT_METHOD_NAME_AFTERPAY,
klarna: PAYMENT_METHOD_NAME_KLARNA,
};

const enabledPaymentMethodsConfig = getUPEConfig( 'paymentMethodsConfig' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
generateCheckoutEventNames,
getSelectedUPEGatewayPaymentMethod,
isLinkEnabled,
isPaymentMethodRestrictedToLocation,
isUsingSavedPaymentMethod,
togglePaymentMethodForCountry,
} from '../../utils/upe';
import {
processPayment,
Expand Down Expand Up @@ -109,8 +111,18 @@ jQuery( function ( $ ) {
) {
for ( const upeElement of $( '.wcpay-upe-element' ).toArray() ) {
await mountStripePaymentElement( api, upeElement );
restrictPaymentMethodToLocation( upeElement );
}
maybeEnableStripeLink( api );
}
}

function restrictPaymentMethodToLocation( upeElement ) {
if ( isPaymentMethodRestrictedToLocation( upeElement ) ) {
togglePaymentMethodForCountry( upeElement );
$( '#billing_country' ).on( 'change', function () {
togglePaymentMethodForCountry( upeElement );
} );
}
}
} );
2 changes: 2 additions & 0 deletions client/checkout/classic/upe-split.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
PAYMENT_METHOD_NAME_SOFORT,
PAYMENT_METHOD_NAME_AFFIRM,
PAYMENT_METHOD_NAME_AFTERPAY,
PAYMENT_METHOD_NAME_KLARNA,
SHORTCODE_SHIPPING_ADDRESS_FIELDS,
SHORTCODE_BILLING_ADDRESS_FIELDS,
} from '../constants';
Expand Down Expand Up @@ -657,6 +658,7 @@ jQuery( function ( $ ) {
PAYMENT_METHOD_NAME_SOFORT,
PAYMENT_METHOD_NAME_AFFIRM,
PAYMENT_METHOD_NAME_AFTERPAY,
PAYMENT_METHOD_NAME_KLARNA,
paymentMethodsConfig.card !== undefined && PAYMENT_METHOD_NAME_CARD,
].filter( Boolean );
const checkoutEvents = wcpayPaymentMethods
Expand Down
2 changes: 2 additions & 0 deletions client/checkout/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const PAYMENT_METHOD_NAME_SOFORT = 'woocommerce_payments_sofort';
export const PAYMENT_METHOD_NAME_AFFIRM = 'woocommerce_payments_affirm';
export const PAYMENT_METHOD_NAME_AFTERPAY =
'woocommerce_payments_afterpay_clearpay';
export const PAYMENT_METHOD_NAME_KLARNA = 'woocommerce_payments_klarna';
export const PAYMENT_METHOD_NAME_UPE = 'woocommerce_payments_upe';
export const PAYMENT_METHOD_NAME_PAYMENT_REQUEST =
'woocommerce_payments_payment_request';
Expand All @@ -30,6 +31,7 @@ export function getPaymentMethodsConstants() {
PAYMENT_METHOD_NAME_AFFIRM,
PAYMENT_METHOD_NAME_AFTERPAY,
PAYMENT_METHOD_NAME_CARD,
PAYMENT_METHOD_NAME_KLARNA,
];
}

Expand Down
32 changes: 32 additions & 0 deletions client/checkout/utils/upe.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,35 @@ export const getShippingDetails = ( fields ) => {

return billingAsShippingAddress;
};

/**
* Hides payment method if it has set specific countries in the PHP class.
*
* @param {Object} upeElement The selector of the DOM element of particular payment method to mount the UPE element to.
* @return {boolean} Whether the payment method is restricted to selected billing country.
**/
export const isPaymentMethodRestrictedToLocation = ( upeElement ) => {
const paymentMethodsConfig = getUPEConfig( 'paymentMethodsConfig' );
const paymentMethodType = upeElement.dataset.paymentMethodType;
return !! paymentMethodsConfig[ paymentMethodType ].countries.length;
};

/**
* @param {Object} upeElement The selector of the DOM element of particular payment method to mount the UPE element to.
**/
export const togglePaymentMethodForCountry = ( upeElement ) => {
const paymentMethodsConfig = getUPEConfig( 'paymentMethodsConfig' );
const paymentMethodType = upeElement.dataset.paymentMethodType;
const supportedCountries =
paymentMethodsConfig[ paymentMethodType ].countries;

const billingCountry = document.getElementById( 'billing_country' ).value;
const upeContainer = document.querySelector(
'.payment_method_woocommerce_payments_' + paymentMethodType
);
if ( supportedCountries.includes( billingCountry ) ) {
upeContainer.style.display = 'block';
} else {
upeContainer.style.display = 'none';
}
};
Loading
Loading