tf-checkout-react 1.0.99 → 1.0.100-beta.2

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.
Files changed (117) hide show
  1. package/README.md +278 -1
  2. package/dist/api/index.d.ts +31 -26
  3. package/dist/components/account-settings/index.d.ts +3 -0
  4. package/dist/components/billing-info-container/index.d.ts +5 -5
  5. package/dist/components/billing-info-container/utils.d.ts +1 -0
  6. package/dist/components/common/CustomField.d.ts +1 -1
  7. package/dist/components/common/DatePickerField.d.ts +14 -0
  8. package/dist/components/common/RedirectModal.d.ts +7 -0
  9. package/dist/components/common/SnackbarAlert.d.ts +13 -0
  10. package/dist/components/confirmationContainer/index.d.ts +2 -1
  11. package/dist/components/countdown/index.d.ts +4 -1
  12. package/dist/components/myTicketsContainer/tableConfig.d.ts +0 -1
  13. package/dist/components/orderDetailsContainer/index.d.ts +5 -1
  14. package/dist/components/orderDetailsContainer/ticketsTable.d.ts +4 -1
  15. package/dist/components/paymentContainer/index.d.ts +3 -1
  16. package/dist/components/rsvpContainer/index.d.ts +7 -0
  17. package/dist/components/stripePayment/index.d.ts +2 -1
  18. package/dist/components/ticketResale/index.d.ts +5 -3
  19. package/dist/components/ticketsContainer/AccessCodeSection.d.ts +7 -0
  20. package/dist/components/ticketsContainer/PromoCodeSection.d.ts +6 -9
  21. package/dist/components/ticketsContainer/TicketsSection.d.ts +5 -3
  22. package/dist/components/ticketsContainer/index.d.ts +13 -2
  23. package/dist/components/timerWidget/index.d.ts +3 -3
  24. package/dist/env.d.ts +1 -0
  25. package/dist/images/cross.svg +44 -0
  26. package/dist/images/done.svg +3 -3
  27. package/dist/index.d.ts +2 -0
  28. package/dist/tf-checkout-react.cjs.development.js +1400 -575
  29. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  30. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  31. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  32. package/dist/tf-checkout-react.esm.js +1409 -586
  33. package/dist/tf-checkout-react.esm.js.map +1 -1
  34. package/dist/tf-checkout-styles.css +1 -1
  35. package/dist/utils/cookies.d.ts +3 -0
  36. package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +6 -1
  37. package/dist/utils/downloadPDF.d.ts +1 -1
  38. package/dist/utils/getDomain.d.ts +1 -0
  39. package/dist/utils/index.d.ts +2 -0
  40. package/package.json +89 -89
  41. package/src/.DS_Store +0 -0
  42. package/src/.d.ts +2 -2
  43. package/src/api/index.ts +313 -278
  44. package/src/assets/images/cross.svg +44 -0
  45. package/src/assets/images/done.svg +3 -3
  46. package/src/components/.DS_Store +0 -0
  47. package/src/components/account-settings/index.tsx +161 -0
  48. package/src/components/account-settings/style.css +200 -0
  49. package/src/components/billing-info-container/index.tsx +821 -777
  50. package/src/components/billing-info-container/style.css +106 -106
  51. package/src/components/billing-info-container/utils.ts +233 -223
  52. package/src/components/common/CheckboxField.tsx +41 -41
  53. package/src/components/common/CustomField.tsx +87 -84
  54. package/src/components/common/DatePickerField.tsx +98 -0
  55. package/src/components/common/FormikPhoneNumberField.tsx +51 -51
  56. package/src/components/common/Loader.tsx +9 -9
  57. package/src/components/common/RadioField.tsx +35 -35
  58. package/src/components/common/RedirectModal.tsx +43 -0
  59. package/src/components/common/SelectField.tsx +80 -80
  60. package/src/components/common/SnackbarAlert.tsx +54 -0
  61. package/src/components/common/dist/PhoneNumberField.js +96 -0
  62. package/src/components/common/index.tsx +4 -4
  63. package/src/components/confirmModal/index.tsx +51 -51
  64. package/src/components/confirmModal/style.css +21 -21
  65. package/src/components/confirmationContainer/config.ts +72 -72
  66. package/src/components/confirmationContainer/index.tsx +197 -194
  67. package/src/components/confirmationContainer/social-buttons.tsx +94 -94
  68. package/src/components/confirmationContainer/style.css +202 -202
  69. package/src/components/countdown/index.tsx +100 -89
  70. package/src/components/countdown/style.css +9 -9
  71. package/src/components/index.ts +7 -7
  72. package/src/components/loginModal/index.tsx +171 -209
  73. package/src/components/loginModal/style.css +71 -71
  74. package/src/components/myTicketsContainer/index.tsx +201 -137
  75. package/src/components/myTicketsContainer/row.tsx +41 -41
  76. package/src/components/myTicketsContainer/style.css +40 -40
  77. package/src/components/myTicketsContainer/tableConfig.tsx +32 -34
  78. package/src/components/orderDetailsContainer/index.tsx +289 -249
  79. package/src/components/orderDetailsContainer/style.css +73 -73
  80. package/src/components/orderDetailsContainer/ticketsTable.tsx +177 -124
  81. package/src/components/paymentContainer/index.tsx +352 -284
  82. package/src/components/registerModal/index.tsx +183 -190
  83. package/src/components/rsvpContainer/index.tsx +126 -0
  84. package/src/components/stripePayment/index.tsx +258 -253
  85. package/src/components/stripePayment/style.css +60 -60
  86. package/src/components/ticketResale/index.tsx +74 -56
  87. package/src/components/ticketResaleModal/index.tsx +213 -210
  88. package/src/components/ticketResaleModal/style.css +28 -28
  89. package/src/components/ticketsContainer/AccessCodeSection.tsx +50 -0
  90. package/src/components/ticketsContainer/PromoCodeSection.tsx +89 -99
  91. package/src/components/ticketsContainer/ReferralLogic.tsx +31 -33
  92. package/src/components/ticketsContainer/TicketRow.tsx +89 -83
  93. package/src/components/ticketsContainer/TicketsSection.tsx +87 -81
  94. package/src/components/ticketsContainer/index.tsx +506 -409
  95. package/src/components/ticketsContainer/style.css +181 -181
  96. package/src/components/ticketsContainer/utils.ts +11 -11
  97. package/src/components/timerWidget/index.tsx +87 -70
  98. package/src/components/timerWidget/style.css +34 -26
  99. package/src/components/waitingList/index.tsx +178 -178
  100. package/src/components/waitingList/style.css +26 -26
  101. package/src/env.ts +20 -19
  102. package/src/index.ts +15 -13
  103. package/src/normalizers/index.ts +45 -45
  104. package/src/types/billing-info-data.ts +37 -37
  105. package/src/types/payment-field.ts +7 -7
  106. package/src/types/referral-promotion.ts +7 -7
  107. package/src/utils/cookies.ts +42 -0
  108. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +71 -59
  109. package/src/utils/downloadPDF.tsx +52 -30
  110. package/src/utils/formikErrorFocus.ts +24 -24
  111. package/src/utils/getDomain.ts +15 -0
  112. package/src/utils/getImage.ts +14 -14
  113. package/src/utils/getQueryVariable.ts +13 -13
  114. package/src/utils/index.ts +7 -5
  115. package/src/utils/setConfigs.ts +26 -26
  116. package/src/utils/showZero.tsx +10 -10
  117. package/src/validators/index.ts +20 -20
