tf-checkout-react-native 1.0.17 → 1.0.20

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 (138) hide show
  1. package/README.md +784 -9
  2. package/lib/api/ApiClient.d.ts +14 -36
  3. package/lib/api/ApiClient.js +85 -30
  4. package/lib/api/ApiClient.js.map +1 -1
  5. package/lib/api/Constants.d.ts +2 -0
  6. package/lib/api/Constants.js +2 -0
  7. package/lib/api/Constants.js.map +1 -1
  8. package/lib/api/types.d.ts +100 -21
  9. package/lib/components/index.d.ts +2 -0
  10. package/lib/components/index.js +2 -0
  11. package/lib/components/index.js.map +1 -1
  12. package/lib/components/loggedIn/LoggedIn.js +3 -3
  13. package/lib/components/loggedIn/LoggedIn.js.map +1 -1
  14. package/lib/components/login/Login.d.ts +2 -1
  15. package/lib/components/login/Login.js +25 -63
  16. package/lib/components/login/Login.js.map +1 -1
  17. package/lib/components/login/LoginView.d.ts +2 -1
  18. package/lib/components/login/LoginView.js +18 -7
  19. package/lib/components/login/LoginView.js.map +1 -1
  20. package/lib/components/login/types.d.ts +9 -9
  21. package/lib/components/phoneInput/PhoneInput.d.ts +4 -0
  22. package/lib/components/phoneInput/PhoneInput.js +33 -0
  23. package/lib/components/phoneInput/PhoneInput.js.map +1 -0
  24. package/lib/components/phoneInput/styles.d.ts +28 -0
  25. package/lib/components/phoneInput/styles.js +30 -0
  26. package/lib/components/phoneInput/styles.js.map +1 -0
  27. package/lib/components/phoneInput/types.d.ts +30 -0
  28. package/lib/components/phoneInput/types.js +2 -0
  29. package/lib/components/phoneInput/types.js.map +1 -0
  30. package/lib/components/promoCode/PromoCode.d.ts +2 -1
  31. package/lib/components/promoCode/PromoCode.js.map +1 -1
  32. package/lib/components/promoCode/types.d.ts +1 -1
  33. package/lib/components/stripePayment/StripePayment.d.ts +4 -0
  34. package/lib/components/stripePayment/StripePayment.js +23 -0
  35. package/lib/components/stripePayment/StripePayment.js.map +1 -0
  36. package/lib/components/stripePayment/types.d.ts +12 -0
  37. package/lib/components/stripePayment/types.js +2 -0
  38. package/lib/components/stripePayment/types.js.map +1 -0
  39. package/lib/components/waitingList/WaitingList.d.ts +2 -1
  40. package/lib/components/waitingList/WaitingList.js +32 -29
  41. package/lib/components/waitingList/WaitingList.js.map +1 -1
  42. package/lib/components/waitingList/WaitingListView.d.ts +2 -1
  43. package/lib/components/waitingList/WaitingListView.js.map +1 -1
  44. package/lib/components/waitingList/types.d.ts +0 -1
  45. package/lib/containers/billingInfo/Billing.js +209 -123
  46. package/lib/containers/billingInfo/Billing.js.map +1 -1
  47. package/lib/containers/billingInfo/types.d.ts +10 -6
  48. package/lib/containers/checkout/Checkout.d.ts +2 -1
  49. package/lib/containers/checkout/Checkout.js +58 -65
  50. package/lib/containers/checkout/Checkout.js.map +1 -1
  51. package/lib/containers/checkout/types.d.ts +1 -1
  52. package/lib/containers/myOrderDetails/MyOrderDetailsView.js +4 -3
  53. package/lib/containers/myOrderDetails/MyOrderDetailsView.js.map +1 -1
  54. package/lib/containers/myOrderDetails/types.d.ts +10 -2
  55. package/lib/containers/myOrders/MyOrders.js +26 -4
  56. package/lib/containers/myOrders/MyOrders.js.map +1 -1
  57. package/lib/containers/myOrders/MyOrdersView.d.ts +2 -1
  58. package/lib/containers/myOrders/MyOrdersView.js.map +1 -1
  59. package/lib/containers/myOrders/types.d.ts +2 -2
  60. package/lib/containers/purchaseConfirmation/PurchaseConfirmation.d.ts +2 -1
  61. package/lib/containers/purchaseConfirmation/PurchaseConfirmation.js +23 -8
  62. package/lib/containers/purchaseConfirmation/PurchaseConfirmation.js.map +1 -1
  63. package/lib/containers/purchaseConfirmation/PurchaseConfirmationView.d.ts +2 -1
  64. package/lib/containers/purchaseConfirmation/PurchaseConfirmationView.js.map +1 -1
  65. package/lib/containers/tickets/Tickets.d.ts +2 -1
  66. package/lib/containers/tickets/Tickets.js +75 -84
  67. package/lib/containers/tickets/Tickets.js.map +1 -1
  68. package/lib/containers/tickets/TicketsView.d.ts +1 -1
  69. package/lib/containers/tickets/TicketsView.js +2 -2
  70. package/lib/containers/tickets/TicketsView.js.map +1 -1
  71. package/lib/containers/tickets/types.d.ts +3 -14
  72. package/lib/core/BillingCore/BillingCore.d.ts +5 -0
  73. package/lib/core/BillingCore/BillingCore.js +28 -0
  74. package/lib/core/BillingCore/BillingCore.js.map +1 -0
  75. package/lib/core/BillingCore/BillingCoreTypes.d.ts +16 -0
  76. package/lib/core/BillingCore/BillingCoreTypes.js +2 -0
  77. package/lib/core/BillingCore/BillingCoreTypes.js.map +1 -0
  78. package/lib/core/CheckoutCore/CheckoutCore.d.ts +5 -0
  79. package/lib/core/CheckoutCore/CheckoutCore.js +25 -0
  80. package/lib/core/CheckoutCore/CheckoutCore.js.map +1 -0
  81. package/lib/core/CheckoutCore/CheckoutCoreTypes.d.ts +8 -0
  82. package/lib/core/CheckoutCore/CheckoutCoreTypes.js +2 -0
  83. package/lib/core/CheckoutCore/CheckoutCoreTypes.js.map +1 -0
  84. package/lib/core/CoreProps.d.ts +4 -0
  85. package/lib/core/CoreProps.js +2 -0
  86. package/lib/core/CoreProps.js.map +1 -0
  87. package/lib/core/LoginCore/LoginCore.d.ts +5 -0
  88. package/lib/core/LoginCore/LoginCore.js +100 -0
  89. package/lib/core/LoginCore/LoginCore.js.map +1 -0
  90. package/lib/core/LoginCore/LoginCoreTypes.d.ts +10 -0
  91. package/lib/core/LoginCore/LoginCoreTypes.js +2 -0
  92. package/lib/core/LoginCore/LoginCoreTypes.js.map +1 -0
  93. package/lib/core/MyOrdersCore/MyOrdersCore.d.ts +3 -0
  94. package/lib/core/MyOrdersCore/MyOrdersCore.js +16 -0
  95. package/lib/core/MyOrdersCore/MyOrdersCore.js.map +1 -0
  96. package/lib/core/MyOrdersCore/MyOrdersCoreTypes.d.ts +5 -0
  97. package/lib/core/MyOrdersCore/MyOrdersCoreTypes.js +2 -0
  98. package/lib/core/MyOrdersCore/MyOrdersCoreTypes.js.map +1 -0
  99. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCore.d.ts +5 -0
  100. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCore.js +12 -0
  101. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCore.js.map +1 -0
  102. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCoreTypes.d.ts +4 -0
  103. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCoreTypes.js +2 -0
  104. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCoreTypes.js.map +1 -0
  105. package/lib/core/TicketsCore/TicketsCore.d.ts +5 -0
  106. package/lib/core/TicketsCore/TicketsCore.js +59 -0
  107. package/lib/core/TicketsCore/TicketsCore.js.map +1 -0
  108. package/lib/core/TicketsCore/TicketsCoreTypes.d.ts +15 -0
  109. package/lib/core/TicketsCore/TicketsCoreTypes.js +2 -0
  110. package/lib/core/TicketsCore/TicketsCoreTypes.js.map +1 -0
  111. package/lib/core/WaitingListCore/WaitingListCore.d.ts +5 -0
  112. package/lib/core/WaitingListCore/WaitingListCore.js +17 -0
  113. package/lib/core/WaitingListCore/WaitingListCore.js.map +1 -0
  114. package/lib/core/WaitingListCore/WaitingListCoreTypes.d.ts +9 -0
  115. package/lib/core/WaitingListCore/WaitingListCoreTypes.js +2 -0
  116. package/lib/core/WaitingListCore/WaitingListCoreTypes.js.map +1 -0
  117. package/lib/core/index.d.ts +14 -0
  118. package/lib/core/index.js +8 -0
  119. package/lib/core/index.js.map +1 -0
  120. package/lib/helpers/Config.d.ts +2 -1
  121. package/lib/helpers/Config.js +13 -2
  122. package/lib/helpers/Config.js.map +1 -1
  123. package/lib/helpers/CountryCodes.d.ts +15 -0
  124. package/lib/helpers/CountryCodes.js +3382 -0
  125. package/lib/helpers/CountryCodes.js.map +1 -0
  126. package/lib/helpers/LocalStorage.d.ts +1 -0
  127. package/lib/helpers/LocalStorage.js +4 -1
  128. package/lib/helpers/LocalStorage.js.map +1 -1
  129. package/lib/helpers/Validators.d.ts +6 -0
  130. package/lib/helpers/Validators.js +10 -0
  131. package/lib/helpers/Validators.js.map +1 -1
  132. package/lib/index.d.ts +4 -2
  133. package/lib/index.js +3 -1
  134. package/lib/index.js.map +1 -1
  135. package/lib/types/IEvent.d.ts +6 -0
  136. package/lib/types/ITicket.d.ts +10 -1
  137. package/lib/types/IUserProfile.d.ts +15 -11
  138. package/package.json +13 -6
