tf-checkout-react 1.7.8 → 1.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/paymentContainer/index.d.ts +2 -1
- package/dist/tf-checkout-react.cjs.development.js +42 -29
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +42 -29
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/billing-info-container/hooks/useStripePayment.ts +14 -16
- package/src/components/billing-info-container/index.tsx +3 -2
- package/src/components/paymentContainer/index.tsx +6 -1
package/package.json
CHANGED
|
@@ -36,20 +36,13 @@ export const useStripePayment = ({
|
|
|
36
36
|
if (!isFreeTickets) {
|
|
37
37
|
if (!stripeRef.current) {
|
|
38
38
|
setError('Stripe is not ready')
|
|
39
|
-
console.log('Stripe is not ready in billing-info-container')
|
|
40
39
|
return null
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
console.log('Stripe confirmPayment in billing-info-container')
|
|
44
|
-
|
|
45
42
|
// Step 1: Submit elements first
|
|
46
43
|
const { error: submitError } = await elementsRef.current.submit()
|
|
47
44
|
if (submitError) {
|
|
48
45
|
setError('' + submitError?.message)
|
|
49
|
-
console.log(
|
|
50
|
-
'Stripe elements.submit() error in billing-info-container',
|
|
51
|
-
submitError
|
|
52
|
-
)
|
|
53
46
|
return null
|
|
54
47
|
}
|
|
55
48
|
|
|
@@ -68,28 +61,33 @@ export const useStripePayment = ({
|
|
|
68
61
|
localStorage.setItem('stripe_payment_context', JSON.stringify(paymentContext))
|
|
69
62
|
|
|
70
63
|
// Step 3: Confirm payment with current page return URL
|
|
64
|
+
const confirmParams: any = {
|
|
65
|
+
return_url:
|
|
66
|
+
window.location.href +
|
|
67
|
+
(window.location.href.includes('?') ? '&' : '?') +
|
|
68
|
+
'payment_return=true',
|
|
69
|
+
}
|
|
70
|
+
if (values?.phone) {
|
|
71
|
+
const rawPhone = String(values.phone).replace(/[\s\-().]/g, '')
|
|
72
|
+
const e164Phone = rawPhone.startsWith('+') ? rawPhone : `+${rawPhone}`
|
|
73
|
+
confirmParams.payment_method_data = {
|
|
74
|
+
billing_details: { phone: e164Phone },
|
|
75
|
+
}
|
|
76
|
+
}
|
|
71
77
|
const { error: confirmError } = await stripeRef.current.confirmPayment({
|
|
72
78
|
clientSecret:
|
|
73
79
|
paymentDataResponse.data.attributes.payment_method.stripe_client_secret,
|
|
74
80
|
elements: elementsRef.current,
|
|
75
|
-
confirmParams
|
|
76
|
-
return_url:
|
|
77
|
-
window.location.href +
|
|
78
|
-
(window.location.href.includes('?') ? '&' : '?') +
|
|
79
|
-
'payment_return=true',
|
|
80
|
-
},
|
|
81
|
+
confirmParams,
|
|
81
82
|
redirect: 'if_required',
|
|
82
83
|
})
|
|
83
84
|
|
|
84
85
|
if (confirmError) {
|
|
85
86
|
setError('' + confirmError?.message)
|
|
86
|
-
console.log('Stripe confirmPayment error in billing-info-container')
|
|
87
87
|
return null
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
console.log('Stripe confirmPayment success in billing-info-container')
|
|
92
|
-
|
|
93
91
|
// Handle payment middleware for non-redirect payments
|
|
94
92
|
let paymentResponse = null
|
|
95
93
|
await handlePaymentMiddleWare(
|
|
@@ -517,7 +517,7 @@ const BillingInfoContainer = React.memo(
|
|
|
517
517
|
const orderIsFree = !Number(checkoutData?.total)
|
|
518
518
|
|
|
519
519
|
useEffect(() => {
|
|
520
|
-
const hasUniqueId = _get(
|
|
520
|
+
const hasUniqueId = _get(data, '[0].uniqueId')
|
|
521
521
|
const isEqualData = _isEqual(prevData.current, data)
|
|
522
522
|
if (!hasUniqueId || !isEqualData) {
|
|
523
523
|
setDataWithUniqueIds(assingUniqueIds(data))
|
|
@@ -525,7 +525,7 @@ const BillingInfoContainer = React.memo(
|
|
|
525
525
|
prevData.current = data
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
}, [
|
|
528
|
+
}, [data])
|
|
529
529
|
|
|
530
530
|
const getQuantity = useCallback((cart: any = []) => {
|
|
531
531
|
let qty = 0
|
|
@@ -1575,6 +1575,7 @@ const BillingInfoContainer = React.memo(
|
|
|
1575
1575
|
checkoutData={checkoutData}
|
|
1576
1576
|
elementsOptions={elementsOptions}
|
|
1577
1577
|
paymentElementOptions={{
|
|
1578
|
+
fields: { billingDetails: { phone: 'never' } },
|
|
1578
1579
|
wallets: {
|
|
1579
1580
|
applePay:
|
|
1580
1581
|
checkoutUpdateData?.additional_payment_information
|
|
@@ -43,9 +43,11 @@ import { PaymentPlanSection } from './PaymentPlanSection'
|
|
|
43
43
|
const StripeWrapper = ({
|
|
44
44
|
options,
|
|
45
45
|
onStripeReady,
|
|
46
|
+
onPaymentElementChange,
|
|
46
47
|
}: {
|
|
47
48
|
options?: StripePaymentElementOptions;
|
|
48
49
|
onStripeReady: (stripe: any, elements: any) => void;
|
|
50
|
+
onPaymentElementChange?: (event: any) => void;
|
|
49
51
|
}) => {
|
|
50
52
|
const stripe = useStripe()
|
|
51
53
|
const elements = useElements()
|
|
@@ -56,7 +58,7 @@ const StripeWrapper = ({
|
|
|
56
58
|
}
|
|
57
59
|
}, [stripe, elements, onStripeReady])
|
|
58
60
|
|
|
59
|
-
return <PaymentElement options={options} />
|
|
61
|
+
return <PaymentElement options={options} onChange={onPaymentElementChange} />
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
export interface IPaymentPage {
|
|
@@ -86,6 +88,7 @@ export interface IPaymentPage {
|
|
|
86
88
|
stripePublishableKey?: string;
|
|
87
89
|
stripeAccountId?: string;
|
|
88
90
|
onStripeReady?: (stripe: any, elements: any) => void;
|
|
91
|
+
onPaymentElementChange?: (event: any) => void;
|
|
89
92
|
enablePaymentPlan?: boolean;
|
|
90
93
|
}
|
|
91
94
|
|
|
@@ -166,6 +169,7 @@ export const PaymentContainer = ({
|
|
|
166
169
|
stripePublishableKey,
|
|
167
170
|
stripeAccountId,
|
|
168
171
|
onStripeReady = _identity,
|
|
172
|
+
onPaymentElementChange,
|
|
169
173
|
enablePaymentPlan = true,
|
|
170
174
|
}: IPaymentPage) => {
|
|
171
175
|
const [reviewData, setReviewData] = useState(initialReviewValues)
|
|
@@ -599,6 +603,7 @@ export const PaymentContainer = ({
|
|
|
599
603
|
<StripeWrapper
|
|
600
604
|
onStripeReady={onStripeReady}
|
|
601
605
|
options={paymentElementOptions}
|
|
606
|
+
onPaymentElementChange={onPaymentElementChange}
|
|
602
607
|
/>
|
|
603
608
|
</Elements>
|
|
604
609
|
)}
|