@@ -225,18 +225,6 @@ export function getElementFromSelector(
225
225
: selector ;
226
226
}
227
227
228
- export function getTrackingId (
229
- HostedButtonSelector : string | HTMLElement
230
- ) : string {
231
- if ( typeof HostedButtonSelector !== "string" ) {
232
- return "" ;
233
- }
234
- const ele = document . querySelector (
235
- `${ HostedButtonSelector } input[name="uuid"]`
236
- ) ;
237
- return ele ? ele . getAttribute ( "value" ) || "" : "" ;
238
- }
239
-
240
228
/**
241
229
* Attaches form fields (html) to the given selector, and
242
230
* initializes window.__pp_form_fields (htmlScript).
@@ -269,7 +257,7 @@ export const buildHostedButtonCreateOrder = ({
269
257
enableDPoP,
270
258
hostedButtonId,
271
259
merchantId,
272
- trackingId ,
260
+ fptiTrackingParams ,
273
261
} : GetCallbackProps ) : CreateOrder => {
274
262
return async ( data ) => {
275
263
const userInputs =
@@ -280,15 +268,15 @@ export const buildHostedButtonCreateOrder = ({
280
268
const url = `${ apiUrl } /v1/checkout/links/${ hostedButtonId } /create-context` ;
281
269
const method = "POST" ;
282
270
const headers = await buildRequestHeaders ( { url, method, enableDPoP } ) ;
283
-
271
+ const funding_source = data . paymentSource . toUpperCase ( ) ;
284
272
const response = await request ( {
285
273
url,
286
274
// $FlowIssue optional properties are not compatible with [key: string]: string
287
275
headers,
288
276
method,
289
277
body : JSON . stringify ( {
290
278
entry_point : entryPoint ,
291
- funding_source : data . paymentSource . toUpperCase ( ) ,
279
+ funding_source,
292
280
merchant_id : merchantId ,
293
281
...userInputs ,
294
282
} ) ,
@@ -297,9 +285,10 @@ export const buildHostedButtonCreateOrder = ({
297
285
const { body } = response ;
298
286
getLogger ( )
299
287
. track ( {
288
+ ...fptiTrackingParams ,
300
289
[ FPTI_KEY . CONTEXT_ID ] : body . context_id ,
301
290
[ FPTI_KEY . EVENT_NAME ] : "ncps_create_order" ,
302
- tracking_id : trackingId ,
291
+ funding_type : funding_source ,
303
292
} )
304
293
. flush ( ) ;
305
294
return body . context_id || onError ( body . details ?. [ 0 ] ?. issue || body . name ) ;
@@ -313,7 +302,7 @@ export const buildHostedButtonOnApprove = ({
313
302
enableDPoP,
314
303
hostedButtonId,
315
304
merchantId,
316
- trackingId ,
305
+ fptiTrackingParams ,
317
306
} : GetCallbackProps ) : OnApprove => {
318
307
return async ( data ) => {
319
308
const url = `${ apiUrl } /v1/checkout/links/${ hostedButtonId } /pay` ;
@@ -333,9 +322,9 @@ export const buildHostedButtonOnApprove = ({
333
322
} ) . then ( ( response ) => {
334
323
getLogger ( )
335
324
. track ( {
325
+ ...fptiTrackingParams ,
336
326
[ FPTI_KEY . CONTEXT_ID ] : data . orderID ,
337
327
[ FPTI_KEY . EVENT_NAME ] : "ncps_onapprove_order" ,
338
- tracking_id : trackingId ,
339
328
} )
340
329
. flush ( ) ;
341
330
@@ -359,7 +348,7 @@ export const buildHostedButtonOnShippingAddressChange = ({
359
348
enableDPoP,
360
349
hostedButtonId,
361
350
shouldIncludeShippingCallbacks,
362
- trackingId ,
351
+ fptiTrackingParams ,
363
352
} : GetCallbackProps ) : OnShippingAddressChange | typeof undefined = > {
364
353
if ( shouldIncludeShippingCallbacks ) {
365
354
return async ( data , actions ) => {
@@ -398,9 +387,9 @@ export const buildHostedButtonOnShippingAddressChange = ({
398
387
399
388
getLogger ( )
400
389
. track ( {
390
+ ...fptiTrackingParams ,
401
391
[ FPTI_KEY . CONTEXT_ID ] : orderID ,
402
392
[ FPTI_KEY . EVENT_NAME ] : "ncps_shipping_address_change" ,
403
- tracking_id : trackingId ,
404
393
} )
405
394
. flush ( ) ;
406
395
} ;
@@ -411,7 +400,7 @@ export const buildHostedButtonOnShippingOptionsChange = ({
411
400
enableDPoP,
412
401
hostedButtonId,
413
402
shouldIncludeShippingCallbacks,
414
- trackingId ,
403
+ fptiTrackingParams ,
415
404
} : GetCallbackProps ) : OnShippingOptionsChange | typeof undefined = > {
416
405
if ( shouldIncludeShippingCallbacks ) {
417
406
return async ( data , actions ) => {
@@ -439,9 +428,9 @@ export const buildHostedButtonOnShippingOptionsChange = ({
439
428
440
429
getLogger ( )
441
430
. track ( {
431
+ ...fptiTrackingParams ,
442
432
[ FPTI_KEY . CONTEXT_ID ] : orderID ,
443
433
[ FPTI_KEY . EVENT_NAME ] : "ncps_shipping_options_change" ,
444
- tracking_id : trackingId ,
445
434
} )
446
435
. flush ( ) ;
447
436
} ;
0 commit comments