Skip to content

Update NodeJS to v20 #4264

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

Draft
wants to merge 67 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
16e0caa
Specify the --user argument to wp wc CLI calls before wc
daledupreez Apr 28, 2025
d6bedb7
Merge branch 'develop' into update/e2e-setup-scripts
daledupreez Apr 29, 2025
04bbd9a
Bump nodejs version to v20.19.1
diegocurbelo Apr 24, 2025
ad71d37
Update webpack config to v5
diegocurbelo Apr 24, 2025
bec8c7d
Fix babel configuration compat
diegocurbelo Apr 24, 2025
23a4e52
Update wp-prettier to 2.8.5 (used by woo)
diegocurbelo Apr 24, 2025
fd856cb
Update @woocommerce/dependency-extraction-webpack-plugin
diegocurbelo Apr 25, 2025
9ceabb1
Update @wordpress/base-styles to 4.49.0
diegocurbelo Apr 25, 2025
4836e74
Fix webpack 5 source map generation
diegocurbelo Apr 25, 2025
0740c53
Replace wp-prettier with @wordpress/prettier-config
diegocurbelo Apr 25, 2025
14552aa
Copy prettier config from gutenberg
diegocurbelo Apr 25, 2025
7efdb6a
Update @wordpress/jest-preset-default
daledupreez Apr 28, 2025
1feb133
Update eslint-plugin-prettier to fix linting runtime errors
daledupreez Apr 28, 2025
fec00f4
Add i18n text domain to @wordpress/i18n-text-domain config
daledupreez Apr 28, 2025
93ded00
Ignore phpunit-html/ directory for linting
daledupreez Apr 28, 2025
775279e
Remove old lint ignores
daledupreez Apr 28, 2025
68bff0b
Fix type defs and linting
daledupreez Apr 28, 2025
4a184ed
Linting changes for /tests/e2e/
daledupreez Apr 28, 2025
7c9f75a
Fix constant import in CashApp notice test
daledupreez Apr 28, 2025
0bec463
Linting updates for client/[smart-checkout|stripe-utils|styles|utils]
daledupreez Apr 28, 2025
8b1f1a8
Linting fixes in client/api; includes function move
daledupreez Apr 28, 2025
2c82ed4
Linting updates in client/blocks/
daledupreez Apr 28, 2025
dc0a6d5
Linting updates in client/[brand-logos|classic]
daledupreez Apr 28, 2025
f927c4a
Linting updates in client/components
daledupreez Apr 28, 2025
6dc9758
Linting updates in client/data
daledupreez Apr 28, 2025
1759faf
Linting updates in client/entrypoints
daledupreez Apr 28, 2025
0c3e9f8
Linting updates in client/express-checkout and client/payments-method…
daledupreez Apr 28, 2025
75fce62
Linting updates in client/settings; part I
daledupreez Apr 28, 2025
3e0345c
Linting updates in client/settings/[general-settings-section|payment-…
daledupreez Apr 28, 2025
d79b754
Linting updates in client/settings/[payment-settings|payments-and-tra…
daledupreez Apr 28, 2025
aa26844
Linting updates in client/settings; part II
daledupreez Apr 28, 2025
8cded66
Add ^ spec to eslint-plugin-prettier in package-lock.json
daledupreez Apr 28, 2025
23038b4
Use createRoot() instead of ReactDOM.render()
daledupreez Apr 29, 2025
b0796e5
Remove unnecessary hook deps in client/data/payment-gateway/hooks.js
daledupreez Apr 29, 2025
8eb5552
Remove unnecessary hook deps in client/data/settings/hooks.js
daledupreez Apr 29, 2025
dea439c
Restructure express-checkout entrypoint to avoid circular dependencies
daledupreez Apr 29, 2025
c1dbefe
Move CSS declaration before nested rule
daledupreez Apr 29, 2025
a337c11
Ignore SASS warnings from dependencies; switch from @import to @use
daledupreez Apr 29, 2025
e72e5c3
Revert "Specify the --user argument to wp wc CLI calls before wc"
daledupreez Apr 29, 2025
4cc361a
Merge branch 'develop' into dev/update-nodejs-to-v20
daledupreez Apr 29, 2025
0d4ee34
Move eslint-plugin-jest to dev dependencies and bump version slightly
daledupreez Apr 30, 2025
398f0e7
Move @typescript-eslint/parser to devDepencies
daledupreez Apr 30, 2025
0cf831f
Move @testing-library/react-hooks to devDependencies
daledupreez Apr 30, 2025
1a3d9f0
Move @typescript-eslint/eslint-plugin to devDependencies
daledupreez Apr 30, 2025
35d0bc1
Merge upstream dev/update-nodejs-to-v20 into local dev/update-nodejs-…
daledupreez Apr 30, 2025
1482cc2
Merge branch 'develop' into dev/update-nodejs-to-v20
daledupreez Apr 30, 2025
a068088
Add more global mocks to reduce errors and need for individual tests …
laurendavissmith May 2, 2025
89c54b9
Cleanup and better comments
laurendavissmith May 2, 2025
85c8e22
Fix DisableConfirmationModal tests
daledupreez May 5, 2025
04c8120
Fix RemoveMethodConfirmationModal tests
daledupreez May 5, 2025
6299c98
Fix ManualCaptureControl tests
daledupreez May 5, 2025
27f0d6a
Fix DisplayOrderCustomizationNotice tests
daledupreez May 5, 2025
354f604
Fix PromotionalBanner tests
daledupreez May 5, 2025
f0b4ccf
Fix ConnectStripeAccount tests
daledupreez May 5, 2025
5b92371
Fix AmazonPaySettingsSection tests
daledupreez May 5, 2025
27b4289
Fix GeneralSettingsSection tests
daledupreez May 5, 2025
39dc563
Fix PaymentRequestsSettingsSection tests
daledupreez May 5, 2025
72ba24f
Fix the other PaymentRequestsSettingsSection tests
daledupreez May 5, 2025
12ee857
Fix PaymentGatewaySection tests
daledupreez May 5, 2025
ad11e06
Fix Popover tests
daledupreez May 5, 2025
9e5ae58
Fix SaveSettingsSection tests
daledupreez May 5, 2025
086e697
Fix SavePaymentGatewaySection tests
daledupreez May 5, 2025
d0644d6
Fix TestModeCheckbox tests
daledupreez May 5, 2025
9df9777
Fix CustomizePaymentMethod tests
daledupreez May 5, 2025
5388eaa
Fix AdvancedSettings tests
daledupreez May 5, 2025
d4302c6
Fix AmazonPaySettingsSection tests
daledupreez May 5, 2025
3b74ea7
Merge branch 'develop' into dev/update-nodejs-to-v20
daledupreez May 5, 2025
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
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ module.exports = {
'testing-library/no-unnecessary-act': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@wordpress/i18n-text-domain': [
'error',
{
allowedTextDomain: 'woocommerce-gateway-stripe',
},
],
Comment on lines +65 to +70
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wordpress/i18n-text-domain was reporting a lot of issues. I chose to specify our expected text domain, but we could also keep to the defaults.

},
settings: {
react: {
Expand All @@ -82,4 +88,5 @@ module.exports = {
'@wordpress/data',
],
},
ignorePatterns: [ 'phpunit-html/**' ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tripped over a local folder left over from testing and realised it should always be ignored for linting.

};
7 changes: 5 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
legacy-peer-deps=true
engine-strict=true
save-exact = true
engine-strict = true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config copied from Guteberg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While working on various dependencies, I noticed that this results in the default ^ prefix for compatible versions being removed. I am not sure how I feel about that, but I wanted to flag it as a key side-effect.

legacy-peer-deps = true
prefer-dedupe = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this? Maybe something for a follow-up PR.

lockfile-version = 3
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.18.0
v20.19.1
10 changes: 9 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// Import the default config file and expose it in the project root.
// Useful for editor integrations.
module.exports = require( '@wordpress/prettier-config' );
module.exports = {
...require( '@wordpress/prettier-config' ),
overrides: [
{
files: [ 'changelog.txt' ],
options: { parser: 'markdown' },
},
],
};
Comment on lines +3 to +11
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config copied from Guteberg

4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
plugins: [
'@emotion',
[ '@babel/transform-runtime', { corejs: 3 } ],
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-transform-optional-chaining',
'@babel/plugin-transform-nullish-coalescing-operator',
],
};
2 changes: 1 addition & 1 deletion bin/update-pot-file-references.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function load_js_transpiling_source_maps(): array {
}

foreach ( $file_json[ 'sources' ] as $source ) {
$source = preg_replace( '%^webpack:///\./(client/.*)$%', '${1}', $source );
$source = preg_replace( '%^webpack://\./(client/.*)$%', '${1}', $source );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Webpack 5 config, we are manually setting devtoolModuleFilenameTemplate, so we can replace the previous triple slash prefixes with normal URL-like paths webpack://[resource-path]

if ( 'webpack' !== substr( $source, 0, 7 ) ) {
$mappings[ $source ][] = $file_json[ 'file' ];
}
Expand Down
28 changes: 14 additions & 14 deletions client/api/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getBlocksConfiguration } from 'wcstripe/blocks/utils';
* Construct WC AJAX endpoint URL.
*
* @param {string} endpoint Request endpoint URL.
* @param {string} prefix Endpoint URI prefix (default: 'wc_stripe_').
* @param {string} prefix Endpoint URI prefix (default: 'wc_stripe_').
* @return {string} URL with interpolated endpoint.
*/
const getAjaxUrl = ( endpoint, prefix = 'wc_stripe_' ) => {
Expand All @@ -33,7 +33,7 @@ export const getCartDetails = () => {
/**
* Update shipping options.
*
* @param {Object} address Customer address.
* @param {Object} address Customer address.
* @param {string} paymentRequestType Either 'apple_pay' or 'payment_request_api' depending on the type of request.
*/
export const updateShippingOptions = ( address, paymentRequestType ) => {
Expand Down Expand Up @@ -65,18 +65,6 @@ export const updateShippingDetails = ( shippingOption ) => {
} );
};

export const createOrder = ( sourceEvent, paymentRequestType ) => {
let data = normalizeOrderData( sourceEvent, paymentRequestType );
data = getRequiredFieldDataFromCheckoutForm( data );

return $.ajax( {
type: 'POST',
data,
dataType: 'json',
url: getAjaxUrl( 'create_order' ),
} );
};

const getRequiredFieldDataFromCheckoutForm = ( data ) => {
const checkoutForm = document.querySelector( '.wc-block-checkout' );
// Return if cart page.
Expand Down Expand Up @@ -109,3 +97,15 @@ const getRequiredFieldDataFromCheckoutForm = ( data ) => {

return data;
};

export const createOrder = ( sourceEvent, paymentRequestType ) => {
let data = normalizeOrderData( sourceEvent, paymentRequestType );
data = getRequiredFieldDataFromCheckoutForm( data );

return $.ajax( {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked to see how this gets utilized but I don't love that we return a promise with no default error state. It forces every instance of createOrder to implement an error catch since there is no fallback.

type: 'POST',
data,
dataType: 'json',
url: getAjaxUrl( 'create_order' ),
} );
};
31 changes: 16 additions & 15 deletions client/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class WCStripeAPI {
* Construct WC AJAX endpoint URL.
*
* @param {string} endpoint Request endpoint URL.
* @param {string} prefix Endpoint URI prefix (default: 'wc_stripe_').
* @param {string} prefix Endpoint URI prefix (default: 'wc_stripe_').
* @return {string} URL with interpolated endpoint.
*/
getAjaxUrl( endpoint, prefix = 'wc_stripe_' ) {
Expand Down Expand Up @@ -141,7 +141,7 @@ export default class WCStripeAPI {
/**
* Creates an intent based on a payment method.
*
* @param {number|null} orderId The id of the order if creating the intent on Order Pay page.
* @param {number|null} orderId The id of the order if creating the intent on Order Pay page.
* @param {string|null} paymentMethodType The type of payment method.
*
* @return {Promise} The final promise for the request to the server.
Expand Down Expand Up @@ -173,7 +173,7 @@ export default class WCStripeAPI {
/**
* Creates and confirms a setup intent.
*
* @param {Object} paymentMethod Payment method data.
* @param {Object} paymentMethod Payment method data.
* @param {Object} additionalData Additional data to send with the request.
*
* @return {Promise} Promise containing the setup intent.
Expand Down Expand Up @@ -255,12 +255,12 @@ export default class WCStripeAPI {
/**
* Updates a payment intent with data from order: customer, level3 data and and maybe sets the payment for future use.
*
* @param {string} intentId The id of the payment intent.
* @param {number} orderId The id of the order.
* @param {string} savePaymentMethod 'yes' if saving.
* @param {string} intentId The id of the payment intent.
* @param {number} orderId The id of the order.
* @param {string} savePaymentMethod 'yes' if saving.
* @param {string} selectedUPEPaymentType The name of the selected UPE payment type or empty string.
*
* @return {Promise} The final promise for the request to the server.
* @return {Object|undefined} The response from the server or undefined if the intent is a setup intent.
*/
updateIntent(
intentId,
Expand Down Expand Up @@ -302,7 +302,7 @@ export default class WCStripeAPI {
* Extracts the details about a payment intent from the redirect URL,
* and displays the intent confirmation modal (if needed).
*
* @param {string} redirectUrl The redirect URL, returned from the server.
* @param {string} redirectUrl The redirect URL, returned from the server.
* @param {string} paymentMethodToSave The ID of a Payment Method if it should be saved (optional).
* @return {Object|true} An object containing the redirect URL on success and a flag indicating
* if the page is the Pay for order page, or `true` if no confirmation is needed.
Expand Down Expand Up @@ -389,7 +389,7 @@ export default class WCStripeAPI {
* Process checkout and update payment intent via AJAX.
*
* @param {string} paymentIntentId ID of payment intent to be updated.
* @param {Object} fields Checkout fields.
* @param {Object} fields Checkout fields.
* @return {Promise} Promise containing redirect URL for UPE element.
*/
processCheckout( paymentIntentId, fields ) {
Expand Down Expand Up @@ -419,7 +419,7 @@ export default class WCStripeAPI {
* Updates order status, if there is an error while confirming intent.
*
* @param {string} intentId The id of the Payment/Setup Intent.
* @param {number} orderId The id of the WC_Order.
* @param {number} orderId The id of the WC_Order.
*/
updateFailedOrder( intentId, orderId ) {
this.request( this.getAjaxUrl( 'update_failed_order' ), {
Expand Down Expand Up @@ -591,7 +591,7 @@ export default class WCStripeAPI {
/**
* Empty the cart (legacy version, non-StoreAPI).
*
* @param {Object} params Parameters.
* @param {Object} params Parameters.
* @param {number} params.bookingId Booking ID.
* @return {Promise} Promise for the request to the server.
*/
Expand All @@ -618,9 +618,9 @@ export default class WCStripeAPI {
/**
* Pays for an order based on the Express Checkout payment method.
*
* @param {number} order The order ID.
* @param {number} order The order ID.
* @param {Object} orderDetails Order details, including order key and billing email.
* @param {Object} paymentData Order data.
* @param {Object} paymentData Order data.
* @return {Promise} Promise for the request to the server.
*/
expressCheckoutECEPayForOrder( order, orderDetails, paymentData ) {
Expand Down Expand Up @@ -660,8 +660,9 @@ export default class WCStripeAPI {
return this.request(
getExpressCheckoutAjaxURL( 'get_selected_product_data' ),
{
security: getExpressCheckoutData( 'nonce' )
?.get_selected_product_data,
security:
getExpressCheckoutData( 'nonce' )
?.get_selected_product_data,
...productData,
}
);
Expand Down
12 changes: 6 additions & 6 deletions client/blocks/credit-card/elements.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import {
CardElement,
CardNumberElement,
CardExpiryElement,
CardCvcElement,
} from '@stripe/react-stripe-js';
import { useElementOptions } from './use-element-options';
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/** @typedef {import('react')} React */

Expand All @@ -15,9 +15,9 @@ const baseTextInputStyles = 'wc-block-gateway-input';
/**
* InlineCard component
*
* @param {Object} props Incoming props for the component.
* @param {Object} props Incoming props for the component.
* @param {React.ReactElement} props.inputErrorComponent
* @param {function(any):any} props.onChange
* @param {function(any):any} props.onChange
*/
export const InlineCard = ( {
inputErrorComponent: ValidationInputError,
Expand Down Expand Up @@ -63,8 +63,8 @@ export const InlineCard = ( {
/**
* CardElements component.
*
* @param {Object} props
* @param {function(any):any} props.onChange
* @param {Object} props
* @param {function(any):any} props.onChange
* @param {React.ReactElement} props.inputErrorComponent
*/
export const CardElements = ( {
Expand Down
4 changes: 2 additions & 2 deletions client/blocks/credit-card/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { __ } from '@wordpress/i18n';
import { useEffect, useState } from '@wordpress/element';
import { ThreeDSecurePaymentHandler } from '../three-d-secure';
import { StripeCreditCard, getStripeCreditCardIcons } from './payment-method';
import { PAYMENT_METHOD_NAME } from './constants';
import { useEffect, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { getBlocksConfiguration } from 'wcstripe/blocks/utils';
import { loadStripe } from 'wcstripe/blocks/load-stripe';

Expand Down
2 changes: 1 addition & 1 deletion client/blocks/credit-card/payment-method.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from '@wordpress/element';
import { Elements, useStripe } from '@stripe/react-stripe-js';
import { useCheckoutSubscriptions } from './use-checkout-subscriptions';
import { InlineCard, CardElements } from './elements';
import { useState } from '@wordpress/element';
import { getBlocksConfiguration } from 'wcstripe/blocks/utils';

/**
Expand Down
7 changes: 3 additions & 4 deletions client/blocks/credit-card/use-checkout-subscriptions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useCallback, useState } from '@wordpress/element';
import { getErrorMessageForTypeAndCode } from '../../stripe-utils';
import { usePaymentIntents } from '../three-d-secure';
import { usePaymentProcessing } from './use-payment-processing';
import { useEffect, useCallback, useState } from '@wordpress/element';

/**
* @typedef {import('@woocommerce/type-defs/registered-payment-method-props').EventRegistrationProps} EventRegistrationProps
Expand Down Expand Up @@ -75,9 +75,8 @@ export const useCheckoutSubscriptions = (
// so we don't break the observers.
return true;
};
const unsubscribeAfterProcessing = onCheckoutAfterProcessingWithError(
onError
);
const unsubscribeAfterProcessing =
onCheckoutAfterProcessingWithError( onError );
return () => {
unsubscribeAfterProcessing();
};
Expand Down
2 changes: 1 addition & 1 deletion client/blocks/credit-card/use-payment-processing.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useEffect } from '@wordpress/element';
import {
CardElement,
CardNumberElement,
Expand All @@ -7,6 +6,7 @@ import {
import { getErrorMessageForTypeAndCode } from '../../stripe-utils';
import { errorTypes, PAYMENT_METHOD_CARD } from '../../stripe-utils/constants';
import { PAYMENT_METHOD_NAME } from './constants';
import { useEffect } from '@wordpress/element';
import { getBlocksConfiguration } from 'wcstripe/blocks/utils';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import './style.scss';
* Base PaymentButtonPreview Component
*
* @param {Object} props
* @param {string} props.icon - The icon to display.
* @param {string} props.icon - The icon to display.
* @param {string} [props.className] - Optional additional class names.
* @return {JSX.Element} The rendered component.
*/
Expand Down
23 changes: 9 additions & 14 deletions client/blocks/express-checkout/express-checkout-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,15 @@ const ExpressCheckoutComponent = ( {
onClose,
expressPaymentMethod = '',
} ) => {
const {
buttonOptions,
onButtonClick,
onConfirm,
onCancel,
elements,
} = useExpressCheckout( {
api,
billing,
shippingData,
onClick,
onClose,
setExpressPaymentError,
} );
const { buttonOptions, onButtonClick, onConfirm, onCancel, elements } =
useExpressCheckout( {
api,
billing,
shippingData,
onClick,
onClose,
setExpressPaymentError,
} );

const onShippingAddressChange = ( event ) =>
shippingAddressChangeHandler( api, event, elements );
Expand Down
5 changes: 2 additions & 3 deletions client/blocks/express-checkout/express-checkout-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ export const ExpressCheckoutContainer = ( props ) => {
} ),
amount: billing.cartTotal.value,
currency: billing.currency.code.toLowerCase(),
paymentMethodTypes: getPaymentMethodTypesForExpressMethod(
expressPaymentMethod
),
paymentMethodTypes:
getPaymentMethodTypesForExpressMethod( expressPaymentMethod ),
appearance: getExpressCheckoutButtonAppearance(),
locale: getExpressCheckoutData( 'stripe' )?.locale ?? 'en',
};
Expand Down
9 changes: 5 additions & 4 deletions client/blocks/express-checkout/hooks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useStripe, useElements } from '@stripe/react-stripe-js';
import { useCallback } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { useStripe, useElements } from '@stripe/react-stripe-js';
import {
onAbortPaymentHandler,
onCancelHandler,
Expand Down Expand Up @@ -70,9 +70,10 @@ export const useExpressCheckout = ( {

// Return a default shipping option, as a non-empty shippingRates array
// is required when shippingAddressRequired is true.
const defaultShippingOption = getExpressCheckoutData(
'checkout'
)?.default_shipping_option;
const defaultShippingOption =
getExpressCheckoutData(
'checkout'
)?.default_shipping_option;
return defaultShippingOption ? [ defaultShippingOption ] : [];
};

Expand Down
2 changes: 1 addition & 1 deletion client/blocks/express-checkout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const getEditorElement = ( expressPaymentMethod ) => {
/**
*
* @param {string} expressPaymentMethod
* @param {Object} api The Stripe API object.
* @param {Object} api The Stripe API object.
* @return {Object} The express payment method configuration.
*/
const expressCheckoutElement = ( expressPaymentMethod, api ) => {
Expand Down
Loading
Loading