tf-checkout-react 1.1.0 → 1.2.0
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/tf-checkout-react.cjs.development.js +39 -5
- 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 +39 -5
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/index.ts +39 -5
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import _get from 'lodash/get'
|
|
|
4
4
|
import { CONFIGS, getCookieByName, setCustomCookie } from '../utils'
|
|
5
5
|
|
|
6
6
|
const isWindowDefined = typeof window !== 'undefined'
|
|
7
|
+
const isDocumentDefined = typeof document !== 'undefined'
|
|
7
8
|
|
|
8
9
|
const ttfHeaders: { [key: string]: any } = {
|
|
9
10
|
Accept: 'application/vnd.api+json',
|
|
@@ -160,8 +161,24 @@ export const handleSetAccessToken = (token: string) => {
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
export function getEvent(id: string | number) {
|
|
164
|
+
let referralValue = ""
|
|
165
|
+
if (isWindowDefined) {
|
|
166
|
+
const params = new URL(`${window.location}`)
|
|
167
|
+
const referralId = params.searchParams.get('ttf_r') || ''
|
|
168
|
+
const referral_key = window.localStorage.getItem('referral_key')
|
|
169
|
+
let referralIdlocal = ""
|
|
170
|
+
if (referral_key) {
|
|
171
|
+
referralIdlocal = referral_key.split('.')[1]
|
|
172
|
+
}
|
|
173
|
+
referralValue = referralId || referralIdlocal
|
|
174
|
+
}
|
|
175
|
+
|
|
163
176
|
const response = publicRequest
|
|
164
|
-
.get(`v1/event/${id}`, {
|
|
177
|
+
.get(`v1/event/${id}`, {
|
|
178
|
+
headers: { ...ttfHeaders,
|
|
179
|
+
"Referer-Url": isDocumentDefined ? document.referrer : '',
|
|
180
|
+
"Referrer-Id": isWindowDefined ? referralValue : ''
|
|
181
|
+
} })
|
|
165
182
|
.catch(error => {
|
|
166
183
|
throw error
|
|
167
184
|
})
|
|
@@ -186,7 +203,12 @@ export function getTickets(id: string | number, promoCode: string) {
|
|
|
186
203
|
}
|
|
187
204
|
|
|
188
205
|
export const addToCart = (id: string | number, data: any) => {
|
|
189
|
-
const res = publicRequest.post(`v1/event/${id}/add-to-cart/`, {
|
|
206
|
+
const res = publicRequest.post(`v1/event/${id}/add-to-cart/`, {
|
|
207
|
+
data,
|
|
208
|
+
headers: {
|
|
209
|
+
"Referer-Url": isDocumentDefined ? document.referrer : '',
|
|
210
|
+
}
|
|
211
|
+
})
|
|
190
212
|
return res
|
|
191
213
|
}
|
|
192
214
|
|
|
@@ -223,7 +245,11 @@ export const getAccessToken = (data: FormData) =>
|
|
|
223
245
|
|
|
224
246
|
export const getPaymentData = (hash: string) => {
|
|
225
247
|
const response = publicRequest
|
|
226
|
-
.get(`v1/order/${hash}/review
|
|
248
|
+
.get(`v1/order/${hash}/review/`, {
|
|
249
|
+
headers: {
|
|
250
|
+
"Referer-Url": isDocumentDefined ? document.referrer : '' ,
|
|
251
|
+
}
|
|
252
|
+
})
|
|
227
253
|
.catch(error => {
|
|
228
254
|
throw error
|
|
229
255
|
})
|
|
@@ -243,7 +269,11 @@ export const handlePaymentData = (orderHash: string, data: any) => {
|
|
|
243
269
|
|
|
244
270
|
export const handlePaymentSuccess = (orderHash: string) => {
|
|
245
271
|
const res = publicRequest
|
|
246
|
-
.post(`v1/order/${orderHash}/success
|
|
272
|
+
.post(`v1/order/${orderHash}/success`, {
|
|
273
|
+
headers: {
|
|
274
|
+
"Referer-Url": isDocumentDefined ? document.referrer : ''
|
|
275
|
+
}
|
|
276
|
+
})
|
|
247
277
|
.catch(error => {
|
|
248
278
|
throw error
|
|
249
279
|
})
|
|
@@ -252,7 +282,11 @@ export const handlePaymentSuccess = (orderHash: string) => {
|
|
|
252
282
|
|
|
253
283
|
export const handleFreeSuccess = (orderHash: string) => {
|
|
254
284
|
const res = publicRequest
|
|
255
|
-
.post(`v1/order/${orderHash}/complete_free_registration
|
|
285
|
+
.post(`v1/order/${orderHash}/complete_free_registration`, {
|
|
286
|
+
headers: {
|
|
287
|
+
"Referer-Url": isDocumentDefined ? document.referrer : ''
|
|
288
|
+
}
|
|
289
|
+
})
|
|
256
290
|
.catch(error => {
|
|
257
291
|
throw error
|
|
258
292
|
})
|