@@ -1,284 +1,352 @@
1
- import React, { useEffect, useState } from 'react'
2
- import { AxiosError } from 'axios'
3
- import Container from '@mui/material/Container'
4
- import CircularProgress from '@mui/material/CircularProgress'
5
- import Alert from '@mui/material/Alert'
6
- import { Elements } from '@stripe/react-stripe-js'
7
- import {
8
- loadStripe,
9
- StripeConstructorOptions,
10
- StripeElementsOptions,
11
- } from '@stripe/stripe-js'
12
- import _map from 'lodash/map'
13
- import _get from 'lodash/get'
14
- import _identity from 'lodash/identity'
15
- import { CONFIGS } from '../../utils'
16
- import { nanoid } from 'nanoid'
17
- import { getQueryVariable } from '../../utils/getQueryVariable'
18
-
19
- import './style.css'
20
- import StripePayment from '../stripePayment'
21
- import { IOrderData, IPaymentField } from '../../types'
22
-
23
- import { getPaymentData, handlePaymentSuccess, getConditions, handleFreeSuccess } from '../../api'
24
- import { StripeCardNumberElementOptions } from '@stripe/stripe-js'
25
- import { ThemeProvider, createTheme } from '@mui/material/styles'
26
- import { ThemeOptions } from '@mui/material'
27
- import { CSSProperties } from '@mui/styles'
28
- import TimerWidget from '../timerWidget'
29
- import { Loader } from '../common/index'
30
-
31
- const publishableKey = CONFIGS.STRIPE_PUBLISHABLE_KEY || ''
32
-
33
- const getStripePromise = (reviewData: any) => {
34
- const stripePublishableKey =
35
- _get(reviewData, 'payment_method.stripe_publishable_key') || publishableKey
36
- const stripeAccount = _get(
37
- reviewData,
38
- 'payment_method.stripe_connected_account'
39
- )
40
-
41
- const options: StripeConstructorOptions = {}
42
- if (stripeAccount) {
43
- options.stripeAccount = stripeAccount
44
- }
45
-
46
- return loadStripe(stripePublishableKey, options)
47
- }
48
-
49
- export interface IPaymentPage {
50
- paymentFields: IPaymentField[];
51
- handlePayment: any;
52
- checkoutData: any;
53
- formTitle?: string;
54
- errorText?: string;
55
- onErrorClose?: () => void;
56
- onGetPaymentDataSuccess: (value: any) => void;
57
- onGetPaymentDataError: (value: AxiosError) => void;
58
- onPaymentError: (value: AxiosError) => void;
59
- stripeCardOptions?: StripeCardNumberElementOptions;
60
- disableZipSection: boolean;
61
- themeOptions?: ThemeOptions & {
62
- input?: CSSProperties;
63
- checkbox?: CSSProperties;
64
- };
65
- elementsOptions?: StripeElementsOptions;
66
- onCountdownFinish?: () => void;
67
- enableTimer?: boolean;
68
- }
69
-
70
- const initialOrderValues: IOrderData = {
71
- product_name: '',
72
- ticketType: '',
73
- quantity: '',
74
- price: '',
75
- total: '',
76
- currency: '',
77
- }
78
- const initialReviewValues = {
79
- order_details: {
80
- order_hash: '',
81
- },
82
- payment_method: {
83
- stripe_client_secret: '',
84
- },
85
- billing_info: {},
86
- }
87
-
88
- export const PaymentContainer = ({
89
- paymentFields = [],
90
- handlePayment,
91
- formTitle = 'Get Your Tickets',
92
- errorText,
93
- checkoutData,
94
- onErrorClose = _identity,
95
- onGetPaymentDataSuccess = () => {},
96
- onGetPaymentDataError = () => {},
97
- onPaymentError = () => {},
98
- stripeCardOptions = {},
99
- disableZipSection = false,
100
- themeOptions,
101
- elementsOptions,
102
- onCountdownFinish = () => {},
103
- enableTimer = false,
104
- }: IPaymentPage) => {
105
- const [reviewData, setReviewData] = useState(initialReviewValues)
106
- const [orderData, setOrderData] = useState(initialOrderValues)
107
- const [error, setError] = useState(null)
108
- const [paymentIsLoading, setPaymentIsLoading] = useState(false)
109
- const [paymentDataIsLoading, setPaymentDataIsLoading] = useState(true)
110
- const [conditions, setConditions] = useState<{ id: string; text: string }[]>(
111
- []
112
- )
113
-
114
- const showFormTitle: boolean = Boolean(formTitle)
115
- const showErrorText: boolean = Boolean(errorText)
116
-
117
- const eventId = getQueryVariable('event_id')
118
- const { hash, total } = checkoutData;
119
-
120
- useEffect(() => {
121
- (async () => {
122
- try {
123
- const response = await getPaymentData(hash)
124
- if (response.data.success) {
125
- const attributes = _get(response, 'data.data.attributes')
126
- setReviewData(attributes)
127
- const { cart, order_details } = attributes
128
- const {
129
- tickets: [ticket],
130
- } = order_details
131
- const orderData = {
132
- product_name: cart[0]?.product_name,
133
- ticketType: ticket?.name,
134
- quantity: ticket?.quantity,
135
- price: ticket?.price,
136
- total: order_details?.total,
137
- currency: order_details?.currency,
138
- }
139
- setOrderData(orderData)
140
- onGetPaymentDataSuccess(response.data)
141
- }
142
- } catch (e) {
143
- setError(_get(e, 'response.data.message'))
144
- onGetPaymentDataError(e.response)
145
- } finally {
146
- setPaymentDataIsLoading(false)
147
- }
148
- })()
149
- }, [checkoutData])
150
-
151
- //just once
152
- useEffect(() => {
153
- // fetch conditions data
154
- const fetchConditions = async () => {
155
- if (eventId) {
156
- const res = await getConditions(eventId)
157
- const conditionsInfo = _get(res, 'data.data.attributes')
158
- setConditions(
159
- conditionsInfo
160
- ? conditionsInfo.map((item: string) => ({
161
- id: nanoid(),
162
- text: item,
163
- checked: false,
164
- }))
165
- : []
166
- )
167
- }
168
- }
169
- fetchConditions()
170
- }, [])
171
-
172
- // 1. get payment data ---> v1/order/${hash}/review/ done
173
- // 2. handle payment ---> v1/order/${orderHash}/pay/
174
- // 3. redirect to confirmation page
175
- const handlePaymentMiddleWare = async (error: any) => {
176
- try {
177
- if (error) {
178
- setPaymentIsLoading(false)
179
- throw error
180
- }
181
- const {
182
- order_details: { order_hash },
183
- } = reviewData
184
- const paymentSuccessResponse = total === "0.00" ? (await handleFreeSuccess(order_hash)) : (await handlePaymentSuccess(order_hash))
185
- if (paymentSuccessResponse.status === 200) {
186
- handlePayment(paymentSuccessResponse)
187
- setPaymentIsLoading(false)
188
- }
189
- } catch (e) {
190
- setError(_get(e, 'response.data.message'))
191
- onPaymentError(e.response)
192
- }
193
- }
194
-
195
- const themeMui = createTheme(themeOptions)
196
-
197
- return (
198
- <ThemeProvider theme={themeMui}>
199
- <div className="payment_page">
200
- {!paymentIsLoading && !error && enableTimer && (
201
- <TimerWidget
202
- expires_at={_get(reviewData, 'expires_at', 0)}
203
- buyLoading={paymentIsLoading}
204
- onCountdownFinish={onCountdownFinish}
205
- />
206
- )}
207
- {error && (
208
- <Alert severity="error" onClose={onErrorClose} variant="filled">
209
- {error}
210
- </Alert>
211
- )}
212
- {paymentDataIsLoading && <Loader />}
213
- {!paymentDataIsLoading && (
214
- <Container maxWidth="md">
215
- {showFormTitle && <h1>{formTitle}</h1>}
216
- <div className="order_info_text">Order Review</div>
217
- <div className="order_info_section">
218
- {_map(paymentFields, field => {
219
- const {
220
- id,
221
- label,
222
- className = '',
223
- normalizer = _identity,
224
- } = field
225
- return (
226
- <div key={id} className="order_info_block">
227
- <div className="order_info_title">{label}</div>
228
- <div className={`${className} order_info_text`}>
229
- {normalizer(orderData[id], orderData.currency)}
230
- </div>
231
- </div>
232
- )
233
- })}
234
- </div>
235
- {total !== "0.00" ? <div className="payment_info">
236
- <div className="payment_info_label">
237
- Please provide your payment information
238
- </div>
239
- {showErrorText && (
240
- <p className="payment_info__error">{errorText}</p>
241
- )}
242
- <div>
243
- <Elements
244
- stripe={getStripePromise(reviewData)}
245
- options={elementsOptions}
246
- >
247
- <StripePayment
248
- stripe_client_secret={_get(
249
- reviewData,
250
- 'payment_method.stripe_client_secret'
251
- )}
252
- total={orderData.total}
253
- onSubmit={handlePaymentMiddleWare}
254
- error={error}
255
- currency={orderData.currency}
256
- billing_info={reviewData.billing_info}
257
- isLoading={paymentIsLoading}
258
- handleSetLoading={value => setPaymentIsLoading(value)}
259
- conditions={conditions}
260
- stripeCardOptions={stripeCardOptions}
261
- disableZipSection={disableZipSection}
262
- />
263
- </Elements>
264
- </div>
265
- </div> :
266
- <div
267
- className={`payment_button ${paymentIsLoading ? 'disabled-payment-button' : ''}`}
268
- >
269
- <button disabled={paymentIsLoading} type="button" onClick={() => {
270
- handlePaymentMiddleWare(null)
271
- }}>
272
- {paymentIsLoading ? (
273
- <CircularProgress size={26} />
274
- ) : (
275
- "Complete Registration"
276
- )}
277
- </button>
278
- </div>}
279
- </Container>
280
- )}
281
- </div>
282
- </ThemeProvider>
283
- )
284
- }
1
+ import React, { useEffect, useState } from 'react'
2
+ import { AxiosError } from 'axios'
3
+ import Container from '@mui/material/Container'
4
+ import CircularProgress from '@mui/material/CircularProgress'
5
+ import Alert from '@mui/material/Alert'
6
+ import { Elements } from '@stripe/react-stripe-js'
7
+ import {
8
+ loadStripe,
9
+ StripeConstructorOptions,
10
+ StripeElementsOptions,
11
+ } from '@stripe/stripe-js'
12
+ import _map from 'lodash/map'
13
+ import _get from 'lodash/get'
14
+ import _identity from 'lodash/identity'
15
+ import { CONFIGS } from '../../utils'
16
+ import { nanoid } from 'nanoid'
17
+ import { getQueryVariable } from '../../utils/getQueryVariable'
18
+
19
+ import './style.css'
20
+ import StripePayment from '../stripePayment'
21
+ import { IOrderData, IPaymentField } from '../../types'
22
+
23
+ import {
24
+ getPaymentData,
25
+ handlePaymentSuccess,
26
+ getConditions,
27
+ handleFreeSuccess,
28
+ } from '../../api'
29
+ import { StripeCardNumberElementOptions } from '@stripe/stripe-js'
30
+ import { ThemeProvider, createTheme } from '@mui/material/styles'
31
+ import { ThemeOptions } from '@mui/material'
32
+ import { CSSProperties } from '@mui/styles'
33
+ import TimerWidget from '../timerWidget'
34
+ import { Loader } from '../common/index'
35
+
36
+ const publishableKey = CONFIGS.STRIPE_PUBLISHABLE_KEY || ''
37
+
38
+ const getStripePromise = (reviewData: any) => {
39
+ const stripePublishableKey =
40
+ _get(reviewData, 'payment_method.stripe_publishable_key') || publishableKey
41
+ const stripeAccount = _get(
42
+ reviewData,
43
+ 'payment_method.stripe_connected_account'
44
+ )
45
+
46
+ const options: StripeConstructorOptions = {}
47
+ if (stripeAccount) {
48
+ options.stripeAccount = stripeAccount
49
+ }
50
+
51
+ return loadStripe(stripePublishableKey, options)
52
+ }
53
+
54
+ export interface IPaymentPage {
55
+ paymentFields: IPaymentField[];
56
+ handlePayment: any;
57
+ checkoutData: any;
58
+ formTitle?: string;
59
+ errorText?: string;
60
+ onErrorClose?: () => void;
61
+ onGetPaymentDataSuccess: (value: any) => void;
62
+ onGetPaymentDataError: (value: AxiosError) => void;
63
+ onPaymentError: (value: AxiosError) => void;
64
+ stripeCardOptions?: StripeCardNumberElementOptions;
65
+ disableZipSection: boolean;
66
+ themeOptions?: ThemeOptions & {
67
+ input?: CSSProperties;
68
+ checkbox?: CSSProperties;
69
+ };
70
+ elementsOptions?: StripeElementsOptions;
71
+ onCountdownFinish?: () => void;
72
+ enableTimer?: boolean;
73
+ enablePaymentPlan?: boolean;
74
+ paymentButtonText?: string;
75
+ }
76
+
77
+ const initialOrderValues: IOrderData = {
78
+ product_name: '',
79
+ ticketType: '',
80
+ quantity: '',
81
+ price: '',
82
+ total: '',
83
+ currency: '',
84
+ }
85
+ const initialReviewValues = {
86
+ order_details: {
87
+ order_hash: '',
88
+ },
89
+ payment_method: {
90
+ stripe_client_secret: '',
91
+ },
92
+ billing_info: {},
93
+ }
94
+
95
+ export const PaymentContainer = ({
96
+ paymentFields = [],
97
+ handlePayment,
98
+ formTitle = 'Get Your Tickets',
99
+ errorText,
100
+ checkoutData,
101
+ onErrorClose = _identity,
102
+ onGetPaymentDataSuccess = () => { },
103
+ onGetPaymentDataError = () => { },
104
+ onPaymentError = () => { },
105
+ stripeCardOptions = {},
106
+ disableZipSection = false,
107
+ themeOptions,
108
+ elementsOptions,
109
+ onCountdownFinish = () => { },
110
+ enableTimer = false,
111
+ enablePaymentPlan = false,
112
+ paymentButtonText
113
+ }: IPaymentPage) => {
114
+ const [reviewData, setReviewData] = useState(initialReviewValues)
115
+ const [orderData, setOrderData] = useState(initialOrderValues)
116
+ const [error, setError] = useState(null)
117
+ const [showPaymentPlanSection, setShowPaymentPlanSection] = useState(false)
118
+ const [paymentIsLoading, setPaymentIsLoading] = useState(false)
119
+ const [paymentDataIsLoading, setPaymentDataIsLoading] = useState(true)
120
+ const [conditions, setConditions] = useState<{ id: string; text: string }[]>(
121
+ []
122
+ )
123
+
124
+ const showFormTitle: boolean = Boolean(formTitle)
125
+ const showErrorText: boolean = Boolean(errorText)
126
+
127
+ const eventId = getQueryVariable('event_id')
128
+ const { hash, total } = checkoutData
129
+
130
+ useEffect(() => {
131
+ (async () => {
132
+ try {
133
+ const response = await getPaymentData(hash)
134
+ if (response.data.success) {
135
+ const attributes = _get(response, 'data.data.attributes')
136
+ setReviewData(attributes)
137
+ const { cart, order_details } = attributes
138
+ const {
139
+ tickets: [ticket],
140
+ } = order_details
141
+ const orderData = {
142
+ product_name: cart[0]?.product_name,
143
+ ticketType: ticket?.name,
144
+ quantity: ticket?.quantity,
145
+ price: ticket?.price,
146
+ total: order_details?.total,
147
+ currency: order_details?.currency,
148
+ }
149
+ setOrderData(orderData)
150
+ onGetPaymentDataSuccess(response.data)
151
+ }
152
+ } catch (e) {
153
+ setError(_get(e, 'response.data.message'))
154
+ onGetPaymentDataError(e.response)
155
+ } finally {
156
+ setPaymentDataIsLoading(false)
157
+ }
158
+ })()
159
+ }, [checkoutData])
160
+
161
+ //just once
162
+ useEffect(() => {
163
+ // fetch conditions data
164
+ const fetchConditions = async () => {
165
+ if (eventId) {
166
+ const res = await getConditions(eventId)
167
+ const conditionsInfo = _get(res, 'data.data.attributes')
168
+ setConditions(
169
+ conditionsInfo
170
+ ? conditionsInfo.map((item: string) => ({
171
+ id: nanoid(),
172
+ text: item,
173
+ checked: false,
174
+ }))
175
+ : []
176
+ )
177
+ }
178
+ }
179
+ fetchConditions()
180
+ }, [])
181
+
182
+ // 1. get payment data ---> v1/order/${hash}/review/ done
183
+ // 2. handle payment ---> v1/order/${orderHash}/pay/
184
+ // 3. redirect to confirmation page
185
+ const handlePaymentMiddleWare = async (error: any) => {
186
+ try {
187
+ if (error) {
188
+ throw error
189
+ }
190
+ const {
191
+ order_details: { order_hash },
192
+ } = reviewData
193
+ const paymentSuccessResponse =
194
+ total === '0.00'
195
+ ? await handleFreeSuccess(order_hash)
196
+ : await handlePaymentSuccess(order_hash)
197
+ if (paymentSuccessResponse.status === 200) {
198
+ handlePayment(paymentSuccessResponse)
199
+ setPaymentIsLoading(false)
200
+ }
201
+ } catch (e) {
202
+ setError(_get(e, 'response.data.message'))
203
+ setPaymentIsLoading(false)
204
+ onPaymentError(e.response)
205
+ }
206
+ }
207
+
208
+ const themeMui = createTheme(themeOptions)
209
+
210
+ return (
211
+ <ThemeProvider theme={themeMui}>
212
+ <div className="payment_page">
213
+ {enableTimer && (
214
+ <TimerWidget
215
+ expires_at={_get(reviewData, 'expires_at', 0)}
216
+ buyLoading={paymentIsLoading}
217
+ onCountdownFinish={onCountdownFinish}
218
+ />
219
+ )}
220
+ {error && (
221
+ <Alert severity="error" onClose={onErrorClose} variant="filled">
222
+ {error}
223
+ </Alert>
224
+ )}
225
+ {paymentDataIsLoading && <Loader />}
226
+ {!paymentDataIsLoading && (
227
+ <Container maxWidth="md">
228
+ {showFormTitle && <h1>{formTitle}</h1>}
229
+ <div className="order_info_text">Order Review</div>
230
+ <div className="order_info_section">
231
+ {_map(paymentFields, field => {
232
+ const {
233
+ id,
234
+ label,
235
+ className = '',
236
+ normalizer = _identity,
237
+ } = field
238
+ return (
239
+ <div key={id} className="order_info_block">
240
+ <div className="order_info_title">{label}</div>
241
+ <div className={`${className} order_info_text`}>
242
+ {normalizer(orderData[id], orderData.currency)}
243
+ </div>
244
+ </div>
245
+ )
246
+ })}
247
+ </div>
248
+ {enablePaymentPlan && <div className="payment_toggle">
249
+ <label htmlFor="togBtn" className="switch">
250
+ <input
251
+ type="checkbox"
252
+ id="togBtn"
253
+ disabled={true}
254
+ onChange={() =>
255
+ setShowPaymentPlanSection(!showPaymentPlanSection)
256
+ }
257
+ />
258
+ <div className="slider round"></div>
259
+ <span className="tog_text">
260
+ Click to checkout using Payment Plan
261
+ </span>
262
+ </label>
263
+ </div>}
264
+ {showPaymentPlanSection && (
265
+ <div className="payment_plan">
266
+ <h2>PAYMENT PLAN</h2>
267
+ <div className="plan_block">
268
+ <h3>Mbrand Payment Plan Terms</h3>
269
+ <p>
270
+ By clicking on the “Confirm Payment Plan” button, you are
271
+ starting your payment plan of 2 payments of $115.00, which
272
+ will be drawn from your account every 2 weeks, with the
273
+ first payment taken later today.
274
+ </p>
275
+ <p>
276
+ This includes a non-refundable admin fee of $3.00 per
277
+ payment.
278
+ </p>
279
+ <p className="payment_note">
280
+ NOTE: If today’s payment fails, your payment plan will not
281
+ activate, and your tickets will not be issued until you
282
+ complete your final payment.
283
+ </p>
284
+ <p>
285
+ If you do not complete your payements, your order will be
286
+ canceled. Your first payment of $115.00, plus the
287
+ non-refundable admin fee of $3.00 will not be refunded.
288
+ </p>
289
+ <p>
290
+ Your payment will proceed with the card ending in **** 4242.
291
+ </p>
292
+ </div>
293
+ </div>
294
+ )}
295
+ {total !== '0.00' ? (
296
+ <div className="payment_info">
297
+ <div className="payment_info_label">ORDER CONFIRMATION</div>
298
+ {showErrorText && (
299
+ <p className="payment_info__error">{errorText}</p>
300
+ )}
301
+ <div>
302
+ <Elements
303
+ stripe={getStripePromise(reviewData)}
304
+ options={elementsOptions}
305
+ >
306
+ <StripePayment
307
+ stripe_client_secret={_get(
308
+ reviewData,
309
+ 'payment_method.stripe_client_secret'
310
+ )}
311
+ total={orderData.total}
312
+ onSubmit={handlePaymentMiddleWare}
313
+ error={error}
314
+ currency={orderData.currency}
315
+ billing_info={reviewData.billing_info}
316
+ isLoading={paymentIsLoading}
317
+ handleSetLoading={value => setPaymentIsLoading(value)}
318
+ conditions={conditions}
319
+ stripeCardOptions={stripeCardOptions}
320
+ disableZipSection={disableZipSection}
321
+ paymentButtonText={paymentButtonText}
322
+ />
323
+ </Elements>
324
+ </div>
325
+ </div>
326
+ ) : (
327
+ <div
328
+ className={`payment_button ${paymentIsLoading ? 'disabled-payment-button' : ''
329
+ }`}
330
+ >
331
+ <button
332
+ disabled={paymentIsLoading}
333
+ type="button"
334
+ onClick={() => {
335
+ setPaymentIsLoading(true)
336
+ handlePaymentMiddleWare(null)
337
+ }}
338
+ >
339
+ {paymentIsLoading ? (
340
+ <CircularProgress size={26} />
341
+ ) : (
342
+ 'Complete Registration'
343
+ )}
344
+ </button>
345
+ </div>
346
+ )}
347
+ </Container>
348
+ )}
349
+ </div>
350
+ </ThemeProvider>
351
+ )
352
+ }