Skip to content

Commit

Permalink
Merge branch 'develop' into fix/pass-additional-data-to-intent-authen…
Browse files Browse the repository at this point in the history
…tication-exception
  • Loading branch information
hsingyuc authored Dec 13, 2023
2 parents fb61488 + 56863b2 commit 4f5510a
Show file tree
Hide file tree
Showing 70 changed files with 269 additions and 2,104 deletions.
4 changes: 4 additions & 0 deletions changelog/add-thank-you-page-tracks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Thank you page Tracks event
4 changes: 4 additions & 0 deletions changelog/cleanup-is-upe-enabled-logic
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Cleanup the deprecated payment gateway processing - part III
5 changes: 5 additions & 0 deletions changelog/dev-fix-multi-currency-e2e-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Fix multi-currency e2e tests.


4 changes: 4 additions & 0 deletions changelog/dev-test-ci-without-3ds1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Comment: Fix declined 3DS card E2E test.
4 changes: 4 additions & 0 deletions changelog/fix-3693-qualitative-feedback-note
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Update Qualitative Feedback note to have more efficient sql query.
4 changes: 4 additions & 0 deletions changelog/fix-7750-include-discount-in-tooltip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Include discount fee in fees tooltip
4 changes: 4 additions & 0 deletions changelog/fix-account-currency-hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

fix: account currency hook return value
13 changes: 1 addition & 12 deletions client/additional-methods-setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,13 @@
*/
import Page from 'components/page';
import UpePreviewMethodSelector from './upe-preview-methods-selector';
import WcPayUpeContextProvider from '../settings/wcpay-upe-toggle/provider';
import WCPaySettingsContext from '../settings/wcpay-settings-context';