package/README.md CHANGED
@@ -9,7 +9,7 @@ Configure [ReactNative environment](https://reactnative.dev/docs/environment-set
9
9
  ### React Native
10
10
 
11
11
  - Suggested ReactNative version `0.66.3`
12
- - Suggested Flipper version `0.66`
12
+ - Suggested Flipper version `0.99.0`
13
13
  - React version `0.17.1`
14
14
 
15
15
  ### Android
@@ -57,6 +57,24 @@ npm install tf-checkout-react-native
57
57
 
58
58
  Make sure to install all the required dependencies in your project.
59
59
 
60
+ ### Metro
61
+ Add the following to your `metro.config.js` in the resolver property:
62
+
63
+ `sourceExts: ['jsx', 'js', 'ts', 'tsx']`
64
+
65
+ Result:
66
+ ````js
67
+ module.exports = {
68
+ watchFolders: [moduleRoot],
69
+ resolver: {
70
+ sourceExts: ['jsx', 'js', 'ts', 'tsx'],
71
+ extraNodeModules: {
72
+ react: path.resolve(__dirname,
73
+ }
74
+ ....
75
+ ````
76
+
77
+
60
78
  ### Required for Android
61
79
 
62
80
  Add below dependency to your `app/build.gradle` file with specified version (in our example we are using `1.4.0`).
@@ -86,6 +104,7 @@ Use it in your initial useEffect function:
86
104
  ```js
87
105
  useEffect(() => {
88
106
  setConfig({
107
+ EVENT_ID: '4344',
89
108
  DOMAIN: 'https://yourdomain.mx',
90
109
  })
91
110
  }, [])
@@ -93,22 +112,24 @@ useEffect(() => {
93
112
 
94
113
  `setConfig` set your event's configuration, with the following options:
95
114
 
96
- ```js
115
+ ````js
97
116
  {
117
+ EVENT_ID: string,
98
118
  DOMAIN?: string,
99
- BASE_URL?: string,
119
+ ENV?: 'PROD' | 'DEV' | 'STAG',
100
120
  CLIENT_ID?: string,
101
121
  CLIENT_SECRET?: string,
102
122
  TIMEOUT?: number,
103
123
  BRAND?: string,
104
124
  ARE_SUB_BRANDS_INCLUDED?: boolean
105
125
  }
106
- ```
126
+ ````
107
127
  ### Props
108
128
  | Property | Description |
109
129
  | -------- | ----------- |
130
+ | EVENT_ID | Specify the event's ID. |
110
131
  | DOMAIN | Specify your domains name example: `https://google.com` this is important to maintain cart session active and prevent it from expiring when user login in the BillingInfo component. |
111
- | BASE_URL | If our dev team gives you a custom BASE_URL.|
132
+ | ENV | Sets the environment to any of the following environments: Production, Staging or Development. Receives the following values: `PROD`, `DEV`, `STAG`. Defaults to `PROD`.|
112
133
  | CLIENT_ID | Set your CLIENT_ID. |
113
134
  | CLIENT_SECRET | Set your CLIENT_SECRET. |
114
135
  | BRAND | Set your BRAND so users can only see this brand in their orders. |
@@ -183,6 +204,13 @@ interface IInputStyles {
183
204
  }
184
205
  ```
185
206
  # Exported components
207
+ Depending on your needs, you can use the UI Components or the Core Components.
208
+
209
+ [UI Components](#ui-components) use the Core Components at their core but also exposes an UI that you can configure with your own styles. There is no need to create any kind of logic with them, only setConfig and implement the callbacks to get their data.
210
+
211
+ [Core Components](#core-components) are wrappers that don't include any UI neither validation logics, they only act as a Middleware to retrieve and send data from the server and return it to your implementation components. They are useful when your design cannot be achieved by the UI components. You will need to use references to access their exposed functions.
212
+
213
+ # UI Components
186
214
  ## Login
187
215
 
188
216
  Import the component from the library
@@ -311,7 +339,6 @@ interface ILoginViewStyles {
311
339
 
312
340
  ```
313
341
  ---
314
-
315
342
  ## Tickets
316
343
 
317
344
  Import the component from the library
@@ -557,7 +584,6 @@ Add it to the render function.
557
584
  onLoginSuccess: (data: any) => void
558
585
  onLoginError?: (error: IError) => void
559
586
 
560
-
561
587
  onFetchUserProfileSuccess?: (data: any) => void
562
588
  onFetchUserProfileError?: (error: IError) => void
563
589
 
@@ -623,6 +649,7 @@ interface IBillingInfoViewTexts {
623
649
  loginTexts?: ILoginViewTexts
624
650
  checkoutButton?: string
625
651
  skippingMessage?: string
652
+ invalidPhoneNumberError?: string
626
653
  form?: {
627
654
  firstName?: string
628
655
  lastName?: string
@@ -648,6 +675,10 @@ interface IBillingInfoViewTexts {
648
675
  emailsAdvice?: string
649
676
  choosePassword?: string
650
677
  optional?: string
678
+ phoneInput?: {
679
+ label?: string
680
+ customError?: string
681
+ }
651
682
  }
652
683
  }
653
684
  ```
@@ -664,6 +695,22 @@ interface IBillingInfoViewStyles {
664
695
 
665
696
  inputStyles?: IInputStyles
666
697
  dropdownStyles?: IDropdownStyles
698
+ dropdownMaterialStyles?: {
699
+ container?: StyleProp<ViewStyle>
700
+ button?: StyleProp<ViewStyle>
701
+ icon?: StyleProp<ImageStyle>
702
+ label?: StyleProp<TextStyle>
703
+ dialog?: StyleProp<ViewStyle>
704
+ flatListContainer?: StyleProp<ViewStyle>
705
+ listItem?: {
706
+ container?: StyleProp<ViewStyle>
707
+ button?: StyleProp<ViewStyle>
708
+ buttonSelected?: StyleProp<ViewStyle>
709
+ text?: StyleProp<TextStyle>
710
+ textSelected?: StyleProp<TextStyle>
711
+ }
712
+ input?: IInputStyles
713
+ }
667
714
  checkboxStyles?: ICheckboxStyles
668
715
 
669
716
  screenTitle?: StyleProp<TextStyle>
@@ -676,9 +723,18 @@ interface IBillingInfoViewStyles {
676
723
  datePicker?: IDatePickerStyles
677
724
 
678
725
  privacyPolicyLinkStyle?: StyleProp<TextStyle>
726
+
727
+ phoneInput?: {
728
+ rootContainer?: StyleProp<ViewStyle>
729
+ errorColor?: ColorValue
730
+ country?: {
731
+ container?: StyleProp<ViewStyle>
732
+ button?: StyleProp<ViewStyle>
733
+ }
734
+ input?: IInputStyles
735
+ }
679
736
  }
680
737
  ```
681
-
682
738
  ---
683
739
 
684
740
  ## Checkout
@@ -991,7 +1047,7 @@ import { MyOrderDetails } from 'tf-checkout-react-native'
991
1047
 
992
1048
  ```js
993
1049
  {
994
- data: IMyOrderDetailsResponse
1050
+ data: IMyOrderDetailsData
995
1051
  config?: {
996
1052
  areActivityIndicatorsEnabled?: boolean
997
1053
  areAlertsEnabled?: boolean
@@ -1086,3 +1142,722 @@ import { MyOrderDetails } from 'tf-checkout-react-native'
1086
1142
  }
1087
1143
  ```
1088
1144
 
1145
+ # Core Components
1146
+ **⚠️ Remember that you first need to set your configuration using the [setConfig](#set-your-configuration)
1147
+ function. ⚠️**
1148
+
1149
+ ### Index
1150
+
1151
+ [TicketsCore](#ticketscore)
1152
+
1153
+ [WaitingListCore](#waitinglistcore)
1154
+
1155
+ [BillingCore](#billingcore)
1156
+
1157
+ [CheckoutCore](#checkoutcore)
1158
+
1159
+ [PurchaseConfirmationCore](#purchaseconfirmationcore)
1160
+
1161
+ [MyOrdersCore](#myorderscore)
1162
+
1163
+ [LoginCore](#logincore)
1164
+
1165
+ ---
1166
+
1167
+ ## TicketsCore
1168
+ This is the initial component to show. It will retrieve the tickets, event, present My Orders and Logout buttons if the user is logged in, and will add the selected tickets to the cart.
1169
+
1170
+ Exposes the following functions:
1171
+
1172
+ `getTickets` Fetches the tickets from the event set in the config function. It receives a promoCode parameter to apply to the tickets.
1173
+
1174
+ `getEvent` Fetches the event from the eventId set in the config function.
1175
+
1176
+ `addToCart` Adds the selected tickets to the cart.
1177
+
1178
+ ```js
1179
+ {
1180
+ // Fetches the tickets from the event set in the config function. It receives a promoCode parameter to apply to the tickets.
1181
+ getTickets(promoCode?: string): Promise<{
1182
+ tickets?: {
1183
+ sortOrder: number
1184
+ displayTicket?: boolean
1185
+ salesEnded: boolean
1186
+ salesStarted: boolean
1187
+ id: string
1188
+ displayName: string
1189
+ optionName: string
1190
+ optionValue: string
1191
+ isTable: string
1192
+ feeIncluded: boolean
1193
+ price: number
1194
+ basePrice: number
1195
+ chosen: number
1196
+ priceCurrency: string
1197
+ priceSymbol: string
1198
+ taxesIncluded: boolean
1199
+ taxName: string
1200
+ minQuantity: number
1201
+ maxQuantity: number
1202
+ multiplier: number
1203
+ tags: []
1204
+ allowMultiplePurchases: number
1205
+ priceReplacementText: string
1206
+ waitingListEnabled: boolean
1207
+ soldOut?: boolean
1208
+ soldOutMessage: string
1209
+ minGuests?: number
1210
+ maxGuests?: number
1211
+ buyButtonText?: string
1212
+ totalStock: number
1213
+ guestPrice?: number
1214
+ alwaysAvailable: string
1215
+ feeText: string
1216
+ x_face_value: number
1217
+ sold_out?: boolean
1218
+ oldPrice?: number
1219
+ oldBasePrice?: number
1220
+ descriptionRich?: string
1221
+ }[]
1222
+ error?: {
1223
+ code?: number
1224
+ message: string
1225
+ extraData?: any
1226
+ }
1227
+ promoCodeResult?: {
1228
+ isValid: boolean | number
1229
+ message: string
1230
+ }
1231
+ isInWaitingList?: boolean
1232
+ isAccessCodeRequired?: boolean
1233
+ }>
1234
+
1235
+ // Fetches the event from the eventId set in the config function.
1236
+ getEvent(): Promise<{
1237
+ eventError?: {
1238
+ code?: number
1239
+ message: string
1240
+ extraData?: any
1241
+ }
1242
+ eventData?: {
1243
+ passwordProtected: boolean
1244
+ passwordAuthenticated: boolean
1245
+ name: string
1246
+ description?: string
1247
+ slug: string
1248
+ redirectUrl?: string
1249
+ facebookEvent?: string
1250
+ title: string
1251
+ relatedProducts: []
1252
+ country: string
1253
+ date: string
1254
+ startDate: string
1255
+ endDate: string
1256
+ timezone: string
1257
+ formattedDate: string
1258
+ venueCountry: string
1259
+ venueCity?: string
1260
+ venueState?: string
1261
+ hideVenueUntil?: string
1262
+ hideVenue?: boolean
1263
+ venueName?: string
1264
+ venueGooglePlaceId?: string
1265
+ venueLatitude?: string
1266
+ venueLongitude?: string
1267
+ venuePostalCode?: string
1268
+ venueStreet?: string
1269
+ venueStreetNumber?: string
1270
+ eventType: any
1271
+ productImage: string
1272
+ imageUrl: string
1273
+ imageUrlHd: string
1274
+ backgroundImage: string
1275
+ backgroundVideo?: string
1276
+ twitterImage?: string
1277
+ ogImage?: string
1278
+ tags: []
1279
+ preregEnabled: boolean
1280
+ presalesStarted: boolean
1281
+ presalesEnded: boolean
1282
+ salesStart?: string
1283
+ salesEnd: string
1284
+ salesStarted: boolean
1285
+ salesEnded: boolean
1286
+ feeMode: string
1287
+ feesIncluded?: any
1288
+ minimumAge?: any
1289
+ enableWaitingList: boolean
1290
+ alwaysShowWaitingList?: any
1291
+ titleReplacementImage?: any
1292
+ titleReplacementHeight?: any
1293
+ titleReplacementImageSvg?: any
1294
+ fullTitleReplacement?: any
1295
+ affirmAllowed: boolean
1296
+ subHeading?: any
1297
+ isTimeSlotEvent: boolean
1298
+ preregistered: []
1299
+ referralsEnabled: boolean
1300
+ referrals: []
1301
+ faq: []
1302
+ l10nLanguages: []
1303
+ imageURLs: any
1304
+ descriptions: any
1305
+ }
1306
+ }>
1307
+
1308
+ // Adds selected tickets to the cart.
1309
+ addToCart(
1310
+ options: {
1311
+ optionName: string
1312
+ ticketId: string
1313
+ quantity: number
1314
+ price: number
1315
+ }
1316
+ ): Promise<{
1317
+ error?: {
1318
+ code?: number
1319
+ message: string
1320
+ extraData?: any
1321
+ }
1322
+ data?: {
1323
+ isBillingRequired: boolean
1324
+ isPhoneRequired?: boolean
1325
+ isAgeRequired?: boolean
1326
+ minimumAge?: number
1327
+ isNameRequired?: boolean
1328
+ }
1329
+ }>
1330
+ }
1331
+ ```
1332
+
1333
+ Import the component from the library
1334
+
1335
+ ```js
1336
+ import {
1337
+ TicketsCore
1338
+ TicketsCoreHandle // You can import the Handle to use it as type in the useRef hook
1339
+
1340
+ } from 'tf-checkout-react-native'
1341
+ ```
1342
+
1343
+ Declare a reference to pass it to the component.
1344
+
1345
+ ```js
1346
+ const ticketsCoreRef = useRef<TicketsCoreHandle>(null)
1347
+ ```
1348
+
1349
+ Then add it to the render function and assign the reference to the corresponding component.
1350
+
1351
+ ```js
1352
+ <TicketsCore ref={ticketsCoreRef}>
1353
+ <YourComponent />
1354
+ </TicketsCore>
1355
+ ```
1356
+
1357
+ Use the reference to access the component methods.
1358
+
1359
+ ```js
1360
+ const handleGetTickets = async () => {
1361
+ const res = await ticketsCoreRef.current.getTickets()
1362
+ }
1363
+
1364
+ ```
1365
+
1366
+ ## WaitingListCore
1367
+ This component *must* appear after getting the response from **getTickets()** and the property `isInWaitingList` is set to true.
1368
+
1369
+
1370
+ Exposes the following functions:
1371
+ ```js
1372
+ {
1373
+ addToWaitingList(
1374
+ params: {
1375
+ firstName: string
1376
+ lastName: string
1377
+ email: string
1378
+ }
1379
+ ): Promise<{
1380
+ addToWaitingListError?: {
1381
+ code?: number
1382
+ message: string
1383
+ extraData?: any
1384
+ }
1385
+ addToWaitingListData?: {
1386
+ error: boolean
1387
+ message: string
1388
+ status: number
1389
+ success: boolean
1390
+ }
1391
+ }>
1392
+ }
1393
+ ```
1394
+ **addToWaitingList** Receives params with the following properties:
1395
+ ```js
1396
+ firstName: string
1397
+ lastName: string
1398
+ email: string
1399
+ ```
1400
+
1401
+ And returns a Promise with the following object:
1402
+
1403
+ ```js
1404
+ {
1405
+ addToWaitingListError?: {
1406
+ code?: number // If it was a server error, this will be the error code
1407
+ message: string //Error message that you could use it in your UI
1408
+ extraData?: any // If there is a relevant extra data, it will be returned here
1409
+ }
1410
+ addToWaitingListData?: {
1411
+ error: boolean // If there was an error, this will be true
1412
+ message: string // message that you could use it in your UI, could be due an error or a success message
1413
+ status: number // Status code
1414
+ success: boolean // If there was no error, this will be true
1415
+ }
1416
+ }
1417
+ ```
1418
+
1419
+ Import the component from the library
1420
+
1421
+ ```js
1422
+ import {
1423
+ WaitingListCore
1424
+ WaitingListCoreHandle // You can import the Handle to use as type it in the useRef hook
1425
+ } from 'tf-checkout-react-native'
1426
+ ```
1427
+
1428
+ Declare a reference to pass it to the component.
1429
+
1430
+ ```js
1431
+ const waitingListCoreRef = useRef<WaitingListCoreHandle>(null)
1432
+ ```
1433
+
1434
+ Then add it to the render function and assign the reference to the corresponding component.
1435
+
1436
+ ```js
1437
+ <WaitingListCore ref={waitingListCoreRef}>
1438
+ <YourComponent />
1439
+ </WaitingListCore>
1440
+ ```
1441
+
1442
+ Use the reference to access the component methods.
1443
+
1444
+ ```js
1445
+ const handleAddToWaitingList = async (params: IAddToWaitingListCoreParams) => {
1446
+ const res = await waitingListCoreRef.current.addToWaitingList(params)
1447
+ }
1448
+ ```
1449
+
1450
+ ## BillingCore
1451
+ This component collects user's billing information and checks the order out. If the entered user data is already in the system it will perform checkout, other wise it will perform a registration and then the checkout.
1452
+
1453
+ Exposes the following functions:
1454
+
1455
+ `getCart` Fetches the current cart information, needed to know how many ticket holders data is needed.
1456
+
1457
+ `getCountries` Fetches the countries list.
1458
+
1459
+ `getStates` Fetches the states list.
1460
+
1461
+ `getUserProfile` Fetches the user profile information.
1462
+
1463
+ `registerNewUser` Registers a new user.
1464
+
1465
+ `checkoutOrder` Performs the checkout.
1466
+
1467
+
1468
+ ```ts
1469
+ {
1470
+ // Fetches the current cart information, needed to know how many ticket holders data is needed.
1471
+ getCart(): Promise<{
1472
+ cartError?: {
1473
+ code?: number
1474
+ message: string
1475
+ extraData?: any
1476
+ }
1477
+ cartData?: {
1478
+ quantity: number
1479
+ isTfOptInHidden?: boolean
1480
+ isTfOptIn: boolean // Ticket fairy
1481
+ isMarketingOptedIn: boolean // Brand
1482
+ }
1483
+ }>
1484
+
1485
+ // Performs the checkout.
1486
+ checkoutOrder(body: ICheckoutBody): Promise<{
1487
+ error?: {
1488
+ code?: number
1489
+ message: string
1490
+ extraData?: any
1491
+ }
1492
+ data?: {
1493
+ id: string
1494
+ hash: string
1495
+ total: string
1496
+ status: string
1497
+ }
1498
+ }>
1499
+
1500
+ // Fetches the country list.
1501
+ getCountries(): Promise<{
1502
+ countriesError?: {
1503
+ code?: number
1504
+ message: string
1505
+ extraData?: any
1506
+ }
1507
+ countriesData?: {
1508
+ [key: number | string]: string
1509
+ }
1510
+ }>
1511
+
1512
+ // Fetches the states list.
1513
+ getStates(countryId: string): Promise<{
1514
+ statesError?: {
1515
+ code?: number
1516
+ message: string
1517
+ extraData?: any
1518
+ }
1519
+ statesData?: {
1520
+ [key: number | string]: string
1521
+ }
1522
+ }>
1523
+
1524
+ // Fetches the user profile information.
1525
+ getUserProfile(): Promise<{
1526
+ userProfileError?: {
1527
+ code?: number
1528
+ message: string
1529
+ extraData?: any
1530
+ }
1531
+ userProfileData?: {
1532
+ customerId: string
1533
+ firstName: string
1534
+ lastName: string
1535
+ email: string
1536
+ phone: string
1537
+ streetAddress: string
1538
+ zipCode: string
1539
+ countryId: string
1540
+ company?: string
1541
+ state: string
1542
+ stateId: string
1543
+ city: string
1544
+ }
1545
+ }>
1546
+
1547
+ // Registers a new user.
1548
+ registerNewUser(data: FormData): Promise<{
1549
+ error?: {
1550
+ isAlreadyRegistered?: boolean
1551
+ message?: string
1552
+ raw?: any
1553
+ }
1554
+ data?: {
1555
+ token_type: string
1556
+ scope: string
1557
+ user_profile: {
1558
+ first_name: string
1559
+ last_name: string
1560
+ email: string
1561
+ }
1562
+ }
1563
+ }>
1564
+ }
1565
+
1566
+ ```
1567
+
1568
+ ## CheckoutCore
1569
+ Shows the event conditions, purchase details and process the payment and free registration to an event.
1570
+
1571
+ You will need to install and use the [ReactNative Stripe SDK](https://github.com/stripe/stripe-react-native) (we recommend version 0.2.3). Follow their documentation to implement it. Our backend is already prepared to process the payments.
1572
+
1573
+ Remember that you will need the `publishableKey`.
1574
+
1575
+ After you collect the card information and call the `confirmPayment` function, you will need to call the `paymentSuccess` function to complete the payment.
1576
+
1577
+
1578
+ Exposes the following functions:
1579
+
1580
+ `getEventConditions` Get event conditions for the current event.
1581
+
1582
+ `getPurchaseOrderDetails` Get purchase order details for the current event.
1583
+
1584
+ `getOrderReview` Get order review for the current event.
1585
+
1586
+ `freeRegistration` Free registration to an event.
1587
+
1588
+ `paymentSuccess` Payment success.
1589
+
1590
+
1591
+ ```ts
1592
+ // Get event conditions for the current event.
1593
+ getEventConditions(eventId: string): Promise<any>
1594
+
1595
+ // Get purchase order details for the current event.
1596
+ getPurchaseOrderDetails(orderId: string): Promise<{
1597
+ orderDetailsError?: {
1598
+ code?: number
1599
+ message: string
1600
+ extraData?: any
1601
+ }
1602
+ orderDetailsData?: {
1603
+ header: {
1604
+ isReferralDisabled: boolean
1605
+ shareLink: string
1606
+ total: string
1607
+ salesReferred: string
1608
+ }
1609
+ items: {
1610
+ isActive: boolean
1611
+ currency: string
1612
+ discount: string
1613
+ name: string
1614
+ price: string
1615
+ quantity: string
1616
+ total: string
1617
+ }[]
1618
+ tickets: {
1619
+ currency: string
1620
+ description: string
1621
+ descriptionPlain?: string
1622
+ eventName: string
1623
+ hash: string
1624
+ holderEmail?: string
1625
+ holderName: string
1626
+ holderPhone?: string
1627
+ isOnSale: boolean
1628
+ isSellable: true
1629
+ pdfLink: string
1630
+ qrData: string
1631
+ resaleFeeAmount: number
1632
+ status: string
1633
+ ticketType: string
1634
+ }[]
1635
+ }
1636
+ }>
1637
+
1638
+ // Get order review for the current event.
1639
+ getOrderReview(orderHash: string): Promise<{
1640
+ orderReviewError?: {
1641
+ code?: number
1642
+ message: string
1643
+ extraData?: any
1644
+ }
1645
+ orderReviewData?: {
1646
+ reviewData: {
1647
+ event: string
1648
+ price: string
1649
+ ticketType: string
1650
+ total: string
1651
+ numberOfTickets: string
1652
+ currency: string
1653
+ }
1654
+ paymentData: {
1655
+ id: string
1656
+ name: string
1657
+ stripeClientSecret?: string
1658
+ stripeConnectedAccount?: string
1659
+ stripePublishableKey?: string
1660
+ }
1661
+ addressData: {
1662
+ city: string
1663
+ line1: string
1664
+ state: string
1665
+ postalCode: string
1666
+ }
1667
+ billingData: {
1668
+ firstName: string
1669
+ lastName: string
1670
+ }
1671
+ }
1672
+ }>
1673
+
1674
+ // Free registration to an event.
1675
+ freeRegistration(orderHash: string): Promise<{
1676
+ freeRegistrationError?: {
1677
+ code?: number
1678
+ message: string
1679
+ extraData?: any
1680
+ }
1681
+ freeRegistrationData?: {
1682
+ id: string
1683
+ customerId: string
1684
+ total: string
1685
+ currency: string
1686
+ orderHash: string
1687
+ }
1688
+ }>
1689
+
1690
+ // Payment success.
1691
+ paymentSuccess(orderHash: string): Promise<any>
1692
+ ```
1693
+
1694
+ ## PurchaseConfirmationCore
1695
+ Shows the purchase confirmation information.
1696
+
1697
+ It exposes the following functions:
1698
+
1699
+ `getPurchaseConfirmation` Get purchase confirmation for the current event.
1700
+
1701
+ ```ts
1702
+ getPurchaseConfirmation(
1703
+ orderHash: string
1704
+ ): Promise<{
1705
+ purchaseConfirmationError?: {
1706
+ code?: number
1707
+ message: string
1708
+ extraData?: any
1709
+ }
1710
+ purchaseConfirmationData?: {
1711
+ conversionPixels?: any
1712
+ currency: {
1713
+ currency: string;
1714
+ decimalPlaces: number;
1715
+ symbol: string
1716
+ }
1717
+ customConfirmationPageText?: string
1718
+ customerId: string
1719
+ isReferralDisabled: boolean
1720
+ eventDate: string
1721
+ eventDescription: string
1722
+ eventType: string
1723
+ message: string
1724
+ orderTotal: number
1725
+ personalShareLink: string
1726
+ productId: string
1727
+ productImage: string
1728
+ productName: string
1729
+ productPrice: number
1730
+ productUrl: string
1731
+ twitterHashtag?: string
1732
+ personalShareSales: {
1733
+ price: number
1734
+ sales: number
1735
+ }[]
1736
+ }
1737
+ }>
1738
+ ```
1739
+
1740
+ ## MyOrdersCore
1741
+ Shows the purchased orders from the user. It can also show the sub-brands if the `ARE_SUB_BRANDS_INCLUDED` was set to true and the `BRAND` was set to an existing brand.
1742
+
1743
+ Exposes the following functions:
1744
+
1745
+ `getMyOrders` Get the orders purchased from the current user.
1746
+
1747
+ `getOrderDetails` Get the details from a specific order.
1748
+
1749
+
1750
+ ```ts
1751
+ getMyOrders(page: number, filter: string): Promise<{
1752
+ myOrdersData?: {
1753
+ events: {
1754
+ url_name: string
1755
+ event_name: string
1756
+ }[]
1757
+
1758
+ orders: {
1759
+ id: string
1760
+ date: string
1761
+ currency: string
1762
+ amount: string
1763
+ eventName: string
1764
+ eventUrl: string
1765
+ image: string
1766
+ }[]
1767
+ }
1768
+
1769
+ myOrdersError?: {
1770
+ code?: number
1771
+ message: string
1772
+ extraData?: any
1773
+ }
1774
+ }>
1775
+
1776
+
1777
+ getOrderDetails(orderId: string): Promise<{
1778
+ orderDetailsError?: {
1779
+ code?: number
1780
+ message: string
1781
+ extraData?: any
1782
+ }
1783
+ orderDetailsData?: {
1784
+ header: {
1785
+ isReferralDisabled: boolean
1786
+ shareLink: string
1787
+ total: string
1788
+ salesReferred: string
1789
+ }
1790
+ items: {
1791
+ isActive: boolean
1792
+ currency: string
1793
+ discount: string
1794
+ name: string
1795
+ price: string
1796
+ quantity: string
1797
+ total: string
1798
+ }[]
1799
+ tickets: {
1800
+ currency: string
1801
+ description: string
1802
+ descriptionPlain?: string
1803
+ eventName: string
1804
+ hash: string
1805
+ holderEmail?: string
1806
+ holderName: string
1807
+ holderPhone?: string
1808
+ isOnSale: boolean
1809
+ isSellable: true
1810
+ pdfLink: string
1811
+ qrData: string
1812
+ resaleFeeAmount: number
1813
+ status: string
1814
+ ticketType: string
1815
+ }[]
1816
+ }
1817
+ }>
1818
+ ```
1819
+
1820
+ ## LoginCore
1821
+ Handles the login and logout process.
1822
+
1823
+ Exposes the following functions:
1824
+
1825
+ `login` Logs in the user.
1826
+
1827
+ `logout` Logs out the user.
1828
+
1829
+ ```ts
1830
+ login(fields?: {
1831
+ email: string
1832
+ password: string
1833
+ }): Promise<{
1834
+ error?: {
1835
+ code?: number
1836
+ message: string
1837
+ extraData?: any
1838
+ }
1839
+
1840
+ data?: {
1841
+ customerId: string
1842
+ firstName: string
1843
+ lastName: string
1844
+ email: string
1845
+ phone: string
1846
+ streetAddress: string
1847
+ zipCode: string
1848
+ countryId: string
1849
+ company?: string
1850
+ state: string
1851
+ stateId: string
1852
+ city: string
1853
+ }
1854
+ }>
1855
+
1856
+ logout(): Promise<void>
1857
+ ```
1858
+
1859
+
1860
+ # Utils
1861
+
1862
+ `deleteAllData` asynchronously deletes all the data stored in the local storage. Use this with caution, only in an edge case.
1863
+