Skip to content

Commit 4429d05

Browse files
authored
refactor: clean up _wcpay_feature_tokenized_cart_ece feature (#10784)
1 parent 08b85f9 commit 4429d05

File tree

67 files changed

+565
-4684
lines changed

Some content is hidden

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

67 files changed

+565
-4684
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: update
3+
4+
update: remove `_wcpay_feature_tokenized_cart_ece` feature flag; remove `client/express-checkout` in favor of `client/tokenized-express-checkout`

client/checkout/api/index.js

Lines changed: 2 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
/**
44
* Internal dependencies
55
*/
6-
import { getConfig, getUPEConfig } from 'utils/checkout';
6+
import { getConfig, getUPEConfig } from 'wcpay/utils/checkout';
77
import {
88
getExpressCheckoutConfig,
99
buildAjaxURL,
10-
getExpressCheckoutAjaxURL,
11-
} from 'utils/express-checkout';
10+
} from 'wcpay/utils/express-checkout';
1211
import { getAppearance } from 'checkout/upe-styles';
1312
import { getAppearanceType } from '../utils';
1413

@@ -348,115 +347,6 @@ export default class WCPayAPI {
348347
} );
349348
}
350349

351-
/**
352-
* Updates cart with selected shipping option.
353-
*
354-
* @param {Object} shippingOption Shipping option.
355-
* @return {Promise} Promise for the request to the server.
356-
*/
357-
expressCheckoutECEUpdateShippingDetails( shippingOption ) {
358-
return this.request(
359-
getExpressCheckoutAjaxURL( 'ece_update_shipping_method' ),
360-
{
361-
security: getExpressCheckoutConfig( 'nonce' )?.update_shipping,
362-
shipping_method: [ shippingOption.id ],
363-
is_product_page:
364-
getExpressCheckoutConfig( 'button_context' ) === 'product',
365-
}
366-
);
367-
}
368-
369-
/**
370-
* Get cart items and total amount.
371-
*
372-
* @return {Promise} Promise for the request to the server.
373-
*/
374-
expressCheckoutECEGetCartDetails() {
375-
return this.request(
376-
getExpressCheckoutAjaxURL( 'ece_get_cart_details' ),
377-
{
378-
security: getExpressCheckoutConfig( 'nonce' )?.get_cart_details,
379-
}
380-
);
381-
}
382-
383-
/**
384-
* Add product to cart from variable product page.
385-
*
386-
* @param {Object} productData Product data.
387-
* @return {Promise} Promise for the request to the server.
388-
*/
389-
expressCheckoutECEAddToCart( productData ) {
390-
return this.request( getExpressCheckoutAjaxURL( 'add_to_cart' ), {
391-
security: getExpressCheckoutConfig( 'nonce' )?.add_to_cart,
392-
...productData,
393-
} );
394-
}
395-
396-
/**
397-
* Get selected product data from variable product page.
398-
*
399-
* @param {Object} productData Product data.
400-
* @return {Promise} Promise for the request to the server.
401-
*/
402-
expressCheckoutECEGetSelectedProductData( productData ) {
403-
return this.request(
404-
getExpressCheckoutAjaxURL( 'ece_get_selected_product_data' ),
405-
{
406-
security: getExpressCheckoutConfig( 'nonce' )
407-
?.get_selected_product_data,
408-
...productData,
409-
}
410-
);
411-
}
412-
413-
/**
414-
* Submits shipping address to get available shipping options
415-
* from Express Checkout ECE payment method.
416-
*
417-
* @param {Object} shippingAddress Shipping details.
418-
* @return {Promise} Promise for the request to the server.
419-
*/
420-
expressCheckoutECECalculateShippingOptions( shippingAddress ) {
421-
return this.request(
422-
getExpressCheckoutAjaxURL( 'ece_get_shipping_options' ),
423-
{
424-
security: getExpressCheckoutConfig( 'nonce' )?.shipping,
425-
is_product_page:
426-
getExpressCheckoutConfig( 'button_context' ) === 'product',
427-
...shippingAddress,
428-
}
429-
);
430-
}
431-
432-
/**
433-
* Creates order based on Express Checkout ECE payment method.
434-
*
435-
* @param {Object} paymentData Order data.
436-
* @return {Promise} Promise for the request to the server.
437-
*/
438-
expressCheckoutECECreateOrder( paymentData ) {
439-
return this.request( getExpressCheckoutAjaxURL( 'ece_create_order' ), {
440-
_wpnonce: getExpressCheckoutConfig( 'nonce' )?.checkout,
441-
...paymentData,
442-
} );
443-
}
444-
445-
/**
446-
* Pays for an order based on the Express Checkout payment method.
447-
*
448-
* @param {integer} order The order ID.
449-
* @param {Object} paymentData Order data.
450-
* @return {Promise} Promise for the request to the server.
451-
*/
452-
expressCheckoutECEPayForOrder( order, paymentData ) {
453-
return this.request( getExpressCheckoutAjaxURL( 'ece_pay_for_order' ), {
454-
_wpnonce: getExpressCheckoutConfig( 'nonce' )?.pay_for_order,
455-
order,
456-
...paymentData,
457-
} );
458-
}
459-
460350
initWooPay( userEmail, woopayUserSession ) {
461351
if ( ! this.isWooPayRequesting ) {
462352
this.isWooPayRequesting = true;

client/checkout/api/test/index.test.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@
33
*/
44
import WCPayAPI from '..';
55
import request from 'wcpay/checkout/utils/request';
6-
import {
7-
buildAjaxURL,
8-
getExpressCheckoutAjaxURL,
9-
getExpressCheckoutConfig,
10-
} from 'wcpay/utils/express-checkout';
6+
import { buildAjaxURL } from 'wcpay/utils/express-checkout';
117
import { getConfig } from 'wcpay/utils/checkout';
128

139
jest.mock( 'wcpay/checkout/utils/request', () =>
1410
jest.fn( () => Promise.resolve( {} ).finally( () => {} ) )
1511
);
1612
jest.mock( 'wcpay/utils/express-checkout', () => ( {
1713
buildAjaxURL: jest.fn(),
18-
getExpressCheckoutAjaxURL: jest.fn(),
1914
getExpressCheckoutConfig: jest.fn(),
2015
} ) );
2116
jest.mock( 'wcpay/utils/checkout', () => ( {
@@ -146,20 +141,6 @@ describe( 'WCPayAPI', () => {
146141
expect( api.isWooPayRequesting ).toBe( false );
147142
} );
148143

149-
test( 'express checkout pay for order is initialized correctly', async () => {
150-
getExpressCheckoutAjaxURL.mockReturnValue( 'https://example.org/' );
151-
getExpressCheckoutConfig.mockReturnValue( { pay_for_order: '1234' } );
152-
153-
const api = new WCPayAPI( {}, request );
154-
await api.expressCheckoutECEPayForOrder( '12', { foo: 'bar' } );
155-
156-
expect( request ).toHaveBeenLastCalledWith( 'https://example.org/', {
157-
_wpnonce: '1234',
158-
order: '12',
159-
foo: 'bar',
160-
} );
161-
} );
162-
163144
test( 'WooPay should not support global theme styles', async () => {
164145
buildAjaxURL.mockReturnValue( 'https://example.org/' );
165146
getConfig.mockImplementation( ( key ) => {

client/checkout/blocks/index.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ import enqueueFraudScripts from 'fraud-scripts';
2121
import {
2222
expressCheckoutElementApplePay,
2323
expressCheckoutElementGooglePay,
24-
} from '../../express-checkout/blocks';
25-
import {
26-
tokenizedExpressCheckoutElementApplePay,
27-
tokenizedExpressCheckoutElementGooglePay,
28-
} from 'wcpay/tokenized-express-checkout/blocks';
24+
} from 'wcpay/express-checkout/blocks';
2925

3026
import { getDeferredIntentCreationUPEFields } from './payment-elements';
3127
import { handleWooPayEmailInput } from '../woopay/email-input-iframe';
@@ -131,17 +127,8 @@ if ( getUPEConfig( 'isWooPayEnabled' ) ) {
131127
}
132128

133129
if ( getUPEConfig( 'isPaymentRequestEnabled' ) ) {
134-
if ( getUPEConfig( 'isTokenizedCartEceEnabled' ) ) {
135-
registerExpressPaymentMethod(
136-
tokenizedExpressCheckoutElementApplePay( api )
137-
);
138-
registerExpressPaymentMethod(
139-
tokenizedExpressCheckoutElementGooglePay( api )
140-
);
141-
} else {
142-
registerExpressPaymentMethod( expressCheckoutElementApplePay( api ) );
143-
registerExpressPaymentMethod( expressCheckoutElementGooglePay( api ) );
144-
}
130+
registerExpressPaymentMethod( expressCheckoutElementApplePay( api ) );
131+
registerExpressPaymentMethod( expressCheckoutElementGooglePay( api ) );
145132
}
146133
window.addEventListener( 'load', () => {
147134
enqueueFraudScripts( getUPEConfig( 'fraudServices' ) );

0 commit comments

Comments
 (0)