Skip to content

Commit 3b74ea7

Browse files
committed
Merge branch 'develop' into dev/update-nodejs-to-v20
2 parents d4302c6 + 0a9c6b9 commit 3b74ea7

File tree

60 files changed

+618
-333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+618
-333
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
max-parallel: 10
1616
matrix:
17-
checkout: [ 'Default', 'Legacy', 'SPE' ]
17+
checkout: [ 'Default', 'Legacy', 'OptimizedCheckout' ]
1818

1919
name: ${{ matrix.checkout }} WP=latest, WC=latest, PHP=7.4
2020
steps:
@@ -88,8 +88,8 @@ jobs:
8888
run: |
8989
if [ "${{ matrix.checkout }}" = "Legacy" ]; then
9090
npm run test:e2e-legacy
91-
elif [ "${{ matrix.checkout }}" = "SPE" ]; then
92-
npm run test:e2e-spe
91+
elif [ "${{ matrix.checkout }}" = "OptimizedCheckout" ]; then
92+
npm run test:e2e-oc
9393
else
9494
npm run test:e2e
9595
fi

.github/workflows/run-e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
max-parallel: 10
2222
matrix:
23-
project: [ 'default', 'legacy', 'acss', 'spe' ]
23+
project: [ 'default', 'legacy', 'acss', 'optimized-checkout' ]
2424

2525
name: E2E - ${{ matrix.project }} (WP=${{ inputs.wp-version }}, WC=${{ inputs.wc-version }}, PHP=${{ inputs.php-version }})
2626
steps:

bin/docker-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ cli wp option set woocommerce_allow_tracking "no"
103103
cli wp option set woocommerce_coming_soon "no"
104104

105105
echo "Importing WooCommerce shop pages..."
106-
cli wp wc --user=admin tool run install_pages
106+
cli wp --user=admin wc tool run install_pages
107107

108108
echo "Installing and activating the WordPress Importer plugin..."
109109
cli wp plugin install wordpress-importer --activate

changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
*** Changelog ***
22

33
= 9.5.0 - xxxx-xx-xx =
4+
* Fix - Fixes the listing of payment methods on the classic checkout when the Optimized Checkout is enabled.
5+
* Fix - Fixes the availability of WeChat Pay when the Optimized Checkout is enabled on the block checkout. Removes it from the classic/shortcode checkout to avoid issues.
6+
* Dev - Renames all references to "Smart Checkout" and "Single Payment Element" (and "SPE") to "Optimized Checkout" (and "OC"), following the feature rebranding.
7+
* Tweak - Updates the "Smart Checkout" setting name to "Optimized Checkout", and the description accordingly.
48
* Fix - Checks for the existence of the WC_Stripe_Feature_Flags class before including it during extension initialization.
59
* Dev - Implements the new Stripe order class into the new checkout experience files.
610
* Dev - Splits the code coverage GitHub Actions Workflow into two separate actions.
@@ -20,6 +24,9 @@
2024
* Fix - Prevents fatal errors for cases where we fail to load product details
2125
* Fix - Address an edge case with webhook URL comparisons
2226
* Fix - Show correct gateway name in non payments settings pages.
27+
* Update - Add support for customer order notes and express checkout
28+
* Dev - Minor fix to e2e setup code
29+
* Dev - Make PHP error log from Docker container available in docker/logs/php/error.log
2330

2431
= 9.4.1 - 2025-04-17 =
2532
* Dev - Forces rollback of version 9.4.0.

