tf-checkout-react 1.0.95 → 1.0.96

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.95",
2
+ "version": "1.0.96",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
package/src/api/index.ts CHANGED
@@ -216,6 +216,15 @@ export const handlePaymentSuccess = (orderHash: string) => {
216
216
  return res
217
217
  }
218
218
 
219
+ export const handleFreeSuccess = (orderHash: string) => {
220
+ const res = publicRequest
221
+ .post(`v1/order/${orderHash}/complete_free_registration`)
222
+ .catch(error => {
223
+ throw error
224
+ })
225
+ return res
226
+ }
227
+
219
228
  export const getProfileData = (accessToken: any) =>
220
229
  publicRequest
221
230
  .get('/customer/profile/', {
@@ -28,7 +28,6 @@ import {
28
28
  register,
29
29
  setCustomHeader,
30
30
  getStates,
31
- getPaymentData,
32
31
  } from '../../api'
33
32
  import { LoginModal } from '../loginModal'
34
33
  import { RegisterModal } from '../registerModal'
@@ -448,7 +447,6 @@ export const BillingInfoContainer = ({
448
447
 
449
448
  const checkoutBody = collectCheckoutBody(values)
450
449
  const res = await postOnCheckout(checkoutBody, access_token)
451
- await getPaymentData(res.data.data.attributes.hash)
452
450
  handleSubmit(
453
451
  values,
454
452
  formikHelpers as FormikHelpers<any>,
@@ -521,7 +519,6 @@ export const BillingInfoContainer = ({
521
519
  checkoutBody,
522
520
  access_token_register
523
521
  )
524
- await getPaymentData(res.data.data.attributes.hash)
525
522
  handleSubmit(
526
523
  values,
527
524
  formikHelpers as FormikHelpers<any>,
@@ -20,7 +20,7 @@ import './style.css'
20
20
  import StripePayment from '../stripePayment'
21
21
  import { IOrderData, IPaymentField } from '../../types'
22
22
 
23
- import { getPaymentData, handlePaymentSuccess, getConditions } from '../../api'
23
+ import { getPaymentData, handlePaymentSuccess, getConditions, handleFreeSuccess } from '../../api'
24
24
  import { StripeCardNumberElementOptions } from '@stripe/stripe-js'
25
25
  import { ThemeProvider, createTheme } from '@mui/material/styles'
26
26
  import { ThemeOptions } from '@mui/material'
@@ -121,9 +121,9 @@ export const PaymentContainer = ({
121
121
  const showErrorText: boolean = Boolean(errorText)
122
122
 
123
123
  const eventId = getQueryVariable('event_id')
124
+ const { hash, total } = checkoutData;
124
125
 
125
126
  useEffect(() => {
126
- const { hash } = checkoutData;
127
127
  (async () => {
128
128
  try {
129
129
  const response = await getPaymentData(hash)
@@ -187,7 +187,7 @@ export const PaymentContainer = ({
187
187
  const {
188
188
  order_details: { order_hash },
189
189
  } = reviewData
190
- const paymentSuccessResponse = await handlePaymentSuccess(order_hash)
190
+ const paymentSuccessResponse = total === "0.00" ? (await handleFreeSuccess(order_hash)) : (await handlePaymentSuccess(order_hash))
191
191
  if (paymentSuccessResponse.status === 200) {
192
192
  handlePayment(paymentSuccessResponse)
193
193
  setPaymentIsLoading(false)
@@ -238,7 +238,7 @@ export const PaymentContainer = ({
238
238
  )
239
239
  })}
240
240
  </div>
241
- <div className="payment_info">
241
+ {total !== "0.00" ? <div className="payment_info">
242
242
  <div className="payment_info_label">
243
243
  Please provide your payment information
244
244
  </div>
@@ -268,7 +268,20 @@ export const PaymentContainer = ({
268
268
  />
269
269
  </Elements>
270
270
  </div>
271
- </div>
271
+ </div> :
272
+ <div
273
+ className={`payment_button ${paymentIsLoading ? 'disabled-payment-button' : ''}`}
274
+ >
275
+ <button disabled={paymentIsLoading} type="button" onClick={() => {
276
+ handlePaymentMiddleWare(null)
277
+ }}>
278
+ {paymentIsLoading ? (
279
+ <CircularProgress size={26} />
280
+ ) : (
281
+ "Complete Registration"
282
+ )}
283
+ </button>
284
+ </div>}
272
285
  </Container>
273
286
  )}
274
287
  </div>