Skip to content

Commit ab1536f

Browse files
annemirasolwjrosa
andauthored
Pre-fill user info for Link in the Payment Element (block checkout) (#3620)
* Prefill user email and phone for Link in the Payment Element * Add changelog and readme entries --------- Co-authored-by: Wesley Rosa <[email protected]>
1 parent a4e0bf6 commit ab1536f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
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+
* Add - Pre-fill user email and phone number for Link in the Payment Element and block checkout.
45
* Remove - Remove Link autofill modal feature.
56
* Update - Improve accuracy of webhook status information displayed in settings page.
67
* Tweak - Standardize ECE Express payment buttons on Pay for Order page to match cart and checkout itemization behavior.

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import {
2020
maybeShowCashAppLimitNotice,
2121
removeCashAppLimitNotice,
2222
} from 'wcstripe/stripe-utils/cash-app-limit-notice-handler';
23+
import { isLinkEnabled } from 'wcstripe/stripe-utils';
2324

2425
/**
2526
* Gets the Stripe element options.
2627
*
2728
* @return {Object} The Stripe element options.
2829
*/
2930
const getStripeElementOptions = () => {
30-
const options = {
31+
let options = {
3132
fields: {
3233
billingDetails: {
3334
name: 'never',
@@ -49,6 +50,26 @@ const getStripeElementOptions = () => {
4950
},
5051
};
5152

53+
// Prefill Link customer data if available.
54+
if ( isLinkEnabled() ) {
55+
const userEmail = document.getElementById( 'email' )?.value;
56+
if ( userEmail ) {
57+
const userPhone =
58+
document.getElementById( 'billing-phone' )?.value ||
59+
document.getElementById( 'shipping-phone' )?.value;
60+
61+
options = {
62+
...options,
63+
defaultValues: {
64+
billingDetails: {
65+
email: userEmail,
66+
phone: userPhone,
67+
},
68+
},
69+
};
70+
}
71+
}
72+
5273
return options;
5374
};
5475

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.0.0 - xxxx-xx-xx =
114+
* Add - Pre-fill user email and phone number for Link in the Payment Element and block checkout.
114115
* Remove - Remove Link autofill modal feature.
115116
* Update - Improve accuracy of webhook status information displayed in settings page.
116117
* Tweak - Standardize ECE Express payment buttons on Pay for Order page to match cart and checkout itemization behavior.

0 commit comments

Comments
 (0)