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

POC: Multiple instances of single-method UPE at checkout #3968

Merged
merged 105 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
443c071
adds separated upe gateway exclusively for sepa direct debit
FangedParakeet Mar 10, 2022
dd38b32
moves upe payment gateway utility functions to separate opportunistic…
FangedParakeet Mar 12, 2022
fd024b2
refactors upe trait back into reusable class
FangedParakeet Mar 13, 2022
42d37b6
adds fixes to resolve issues for admin pages
FangedParakeet Mar 14, 2022
87c3b93
adds dynamic ids for new upe payment gateways and dom elements
FangedParakeet Mar 14, 2022
a97aed9
adds client side implementation to mount upe element when single upe …
FangedParakeet Mar 14, 2022
d53453d
adds working client side implementation for checkout using single upe…
FangedParakeet Mar 14, 2022
9e98d9c
adds working server side round trip checkout flow supporting multiple…
FangedParakeet Mar 15, 2022
709dc31
uses correct sepa_debit constant for payment method
FangedParakeet Mar 15, 2022
f36ae0f
merge develop and resolve conflicts
FangedParakeet Mar 15, 2022
c6b5bce
amaneds order tracking
FangedParakeet Mar 15, 2022
4983af9
removes unused html gateway elements
FangedParakeet Mar 15, 2022
1806baa
fix becs debit constant
FangedParakeet Mar 15, 2022
af062bc
adds dynamic testing instructions for different payment methods
FangedParakeet Mar 15, 2022
b5aa8d7
fixes currency check when collecting enabled payment methods
FangedParakeet Mar 16, 2022
fe6e7b0
uses legacy card gateway for cc method only, uses upe settings when u…
FangedParakeet Mar 16, 2022
a6e5b3b
merge develop and resolve conflicts
FangedParakeet Mar 16, 2022
248c5db
merge develop and resolve conflicts
mdmoore Jun 15, 2022
7e5f155
Merge branch 'develop' into poc/upe-instances-multiplied
mdmoore Jun 15, 2022
f11e155
Send selected payment method Stripe ID rather than all enabled Stripe…
mdmoore Jun 23, 2022
6c408c0
Merge branch 'develop' into poc/upe-instances-multiplied
mdmoore Jul 6, 2022
623f05d
Remove mountUPEElement() because we are creating one for each payment…
harriswong Jul 22, 2022
db49291
Changed isUsingSavedPaymentMethod() signature (#4493)
harriswong Aug 4, 2022
7ce0482
Register only reusable payment methods when adding a payment method (…
mdmoore Aug 8, 2022
a277700
Merge branch 'develop' into poc/upe-instances-multiplied
harriswong Aug 8, 2022
ffd58ae
Only show test mode notice once (#4545)
mdmoore Aug 11, 2022
c02dd9a
Multiple UPE - Fix unit tests on POC branch (#4557)
harriswong Aug 16, 2022
1b0d22d
Merge branch 'develop' into poc/upe-instances-multiplied
harriswong Aug 16, 2022
45b93ae
Merge branch 'develop' into poc/upe-instances-multiplied
harriswong Aug 17, 2022
1d22ac3
Merge branch 'develop' into poc/upe-instances-multiplied
harriswong Aug 17, 2022
7172f16
Merge branch 'develop' into poc/upe-instances-multiplied
harriswong Aug 19, 2022
24b8c78
Merge branch 'develop' into poc/upe-instances-multiplied
harriswong Aug 23, 2022
a7748ac
Merge branch 'develop' into poc/upe-instances-multiplied
harriswong Aug 30, 2022
ee57148
Merge branch 'develop' into poc/upe-instances-multiplied
mdmoore Sep 9, 2022
006c066
show apple pay and supported currency notice once only (#4719)
Mayisha Sep 12, 2022
0ade3e9
display save platform user checkbox when woopay is enabled with multi…
Mayisha Sep 27, 2022
ef1de66
fixes missing function parameters
FangedParakeet Oct 10, 2022
3b9a31f
Merge branch 'develop' into poc/upe-instances-multiplied
bborman22 Oct 11, 2022
88be4a9
Add payment icons to multiple UPE (#4860)
bborman22 Oct 13, 2022
6444432
Integrate split UPE payments with WooCommerce Blocks (#4681)
harriswong Nov 9, 2022
306dcae
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
Nov 10, 2022
bcb1196
Provide minor post-conflicts fixes and ensure that Blocks checkout wo…
Nov 10, 2022
c38ddf2
Make the legacy card gateway work on the classic checkout
Nov 10, 2022
338f289
Split UPE: Correct token behavior (#4670)
mdmoore Nov 11, 2022
850f2d4
Adjust the checkout and fix the wcpay-upe-element element delivery to…
Nov 11, 2022
f352737
Provide payment gateway as the callback parameter
Nov 11, 2022
157a9e5
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
Nov 11, 2022
13e2384
Merge branch 'poc/upe-instances-multiplied' of https://github.com/Aut…
Nov 11, 2022
b138c2c
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
Nov 11, 2022
672adb9
Fix post-merge tests failures - part I
Nov 11, 2022
3813235
Extend the token service with LINK support
Nov 11, 2022
c84178e
Fix post-merge tests failures - part II
Nov 11, 2022
c2d67f1
Decrease the complexity of initializing both legacy and UPE checkouts
Nov 14, 2022
15f08c7
Provide gateway to the UPE checkout
Nov 14, 2022
4a4d03c
Fix post-merge tests failures - part III
Nov 14, 2022
7115db4
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
Nov 14, 2022
6621a7e
Remove useless collections and variables after the PR review
Nov 15, 2022
6a483e2
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
Nov 15, 2022
a4222e7
Fix the failing test for UPE gateway
Nov 16, 2022
1bebfee
Fix card payment gateway hiding on the admin page
Nov 16, 2022
7beab2a
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
Nov 16, 2022
874ba03
Merge develop into poc/upe instances multiplied (#5082)
timur27 Nov 16, 2022
2b7b6cf
Revert "Merge develop into poc/upe instances multiplied (#5082)"
Nov 17, 2022
0731300
Merge branch 'merge-develop-into-poc/upe-instances-multiplied' into p…
Nov 17, 2022
9885a2c
Merge branch 'develop' into poc/upe-instances-multiplied
FangedParakeet Nov 17, 2022
6c320f1
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
Nov 21, 2022
7211d70
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
Nov 22, 2022
1cdee71
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
Nov 23, 2022
575c387
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
timur27 Nov 24, 2022
bd29334
Adjust request parameter name for new card method generation (#5168)
timur27 Nov 29, 2022
adce81c
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
timur27 Nov 30, 2022
cad0766
Fix fingerprint tests
timur27 Nov 30, 2022
119b3b6
Merge branch 'develop' of https://github.com/Automattic/woocommerce-p…
timur27 Dec 2, 2022
737b0f4
Increase the test coverage and fix failing tests (#5205)
timur27 Dec 5, 2022
54194f7
Merge branch 'develop' into poc/upe-instances-multiplied
timur27 Dec 6, 2022
4e08ba3
Skip adding cards as UPE methods (#5237)
mdmoore Dec 6, 2022
12d7858
Ensure SEPA token labels are capitalized (#5239)
mdmoore Dec 6, 2022
41b72c1
Assign callbacks to gateway-specific actions in the abstract checkout…
timur27 Dec 8, 2022
f6b0f51
Merge branch 'merge/develop-to-poc' into poc/upe-instances-multiplied
timur27 Dec 8, 2022
b5b8559
Merge branch 'develop' into poc/upe-instances-multiplied
timur27 Dec 8, 2022
4aba3b7
Merge branch 'develop' into poc/upe-instances-multiplied
timur27 Dec 9, 2022
5ac04a6
Merge branch 'develop' into poc/upe-instances-multiplied
Dec 14, 2022
176ac0c
Merge branch 'develop' into poc/upe-instances-multiplied
timur27 Dec 23, 2022
9e83a59
Use the correct key for blocks payment method registration (#5344)
timur27 Jan 2, 2023
2280a3f
Allow UPE methods to be saved during Blocks checkout (#5301)
mdmoore Jan 4, 2023
7c1dca4
Add icons to payment methods in blocks (#5381)
timur27 Jan 12, 2023
9ffe510
Display the platform checkout block when necessary (#5402)
timur27 Jan 16, 2023
87b9ac6
Fix margins on payment methods at checkout (#5422)
timur27 Jan 19, 2023
c7c5f6e
Merge branch 'develop' into poc/upe-instances-multiplied
Jan 20, 2023
9547544
Align tests
Jan 20, 2023
e0cfee0
Remove redundant variable
Jan 20, 2023
7f83c9a
Merge branch 'develop' into resolve/merge-conflicts-develop-split-upe
Jan 23, 2023
0f2b02a
Merge branch 'develop' into poc/upe-instances-multiplied
frosso Jan 25, 2023
ff3d99a
Improve the decision-making process to determine if the save option s…
timur27 Feb 2, 2023
3593c55
fix: add Link and WooPay compatibility tooltip (#5515)
frosso Feb 3, 2023
5d59c07
chore: changelog entry
frosso Feb 8, 2023
e86d679
Single separator for express checkout methods (#5520)
mdmoore Feb 8, 2023
5e9f9d4
Merge branch 'develop' into poc/upe-instances-multiplied
frosso Feb 9, 2023
76440e4
Fix credit card and UPE payments on the Pay for order page (#5513)
timur27 Feb 9, 2023
9111325
Adds and implements new separate feature flag for Split UPE feature (…
FangedParakeet Feb 13, 2023
ee3196a
Merge branch 'develop' into poc/upe-instances-multiplied
frosso Feb 13, 2023
ba9eccd
Make the new split UPE the default experience. (#5542)
frosso Feb 13, 2023
f32b82e
feat: add UPE REST controller tests (#5543)
frosso Feb 13, 2023
1d4974e
Merge branch 'develop' into poc/upe-instances-multiplied
frosso Feb 13, 2023
3d0b8b0
skip failing tests for now
frosso Feb 14, 2023
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: 6 additions & 1 deletion .github/workflows/e2e-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ jobs:
strategy:
fail-fast: false
matrix:
test_groups: [ 'wcpay', 'subscriptions' ] # [TODO] Unskip blocks tests after investigating constant failures.
test_groups: [ 'wcpay', 'subscriptions', 'upe', 'upeSplit' ] # [TODO] Unskip blocks tests after investigating constant failures.
test_branches: [ 'merchant', 'shopper' ]
exclude:
- test_groups: 'upe'
test_branches: 'merchant'
- test_groups: 'upeSplit'
test_branches: 'merchant'

name: WC - latest | ${{ matrix.test_groups }} - ${{ matrix.test_branches }}

Expand Down
40 changes: 40 additions & 0 deletions assets/images/payment-methods/cc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions changelog/split-upe
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

The UPE is now the default checkout experience for newly onboarded merchants. It can sbe disabled with these instructions: https://woocommerce.com/?p=3337362#disabling
72 changes: 45 additions & 27 deletions client/checkout/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ export default class WCPayAPI {
isStripeLinkEnabled,
} = this.options;

if ( forceNetworkSavedCards && ! forceAccountRequest ) {
if (
forceNetworkSavedCards &&
! forceAccountRequest &&
! isUPEEnabled
) {
if ( ! this.stripePlatform ) {
this.stripePlatform = this.createStripe(
publishableKey,
Expand Down Expand Up @@ -331,13 +335,17 @@ 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() {
return this.request(
buildAjaxURL( getConfig( 'wcAjaxUrl' ), 'init_setup_intent' ),
{ _ajax_nonce: getConfig( 'createSetupIntentNonce' ) }
).then( ( response ) => {
initSetupIntent( paymentMethodType = '' ) {
let path = 'init_setup_intent';
if ( this.options.isUPESplitEnabled && paymentMethodType ) {
path += `_${ paymentMethodType }`;
}
return this.request( buildAjaxURL( getConfig( 'wcAjaxUrl' ), path ), {
_ajax_nonce: getConfig( 'createSetupIntentNonce' ),
} ).then( ( response ) => {
if ( ! response.success ) {
throw response.data.error;
}
Expand Down Expand Up @@ -384,19 +392,28 @@ export default class WCPayAPI {
/**
* Creates an intent based on a payment method.
*
* @param {string} fingerprint User fingerprint.
* @param {int?} orderId The id of the order if creating the intent on Order Pay page.
* @param {Object} options Object containing intent optional parameters (fingerprint, paymentMethodType, orderId)
*
* @return {Promise} The final promise for the request to the server.
*/
createIntent( fingerprint = '', orderId ) {
createIntent( options ) {
const { fingerprint, paymentMethodType, orderId } = options;
let 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;
}

return this.request(
buildAjaxURL( getConfig( 'wcAjaxUrl' ), 'create_payment_intent' ),
{
wcpay_order_id: orderId,
_ajax_nonce: getConfig( 'createPaymentIntentNonce' ),
'wcpay-fingerprint': fingerprint,
}
buildAjaxURL( getConfig( 'wcAjaxUrl' ), path ),
params
)
.then( ( response ) => {
if ( ! response.success ) {
Expand Down Expand Up @@ -434,18 +451,19 @@ export default class WCPayAPI {
paymentCountry,
fingerprint
) {
return this.request(
buildAjaxURL( getConfig( 'wcAjaxUrl' ), 'update_payment_intent' ),
{
wcpay_order_id: orderId,
wc_payment_intent_id: paymentIntentId,
save_payment_method: savePaymentMethod,
wcpay_selected_upe_payment_type: selectedUPEPaymentType,
wcpay_payment_country: paymentCountry,
_ajax_nonce: getConfig( 'updatePaymentIntentNonce' ),
'wcpay-fingerprint': fingerprint,
}
)
let path = 'update_payment_intent';
if ( this.options.isUPESplitEnabled ) {
path += `_${ selectedUPEPaymentType }`;
}
return this.request( buildAjaxURL( getConfig( 'wcAjaxUrl' ), path ), {
wcpay_order_id: orderId,
wc_payment_intent_id: paymentIntentId,
save_payment_method: savePaymentMethod,
wcpay_selected_upe_payment_type: selectedUPEPaymentType,
wcpay_payment_country: paymentCountry,
_ajax_nonce: getConfig( 'updatePaymentIntentNonce' ),
'wcpay-fingerprint': fingerprint,
} )
.then( ( response ) => {
if ( 'failure' === response.result ) {
throw new Error( response.messages );
Expand Down
28 changes: 22 additions & 6 deletions client/checkout/blocks/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
CardElement,
} from '@stripe/react-stripe-js';
import { useEffect, useState } from '@wordpress/element';
import { getConfig } from 'utils/checkout';

/**
* Internal dependencies
Expand All @@ -30,6 +31,18 @@ const WCPayFields = ( {
shouldSavePayment,
} ) => {
const [ errorMessage, setErrorMessage ] = useState( null );
const isTestMode = getConfig( 'testMode' );
const testingInstructions = (
<p>
<strong>Test mode:</strong> use the test VISA card 4242424242424242
with any expiry date and CVC, or any test card numbers listed{ ' ' }
<a href="https://woocommerce.com/document/payments/testing/#test-cards">
here
</a>
.
</p>
);

const [ fingerprint, fingerprintErrorMessage ] = useFingerprint();

useEffect( () => {
Expand Down Expand Up @@ -92,12 +105,15 @@ const WCPayFields = ( {
};

return (
<div className="wc-block-gateway-container wc-inline-card-element">
<CardElement
options={ elementOptions }
onChange={ checkForErrors }
/>
</div>
<>
{ isTestMode ? testingInstructions : '' }
<div className="wc-block-gateway-container wc-inline-card-element">
<CardElement
options={ elementOptions }
onChange={ checkForErrors }
/>
</div>
</>
);
};

Expand Down
2 changes: 1 addition & 1 deletion client/checkout/blocks/generate-payment-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const generatePaymentMethod = async (
type: 'success',
meta: {
paymentMethodData: {
paymentMethod: PAYMENT_METHOD_NAME_CARD,
payment_method: PAYMENT_METHOD_NAME_CARD,
'wcpay-payment-method': id,
'wcpay-fraud-prevention-token': fraudPreventionToken ?? '',
'wcpay-fingerprint': fingerprint,
Expand Down
18 changes: 16 additions & 2 deletions client/checkout/blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,25 @@ registerPaymentMethod( {
savedTokenComponent: <SavedTokenHandler api={ api } />,
canMakePayment: () => !! api.getStripe(),
paymentMethodId: PAYMENT_METHOD_NAME_CARD,
label: __( 'Credit card', 'woocommerce-payments' ),
// see .wc-block-checkout__payment-method styles in blocks/style.scss
label: (
<>
<span>
{ __( 'Credit card', 'woocommerce-payments' ) }
<img
src={ getConfig( 'icon' ) }
alt={ __( 'Credit card', 'woocommerce-payments' ) }
/>
</span>
</>
),
ariaLabel: __( 'Credit card', 'woocommerce-payments' ),
supports: {
showSavedCards: getConfig( 'isSavedCardsEnabled' ) ?? false,
showSaveOption: getConfig( 'isSavedCardsEnabled' ) ?? false,
showSaveOption:
( getConfig( 'isSavedCardsEnabled' ) &&
! getConfig( 'isPlatformCheckoutEnabled' ) ) ??
false,
features: getConfig( 'features' ),
},
} );
Expand Down
12 changes: 12 additions & 0 deletions client/checkout/blocks/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,16 @@ button.wcpay-stripelink-modal-trigger:hover {
background-color: transparent;
border-color: transparent;
}

.wc-block-checkout__payment-method
.wc-block-components-radio-control__label
span {
width: 95%;

img {
float: right;
}
}

@import '../platform-checkout/style';
@import '../../components/loadable/style';
9 changes: 2 additions & 7 deletions client/checkout/blocks/upe-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,8 @@ const WCPayUPEFields = ( {
// Checks whether there are errors within a field, and saves them for later reporting.
const upeOnChange = ( event ) => {
// Update WC Blocks gateway config based on selected UPE payment method.
if (
getConfig( 'isSavedCardsEnabled' ) &&
! getConfig( 'cartContainsSubscription' )
) {
gatewayConfig.supports.showSaveOption =
paymentMethodsConfig[ event.value.type ].isReusable;
}
gatewayConfig.supports.showSaveOption =
paymentMethodsConfig[ event.value.type ].showSaveOption;

setIsUPEComplete( event.complete );
setSelectedUPEPaymentType( event.value.type );
Expand Down
Loading