Skip to content

Commit f1da2be

Browse files
authored
Remove Link Autofill (#3613)
* Remove Link autofill code * Add changelog and readme entries
1 parent 5040f12 commit f1da2be

File tree

7 files changed

+6
-313
lines changed

7 files changed

+6
-313
lines changed

changelog.txt

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

33
= 9.0.0 - xxxx-xx-xx =
4+
* Remove - Remove Link autofill modal feature.
45
* Update - Improve accuracy of webhook status information displayed in settings page.
56
* Tweak - Standardize ECE Express payment buttons on Pay for Order page to match cart and checkout itemization behavior.
67
* Tweak - Remove duplicate notice about the new checkout experience.

client/api/index.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* global Stripe */
22
import { __ } from '@wordpress/i18n';
3-
import { isLinkEnabled } from 'wcstripe/stripe-utils';
43
import {
54
getExpressCheckoutData,
65
getExpressCheckoutAjaxURL,
@@ -64,20 +63,9 @@ export default class WCStripeAPI {
6463
* @return {Object} The Stripe Object.
6564
*/
6665
getStripe() {
67-
const {
68-
key,
69-
locale,
70-
isUPEEnabled,
71-
paymentMethodsConfig,
72-
} = this.options;
66+
const { key, locale } = this.options;
7367
if ( ! this.stripe ) {
74-
if ( isUPEEnabled && isLinkEnabled( paymentMethodsConfig ) ) {
75-
this.stripe = this.createStripe( key, locale, [
76-
'link_autofill_modal_beta_1',
77-
] );
78-
} else {
79-
this.stripe = this.createStripe( key, locale );
80-
}
68+
this.stripe = this.createStripe( key, locale );
8169
}
8270
return this.stripe;
8371
}

client/blocks/upe/hooks.js

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { useEffect } from '@wordpress/element';
22
import { useSelect, useDispatch } from '@wordpress/data';
33
import confirmCardPayment from './confirm-card-payment.js';
4-
import enableStripeLinkPaymentMethod from 'wcstripe/stripe-link';
54
import { WC_STORE_CART } from 'wcstripe/blocks/credit-card/constants';
6-
import { isLinkEnabled } from 'wcstripe/stripe-utils';
75

86
/**
97
* Handles the Block Checkout onCheckoutSuccess event.
@@ -80,103 +78,6 @@ export const usePaymentFailHandler = (
8078
);
8179
};
8280

83-
/**
84-
* Handles rendering the Block Checkout Stripe Link payment method.
85-
*
86-
* @param {*} api The api object.
87-
* @param {*} elements The Stripe elements object.
88-
* @param {*} paymentMethodsConfig The payment methods config object. Used to determine if Stripe Link is enabled.
89-
*/
90-
export const useStripeLink = ( api, elements, paymentMethodsConfig ) => {
91-
const customerData = useCustomerData();
92-
useEffect( () => {
93-
if ( isLinkEnabled( paymentMethodsConfig ) ) {
94-
const shippingAddressFields = {
95-
line1: 'shipping-address_1',
96-
line2: 'shipping-address_2',
97-
city: 'shipping-city',
98-
state: 'components-form-token-input-1',
99-
postal_code: 'shipping-postcode',
100-
country: 'components-form-token-input-0',
101-
first_name: 'shipping-first_name',
102-
last_name: 'shipping-last_name',
103-
};
104-
const billingAddressFields = {
105-
line1: 'billing-address_1',
106-
line2: 'billing-address_2',
107-
city: 'billing-city',
108-
state: 'components-form-token-input-3',
109-
postal_code: 'billing-postcode',
110-
country: 'components-form-token-input-2',
111-
first_name: 'billing-first_name',
112-
last_name: 'billing-last_name',
113-
};
114-
115-
enableStripeLinkPaymentMethod( {
116-
api,
117-
elements,
118-
emailId: 'email',
119-
fill_field_method: ( address, nodeId, key ) => {
120-
const setAddress =
121-
shippingAddressFields[ key ] === nodeId
122-
? customerData.setShippingAddress
123-
: customerData.setBillingAddress;
124-
const customerAddress =
125-
shippingAddressFields[ key ] === nodeId
126-
? customerData.shippingAddress
127-
: customerData.billingAddress;
128-
129-
if ( undefined === customerAddress ) {
130-
return;
131-
}
132-
133-
if ( address.address[ key ] === null ) {
134-
address.address[ key ] = '';
135-
}
136-
137-
if ( key === 'line1' ) {
138-
customerAddress.address_1 = address.address[ key ];
139-
} else if ( key === 'line2' ) {
140-
customerAddress.address_2 = address.address[ key ];
141-
} else if ( key === 'postal_code' ) {
142-
customerAddress.postcode = address.address[ key ];
143-
} else {
144-
customerAddress[ key ] = address.address[ key ];
145-
}
146-
147-
if ( undefined !== customerData.billingAddress ) {
148-
customerAddress.email = getEmail();
149-
}
150-
151-
setAddress( customerAddress );
152-
153-
function getEmail() {
154-
return document.getElementById( 'email' ).value;
155-
}
156-
157-
customerData.billingAddress.email = getEmail();
158-
customerData.setBillingAddress(
159-
customerData.billingAddress
160-
);
161-
},
162-
complete_shipping: () => {
163-
return (
164-
document.getElementById( 'shipping-address_1' ) !== null
165-
);
166-
},
167-
shipping_fields: shippingAddressFields,
168-
billing_fields: billingAddressFields,
169-
complete_billing: () => {
170-
return (
171-
document.getElementById( 'billing-address_1' ) !== null
172-
);
173-
},
174-
} );
175-
}
176-
// eslint-disable-next-line react-hooks/exhaustive-deps
177-
}, [ elements ] );
178-
};
179-
18081
/**
18182
* Returns the customer data and setters for the customer data.
18283
*

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import { useEffect, useState } from 'react';
1313
/**
1414
* Internal dependencies
1515
*/
16-
import {
17-
usePaymentCompleteHandler,
18-
usePaymentFailHandler,
19-
useStripeLink,
20-
} from '../hooks';
16+
import { usePaymentCompleteHandler, usePaymentFailHandler } from '../hooks';
2117
import { getBlocksConfiguration } from 'wcstripe/blocks/utils';
2218
import WCStripeAPI from 'wcstripe/api';
2319
import {
@@ -268,8 +264,6 @@ const PaymentProcessor = ( {
268264
emitResponse
269265
);
270266

271-
useStripeLink( api, elements, paymentMethodsConfig );
272-
273267
const onSelectedPaymentMethodChange = ( { value, complete } ) => {
274268
setSelectedPaymentMethodType( value.type );
275269
setIsPaymentElementComplete( complete );

client/classic/upe/deferred-intent.js

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import jQuery from 'jquery';
22
import WCStripeAPI from '../../api';
33
import {
44
generateCheckoutEventNames,
5-
getPaymentMethodTypes,
65
getSelectedUPEGatewayPaymentMethod,
76
getStripeServerData,
87
isPaymentMethodRestrictedToLocation,
@@ -17,7 +16,6 @@ import {
1716
mountStripePaymentElement,
1817
processPayment,
1918
} from './payment-processing';
20-
import enableStripeLinkPaymentMethod from 'wcstripe/stripe-link';
2119

2220
jQuery( function ( $ ) {
2321
// Create an API object, which will be used throughout the checkout.
@@ -89,69 +87,12 @@ jQuery( function ( $ ) {
8987
for ( const upeElement of $(
9088
'.wc-stripe-upe-element'
9189
).toArray() ) {
92-
const component = await mountStripePaymentElement(
93-
api,
94-
upeElement
95-
);
90+
await mountStripePaymentElement( api, upeElement );
9691
restrictPaymentMethodToLocation( upeElement );
97-
maybeEnableStripeLinkPaymentMethod(
98-
component.elements,
99-
upeElement.dataset.paymentMethodType
100-
);
10192
}
10293
}
10394
}
10495

105-
function maybeEnableStripeLinkPaymentMethod( elements, paymentMethodType ) {
106-
const isCheckout = getStripeServerData()?.isCheckout;
107-
if ( ! isCheckout ) {
108-
return;
109-
}
110-
111-
if ( paymentMethodType !== 'card' ) {
112-
return;
113-
}
114-
115-
const isStripeLinkEnabled = getPaymentMethodTypes(
116-
paymentMethodType
117-
).includes( 'link' );
118-
if ( ! isStripeLinkEnabled ) {
119-
return;
120-
}
121-
122-
enableStripeLinkPaymentMethod( {
123-
api,
124-
elements,
125-
emailId: 'billing_email',
126-
complete_billing: () => {
127-
return document.getElementById( 'billing_address_1' ) !== null;
128-
},
129-
complete_shipping: () => {
130-
return document.getElementById( 'shipping_address_1' ) !== null;
131-
},
132-
shipping_fields: {
133-
line1: 'shipping_address_1',
134-
line2: 'shipping_address_2',
135-
city: 'shipping_city',
136-
state: 'shipping_state',
137-
postal_code: 'shipping_postcode',
138-
country: 'shipping_country',
139-
first_name: 'shipping_first_name',
140-
last_name: 'shipping_last_name',
141-
},
142-
billing_fields: {
143-
line1: 'billing_address_1',
144-
line2: 'billing_address_2',
145-
city: 'billing_city',
146-
state: 'billing_state',
147-
postal_code: 'billing_postcode',
148-
country: 'billing_country',
149-
first_name: 'billing_first_name',
150-
last_name: 'billing_last_name',
151-
},
152-
} );
153-
}
154-
15596
function restrictPaymentMethodToLocation( upeElement ) {
15697
if ( isPaymentMethodRestrictedToLocation( upeElement ) ) {
15798
togglePaymentMethodForCountry( upeElement );

client/stripe-link/index.js

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)