@paypal/checkout-components 5.0.405 → 5.0.407-alpha-63f032e.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.
@@ -0,0 +1,983 @@
1
+ /* @flow */
2
+ /** @jsx node */
3
+ /* eslint max-lines: 0 */
4
+
5
+ import {
6
+ getLogger,
7
+ getLocale,
8
+ getClientID,
9
+ getEnv,
10
+ getMerchantID,
11
+ getPayPalDomainRegex,
12
+ getSDKMeta,
13
+ getCSPNonce,
14
+ getPayPalDomain,
15
+ getVersion,
16
+ getCurrency,
17
+ getUserIDToken,
18
+ getAmount,
19
+ getAPIStageHost,
20
+ getBuyerCountry,
21
+ getClientAccessToken,
22
+ getClientMetadataID,
23
+ getCommit,
24
+ getComponents,
25
+ getCorrelationID,
26
+ getDebug,
27
+ getDisableSetCookie,
28
+ getExperimentation,
29
+ getIntent,
30
+ getJsSdkLibrary,
31
+ getMerchantRequestedPopupsDisabled,
32
+ getPartnerAttributionID,
33
+ getPlatform,
34
+ getSDKInitTime,
35
+ getSDKIntegrationSource,
36
+ getSDKToken,
37
+ getStageHost,
38
+ getStorageID,
39
+ getUserExperienceFlow,
40
+ getVault,
41
+ getSDKAttribute,
42
+ } from "@paypal/sdk-client/src";
43
+ import {
44
+ getRememberedFunding,
45
+ getRefinedFundingEligibility,
46
+ rememberFunding,
47
+ } from "@paypal/funding-components/src";
48
+ import { ZalgoPromise } from "@krakenjs/zalgo-promise/src";
49
+ import {
50
+ ENV,
51
+ FPTI_KEY,
52
+ FUNDING,
53
+ SDK_SETTINGS,
54
+ } from "@paypal/sdk-constants/src";
55
+ import { create, EVENT, type ZoidComponent } from "@krakenjs/zoid/src";
56
+ import {
57
+ uniqueID,
58
+ memoize,
59
+ getUserAgent,
60
+ noop,
61
+ supportsPopups as userAgentSupportsPopups,
62
+ } from "@krakenjs/belter/src";
63
+ import { node, dom } from "@krakenjs/jsx-pragmatic/src";
64
+
65
+ import {
66
+ getSessionID,
67
+ logLatencyInstrumentationPhase,
68
+ sessionState,
69
+ storageState,
70
+ } from "../../lib";
71
+ import {
72
+ getButtonColor,
73
+ normalizeButtonMessage,
74
+ normalizeButtonStyle,
75
+ } from "../../ui/buttons/props";
76
+ import { isSupportedNativeVenmoBrowser } from "../../funding/util";
77
+ import {
78
+ getButtonExperiments,
79
+ getButtonSize,
80
+ getModal,
81
+ isSupportedNativeBrowser,
82
+ getRenderedButtons,
83
+ sendPostRobotMessageToButtonIframe,
84
+ } from "../buttons/util";
85
+ import { PayPalAppSwitchOverlay } from "../../ui/overlay/paypal-app-switch/overlay";
86
+
87
+ import { containerTemplate } from "./container";
88
+ import { PrerenderedSavedPaymentMethods } from "./prerender";
89
+ import { type SavedPaymentMethodsProps } from "./props";
90
+ import { getSavedPaymentMethodsSize } from "./util";
91
+
92
+ export type SavedPaymentMethodsComponent = ZoidComponent<
93
+ SavedPaymentMethodsProps,
94
+ void,
95
+ void,
96
+ void
97
+ >;
98
+
99
+ // $FlowIssue
100
+ export const getSavedPaymentMethodsComponent: () => SavedPaymentMethodsComponent =
101
+ memoize(() => {
102
+ const queriedEligibleFunding = [];
103
+
104
+ // $FlowIssue
105
+ return create({
106
+ tag: "paypal-saved-payment-methods",
107
+ url: () =>
108
+ `${getPayPalDomain()}${
109
+ __PAYPAL_CHECKOUT__.__URI__.__SAVED_PAYMENT_METHODS__ ||
110
+ "/smart/saved-payment-methods"
111
+ }`,
112
+
113
+ domain: getPayPalDomainRegex(),
114
+
115
+ autoResize: {
116
+ width: false,
117
+ height: true,
118
+ element: ".saved-payment-methods-container",
119
+ },
120
+
121
+ dimensions: {
122
+ // TODO: Does this have any effect?
123
+ width: "400px",
124
+ height: "30px",
125
+ },
126
+
127
+ containerTemplate,
128
+
129
+ // $FlowIssue mismatch between beaver-logger and zoid logger types
130
+ logger: getLogger(),
131
+
132
+ prerenderTemplate: ({ props, doc, event }) => {
133
+ const { buttonSessionID } = props;
134
+
135
+ event.on(EVENT.PRERENDERED, () => {
136
+ getLogger()
137
+ .info("saved_payment_methods_prerendered", {
138
+ buttonSessionID,
139
+ })
140
+ .flush();
141
+ });
142
+
143
+ return (
144
+ <PrerenderedSavedPaymentMethods nonce={props.nonce} props={props} />
145
+ ).render(dom({ doc }));
146
+ },
147
+
148
+ attributes: {
149
+ iframe: {
150
+ scrolling: "no",
151
+ title: "PayPal Saved Payment Methods",
152
+ },
153
+ },
154
+
155
+ props: {
156
+ appSwitchWhenAvailable: {
157
+ type: "boolean",
158
+ queryParam: true,
159
+ required: false,
160
+ },
161
+
162
+ preferences: {
163
+ type: "object",
164
+ queryParam: true,
165
+ required: false,
166
+ serialization: "json",
167
+ },
168
+
169
+ showPayPalAppSwitchOverlay: {
170
+ type: "function",
171
+ queryParam: false,
172
+ value:
173
+ ({ props: { buttonSessionID } }) =>
174
+ ({ close, focus }) => {
175
+ const overlay = (
176
+ <PayPalAppSwitchOverlay
177
+ buttonSessionID={buttonSessionID}
178
+ close={close}
179
+ focus={focus}
180
+ />
181
+ ).render(dom({ doc: document }));
182
+
183
+ document.body?.appendChild(overlay);
184
+ },
185
+ },
186
+
187
+ hidePayPalAppSwitchOverlay: {
188
+ type: "function",
189
+ queryParam: false,
190
+ value:
191
+ ({ props: { buttonSessionID } }) =>
192
+ ({ close }) => {
193
+ const overlay = document.getElementsByName(
194
+ `paypal-overlay-${buttonSessionID}`
195
+ )?.[0];
196
+
197
+ if (overlay) {
198
+ close();
199
+ overlay.remove();
200
+ }
201
+ },
202
+ },
203
+
204
+ redirect: {
205
+ type: "function",
206
+ sendToChild: true,
207
+ value: () => (url) => {
208
+ location.href = url;
209
+ },
210
+ },
211
+
212
+ hashChangeHandler: {
213
+ type: "function",
214
+ sendToChild: false,
215
+ queryParam: false,
216
+ value: () => (event) => {
217
+ sendPostRobotMessageToButtonIframe({
218
+ eventName: "paypal-hashchange",
219
+ payload: {
220
+ url: event.newURL,
221
+ },
222
+ });
223
+ },
224
+ },
225
+
226
+ listenForHashChanges: {
227
+ type: "function",
228
+ queryParam: false,
229
+ value:
230
+ ({ props }) =>
231
+ () => {
232
+ window.addEventListener("hashchange", props.hashChangeHandler);
233
+ },
234
+ },
235
+
236
+ removeListenerForHashChanges: {
237
+ type: "function",
238
+ queryParam: false,
239
+ value:
240
+ ({ props }) =>
241
+ () => {
242
+ window.removeEventListener("hashchange", props.hashChangeHandler);
243
+ },
244
+ },
245
+
246
+ visibilityChangeHandler: {
247
+ type: "function",
248
+ sendToChild: false,
249
+ queryParam: false,
250
+ value: () => () => {
251
+ sendPostRobotMessageToButtonIframe({
252
+ eventName: "paypal-visibilitychange",
253
+ payload: {
254
+ url: window.location.href,
255
+
256
+ visibilityState: document.visibilityState,
257
+ },
258
+ });
259
+ },
260
+ },
261
+
262
+ listenForVisibilityChange: {
263
+ type: "function",
264
+ queryParam: false,
265
+ value:
266
+ ({ props }) =>
267
+ () => {
268
+ window.addEventListener(
269
+ "visibilitychange",
270
+ props.visibilityChangeHandler
271
+ );
272
+ },
273
+ },
274
+
275
+ removeListenerForVisibilityChanges: {
276
+ type: "function",
277
+ queryParam: false,
278
+ value:
279
+ ({ props }) =>
280
+ () => {
281
+ window.removeEventListener(
282
+ "visibilitychange",
283
+ props.visibilityChangeHandler
284
+ );
285
+ },
286
+ },
287
+
288
+ // allowBillingPayments prop is used by Honey Extension to render the one-click button
289
+ // with payment methods & to use the payment methods instead of the Billing Agreement
290
+ allowBillingPayments: {
291
+ type: "boolean",
292
+ queryParam: true,
293
+ required: false,
294
+ default: () => true,
295
+ },
296
+
297
+ amount: {
298
+ type: "string",
299
+ required: false,
300
+ queryParam: true,
301
+ value: getAmount,
302
+ },
303
+
304
+ apiStageHost: {
305
+ type: "string",
306
+ value: getAPIStageHost,
307
+ required: false,
308
+ },
309
+
310
+ buttonLocation: {
311
+ type: "string",
312
+ value: () => window.location.hostname,
313
+ queryParam: false,
314
+ },
315
+
316
+ buttonSessionID: {
317
+ type: "string",
318
+ value: uniqueID,
319
+ queryParam: true,
320
+ },
321
+
322
+ buyerCountry: {
323
+ type: "string",
324
+ queryParam: true,
325
+ required: false,
326
+ value: getBuyerCountry,
327
+ },
328
+
329
+ clientAccessToken: {
330
+ type: "string",
331
+ required: false,
332
+ queryParam: true,
333
+ value: getClientAccessToken,
334
+ },
335
+
336
+ customerId: {
337
+ type: "string",
338
+ required: false,
339
+ queryParam: true,
340
+ value: getCustomerId,
341
+ },
342
+
343
+ clientID: {
344
+ type: "string",
345
+ value: getClientID,
346
+ queryParam: true,
347
+ },
348
+
349
+ clientMetadataID: {
350
+ type: "string",
351
+ required: false,
352
+ default: () => {
353
+ const clientMetadataId = getClientMetadataID();
354
+ const sessionID = getSessionID();
355
+
356
+ return clientMetadataId || sessionID;
357
+ },
358
+ queryParam: true,
359
+ },
360
+
361
+ commit: {
362
+ type: "boolean",
363
+ queryParam: true,
364
+ value: getCommit,
365
+ },
366
+
367
+ components: {
368
+ type: "array",
369
+ queryParam: true,
370
+ value: getComponents,
371
+ },
372
+
373
+ createOrder: {
374
+ type: "function",
375
+ required: false,
376
+ },
377
+
378
+ csp: {
379
+ type: "object",
380
+ required: false,
381
+ value: () => {
382
+ return {
383
+ nonce: getCSPNonce(),
384
+ };
385
+ },
386
+ },
387
+
388
+ currency: {
389
+ type: "string",
390
+ queryParam: true,
391
+ value: getCurrency,
392
+ },
393
+
394
+ debug: {
395
+ type: "boolean",
396
+ value: getDebug,
397
+ queryParam: true,
398
+ },
399
+
400
+ disableSetCookie: {
401
+ type: "boolean",
402
+ queryParam: true,
403
+ required: false,
404
+ value: getDisableSetCookie,
405
+ },
406
+
407
+ env: {
408
+ type: "string",
409
+ queryParam: true,
410
+ value: getEnv,
411
+ },
412
+
413
+ experiment: {
414
+ type: "object",
415
+ queryParam: true,
416
+ value: getButtonExperiments,
417
+ },
418
+
419
+ experimentation: {
420
+ type: "object",
421
+ queryParam: true,
422
+ required: false,
423
+ value: getExperimentation,
424
+ },
425
+
426
+ fundingEligibility: {
427
+ type: "object",
428
+ default: getRefinedFundingEligibility,
429
+ value:
430
+ __ENV__ === ENV.LOCAL ? undefined : getRefinedFundingEligibility,
431
+ queryParam: true,
432
+ serialization: "base64",
433
+ },
434
+
435
+ fundingSource: {
436
+ type: "string",
437
+ queryParam: true,
438
+ required: false,
439
+ validate: ({ props }) => {}, // TODO: Validate funding source (see buttons/component)
440
+ },
441
+
442
+ getPageUrl: {
443
+ type: "function",
444
+ value: () => {
445
+ return () => window.location.href;
446
+ },
447
+ },
448
+
449
+ getPopupBridge: {
450
+ type: "function",
451
+ required: false,
452
+ value: () => {
453
+ return () => {
454
+ if (!window.popupBridge) {
455
+ return;
456
+ }
457
+
458
+ return {
459
+ nativeUrl: window.popupBridge.getReturnUrlPrefix(),
460
+ start: (url) => {
461
+ return new ZalgoPromise((resolve, reject) => {
462
+ window.popupBridge.onComplete = (err, result) => {
463
+ if (!err && !result) {
464
+ resolve({
465
+ opType: "user_closed_window",
466
+ });
467
+ }
468
+ const queryItems =
469
+ result && result.queryItems ? result.queryItems : {};
470
+ return err ? reject(err) : resolve(queryItems);
471
+ };
472
+ window.popupBridge.open(url);
473
+ });
474
+ },
475
+ };
476
+ };
477
+ },
478
+ },
479
+
480
+ getPrerenderDetails: {
481
+ type: "function",
482
+ value:
483
+ ({ state }) =>
484
+ () =>
485
+ state.prerenderDetails,
486
+ },
487
+
488
+ getQueriedEligibleFunding: {
489
+ type: "function",
490
+ value: () => {
491
+ return () => queriedEligibleFunding;
492
+ },
493
+ },
494
+
495
+ hostedButtonId: {
496
+ type: "string",
497
+ required: false,
498
+ queryParam: true,
499
+ },
500
+
501
+ intent: {
502
+ type: "string",
503
+ queryParam: true,
504
+ value: getIntent,
505
+ },
506
+
507
+ jsSdkLibrary: {
508
+ type: "string",
509
+ queryParam: true,
510
+ required: false,
511
+ value: getJsSdkLibrary,
512
+ },
513
+
514
+ locale: {
515
+ type: "object",
516
+ queryParam: true,
517
+ value: getLocale,
518
+ },
519
+
520
+ merchantID: {
521
+ type: "array",
522
+ queryParam: true,
523
+ value: getMerchantID,
524
+ },
525
+
526
+ merchantRequestedPopupsDisabled: {
527
+ type: "boolean",
528
+ required: false,
529
+ value: getMerchantRequestedPopupsDisabled,
530
+ },
531
+
532
+ message: {
533
+ type: "object",
534
+ queryParam: true,
535
+ required: false,
536
+ decorate: ({ props, value }) => {
537
+ const {
538
+ style: { layout },
539
+ renderedButtons: fundingSources,
540
+ } = props;
541
+ return normalizeButtonMessage(
542
+ // $FlowFixMe
543
+ value,
544
+ layout,
545
+ fundingSources
546
+ );
547
+ },
548
+ },
549
+
550
+ nonce: {
551
+ type: "string",
552
+ default: getCSPNonce,
553
+ },
554
+
555
+ onApprove: {
556
+ type: "function",
557
+ required: false,
558
+ },
559
+
560
+ onCancel: {
561
+ type: "function",
562
+ required: false,
563
+ },
564
+
565
+ onClick: {
566
+ type: "function",
567
+ required: false,
568
+ },
569
+
570
+ onComplete: {
571
+ type: "function",
572
+ required: false,
573
+ },
574
+
575
+ onError: {
576
+ // TODO: Is it necessary? Not present in buttons
577
+ type: "function",
578
+ required: false,
579
+ },
580
+
581
+ onInit: {
582
+ type: "function",
583
+ required: false,
584
+ default: () => noop,
585
+ decorate: ({ props, value = noop }) => {
586
+ logLatencyInstrumentationPhase({
587
+ buttonSessionID: props.buttonSessionID,
588
+ phase: "buttons-first-render",
589
+ });
590
+
591
+ return (...args) => {
592
+ return value(...args);
593
+ };
594
+ },
595
+ },
596
+
597
+ onMessageClick: {
598
+ type: "function",
599
+ required: false,
600
+ value: ({ props }) => {
601
+ return async ({
602
+ offerType,
603
+ messageType,
604
+ offerCountryCode,
605
+ creditProductIdentifier,
606
+ }) => {
607
+ const {
608
+ message,
609
+ clientID,
610
+ currency,
611
+ buttonSessionID,
612
+ merchantID,
613
+ } = props;
614
+ const amount = message?.amount;
615
+
616
+ getLogger()
617
+ .info("saved_payment_methods_message_click")
618
+ .track({
619
+ [FPTI_KEY.TRANSITION]: "saved_payment_methods_message_click",
620
+ [FPTI_KEY.STATE]: "BUTTON_MESSAGE",
621
+ [FPTI_KEY.BUTTON_SESSION_UID]: buttonSessionID,
622
+ [FPTI_KEY.CONTEXT_ID]: buttonSessionID,
623
+ [FPTI_KEY.CONTEXT_TYPE]: "button_session_id",
624
+ [FPTI_KEY.EVENT_NAME]: "message_click",
625
+ [FPTI_KEY.BUTTON_MESSAGE_OFFER_TYPE]: offerType,
626
+ [FPTI_KEY.BUTTON_MESSAGE_CREDIT_PRODUCT_IDENTIFIER]:
627
+ creditProductIdentifier,
628
+ [FPTI_KEY.BUTTON_MESSAGE_TYPE]: messageType,
629
+ [FPTI_KEY.BUTTON_MESSAGE_POSITION]: message?.position,
630
+ [FPTI_KEY.BUTTON_MESSAGE_ALIGN]: message?.align,
631
+ [FPTI_KEY.BUTTON_MESSAGE_COLOR]: message?.color,
632
+ [FPTI_KEY.BUTTON_MESSAGE_OFFER_COUNTRY]: offerCountryCode,
633
+ [FPTI_KEY.BUTTON_MESSAGE_CURRENCY]: currency,
634
+ [FPTI_KEY.BUTTON_MESSAGE_AMOUNT]: amount,
635
+ })
636
+ .flush();
637
+
638
+ const modalInstance = await getModal(
639
+ clientID,
640
+ merchantID,
641
+ buttonSessionID
642
+ );
643
+ return modalInstance?.show({
644
+ amount,
645
+ offer: offerType,
646
+ currency,
647
+ });
648
+ };
649
+ },
650
+ },
651
+
652
+ onMessageHover: {
653
+ type: "function",
654
+ required: false,
655
+ value: ({ props }) => {
656
+ return () => {
657
+ const { buttonSessionID, clientID, merchantID } = props;
658
+ return getModal(clientID, merchantID, buttonSessionID);
659
+ };
660
+ },
661
+ },
662
+
663
+ onMessageReady: {
664
+ type: "function",
665
+ required: false,
666
+ value: ({ props }) => {
667
+ return ({
668
+ offerType,
669
+ messageType,
670
+ offerCountryCode,
671
+ creditProductIdentifier,
672
+ merchantID: serverMerchantId,
673
+ }) => {
674
+ const { message, buttonSessionID, currency } = props;
675
+
676
+ if (serverMerchantId) {
677
+ getLogger().addTrackingBuilder(() => ({
678
+ [FPTI_KEY.SELLER_ID]: serverMerchantId,
679
+ }));
680
+ }
681
+
682
+ getLogger()
683
+ .info("saved_payment_methods_message_render")
684
+ .track({
685
+ [FPTI_KEY.TRANSITION]: "saved_payment_methods_message_render",
686
+ [FPTI_KEY.STATE]: "BUTTON_MESSAGE",
687
+ [FPTI_KEY.BUTTON_SESSION_UID]: buttonSessionID,
688
+ [FPTI_KEY.CONTEXT_ID]: buttonSessionID,
689
+ [FPTI_KEY.CONTEXT_TYPE]: "button_session_id",
690
+ [FPTI_KEY.EVENT_NAME]: "message_render",
691
+ [FPTI_KEY.BUTTON_MESSAGE_OFFER_TYPE]: offerType,
692
+ [FPTI_KEY.BUTTON_MESSAGE_CREDIT_PRODUCT_IDENTIFIER]:
693
+ creditProductIdentifier,
694
+ [FPTI_KEY.BUTTON_MESSAGE_TYPE]: messageType,
695
+ [FPTI_KEY.BUTTON_MESSAGE_POSITION]: message?.position,
696
+ [FPTI_KEY.BUTTON_MESSAGE_ALIGN]: message?.align,
697
+ [FPTI_KEY.BUTTON_MESSAGE_COLOR]: message?.color,
698
+ [FPTI_KEY.BUTTON_MESSAGE_CURRENCY]: currency,
699
+ [FPTI_KEY.BUTTON_MESSAGE_OFFER_COUNTRY]: offerCountryCode,
700
+ [FPTI_KEY.BUTTON_MESSAGE_AMOUNT]: message?.amount,
701
+ })
702
+ .flush();
703
+ };
704
+ },
705
+ },
706
+
707
+ onShippingAddressChange: {
708
+ type: "function",
709
+ required: false,
710
+ },
711
+
712
+ onShippingOptionsChange: {
713
+ type: "function",
714
+ required: false,
715
+ },
716
+
717
+ hasShippingCallback: {
718
+ type: "boolean",
719
+ required: false,
720
+ queryParam: true,
721
+ value: ({ props }) => {
722
+ return Boolean(
723
+ props.onShippingChange ||
724
+ props.onShippingAddressChange ||
725
+ props.onShippingOptionsChange
726
+ );
727
+ },
728
+ },
729
+
730
+ pageType: {
731
+ type: "string",
732
+ required: false,
733
+ queryParam: true,
734
+ value: () => getSDKAttribute(SDK_SETTINGS.PAGE_TYPE),
735
+ },
736
+
737
+ partnerAttributionID: {
738
+ type: "string",
739
+ required: false,
740
+ value: getPartnerAttributionID,
741
+ },
742
+
743
+ paymentMethodNonce: {
744
+ type: "string",
745
+ queryParam: true,
746
+ required: false,
747
+ },
748
+
749
+ paymentMethodToken: {
750
+ type: "string",
751
+ queryParam: true,
752
+ required: false,
753
+ },
754
+
755
+ paymentRequest: {
756
+ type: "object",
757
+ queryParam: false,
758
+ required: false,
759
+ },
760
+
761
+ platform: {
762
+ type: "string",
763
+ queryParam: true,
764
+ value: getPlatform,
765
+ },
766
+
767
+ referrerDomain: {
768
+ type: "string",
769
+ required: false,
770
+ value: () => {
771
+ if (window.document.referrer) {
772
+ return new URL(window.document.referrer).host || undefined;
773
+ }
774
+ },
775
+ },
776
+
777
+ remember: {
778
+ type: "function",
779
+ value: () => {
780
+ return (fundingSources: $ReadOnlyArray<$Values<typeof FUNDING>>) =>
781
+ rememberFunding(fundingSources, { cookie: false });
782
+ },
783
+ },
784
+
785
+ remembered: {
786
+ type: "array",
787
+ queryParam: true,
788
+ value: getRememberedFunding,
789
+ },
790
+
791
+ sessionID: {
792
+ type: "string",
793
+ value: getSessionID,
794
+ queryParam: true,
795
+ },
796
+
797
+ sdkCorrelationID: {
798
+ type: "string",
799
+ required: false,
800
+ value: getCorrelationID,
801
+ queryParam: true,
802
+ },
803
+
804
+ sdkInitTimings: {
805
+ type: "object",
806
+ queryParam: false,
807
+ required: false,
808
+ value: () => {
809
+ // eslint-disable-next-line compat/compat
810
+ const sdkScript = window?.performance
811
+ ?.getEntriesByType("resource")
812
+ // eslint-disable-next-line security/detect-unsafe-regex
813
+ .find(({ name }) => /paypal\.com(?::\d+)?\/sdk\/js/.test(name));
814
+
815
+ const isCached = (performanceEntry) => {
816
+ if (
817
+ !performanceEntry ||
818
+ typeof performanceEntry.duration === "undefined"
819
+ ) {
820
+ return "unknown";
821
+ }
822
+
823
+ return performanceEntry.duration === 0 ? "yes" : "no";
824
+ };
825
+
826
+ let sdkInitTimeStamp;
827
+
828
+ try {
829
+ sdkInitTimeStamp = getSDKInitTime();
830
+ } catch (error) {
831
+ // do nothing
832
+ }
833
+
834
+ return {
835
+ sdkInitTimeStamp,
836
+ sdkScriptDownloadDuration: sdkScript?.duration,
837
+ isSdkCached: isCached(sdkScript),
838
+ };
839
+ },
840
+ },
841
+
842
+ sdkMeta: {
843
+ type: "string",
844
+ queryParam: true,
845
+ sendToChild: false,
846
+ value: getSDKMeta,
847
+ },
848
+
849
+ sdkToken: {
850
+ type: "string",
851
+ required: false,
852
+ value: getSDKToken,
853
+ },
854
+
855
+ /**
856
+ * Version of the SDK used in first render.
857
+ * This is passed to the `/smart/buttons` endpoint in order for the second render
858
+ * to be aware of what sdk version to load during SSR of the buttons
859
+ */
860
+ sdkVersion: {
861
+ type: "string",
862
+ queryParam: true,
863
+ sendToChild: false,
864
+ value: getVersion,
865
+ },
866
+
867
+ sessionState: {
868
+ type: "object",
869
+ value: () => sessionState,
870
+ },
871
+
872
+ stageHost: {
873
+ type: "string",
874
+ value: getStageHost,
875
+ required: false,
876
+ },
877
+
878
+ storageID: {
879
+ type: "string",
880
+ value: getStorageID,
881
+ queryParam: true,
882
+ },
883
+
884
+ storageState: {
885
+ type: "object",
886
+ value: () => storageState,
887
+ },
888
+
889
+ style: {
890
+ type: "object",
891
+ queryParam: true,
892
+ required: false,
893
+ decorate: ({ props, value }) => {
894
+ // $FlowFixMe
895
+ return normalizeButtonStyle(props, value);
896
+ },
897
+
898
+ validate: ({ props, value = {} }) => {
899
+ // $FlowFixMe
900
+ normalizeButtonStyle(props, value);
901
+ },
902
+
903
+ default: () => ({}),
904
+ },
905
+
906
+ supportedNativeBrowser: {
907
+ type: "boolean",
908
+ value: isSupportedNativeBrowser,
909
+ queryParam: true,
910
+ },
911
+
912
+ supportedNativeVenmoBrowser: {
913
+ type: "boolean",
914
+ value: ({ props }) => {
915
+ return isSupportedNativeVenmoBrowser(
916
+ props.experiment,
917
+ props.userAgent
918
+ );
919
+ },
920
+ queryParam: true,
921
+ required: false,
922
+ },
923
+
924
+ supportsPopups: {
925
+ type: "boolean",
926
+ value: () => {
927
+ return userAgentSupportsPopups();
928
+ },
929
+ queryParam: true,
930
+ },
931
+
932
+ test: {
933
+ type: "object",
934
+ default(): Object {
935
+ return {
936
+ action: "checkout",
937
+ };
938
+ },
939
+ },
940
+
941
+ userExperienceFlow: {
942
+ type: "string",
943
+ required: false,
944
+ value: getUserExperienceFlow,
945
+ },
946
+
947
+ userIDToken: {
948
+ type: "string",
949
+ default: getUserIDToken,
950
+ required: false,
951
+ queryParam: true,
952
+ // queryParam: getEnv() !== ENV.LOCAL && getEnv() !== ENV.STAGE,
953
+ // bodyParam: getEnv() === ENV.LOCAL || getEnv() === ENV.STAGE,
954
+ },
955
+
956
+ sdkSource: {
957
+ type: "string",
958
+ value: () => getSDKIntegrationSource(),
959
+ required: false,
960
+ queryParam: true,
961
+ },
962
+
963
+ vault: {
964
+ type: "boolean",
965
+ queryParam: true,
966
+ value: getVault,
967
+ },
968
+
969
+ wallet: {
970
+ type: "object",
971
+ required: false,
972
+ default: () => window.__TEST_WALLET__,
973
+ },
974
+
975
+ userAgent: {
976
+ type: "string",
977
+ required: false,
978
+ queryParam: true,
979
+ value: getUserAgent,
980
+ },
981
+ },
982
+ });
983
+ });