tf-checkout-react 1.6.6-beta.27 → 1.6.6-beta.29
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/addonsContainer/SimpleAddonsContainer.d.ts +1 -1
- package/dist/components/addonsContainer/index.d.ts +1 -1
- package/dist/components/billing-info-container/index.d.ts +1 -0
- package/dist/components/myTicketsContainer/index.d.ts +3 -2
- package/dist/components/paymentContainer/OrderDetails.d.ts +7 -1
- package/dist/components/paymentContainer/index.d.ts +2 -1
- package/dist/tf-checkout-react.cjs.development.js +310 -157
- 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 +310 -157
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/tf-checkout-styles.css +1 -1
- package/dist/utils/getDomain.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/addonsContainer/SimpleAddonsContainer.tsx +4 -0
- package/src/components/addonsContainer/index.tsx +4 -0
- package/src/components/billing-info-container/index.tsx +84 -27
- package/src/components/common/SnackbarAlert.tsx +32 -34
- package/src/components/loginModal/style.css +3 -1
- package/src/components/myTicketsContainer/index.tsx +12 -8
- package/src/components/paymentContainer/OrderDetails.tsx +43 -3
- package/src/components/paymentContainer/index.tsx +25 -23
- package/src/components/paymentContainer/style.css +113 -0
- package/src/types/api/payment.d.ts +2 -2
- package/src/utils/cookies.ts +43 -12
- package/src/utils/getDomain.ts +10 -4
|
@@ -20,7 +20,7 @@ import _identity from 'lodash/identity'
|
|
|
20
20
|
import _isEmpty from 'lodash/isEmpty'
|
|
21
21
|
import _map from 'lodash/map'
|
|
22
22
|
import { nanoid } from 'nanoid'
|
|
23
|
-
import React, { useEffect, useMemo, useState } from 'react'
|
|
23
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
24
24
|
|
|
25
25
|
import { getConditions, getPaymentData } from '../../api'
|
|
26
26
|
import { FEES_STYLES } from '../../constants'
|
|
@@ -41,21 +41,6 @@ import { PaymentPlanSection } from './PaymentPlanSection'
|
|
|
41
41
|
|
|
42
42
|
const publishableKey = CONFIGS.STRIPE_PUBLISHABLE_KEY || ''
|
|
43
43
|
|
|
44
|
-
const getStripePromise = (reviewData: any) => {
|
|
45
|
-
const stripePublishableKey =
|
|
46
|
-
_get(reviewData, 'payment_method.stripe_publishable_key') ||
|
|
47
|
-
publishableKey ||
|
|
48
|
-
'pk_test_3Ov1P1oP33A1cxaSjxWE0VjT'
|
|
49
|
-
const stripeAccount = _get(reviewData, 'payment_method.stripe_connected_account')
|
|
50
|
-
|
|
51
|
-
const options: StripeConstructorOptions = {}
|
|
52
|
-
if (stripeAccount) {
|
|
53
|
-
options.stripeAccount = stripeAccount
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return loadStripe(stripePublishableKey, options)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
44
|
export interface IPaymentPage {
|
|
60
45
|
paymentFields: IPaymentField[];
|
|
61
46
|
handlePayment: any;
|
|
@@ -81,6 +66,7 @@ export interface IPaymentPage {
|
|
|
81
66
|
hideFieldsBlock?: boolean;
|
|
82
67
|
isSinglePageCheckout?: boolean;
|
|
83
68
|
stripePaymentProps?: Partial<ICheckoutForm>;
|
|
69
|
+
stripePublishableKey?: string;
|
|
84
70
|
}
|
|
85
71
|
|
|
86
72
|
const initialPaymentPlanConfiguration: IPaymentPlanConfig = {
|
|
@@ -124,6 +110,7 @@ const initialReviewValues = {
|
|
|
124
110
|
stripe_client_secret: '',
|
|
125
111
|
stripe_payment_plan_enabled: false,
|
|
126
112
|
stripe_payment_plan_configuration: {} as any,
|
|
113
|
+
stripe_publishable_key: '',
|
|
127
114
|
},
|
|
128
115
|
billing_info: {},
|
|
129
116
|
event_details: {
|
|
@@ -154,6 +141,7 @@ export const PaymentContainer = ({
|
|
|
154
141
|
hideFieldsBlock = false,
|
|
155
142
|
isSinglePageCheckout = false,
|
|
156
143
|
stripePaymentProps = {},
|
|
144
|
+
stripePublishableKey: stripePublishableKeyProps,
|
|
157
145
|
}: IPaymentPage) => {
|
|
158
146
|
const [reviewData, setReviewData] = useState(initialReviewValues)
|
|
159
147
|
const [orderData, setOrderData] = useState(initialOrderValues)
|
|
@@ -219,9 +207,11 @@ export const PaymentContainer = ({
|
|
|
219
207
|
}, [showPaymentPlanSection, paymentPlanUseSavedCard, orderData?.id])
|
|
220
208
|
|
|
221
209
|
useEffect(() => {
|
|
222
|
-
if (isSinglePageCheckout
|
|
223
|
-
|
|
224
|
-
|
|
210
|
+
if (isSinglePageCheckout) {
|
|
211
|
+
if (!orderData?.total) {
|
|
212
|
+
setOrderData(current => ({ ...current, pay_now: 1, total: 1 }))
|
|
213
|
+
setPaymentDataIsLoading(false)
|
|
214
|
+
}
|
|
225
215
|
return
|
|
226
216
|
}
|
|
227
217
|
(async () => {
|
|
@@ -320,6 +310,21 @@ export const PaymentContainer = ({
|
|
|
320
310
|
return showPaymentForm
|
|
321
311
|
}
|
|
322
312
|
|
|
313
|
+
const getStripePromise = useCallback(() => {
|
|
314
|
+
const stripePublishableKey =
|
|
315
|
+
stripePublishableKeyProps ||
|
|
316
|
+
_get(reviewData, 'payment_method.stripe_publishable_key') ||
|
|
317
|
+
publishableKey
|
|
318
|
+
const stripeAccount = _get(reviewData, 'payment_method.stripe_connected_account')
|
|
319
|
+
|
|
320
|
+
const options: StripeConstructorOptions = {}
|
|
321
|
+
if (stripeAccount) {
|
|
322
|
+
options.stripeAccount = stripeAccount
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return loadStripe(stripePublishableKey, options)
|
|
326
|
+
}, [reviewData, stripePublishableKeyProps])
|
|
327
|
+
|
|
323
328
|
const themeMui = createTheme(themeOptions)
|
|
324
329
|
const hasTableTypes = Boolean(Number(orderData.guest_count))
|
|
325
330
|
const paymentFieldsData = hasTableTypes
|
|
@@ -541,10 +546,7 @@ export const PaymentContainer = ({
|
|
|
541
546
|
<div className="payment_info_label">{paymentInfoLabel}</div>
|
|
542
547
|
{showErrorText && <p className="payment_info__error">{errorText}</p>}
|
|
543
548
|
<div>
|
|
544
|
-
<Elements
|
|
545
|
-
stripe={getStripePromise(reviewData)}
|
|
546
|
-
options={elementsOptions}
|
|
547
|
-
>
|
|
549
|
+
<Elements stripe={getStripePromise()} options={elementsOptions}>
|
|
548
550
|
<StripePayment
|
|
549
551
|
stripe_client_secret={
|
|
550
552
|
paymentPlanIsAvailable && showPaymentPlanSection
|
|
@@ -52,4 +52,117 @@
|
|
|
52
52
|
|
|
53
53
|
.payment_page .payment_plan .payment_plan_highlight {
|
|
54
54
|
font-weight: bold;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/* Default styles - mobile section is hidden on desktop */
|
|
59
|
+
.mobile-order-summary {
|
|
60
|
+
display: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Mobile-specific styles */
|
|
64
|
+
@media (max-width: 767px) {
|
|
65
|
+
/* Show mobile summary on mobile devices */
|
|
66
|
+
.mobile-order-summary {
|
|
67
|
+
display: block;
|
|
68
|
+
margin-bottom: 15px;
|
|
69
|
+
background-color: #f8f8f8;
|
|
70
|
+
border-radius: 8px;
|
|
71
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.mobile-order-summary-content {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: flex-start;
|
|
77
|
+
padding: 15px;
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.mobile-order-info-container:after {
|
|
82
|
+
display: inline-block;
|
|
83
|
+
content: "⌃";
|
|
84
|
+
font-weight: 900;
|
|
85
|
+
font-size: 15px;
|
|
86
|
+
top: -2px;
|
|
87
|
+
left: 6px;
|
|
88
|
+
float: right;
|
|
89
|
+
position: relative;
|
|
90
|
+
transform: rotate(180deg);
|
|
91
|
+
transition: transform 0.25s, top 0.25s;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.mobile-order-info-container.open:after {
|
|
95
|
+
top: 2px;
|
|
96
|
+
transform: rotate(0deg);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.mobile-order-info-container.order-info-container-left {
|
|
100
|
+
text-align: left;
|
|
101
|
+
}
|
|
102
|
+
.mobile-order-info-container.order-info-container-right {
|
|
103
|
+
text-align: right;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
.mobile-order-icon {
|
|
108
|
+
margin-right: 15px;
|
|
109
|
+
color: #1976d2;
|
|
110
|
+
padding-top: 2px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.mobile-order-info {
|
|
114
|
+
flex: 1;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.mobile-order-text {
|
|
118
|
+
font-size: 14px;
|
|
119
|
+
color: #666;
|
|
120
|
+
margin-bottom: 4px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.mobile-order-total {
|
|
124
|
+
font-size: 18px;
|
|
125
|
+
font-weight: bold;
|
|
126
|
+
color: #333;
|
|
127
|
+
margin-bottom: 8px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.mobile-order-timer {
|
|
131
|
+
display: flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
margin-top: 8px;
|
|
134
|
+
padding-top: 8px;
|
|
135
|
+
border-top: 1px dashed #ddd;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.mobile-timer-icon {
|
|
139
|
+
margin-right: 8px;
|
|
140
|
+
color: #f44336;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.mobile-timer-text {
|
|
144
|
+
font-size: 13px;
|
|
145
|
+
color: #666;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.mobile-timer-countdown {
|
|
149
|
+
font-weight: bold;
|
|
150
|
+
color: #f44336;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.mobile-order-expand {
|
|
154
|
+
color: #666;
|
|
155
|
+
padding-top: 2px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* Hide the original content when collapsed on mobile */
|
|
159
|
+
.order_info_section.collapsed {
|
|
160
|
+
display: none !important;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Show the original content when expanded on mobile */
|
|
164
|
+
.order_info_section.expanded {
|
|
165
|
+
display: grid !important;
|
|
166
|
+
margin-top: 10px;
|
|
167
|
+
}
|
|
55
168
|
}
|
|
@@ -37,7 +37,7 @@ interface IPaymentMethodData {
|
|
|
37
37
|
stripe_payment_plan_enabled: boolean;
|
|
38
38
|
stripe_payment_plan_configuration: any;
|
|
39
39
|
stripeConnectedAccount: string;
|
|
40
|
-
|
|
40
|
+
stripe_publishable_key: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
interface IShippingBillingInfoData {
|
|
@@ -174,4 +174,4 @@ interface ICheckoutCompleteDataResponse extends IAxiosResponseData {
|
|
|
174
174
|
relationships: Array<unknown>;
|
|
175
175
|
type: string;
|
|
176
176
|
};
|
|
177
|
-
}
|
|
177
|
+
}
|
package/src/utils/cookies.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { getDomain } from
|
|
1
|
+
import { getDomain } from './getDomain'
|
|
2
|
+
|
|
3
|
+
let generalDomain: string
|
|
2
4
|
|
|
3
5
|
export function setCustomCookie(name: string, value: string, days = 5) {
|
|
4
6
|
let expires = ''
|
|
@@ -7,11 +9,25 @@ export function setCustomCookie(name: string, value: string, days = 5) {
|
|
|
7
9
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)
|
|
8
10
|
expires = '; expires=' + date.toUTCString()
|
|
9
11
|
}
|
|
10
|
-
if (typeof window
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (typeof window === 'undefined') {
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { hostname } = window.location
|
|
17
|
+
|
|
18
|
+
if (generalDomain && generalDomain.endsWith(getDomain(hostname))) {
|
|
19
|
+
document.cookie = name + '=' + (value || '') + expires + `; path=/;domain=${generalDomain}`
|
|
20
|
+
return
|
|
14
21
|
}
|
|
22
|
+
|
|
23
|
+
let previousDomain = undefined
|
|
24
|
+
let domain = undefined
|
|
25
|
+
do {
|
|
26
|
+
previousDomain = domain
|
|
27
|
+
domain = getDomain(hostname, undefined, previousDomain)
|
|
28
|
+
document.cookie = name + '=' + (value || '') + expires + `; path=/;domain=${domain}`
|
|
29
|
+
} while (getCookieByName(name) === '' && hostname !== domain)
|
|
30
|
+
generalDomain = domain
|
|
15
31
|
}
|
|
16
32
|
|
|
17
33
|
export function getCookieByName(cname: string) {
|
|
@@ -31,12 +47,27 @@ export function getCookieByName(cname: string) {
|
|
|
31
47
|
}
|
|
32
48
|
|
|
33
49
|
export function deleteCookieByName(name: string) {
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
document.cookie =
|
|
37
|
-
name +
|
|
38
|
-
'=; Path=/' +
|
|
39
|
-
`; domain=${domain}` +
|
|
40
|
-
'; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
|
|
50
|
+
if (getCookieByName(name) === '') {
|
|
51
|
+
return
|
|
41
52
|
}
|
|
53
|
+
|
|
54
|
+
if (typeof window === 'undefined') {
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const { hostname } = window.location
|
|
59
|
+
|
|
60
|
+
if (generalDomain && generalDomain.endsWith(getDomain(hostname))) {
|
|
61
|
+
document.cookie = name + `=; Path=/;domain=${generalDomain}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let previousDomain = undefined
|
|
66
|
+
let domain = undefined
|
|
67
|
+
do {
|
|
68
|
+
previousDomain = domain
|
|
69
|
+
domain = getDomain(hostname, undefined, previousDomain)
|
|
70
|
+
document.cookie = name + `=; Path=/;domain=${domain}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`
|
|
71
|
+
} while (getCookieByName(name) !== '' && hostname !== domain)
|
|
72
|
+
generalDomain = domain
|
|
42
73
|
}
|
package/src/utils/getDomain.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
export function getDomain(url: string, subdomain?: string): string {
|
|
1
|
+
export function getDomain(url: string, subdomain?: string, publicSuffix?: string): string {
|
|
2
2
|
let updatedUrl: any = url.replace(/(https?:\/\/)?(www.)?/i, '')
|
|
3
3
|
|
|
4
4
|
if (!subdomain) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
if (publicSuffix) {
|
|
6
|
+
const updatedPublicSuffix = publicSuffix.startsWith('.') ? publicSuffix : '.' + publicSuffix
|
|
7
|
+
updatedUrl = url.replace(updatedPublicSuffix, '').split('.')
|
|
8
|
+
updatedUrl = updatedUrl.length > 0 ? updatedUrl[updatedUrl.length - 1] : ''
|
|
9
|
+
updatedUrl += updatedPublicSuffix
|
|
10
|
+
} else {
|
|
11
|
+
updatedUrl = updatedUrl.split(".")
|
|
12
|
+
updatedUrl = updatedUrl.slice(updatedUrl.length - 2).join(".")
|
|
13
|
+
}
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
if (updatedUrl.indexOf('/') !== -1) {
|