const AdditionalMethodsPage = () => {
const {
isUpeEnabled,
upeType,
} = window.wcpaySettings.additionalMethodsSetup;

return (
<Page>
<WCPaySettingsContext.Provider value={ window.wcpaySettings }>
<WcPayUpeContextProvider
defaultIsUpeEnabled={ isUpeEnabled }
defaultUpeType={ upeType }
>
<UpePreviewMethodSelector />
</WcPayUpeContextProvider>
<UpePreviewMethodSelector />
</WCPaySettingsContext.Provider>
</Page>
);
Expand Down
42 changes: 0 additions & 42 deletions client/additional-methods-setup/test/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,14 @@ import Wizard from '../wizard/wrapper';
import WizardTask from '../wizard/task';
import WizardTaskList from '../wizard/task-list';
import SetupCompleteTask from './setup-complete-task';
import useIsUpeEnabled from '../../settings/wcpay-upe-toggle/hook';
import AddPaymentMethodsTask from './add-payment-methods-task';
import './index.scss';

const UpePreviewMethodsSelector = () => {
const [ isUpeEnabled ] = useIsUpeEnabled();

return (
<Card className="upe-preview-methods-selector">
<CardBody>
<Wizard
defaultActiveTask={
isUpeEnabled
? 'add-payment-methods'
: 'enable-upe-preview'
}
defaultCompletedTasks={ {
'enable-upe-preview': isUpeEnabled,
} }
>
<Wizard defaultActiveTask="add-payment-methods">
<WizardTaskList>
<WizardTask id="add-payment-methods">
<AddPaymentMethodsTask />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import React from 'react';
import { useEffect, useContext } from '@wordpress/element';
import { useContext } from '@wordpress/element';
import { __, _n, sprintf } from '@wordpress/i18n';
import { Button } from '@wordpress/components';

Expand All @@ -11,7 +11,6 @@ import { Button } from '@wordpress/components';
*/
import CollapsibleBody from '../wizard/collapsible-body';
import WizardTaskItem from '../wizard/task-item';
import WizardTaskContext from '../wizard/task/context';
import WCPaySettingsContext from '../../settings/wcpay-settings-context';
import { useEnabledPaymentMethodIds } from '../../data';
import WizardContext from '../wizard/wrapper/context';
Expand Down Expand Up @@ -70,19 +69,10 @@ const EnabledMethodsList = () => {
};

const SetupComplete = () => {
const { isActive } = useContext( WizardTaskContext );
const {
featureFlags: { multiCurrency },
} = useContext( WCPaySettingsContext );

useEffect( () => {
if ( ! isActive ) {
return;
}

window.wcpaySettings.additionalMethodsSetup.isUpeEnabled = true;
}, [ isActive ] );

return (
<WizardTaskItem
title={ __( 'Enablement complete', 'woocommerce-payments' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ jest.mock( '../../../data', () => ( {

describe( 'SetupComplete', () => {
beforeEach( () => {
window.wcpaySettings = {
additionalMethodsSetup: {
isUpeEnabled: false,
},
};

useEnabledPaymentMethodIds.mockReturnValue( [
[
'card',
Expand All @@ -41,30 +35,6 @@ describe( 'SetupComplete', () => {
] );
} );

it( 'sets isUpeEnabled if isActive', () => {
render(
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
);

expect(
window.wcpaySettings.additionalMethodsSetup.isUpeEnabled
).toBeTruthy();
} );

it( 'does not set isUpeEnabled if not isActive', () => {
render(
<WizardTaskContext.Provider value={ { isActive: false } }>
<SetupComplete />
</WizardTaskContext.Provider>
);

expect(
window.wcpaySettings.additionalMethodsSetup.isUpeEnabled
).toBeFalsy();
} );

it( 'renders setup complete messaging when context value is undefined', () => {
render(
<WizardContext.Provider value={ { completedTasks: {} } }>
Expand Down
58 changes: 18 additions & 40 deletions client/checkout/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,10 @@ export default class WCPayAPI {
accountId,
forceNetworkSavedCards,
locale,
isUPEEnabled,
isUPEDeferredEnabled,
isStripeLinkEnabled,
} = this.options;

if (
forceNetworkSavedCards &&
! forceAccountRequest &&
! ( isUPEEnabled && ! isUPEDeferredEnabled )
) {
if ( forceNetworkSavedCards && ! forceAccountRequest ) {
if ( ! this.stripePlatform ) {
this.stripePlatform = this.createStripe(
publishableKey,
Expand All @@ -89,25 +83,17 @@ export default class WCPayAPI {
}

if ( ! this.stripe ) {
if ( isUPEEnabled ) {
let betas = [ 'card_country_event_beta_1' ];
if ( isStripeLinkEnabled ) {
betas = betas.concat( [ 'link_autofill_modal_beta_1' ] );
}

this.stripe = this.createStripe(
publishableKey,
locale,
accountId,
betas
);
} else {
this.stripe = this.createStripe(
publishableKey,
locale,
accountId
);
let betas = [ 'card_country_event_beta_1' ];
if ( isStripeLinkEnabled ) {
betas = betas.concat( [ 'link_autofill_modal_beta_1' ] );
}

this.stripe = this.createStripe(
publishableKey,
locale,
accountId,
betas
);
}
return this.stripe;
}
Expand Down Expand Up @@ -352,14 +338,11 @@ export default class WCPayAPI {
/**
* Creates a setup intent without confirming it.
*
* @param {string} paymentMethodType Stripe payment method type ID.
* @return {Promise} The final promise for the request to the server.
*/
initSetupIntent( paymentMethodType = '' ) {
let path = 'init_setup_intent';
if ( this.options.isUPESplitEnabled && paymentMethodType ) {
path += `_${ paymentMethodType }`;
}
initSetupIntent() {
const path = 'init_setup_intent';

return this.request( buildAjaxURL( getConfig( 'wcAjaxUrl' ), path ), {
_ajax_nonce: getConfig( 'createSetupIntentNonce' ),
} ).then( ( response ) => {
Expand Down Expand Up @@ -414,16 +397,13 @@ export default class WCPayAPI {
* @return {Promise} The final promise for the request to the server.
*/
createIntent( options ) {
const { fingerprint, paymentMethodType, orderId } = options;
let path = 'create_payment_intent';
const { fingerprint, orderId } = options;
const path = 'create_payment_intent';
const params = {
_ajax_nonce: getConfig( 'createPaymentIntentNonce' ),
'wcpay-fingerprint': fingerprint,
};

if ( this.options.isUPESplitEnabled && paymentMethodType ) {
path += `_${ paymentMethodType }`;
}
if ( orderId ) {
params.wcpay_order_id = orderId;
}
Expand Down Expand Up @@ -468,10 +448,8 @@ export default class WCPayAPI {
paymentCountry,
fingerprint
) {
let path = 'update_payment_intent';
if ( this.options.isUPESplitEnabled ) {
path += `_${ selectedUPEPaymentType }`;
}
const path = 'update_payment_intent';

return this.request( buildAjaxURL( getConfig( 'wcAjaxUrl' ), path ), {
wcpay_order_id: orderId,
wc_payment_intent_id: paymentIntentId,
Expand Down
3 changes: 0 additions & 3 deletions client/checkout/blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ const api = new WCPayAPI(
accountId: getUPEConfig( 'accountId' ),
forceNetworkSavedCards: getUPEConfig( 'forceNetworkSavedCards' ),
locale: getUPEConfig( 'locale' ),
isUPEEnabled: getUPEConfig( 'isUPEEnabled' ),
isUPESplitEnabled: getUPEConfig( 'isUPESplitEnabled' ),
isUPEDeferredEnabled: getUPEConfig( 'isUPEDeferredEnabled' ),
isStripeLinkEnabled,
},
request
Expand Down
6 changes: 1 addition & 5 deletions client/checkout/classic/event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ jQuery( function ( $ ) {
accountId: getUPEConfig( 'accountId' ),
forceNetworkSavedCards: getUPEConfig( 'forceNetworkSavedCards' ),
locale: getUPEConfig( 'locale' ),
isUPEEnabled: getUPEConfig( 'isUPEEnabled' ),
isStripeLinkEnabled: isLinkEnabled(
getUPEConfig( 'paymentMethodsConfig' )
),
isUPEDeferredEnabled: getUPEConfig( 'isUPEDeferredEnabled' ),
},
apiRequest
);
Expand Down Expand Up @@ -79,9 +77,7 @@ jQuery( function ( $ ) {
$( 'form#add_payment_method' ).length ||
$( 'form#order_review' ).length
) {
if ( getUPEConfig( 'isUPEEnabled' ) ) {
maybeMountStripePaymentElement();
}
maybeMountStripePaymentElement();
}

$( 'form#add_payment_method' ).on( 'submit', function () {
Expand Down
2 changes: 1 addition & 1 deletion client/checkout/classic/payment-processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export function renderTerms( event ) {
return;
}
const upeElement = gatewayUPEComponents[ paymentMethodType ].upeElement;
if ( getUPEConfig( 'isUPEEnabled' ) && upeElement ) {
if ( upeElement ) {
upeElement.update( {
terms: getTerms( getUPEConfig( 'paymentMethodsConfig' ), value ),
} );
Expand Down
6 changes: 0 additions & 6 deletions client/checkout/classic/test/payment-processing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,10 @@ describe( 'Stripe Payment Element mounting', () => {
if ( argument === 'currency' ) {
return 'eur';
}

if ( argument === 'isUPEEnabled' ) {
return true;
}
} );

getSelectedUPEGatewayPaymentMethod.mockReturnValue( 'card' );
renderTerms( event );
expect( getUPEConfig ).toHaveBeenCalledWith( 'isUPEEnabled' );
expect( mockUpdateFunction ).toHaveBeenCalled();
} );

Expand All @@ -256,7 +251,6 @@ describe( 'Stripe Payment Element mounting', () => {
};
getSelectedUPEGatewayPaymentMethod.mockReturnValue( null );
renderTerms( event );
expect( getUPEConfig ).not.toHaveBeenCalledWith( 'isUPEEnabled' );
expect( mockUpdateFunction ).not.toHaveBeenCalled();
} );

Expand Down
Loading

0 comments on commit 4f5510a

Please sign in to comment.