client/api/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { __ } from '@wordpress/i18n';
33
import apiFetch from '@wordpress/api-fetch';
44
import { applyFilters } from '@wordpress/hooks';
55
import {
6+
getCustomerNote,
67
getExpressCheckoutData,
78
getExpressCheckoutAjaxURL,
89
getRequiredFieldDataFromCheckoutForm,
@@ -610,6 +611,7 @@ export default class WCStripeAPI {
610611
expressCheckoutECECreateOrder( paymentData ) {
611612
return this.postToBlocksAPI( '/wc/store/v1/checkout', {
612613
...getRequiredFieldDataFromCheckoutForm( paymentData ),
614+
customer_note: getCustomerNote(),
613615
} );
614616
}
615617

client/blocks/upe/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const methodsToFilter = [
4545
];
4646

4747
// Register UPE Elements.
48-
if ( getBlocksConfiguration()?.isSPEEnabled ) {
48+
if ( getBlocksConfiguration()?.isOCEnabled ) {
4949
registerPaymentMethod(
5050
upeElement( PAYMENT_METHOD_CARD, api, paymentMethodsConfig.card )
5151
);

client/blocks/upe/upe-deferred-intent-creation/payment-elements.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const PaymentElements = ( {
135135
},
136136
};
137137

138-
if ( getBlocksConfiguration()?.isSPEEnabled ) {
138+
if ( getBlocksConfiguration()?.isOCEnabled ) {
139139
options = {
140140
...options,
141141
...{
@@ -152,19 +152,19 @@ const PaymentElements = ( {
152152
getPaymentMethodTypes( paymentMethodId ),
153153
},
154154
};
155-
}
156155

157-
// If the cart contains a subscription or the payment method supports saving, we need to use off_session setup so Stripe can display appropriate terms and conditions.
158-
if (
159-
getBlocksConfiguration()?.cartContainsSubscription ||
160-
props.showSaveOption
161-
) {
162-
options = {
163-
...options,
164-
...{
165-
setupFutureUsage: 'off_session',
166-
},
167-
};
156+
// If the cart contains a subscription or the payment method supports saving, we need to use off_session setup so Stripe can display appropriate terms and conditions.
157+
if (
158+
getBlocksConfiguration()?.cartContainsSubscription ||
159+
props.showSaveOption
160+
) {
161+
options = {
162+
...options,
163+
...{
164+
setupFutureUsage: 'off_session',
165+
},
166+
};
167+
}
168168
}
169169
} else {
170170
options = {

client/blocks/upe/upe-deferred-intent-creation/payment-processor.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import {
2626
PAYMENT_METHOD_BLIK,
2727
PAYMENT_METHOD_CASHAPP,
2828
} from 'wcstripe/stripe-utils/constants';
29-
import { handleDisplayOfPaymentInstructions } from 'wcstripe/smart-checkout/handle-display-of-payment-instructions';
30-
import { applyStyles } from 'wcstripe/smart-checkout/apply-styles';
31-
import { handleDisplayOfSavingCheckbox } from 'wcstripe/smart-checkout/handle-display-of-saving-checkbox';
29+
import { handleDisplayOfPaymentInstructions } from 'wcstripe/optimized-checkout/handle-display-of-payment-instructions';
30+
import { applyStyles } from 'wcstripe/optimized-checkout/apply-styles';
31+
import { handleDisplayOfSavingCheckbox } from 'wcstripe/optimized-checkout/handle-display-of-saving-checkbox';
3232

3333
const noop = () => null;
3434

@@ -82,7 +82,7 @@ const getStripeElementOptions = () => {
8282
}
8383
}
8484

85-
if ( getBlocksConfiguration()?.isSPEEnabled ) {
85+
if ( getBlocksConfiguration()?.isOCEnabled ) {
8686
options = {
8787
...options,
8888
layout: {
@@ -331,10 +331,28 @@ const PaymentProcessor = ( {
331331
removeCashAppLimitNotice();
332332
}
333333
// Apply single payment element styles if the selected payment method is card and SPE is enabled.
334-
if ( getBlocksConfiguration()?.isSPEEnabled ) {
334+
if ( getBlocksConfiguration()?.isOCEnabled ) {
335335
applyStyles();
336+
337+
// Maybe change the value of `setupFutureUsage` depending on the saving payment method checkbox state.
338+
const savingPaymentMethodCheckbox = document.querySelector(
339+
'.wc-block-components-payment-methods__save-card-info input[type=checkbox]'
340+
);
341+
savingPaymentMethodCheckbox?.addEventListener(
342+
'change',
343+
function () {
344+
elements.update( {
345+
setupFutureUsage:
346+
getBlocksConfiguration()
347+
?.cartContainsSubscription ||
348+
savingPaymentMethodCheckbox?.checked
349+
? 'off_session'
350+
: null,
351+
} );
352+
}
353+
);
336354
}
337-
}, [ selectedPaymentMethodType ] );
355+
}, [ selectedPaymentMethodType, elements ] );
338356

339357
usePaymentCompleteHandler(
340358
api,
@@ -356,7 +374,7 @@ const PaymentProcessor = ( {
356374
const onSelectedPaymentMethodChange = ( { value, complete } ) => {
357375
setSelectedPaymentMethodType( value.type );
358376
setIsPaymentElementComplete( complete );
359-
if ( getBlocksConfiguration()?.isSPEEnabled ) {
377+
if ( getBlocksConfiguration()?.isOCEnabled ) {
360378
handleDisplayOfPaymentInstructions( value.type );
361379
handleDisplayOfSavingCheckbox( value.type );
362380
}

client/blocks/upe/upe-element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const upeMethods = getPaymentMethodsConstants();
2525
* @return {JSX.Element|null} The icon element.
2626
*/
2727
const getUpeElementIcon = ( paymentMethod ) => {
28-
if ( getBlocksConfiguration()?.isSPEEnabled ) {
28+
if ( getBlocksConfiguration()?.isOCEnabled ) {
2929
return null;
3030
}
3131

client/classic/upe/payment-processing.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import {
2626
PAYMENT_METHOD_MULTIBANCO,
2727
PAYMENT_METHOD_WECHAT_PAY,
2828
} from 'wcstripe/stripe-utils/constants';
29-
import { handleDisplayOfPaymentInstructions } from 'wcstripe/smart-checkout/handle-display-of-payment-instructions';
30-
import { handleDisplayOfSavingCheckbox } from 'wcstripe/smart-checkout/handle-display-of-saving-checkbox';
29+
import { handleDisplayOfPaymentInstructions } from 'wcstripe/optimized-checkout/handle-display-of-payment-instructions';
30+
import { handleDisplayOfSavingCheckbox } from 'wcstripe/optimized-checkout/handle-display-of-saving-checkbox';
3131

3232
const gatewayUPEComponents = {};
3333
const paymentMethodsConfig = getStripeServerData()?.paymentMethodsConfig;
@@ -155,11 +155,15 @@ async function createStripePaymentElement( api, paymentMethodType ) {
155155
amount,
156156
};
157157

158-
if ( getStripeServerData()?.isSPEEnabled ) {
158+
if ( getStripeServerData()?.isOCEnabled ) {
159159
options = {
160160
...options,
161161
paymentMethodConfiguration:
162162
getStripeServerData()?.paymentMethodConfigurationParentId,
163+
// There's no way to update this option in the classic checkout dynamically (for SPE).
164+
// So, we cannot update this based on the value of the saving payment method checkbox.
165+
// Setting this value to `off_session` to avoid issues with methods that do not work with this option (i.e. WeChat Pay, BNPLs)
166+
setupFutureUsage: 'off_session',
163167
};
164168
} else {
165169
options = {
@@ -188,8 +192,8 @@ async function createStripePaymentElement( api, paymentMethodType ) {
188192
},
189193
};
190194

191-
// Set the layout to accordion if SPE is enabled.
192-
if ( getStripeServerData()?.isSPEEnabled ) {
195+
// Set the layout to accordion if OC is enabled.
196+
if ( getStripeServerData()?.isOCEnabled ) {
193197
paymentElementOptions = {
194198
...paymentElementOptions,
195199
layout: {
@@ -342,9 +346,9 @@ export async function mountStripePaymentElement( api, domElement ) {
342346
// Setting the flag to true to prevent the form from being submitted.
343347
gatewayUPEComponents[ paymentMethodType ].hasLoadError = true;
344348
} );
345-
if ( getStripeServerData()?.isSPEEnabled ) {
349+
if ( getStripeServerData()?.isOCEnabled ) {
346350
upeElement.on( 'change', ( { value } ) => {
347-
// If the SPE is enabled, we need to handle the display of the saving checkbox.
351+
// If the OC is enabled, we need to handle the display of the saving checkbox.
348352
handleDisplayOfPaymentInstructions( value.type );
349353

350354
// Bind the create account checkbox to the save card info container display function.

0 commit comments

Comments
 (0)