@paypal/checkout-components 5.0.256 → 5.0.258

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 (185) hide show
  1. package/README.md +8 -0
  2. package/__sdk__.js +72 -76
  3. package/dist/button.js +1 -1
  4. package/globals.js +28 -30
  5. package/package.json +6 -4
  6. package/src/constants/button.js +37 -36
  7. package/src/constants/class.js +32 -30
  8. package/src/constants/index.js +3 -3
  9. package/src/constants/misc.js +14 -12
  10. package/src/declarations.js +19 -19
  11. package/src/funding/applepay/config.jsx +51 -50
  12. package/src/funding/applepay/index.js +1 -1
  13. package/src/funding/applepay/style.scoped.scss +1 -1
  14. package/src/funding/applepay/template.jsx +16 -11
  15. package/src/funding/bancontact/config.jsx +48 -37
  16. package/src/funding/bancontact/index.js +1 -2
  17. package/src/funding/blik/config.jsx +48 -37
  18. package/src/funding/blik/index.js +1 -2
  19. package/src/funding/boleto/config.jsx +50 -39
  20. package/src/funding/boleto/index.js +1 -2
  21. package/src/funding/card/amex/config.js +9 -8
  22. package/src/funding/card/amex/index.js +1 -2
  23. package/src/funding/card/config.jsx +246 -177
  24. package/src/funding/card/discover/config.js +9 -7
  25. package/src/funding/card/discover/index.js +1 -2
  26. package/src/funding/card/elo/config.js +6 -7
  27. package/src/funding/card/elo/index.js +1 -2
  28. package/src/funding/card/hiper/config.js +9 -7
  29. package/src/funding/card/hiper/index.js +1 -2
  30. package/src/funding/card/index.js +1 -1
  31. package/src/funding/card/jcb/config.js +6 -7
  32. package/src/funding/card/jcb/index.js +1 -2
  33. package/src/funding/card/mastercard/config.js +9 -7
  34. package/src/funding/card/mastercard/index.js +1 -2
  35. package/src/funding/card/visa/config.js +9 -7
  36. package/src/funding/card/visa/index.js +1 -2
  37. package/src/funding/common.jsx +242 -216
  38. package/src/funding/config.js +212 -65
  39. package/src/funding/content.jsx +1946 -337
  40. package/src/funding/credit/config.jsx +74 -57
  41. package/src/funding/credit/index.js +1 -2
  42. package/src/funding/eps/config.jsx +45 -37
  43. package/src/funding/eps/index.js +1 -2
  44. package/src/funding/funding.js +193 -100
  45. package/src/funding/giropay/config.jsx +48 -38
  46. package/src/funding/giropay/index.js +1 -2
  47. package/src/funding/ideal/config.jsx +48 -37
  48. package/src/funding/ideal/index.js +1 -2
  49. package/src/funding/index.js +2 -2
  50. package/src/funding/itau/config.jsx +41 -41
  51. package/src/funding/itau/index.js +1 -1
  52. package/src/funding/maxima/config.jsx +25 -19
  53. package/src/funding/maxima/index.js +1 -2
  54. package/src/funding/mercadopago/config.jsx +48 -37
  55. package/src/funding/mercadopago/index.js +1 -2
  56. package/src/funding/multibanco/config.jsx +50 -39
  57. package/src/funding/multibanco/index.js +1 -2
  58. package/src/funding/mybank/config.jsx +48 -37
  59. package/src/funding/mybank/index.js +1 -2
  60. package/src/funding/oxxo/config.jsx +50 -39
  61. package/src/funding/oxxo/index.js +1 -2
  62. package/src/funding/p24/config.jsx +45 -37
  63. package/src/funding/p24/index.js +1 -2
  64. package/src/funding/paidy/config.jsx +50 -39
  65. package/src/funding/paidy/index.js +1 -1
  66. package/src/funding/paylater/config.jsx +118 -111
  67. package/src/funding/paylater/index.js +1 -2
  68. package/src/funding/paypal/config.jsx +44 -46
  69. package/src/funding/paypal/index.js +1 -2
  70. package/src/funding/paypal/style.scoped.scss +80 -74
  71. package/src/funding/paypal/template.jsx +450 -354
  72. package/src/funding/payu/config.jsx +50 -39
  73. package/src/funding/payu/index.js +1 -1
  74. package/src/funding/satispay/config.jsx +50 -39
  75. package/src/funding/satispay/index.js +1 -1
  76. package/src/funding/sepa/config.jsx +19 -13
  77. package/src/funding/sepa/index.js +1 -2
  78. package/src/funding/sofort/config.jsx +48 -37
  79. package/src/funding/sofort/index.js +1 -2
  80. package/src/funding/trustly/config.jsx +50 -39
  81. package/src/funding/trustly/index.js +1 -2
  82. package/src/funding/venmo/config.jsx +80 -75
  83. package/src/funding/venmo/index.js +1 -2
  84. package/src/funding/venmo/style.scoped.scss +30 -32
  85. package/src/funding/venmo/template.jsx +56 -57
  86. package/src/funding/verkkopankki/config.jsx +50 -39
  87. package/src/funding/verkkopankki/index.js +1 -1
  88. package/src/funding/wechatpay/config.jsx +48 -37
  89. package/src/funding/wechatpay/index.js +1 -2
  90. package/src/funding/zimpler/config.jsx +19 -13
  91. package/src/funding/zimpler/index.js +1 -2
  92. package/src/interface/button.js +60 -44
  93. package/src/interface/card-fields.js +11 -8
  94. package/src/interface/fields.js +7 -4
  95. package/src/interface/marks.js +4 -4
  96. package/src/interface/payment-fields.js +7 -4
  97. package/src/interface/wallet.js +4 -4
  98. package/src/lib/errors.js +7 -7
  99. package/src/lib/index.js +5 -5
  100. package/src/lib/isRTLLanguage.js +3 -3
  101. package/src/lib/perceived-latency-instrumentation.js +54 -36
  102. package/src/lib/security.js +21 -17
  103. package/src/lib/session.js +39 -35
  104. package/src/marks/component.jsx +114 -65
  105. package/src/marks/index.js +1 -2
  106. package/src/marks/template.jsx +79 -65
  107. package/src/types.js +48 -48
  108. package/src/ui/buttons/button.jsx +311 -249
  109. package/src/ui/buttons/buttonDesigns/control.jsx +3 -5
  110. package/src/ui/buttons/buttonDesigns/divideLogoAnimation.jsx +127 -99
  111. package/src/ui/buttons/buttonDesigns/index.js +78 -75
  112. package/src/ui/buttons/buttonDesigns/inlineLogoTextDesign.jsx +102 -82
  113. package/src/ui/buttons/buttonDesigns/script.jsx +24 -18
  114. package/src/ui/buttons/buttonDesigns/types.js +6 -7
  115. package/src/ui/buttons/buttons.jsx +318 -212
  116. package/src/ui/buttons/config.js +62 -59
  117. package/src/ui/buttons/content.jsx +304 -119
  118. package/src/ui/buttons/index.js +1 -1
  119. package/src/ui/buttons/menu-button/index.js +1 -1
  120. package/src/ui/buttons/menu-button/menu-button.jsx +29 -22
  121. package/src/ui/buttons/menu-button/menu-button.scoped.scss +16 -17
  122. package/src/ui/buttons/poweredBy.jsx +23 -23
  123. package/src/ui/buttons/props.js +680 -529
  124. package/src/ui/buttons/script.jsx +182 -160
  125. package/src/ui/buttons/spinner.jsx +4 -6
  126. package/src/ui/buttons/style.jsx +15 -14
  127. package/src/ui/buttons/styles/base.js +24 -16
  128. package/src/ui/buttons/styles/button.js +24 -22
  129. package/src/ui/buttons/styles/color.js +118 -118
  130. package/src/ui/buttons/styles/custom.js +30 -24
  131. package/src/ui/buttons/styles/index.js +1 -1
  132. package/src/ui/buttons/styles/labels.js +17 -13
  133. package/src/ui/buttons/styles/page.js +3 -3
  134. package/src/ui/buttons/styles/responsive.js +226 -118
  135. package/src/ui/buttons/tagline.jsx +53 -54
  136. package/src/ui/chevron.jsx +27 -16
  137. package/src/ui/index.js +3 -3
  138. package/src/ui/loading.jsx +25 -18
  139. package/src/ui/text/index.js +1 -1
  140. package/src/ui/text/style.scoped.scss +25 -26
  141. package/src/ui/text/text.jsx +42 -20
  142. package/src/ui/tracking.jsx +18 -11
  143. package/src/zoid/buttons/component.jsx +836 -684
  144. package/src/zoid/buttons/container.jsx +140 -107
  145. package/src/zoid/buttons/index.js +1 -1
  146. package/src/zoid/buttons/prerender.jsx +84 -64
  147. package/src/zoid/buttons/util.js +355 -254
  148. package/src/zoid/card-fields/component.jsx +581 -549
  149. package/src/zoid/card-fields/index.js +1 -1
  150. package/src/zoid/card-fields/prerender.jsx +20 -17
  151. package/src/zoid/card-form/component.js +155 -141
  152. package/src/zoid/card-form/index.js +1 -1
  153. package/src/zoid/checkout/component.jsx +314 -282
  154. package/src/zoid/checkout/config.js +2 -2
  155. package/src/zoid/checkout/content.js +190 -154
  156. package/src/zoid/checkout/hacks.js +31 -28
  157. package/src/zoid/checkout/index.js +2 -2
  158. package/src/zoid/checkout/props.js +27 -33
  159. package/src/zoid/installments/component.jsx +83 -70
  160. package/src/zoid/installments/index.js +1 -1
  161. package/src/zoid/installments/props.js +1 -1
  162. package/src/zoid/menu/component.jsx +53 -48
  163. package/src/zoid/menu/index.js +1 -1
  164. package/src/zoid/menu/props.js +1 -3
  165. package/src/zoid/modal/component.jsx +119 -106
  166. package/src/zoid/modal/index.js +1 -1
  167. package/src/zoid/modal/props.js +1 -3
  168. package/src/zoid/payment-fields/component.jsx +215 -191
  169. package/src/zoid/payment-fields/container.jsx +73 -64
  170. package/src/zoid/payment-fields/index.js +1 -1
  171. package/src/zoid/payment-fields/prerender.jsx +16 -14
  172. package/src/zoid/payment-fields/props.js +6 -6
  173. package/src/zoid/qr-code/component.jsx +131 -115
  174. package/src/zoid/qr-code/container.jsx +74 -68
  175. package/src/zoid/qr-code/index.js +1 -1
  176. package/src/zoid/qr-code/prerender.jsx +17 -12
  177. package/src/zoid/qr-code/types.js +2 -2
  178. package/src/zoid/wallet/component.jsx +298 -260
  179. package/src/zoid/wallet/container.jsx +73 -64
  180. package/src/zoid/wallet/index.js +1 -1
  181. package/src/zoid/wallet/prerender.jsx +14 -14
  182. package/src/zoid/wallet/props.js +4 -4
  183. package/src/actions/save/index.js +0 -40
  184. package/src/interface/actions.js +0 -14
  185. package/src/lib/getLogoCDNExperiment.js +0 -25
@@ -2,709 +2,861 @@
2
2
  /** @jsx node */
3
3
  /* eslint max-lines: 0 */
4
4
 
5
- import { getLogger, getLocale, getClientID, getEnv, getIntent, getCommit, getVault, getDisableFunding, getDisableCard,
6
- getMerchantID, getPayPalDomainRegex, getCurrency, getSDKMeta, getCSPNonce, getBuyerCountry, getClientAccessToken, getPlatform,
7
- getPartnerAttributionID, getCorrelationID, getEnableThreeDomainSecure, getDebug, getComponents, getStageHost, getAPIStageHost, getPayPalDomain,
8
- getUserIDToken, getClientMetadataID, getAmount, getEnableFunding, getStorageID, getUserExperienceFlow, getMerchantRequestedPopupsDisabled,
9
- getVersion } from '@paypal/sdk-client/src';
10
- import { rememberFunding, getRememberedFunding, getRefinedFundingEligibility } from '@paypal/funding-components/src';
11
- import { ZalgoPromise } from '@krakenjs/zalgo-promise/src';
12
- import { create, EVENT, type ZoidComponent } from '@krakenjs/zoid/src';
13
- import { uniqueID, memoize, isApplePaySupported, supportsPopups as userAgentSupportsPopups, noop, isLocalStorageEnabled } from '@krakenjs/belter/src';
14
- import { FUNDING, FUNDING_BRAND_LABEL, QUERY_BOOL, ENV, FPTI_KEY } from '@paypal/sdk-constants/src';
15
- import { node, dom } from '@krakenjs/jsx-pragmatic/src';
16
-
17
5
  import {
18
- getSessionID,
19
- storageState,
20
- sessionState,
21
- logLatencyInstrumentationPhase,
22
- prepareInstrumentationPayload
23
- } from '../../lib';
24
- import { normalizeButtonStyle, type ButtonProps } from '../../ui/buttons/props';
25
- import { isFundingEligible } from '../../funding';
26
- import { EXPERIENCE } from '../../constants';
27
- import { type InlineXOEligibilityType } from '../../types';
28
- import { getLogoCDNExperiment } from '../../lib/getLogoCDNExperiment';
29
-
30
- import { containerTemplate } from './container';
31
- import { PrerenderedButtons } from './prerender';
32
- import { applePaySession, determineFlow, isSupportedNativeBrowser, createVenmoExperiment,
33
- getRenderedButtons, getButtonSize, getButtonExperiments, isInlineXOEligible } from './util';
6
+ getLogger,
7
+ getLocale,
8
+ getClientID,
9
+ getEnv,
10
+ getIntent,
11
+ getCommit,
12
+ getVault,
13
+ getDisableFunding,
14
+ getDisableCard,
15
+ getMerchantID,
16
+ getPayPalDomainRegex,
17
+ getCurrency,
18
+ getSDKMeta,
19
+ getCSPNonce,
20
+ getBuyerCountry,
21
+ getClientAccessToken,
22
+ getPlatform,
23
+ getPartnerAttributionID,
24
+ getCorrelationID,
25
+ getEnableThreeDomainSecure,
26
+ getDebug,
27
+ getComponents,
28
+ getStageHost,
29
+ getAPIStageHost,
30
+ getPayPalDomain,
31
+ getUserIDToken,
32
+ getClientMetadataID,
33
+ getAmount,
34
+ getEnableFunding,
35
+ getStorageID,
36
+ getUserExperienceFlow,
37
+ getMerchantRequestedPopupsDisabled,
38
+ getVersion,
39
+ } from "@paypal/sdk-client/src";
40
+ import {
41
+ rememberFunding,
42
+ getRememberedFunding,
43
+ getRefinedFundingEligibility,
44
+ } from "@paypal/funding-components/src";
45
+ import { ZalgoPromise } from "@krakenjs/zalgo-promise/src";
46
+ import { create, EVENT, type ZoidComponent } from "@krakenjs/zoid/src";
47
+ import {
48
+ uniqueID,
49
+ memoize,
50
+ isApplePaySupported,
51
+ supportsPopups as userAgentSupportsPopups,
52
+ noop,
53
+ isLocalStorageEnabled,
54
+ } from "@krakenjs/belter/src";
55
+ import {
56
+ FUNDING,
57
+ FUNDING_BRAND_LABEL,
58
+ QUERY_BOOL,
59
+ ENV,
60
+ FPTI_KEY,
61
+ } from "@paypal/sdk-constants/src";
62
+ import { node, dom } from "@krakenjs/jsx-pragmatic/src";
34
63
 
64
+ import {
65
+ getSessionID,
66
+ storageState,
67
+ sessionState,
68
+ logLatencyInstrumentationPhase,
69
+ prepareInstrumentationPayload,
70
+ } from "../../lib";
71
+ import { normalizeButtonStyle, type ButtonProps } from "../../ui/buttons/props";
72
+ import { isFundingEligible } from "../../funding";
73
+ import { EXPERIENCE } from "../../constants";
74
+ import { type InlineXOEligibilityType } from "../../types";
75
+
76
+ import { containerTemplate } from "./container";
77
+ import { PrerenderedButtons } from "./prerender";
78
+ import {
79
+ applePaySession,
80
+ determineFlow,
81
+ isSupportedNativeBrowser,
82
+ createVenmoExperiment,
83
+ getRenderedButtons,
84
+ getButtonSize,
85
+ getButtonExperiments,
86
+ isInlineXOEligible,
87
+ } from "./util";
35
88
 
36
89
  export type ButtonsComponent = ZoidComponent<ButtonProps>;
37
90
 
38
- export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
39
- const queriedEligibleFunding = [];
40
- return create({
41
- tag: 'paypal-buttons',
42
- url: () => `${ getPayPalDomain() }${ __PAYPAL_CHECKOUT__.__URI__.__BUTTONS__ }`,
43
-
44
- domain: getPayPalDomainRegex(),
45
-
46
- autoResize: {
47
- width: false,
48
- height: true
91
+ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
92
+ const queriedEligibleFunding = [];
93
+ return create({
94
+ tag: "paypal-buttons",
95
+ url: () => `${getPayPalDomain()}${__PAYPAL_CHECKOUT__.__URI__.__BUTTONS__}`,
96
+
97
+ domain: getPayPalDomainRegex(),
98
+
99
+ autoResize: {
100
+ width: false,
101
+ height: true,
102
+ },
103
+
104
+ containerTemplate,
105
+
106
+ logger: getLogger(),
107
+
108
+ prerenderTemplate: ({ state, props, doc, event }) => {
109
+ const { buttonSessionID } = props;
110
+
111
+ if (!isLocalStorageEnabled()) {
112
+ getLogger()
113
+ .info("localstorage_inaccessible_possible_private_browsing")
114
+ .track({
115
+ [FPTI_KEY.BUTTON_SESSION_UID]: buttonSessionID,
116
+ [FPTI_KEY.CONTEXT_TYPE]: "button_session_id",
117
+ [FPTI_KEY.CONTEXT_ID]: buttonSessionID,
118
+ [FPTI_KEY.TRANSITION]:
119
+ "localstorage_inaccessible_possible_private_browsing",
120
+ });
121
+ }
122
+
123
+ event.on(EVENT.PRERENDERED, () => {
124
+ // CPL stands for Consumer Perceived Latency
125
+ logLatencyInstrumentationPhase({
126
+ buttonSessionID,
127
+ phase: "buttons-first-render-end",
128
+ });
129
+ try {
130
+ const cplPhases = prepareInstrumentationPayload(buttonSessionID);
131
+ const cplLatencyMetrics = {
132
+ [FPTI_KEY.STATE]: "CPL_LATENCY_METRICS",
133
+ [FPTI_KEY.TRANSITION]: "process_client_metrics",
134
+ [FPTI_KEY.CONTEXT_ID]: buttonSessionID,
135
+ [FPTI_KEY.PAGE]: "main:xo:paypal-components:smart-payment-buttons",
136
+ [FPTI_KEY.CPL_COMP_METRICS]: JSON.stringify(cplPhases?.comp || {}),
137
+ };
138
+ getLogger()
139
+ .info("CPL_LATENCY_METRICS_FIRST_RENDER")
140
+ .track(cplLatencyMetrics);
141
+ } catch (err) {
142
+ getLogger()
143
+ .info("button_render_CPL_instrumentation_log_error")
144
+ .track({
145
+ err: err.message || "CPL_LOG_PHASE_ERROR",
146
+ details: err.details,
147
+ stack: JSON.stringify(err.stack || err),
148
+ });
149
+ }
150
+ });
151
+
152
+ return (
153
+ <PrerenderedButtons
154
+ nonce={props.nonce}
155
+ props={props}
156
+ onRenderCheckout={({ win, fundingSource, card }) => {
157
+ state.prerenderDetails = { win, fundingSource, card };
158
+ }}
159
+ />
160
+ ).render(dom({ doc }));
161
+ },
162
+
163
+ attributes: {
164
+ iframe: {
165
+ allowpaymentrequest: "allowpaymentrequest",
166
+ scrolling: "no",
167
+ title: FUNDING_BRAND_LABEL.PAYPAL,
168
+ },
169
+ },
170
+
171
+ eligible: ({ props }) => {
172
+ const {
173
+ fundingSource,
174
+ onShippingChange,
175
+ onShippingAddressChange,
176
+ onShippingOptionsChange,
177
+ style = {},
178
+ fundingEligibility = getRefinedFundingEligibility(),
179
+ supportsPopups = userAgentSupportsPopups(),
180
+ supportedNativeBrowser = isSupportedNativeBrowser(),
181
+ experiment = getButtonExperiments(),
182
+ createBillingAgreement,
183
+ createSubscription,
184
+ createVaultSetupToken,
185
+ } = props;
186
+
187
+ const flow = determineFlow({
188
+ createBillingAgreement,
189
+ createSubscription,
190
+ createVaultSetupToken,
191
+ });
192
+ const applePaySupport = fundingEligibility?.applepay?.eligible
193
+ ? isApplePaySupported()
194
+ : false;
195
+
196
+ if (!fundingSource) {
197
+ return {
198
+ eligible: true,
199
+ };
200
+ }
201
+
202
+ if (queriedEligibleFunding.indexOf(fundingSource) === -1) {
203
+ queriedEligibleFunding.push(fundingSource);
204
+ }
205
+
206
+ const { layout } = style;
207
+
208
+ const platform = getPlatform();
209
+ const components = getComponents();
210
+
211
+ if (
212
+ isFundingEligible(fundingSource, {
213
+ layout,
214
+ platform,
215
+ fundingSource,
216
+ fundingEligibility,
217
+ components,
218
+ onShippingChange,
219
+ onShippingAddressChange,
220
+ onShippingOptionsChange,
221
+ flow,
222
+ applePaySupport,
223
+ supportsPopups,
224
+ supportedNativeBrowser,
225
+ experiment,
226
+ })
227
+ ) {
228
+ return {
229
+ eligible: true,
230
+ };
231
+ }
232
+
233
+ return {
234
+ eligible: false,
235
+ reason: `${fundingSource} is not eligible`,
236
+ };
237
+ },
238
+
239
+ props: {
240
+ /**
241
+ * Version of the SDK used in first render.
242
+ * This is passed to the `/smart/buttons` endpoint in order for the second render
243
+ * to be aware of what sdk version to load during SSR of the buttons
244
+ */
245
+ sdkVersion: {
246
+ type: "string",
247
+ queryParam: true,
248
+ sendToChild: false,
249
+ value: getVersion,
250
+ },
251
+ fundingSource: {
252
+ type: "string",
253
+ queryParam: true,
254
+ required: false,
255
+
256
+ validate: ({ props }) => {
257
+ const {
258
+ fundingSource,
259
+ onShippingChange,
260
+ onShippingAddressChange,
261
+ onShippingOptionsChange,
262
+ style = {},
263
+ fundingEligibility = getRefinedFundingEligibility(),
264
+ applePaySupport,
265
+ supportsPopups,
266
+ supportedNativeBrowser,
267
+ createBillingAgreement,
268
+ createSubscription,
269
+ createVaultSetupToken,
270
+ } = props;
271
+
272
+ const flow = determineFlow({
273
+ createBillingAgreement,
274
+ createSubscription,
275
+ createVaultSetupToken,
276
+ });
277
+ const { layout } = style;
278
+
279
+ const platform = getPlatform();
280
+ const components = getComponents();
281
+
282
+ if (
283
+ fundingSource &&
284
+ !isFundingEligible(fundingSource, {
285
+ layout,
286
+ platform,
287
+ fundingSource,
288
+ fundingEligibility,
289
+ components,
290
+ onShippingChange,
291
+ onShippingAddressChange,
292
+ onShippingOptionsChange,
293
+ flow,
294
+ applePaySupport,
295
+ supportsPopups,
296
+ supportedNativeBrowser,
297
+ })
298
+ ) {
299
+ throw new Error(`${fundingSource} is not eligible`);
300
+ }
301
+ },
302
+ },
303
+
304
+ style: {
305
+ type: "object",
306
+ queryParam: true,
307
+ required: false,
308
+ decorate: ({ props, value }) => {
309
+ // $FlowFixMe
310
+ return normalizeButtonStyle(props, value);
49
311
  },
50
312
 
51
- containerTemplate,
52
-
53
- logger: getLogger(),
313
+ validate: ({ props, value = {} }) => {
314
+ // $FlowFixMe
315
+ normalizeButtonStyle(props, value);
316
+ },
54
317
 
55
- prerenderTemplate: ({ state, props, doc, event }) => {
56
- const { buttonSessionID } = props;
318
+ default: () => ({}),
319
+ },
320
+
321
+ storageState: {
322
+ type: "object",
323
+ value: () => storageState,
324
+ },
325
+
326
+ sessionState: {
327
+ type: "object",
328
+ value: () => sessionState,
329
+ },
330
+
331
+ components: {
332
+ type: "array",
333
+ queryParam: true,
334
+ value: getComponents,
335
+ },
336
+
337
+ locale: {
338
+ type: "object",
339
+ queryParam: true,
340
+ value: getLocale,
341
+ },
342
+
343
+ sdkMeta: {
344
+ type: "string",
345
+ queryParam: true,
346
+ sendToChild: false,
347
+ value: getSDKMeta,
348
+ },
349
+
350
+ createOrder: {
351
+ type: "function",
352
+ required: false,
353
+ },
354
+
355
+ createBillingAgreement: {
356
+ type: "function",
357
+ required: false,
358
+ },
359
+
360
+ createSubscription: {
361
+ type: "function",
362
+ required: false,
363
+ },
364
+
365
+ onApprove: {
366
+ type: "function",
367
+ required: false,
368
+ },
369
+
370
+ onComplete: {
371
+ type: "function",
372
+ required: false,
373
+ },
374
+
375
+ onShippingChange: {
376
+ type: "function",
377
+ required: false,
378
+ queryParam: true,
379
+ queryValue: ({ value }) => {
380
+ return value ? QUERY_BOOL.TRUE : QUERY_BOOL.FALSE;
381
+ },
382
+ },
383
+
384
+ onShippingAddressChange: {
385
+ type: "function",
386
+ required: false,
387
+ },
388
+
389
+ onShippingOptionsChange: {
390
+ type: "function",
391
+ required: false,
392
+ },
393
+
394
+ onCancel: {
395
+ type: "function",
396
+ required: false,
397
+ },
398
+
399
+ onClick: {
400
+ type: "function",
401
+ required: false,
402
+ },
403
+
404
+ getPrerenderDetails: {
405
+ type: "function",
406
+ value:
407
+ ({ state }) =>
408
+ () =>
409
+ state.prerenderDetails,
410
+ },
411
+
412
+ getPopupBridge: {
413
+ type: "function",
414
+ required: false,
415
+ value: () => {
416
+ return () => {
417
+ if (!window.popupBridge) {
418
+ return;
419
+ }
57
420
 
58
- if (!isLocalStorageEnabled()) {
59
- getLogger().info('localstorage_inaccessible_possible_private_browsing').track({
60
- [ FPTI_KEY.BUTTON_SESSION_UID ]: buttonSessionID,
61
- [ FPTI_KEY.CONTEXT_TYPE ]: 'button_session_id',
62
- [ FPTI_KEY.CONTEXT_ID ]: buttonSessionID,
63
- [ FPTI_KEY.TRANSITION ]: 'localstorage_inaccessible_possible_private_browsing'
421
+ return {
422
+ nativeUrl: window.popupBridge.getReturnUrlPrefix(),
423
+ start: (url) => {
424
+ return new ZalgoPromise((resolve, reject) => {
425
+ window.popupBridge.onComplete = (err, result) => {
426
+ const queryItems =
427
+ result && result.queryItems ? result.queryItems : {};
428
+ return err ? reject(err) : resolve(queryItems);
429
+ };
430
+ window.popupBridge.open(url);
64
431
  });
432
+ },
433
+ };
434
+ };
435
+ },
436
+ },
437
+
438
+ onInit: {
439
+ type: "function",
440
+ required: false,
441
+ default: () => noop,
442
+ decorate: ({ props, value = noop }) => {
443
+ logLatencyInstrumentationPhase({
444
+ buttonSessionID: props.buttonSessionID,
445
+ phase: "buttons-first-render",
446
+ });
447
+
448
+ return (...args) => {
449
+ const venmoExperiment = createVenmoExperiment();
450
+
451
+ if (venmoExperiment) {
452
+ venmoExperiment.logStart({
453
+ [FPTI_KEY.BUTTON_SESSION_UID]: props.buttonSessionID,
454
+ });
65
455
  }
66
456
 
67
- event.on(EVENT.PRERENDERED, () => {
68
- // CPL stands for Consumer Perceived Latency
69
- logLatencyInstrumentationPhase({ buttonSessionID, phase: 'buttons-first-render-end' });
70
- try {
71
- const cplPhases = prepareInstrumentationPayload(buttonSessionID);
72
- const cplLatencyMetrics = {
73
- [FPTI_KEY.STATE]: 'CPL_LATENCY_METRICS',
74
- [FPTI_KEY.TRANSITION]: 'process_client_metrics',
75
- [FPTI_KEY.CONTEXT_ID]: buttonSessionID,
76
- [FPTI_KEY.PAGE]: 'main:xo:paypal-components:smart-payment-buttons',
77
- [FPTI_KEY.CPL_COMP_METRICS]: JSON.stringify(cplPhases?.comp || {})
78
- };
79
- getLogger().info('CPL_LATENCY_METRICS_FIRST_RENDER').track(cplLatencyMetrics);
80
- } catch (err) {
81
- getLogger().info('button_render_CPL_instrumentation_log_error').track({
82
- err: err.message || 'CPL_LOG_PHASE_ERROR',
83
- details: err.details,
84
- stack: JSON.stringify(err.stack || err)
85
- });
86
- }
87
- });
88
-
89
- return (
90
- <PrerenderedButtons
91
- nonce={ props.nonce }
92
- props={ props }
93
- onRenderCheckout={ ({ win, fundingSource, card }) => {
94
- state.prerenderDetails = { win, fundingSource, card };
95
- } }
96
- />
97
- ).render(dom({ doc }));
457
+ return value(...args);
458
+ };
98
459
  },
460
+ },
99
461
 
100
- attributes: {
101
- iframe: {
102
- allowpaymentrequest: 'allowpaymentrequest',
103
- scrolling: 'no',
104
- title: FUNDING_BRAND_LABEL.PAYPAL
105
- }
462
+ getQueriedEligibleFunding: {
463
+ type: "function",
464
+ value: () => {
465
+ return () => queriedEligibleFunding;
106
466
  },
467
+ },
468
+
469
+ clientID: {
470
+ type: "string",
471
+ value: getClientID,
472
+ queryParam: true,
473
+ },
474
+
475
+ clientAccessToken: {
476
+ type: "string",
477
+ required: false,
478
+ queryParam: true,
479
+ value: getClientAccessToken,
480
+ },
481
+
482
+ partnerAttributionID: {
483
+ type: "string",
484
+ required: false,
485
+ value: getPartnerAttributionID,
486
+ },
487
+
488
+ merchantRequestedPopupsDisabled: {
489
+ type: "boolean",
490
+ required: false,
491
+ value: getMerchantRequestedPopupsDisabled,
492
+ },
493
+
494
+ enableThreeDomainSecure: {
495
+ type: "boolean",
496
+ value: getEnableThreeDomainSecure,
497
+ },
498
+
499
+ sdkCorrelationID: {
500
+ type: "string",
501
+ required: false,
502
+ value: getCorrelationID,
503
+ queryParam: true,
504
+ },
505
+
506
+ storageID: {
507
+ type: "string",
508
+ value: getStorageID,
509
+ queryParam: true,
510
+ },
511
+
512
+ sessionID: {
513
+ type: "string",
514
+ value: getSessionID,
515
+ queryParam: true,
516
+ },
517
+
518
+ buttonLocation: {
519
+ type: "string",
520
+ value: () => window.location.hostname,
521
+ queryParam: false,
522
+ },
523
+
524
+ buttonSessionID: {
525
+ type: "string",
526
+ value: uniqueID,
527
+ queryParam: true,
528
+ },
529
+
530
+ enableVault: {
531
+ type: "boolean",
532
+ required: false,
533
+ queryParam: true,
534
+ },
535
+
536
+ env: {
537
+ type: "string",
538
+ queryParam: true,
539
+ value: getEnv,
540
+ },
541
+
542
+ amount: {
543
+ type: "string",
544
+ required: false,
545
+ queryParam: true,
546
+ value: getAmount,
547
+ },
548
+
549
+ stageHost: {
550
+ type: "string",
551
+ value: getStageHost,
552
+ required: false,
553
+ },
554
+
555
+ buttonSize: {
556
+ type: "string",
557
+ required: false,
558
+ value: ({ props, container }) => {
559
+ return getButtonSize(props, container);
560
+ },
561
+ queryParam: true,
562
+ },
563
+
564
+ apiStageHost: {
565
+ type: "string",
566
+ value: getAPIStageHost,
567
+ required: false,
568
+ },
569
+
570
+ fundingEligibility: {
571
+ type: "object",
572
+ default: getRefinedFundingEligibility,
573
+ value: __ENV__ === ENV.LOCAL ? undefined : getRefinedFundingEligibility,
574
+ queryParam: true,
575
+ serialization: "base64",
576
+ },
577
+
578
+ platform: {
579
+ type: "string",
580
+ queryParam: true,
581
+ value: getPlatform,
582
+ },
583
+
584
+ remembered: {
585
+ type: "array",
586
+ queryParam: true,
587
+ value: getRememberedFunding,
588
+ },
589
+
590
+ experiment: {
591
+ type: "object",
592
+ queryParam: true,
593
+ value: () => {
594
+ const experiments = getButtonExperiments();
595
+ return experiments;
596
+ },
597
+ },
598
+
599
+ paymentRequest: {
600
+ type: "object",
601
+ queryParam: false,
602
+ required: false,
603
+ },
604
+
605
+ flow: {
606
+ type: "string",
607
+ queryParam: true,
608
+ value: ({ props }) => {
609
+ const {
610
+ createBillingAgreement,
611
+ createSubscription,
612
+ createVaultSetupToken,
613
+ } = props;
614
+ return determineFlow({
615
+ createBillingAgreement,
616
+ createSubscription,
617
+ createVaultSetupToken,
618
+ });
619
+ },
620
+ },
107
621
 
108
- eligible: ({ props }) => {
109
- const {
110
- fundingSource,
111
- onShippingChange,
112
- onShippingAddressChange,
113
- onShippingOptionsChange,
114
- style = {},
115
- fundingEligibility = getRefinedFundingEligibility(),
116
- supportsPopups = userAgentSupportsPopups(),
117
- supportedNativeBrowser = isSupportedNativeBrowser(),
118
- experiment = getButtonExperiments(),
119
- createBillingAgreement, createSubscription
120
- } = props;
121
-
122
- const flow = determineFlow({ createBillingAgreement, createSubscription });
123
- const applePaySupport = fundingEligibility?.applepay?.eligible ? isApplePaySupported() : false;
124
-
125
- if (!fundingSource) {
126
- return {
127
- eligible: true
128
- };
129
- }
130
-
131
- if (queriedEligibleFunding.indexOf(fundingSource) === -1) {
132
- queriedEligibleFunding.push(fundingSource);
133
- }
622
+ remember: {
623
+ type: "function",
624
+ value: () => {
625
+ return (fundingSources: $ReadOnlyArray<$Values<typeof FUNDING>>) =>
626
+ rememberFunding(fundingSources, { cookie: false });
627
+ },
628
+ },
629
+
630
+ currency: {
631
+ type: "string",
632
+ queryParam: true,
633
+ value: getCurrency,
634
+ },
635
+
636
+ intent: {
637
+ type: "string",
638
+ queryParam: true,
639
+ value: getIntent,
640
+ },
641
+
642
+ buyerCountry: {
643
+ type: "string",
644
+ queryParam: true,
645
+ required: false,
646
+ value: getBuyerCountry,
647
+ },
648
+
649
+ commit: {
650
+ type: "boolean",
651
+ queryParam: true,
652
+ value: getCommit,
653
+ },
654
+
655
+ vault: {
656
+ type: "boolean",
657
+ queryParam: true,
658
+ value: getVault,
659
+ },
660
+
661
+ enableFunding: {
662
+ type: "array",
663
+ queryParam: true,
664
+ value: getEnableFunding,
665
+ },
666
+
667
+ disableFunding: {
668
+ type: "array",
669
+ queryParam: true,
670
+ value: getDisableFunding,
671
+ },
672
+
673
+ disableCard: {
674
+ type: "array",
675
+ queryParam: true,
676
+ value: getDisableCard,
677
+ },
678
+
679
+ merchantID: {
680
+ type: "array",
681
+ queryParam: true,
682
+ value: getMerchantID,
683
+ },
684
+
685
+ renderedButtons: {
686
+ type: "array",
687
+ queryParam: true,
688
+ value: ({ props }) => getRenderedButtons(props),
689
+ },
690
+
691
+ csp: {
692
+ type: "object",
693
+ required: false,
694
+ value: () => {
695
+ return {
696
+ nonce: getCSPNonce(),
697
+ };
698
+ },
699
+ },
134
700
 
135
- const { layout } = style;
701
+ nonce: {
702
+ type: "string",
703
+ default: getCSPNonce,
704
+ },
136
705
 
137
- const platform = getPlatform();
138
- const components = getComponents();
706
+ getPageUrl: {
707
+ type: "function",
708
+ value: () => {
709
+ return () => window.location.href;
710
+ },
711
+ },
712
+
713
+ userIDToken: {
714
+ type: "string",
715
+ default: getUserIDToken,
716
+ required: false,
717
+ queryParam: getEnv() !== ENV.LOCAL && getEnv() !== ENV.STAGE,
718
+ bodyParam: getEnv() === ENV.LOCAL || getEnv() === ENV.STAGE,
719
+ },
720
+
721
+ clientMetadataID: {
722
+ type: "string",
723
+ required: false,
724
+ default: getClientMetadataID,
725
+ queryParam: true,
726
+ },
727
+
728
+ debug: {
729
+ type: "boolean",
730
+ value: getDebug,
731
+ queryParam: true,
732
+ },
733
+
734
+ test: {
735
+ type: "object",
736
+ default(): Object {
737
+ return {
738
+ action: "checkout",
739
+ };
740
+ },
741
+ },
742
+
743
+ wallet: {
744
+ type: "object",
745
+ required: false,
746
+ default: () => window.__TEST_WALLET__,
747
+ },
748
+
749
+ paymentMethodNonce: {
750
+ type: "string",
751
+ queryParam: true,
752
+ required: false,
753
+ },
754
+
755
+ paymentMethodToken: {
756
+ type: "string",
757
+ queryParam: true,
758
+ required: false,
759
+ },
760
+
761
+ branded: {
762
+ type: "boolean",
763
+ queryParam: true,
764
+ required: false,
765
+ },
766
+
767
+ applePaySupport: {
768
+ type: "boolean",
769
+ value: ({ props }) => {
770
+ return props?.fundingEligibility?.applepay?.eligible
771
+ ? isApplePaySupported()
772
+ : false;
773
+ },
774
+ queryParam: true,
775
+ },
776
+
777
+ supportsPopups: {
778
+ type: "boolean",
779
+ value: () => userAgentSupportsPopups(),
780
+ queryParam: true,
781
+ },
782
+
783
+ supportedNativeBrowser: {
784
+ type: "boolean",
785
+ value: isSupportedNativeBrowser,
786
+ queryParam: true,
787
+ },
788
+
789
+ userExperienceFlow: {
790
+ type: "string",
791
+ required: false,
792
+ value: getUserExperienceFlow,
793
+ },
794
+
795
+ applePay: {
796
+ type: "function",
797
+ required: false,
798
+ value: applePaySession,
799
+ },
800
+
801
+ experience: {
802
+ queryParam: true,
803
+ required: false,
804
+ type: "string",
805
+ value: ({ props }) => {
806
+ const {
807
+ commit,
808
+ createBillingAgreement,
809
+ currency,
810
+ disableFunding = [],
811
+ experience,
812
+ fundingEligibility,
813
+ onComplete,
814
+ style: { custom = {}, layout },
815
+ vault,
816
+ } = props || {};
817
+
818
+ if (experience === "accelerated") {
819
+ return EXPERIENCE.INLINE;
820
+ }
821
+
822
+ const inlineCheckoutEligibility: InlineXOEligibilityType =
823
+ __INLINE_CHECKOUT_ELIGIBILITY__ || {
824
+ eligible: false,
825
+ };
139
826
 
140
- if (isFundingEligible(fundingSource, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser, experiment })) {
141
- return {
142
- eligible: true
143
- };
144
- }
827
+ const eligible =
828
+ inlineCheckoutEligibility &&
829
+ inlineCheckoutEligibility.eligible &&
830
+ isInlineXOEligible({
831
+ props: {
832
+ commit,
833
+ createBillingAgreement,
834
+ currency,
835
+ custom,
836
+ disableFunding,
837
+ fundingEligibility,
838
+ layout,
839
+ onComplete,
840
+ vault,
841
+ },
842
+ });
145
843
 
146
- return {
147
- eligible: false,
148
- reason: `${ fundingSource } is not eligible`
149
- };
844
+ return eligible ? EXPERIENCE.INLINE : "";
150
845
  },
151
-
152
- props: {
153
- /**
154
- * Version of the SDK used in first render.
155
- * This is passed to the `/smart/buttons` endpoint in order for the second render
156
- * to be aware of what sdk version to load during SSR of the buttons
157
- */
158
- sdkVersion: {
159
- type: 'string',
160
- queryParam: true,
161
- sendToChild: false,
162
- value: getVersion
163
- },
164
- fundingSource: {
165
- type: 'string',
166
- queryParam: true,
167
- required: false,
168
-
169
- validate: ({ props }) => {
170
- const { fundingSource, onShippingChange, onShippingAddressChange, onShippingOptionsChange, style = {}, fundingEligibility = getRefinedFundingEligibility(),
171
- applePaySupport, supportsPopups, supportedNativeBrowser, createBillingAgreement, createSubscription } = props;
172
-
173
- const flow = determineFlow({ createBillingAgreement, createSubscription });
174
- const { layout } = style;
175
-
176
- const platform = getPlatform();
177
- const components = getComponents();
178
-
179
- if (fundingSource && !isFundingEligible(fundingSource, { layout, platform, fundingSource, fundingEligibility, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, flow, applePaySupport, supportsPopups, supportedNativeBrowser })) {
180
- throw new Error(`${ fundingSource } is not eligible`);
181
- }
182
- }
183
- },
184
-
185
- style: {
186
- type: 'object',
187
- queryParam: true,
188
- required: false,
189
- decorate: ({ props, value }) => {
190
- // $FlowFixMe
191
- return normalizeButtonStyle(props, value);
192
- },
193
-
194
- validate: ({ props, value = {} }) => {
195
- // $FlowFixMe
196
- normalizeButtonStyle(props, value);
197
- },
198
-
199
- default: () => ({})
200
- },
201
-
202
- storageState: {
203
- type: 'object',
204
- value: () => storageState
205
- },
206
-
207
- sessionState: {
208
- type: 'object',
209
- value: () => sessionState
210
- },
211
-
212
- components: {
213
- type: 'array',
214
- queryParam: true,
215
- value: getComponents
216
- },
217
-
218
- locale: {
219
- type: 'object',
220
- queryParam: true,
221
- value: getLocale
222
- },
223
-
224
- sdkMeta: {
225
- type: 'string',
226
- queryParam: true,
227
- sendToChild: false,
228
- value: getSDKMeta
229
- },
230
-
231
- createOrder: {
232
- type: 'function',
233
- required: false
234
- },
235
-
236
- createBillingAgreement: {
237
- type: 'function',
238
- required: false
239
- },
240
-
241
- createSubscription: {
242
- type: 'function',
243
- required: false
244
- },
245
-
246
- onApprove: {
247
- type: 'function',
248
- required: false
249
- },
250
-
251
- onComplete: {
252
- type: 'function',
253
- required: false
254
- },
255
-
256
- onShippingChange: {
257
- type: 'function',
258
- required: false,
259
- queryParam: true,
260
- queryValue: ({ value }) => {
261
- return value ? QUERY_BOOL.TRUE : QUERY_BOOL.FALSE;
262
- }
263
- },
264
-
265
- onShippingAddressChange: {
266
- type: 'function',
267
- required: false,
268
- },
269
-
270
- onShippingOptionsChange: {
271
- type: 'function',
272
- required: false,
273
- },
274
-
275
- onCancel: {
276
- type: 'function',
277
- required: false
278
- },
279
-
280
- onClick: {
281
- type: 'function',
282
- required: false
283
- },
284
-
285
- getPrerenderDetails: {
286
- type: 'function',
287
- value: ({ state }) => () => state.prerenderDetails
288
- },
289
-
290
- getPopupBridge: {
291
- type: 'function',
292
- required: false,
293
- value: () => {
294
- return () => {
295
- if (!window.popupBridge) {
296
- return;
297
- }
298
-
299
- return {
300
- nativeUrl: window.popupBridge.getReturnUrlPrefix(),
301
- start: (url) => {
302
- return new ZalgoPromise((resolve, reject) => {
303
- window.popupBridge.onComplete = (err, result) => {
304
- const queryItems = result && result.queryItems ? result.queryItems : {};
305
- return err ? reject(err) : resolve(queryItems);
306
- };
307
- window.popupBridge.open(url);
308
- });
309
- }
310
- };
311
- };
312
- }
313
- },
314
-
315
- onInit: {
316
- type: 'function',
317
- required: false,
318
- default: () => noop,
319
- decorate: ({ props, value = noop }) => {
320
- logLatencyInstrumentationPhase({ buttonSessionID: props.buttonSessionID, phase: 'buttons-first-render' });
321
-
322
- return (...args) => {
323
- const venmoExperiment = createVenmoExperiment();
324
-
325
- if (venmoExperiment) {
326
- venmoExperiment.logStart({ [ FPTI_KEY.BUTTON_SESSION_UID ]: props.buttonSessionID });
327
- }
328
-
329
- const logoCDNExperiment = getLogoCDNExperiment();
330
-
331
- if (logoCDNExperiment) {
332
- logoCDNExperiment.logStart({ [ FPTI_KEY.BUTTON_SESSION_UID ]: props.buttonSessionID });
333
- }
334
-
335
- return value(...args);
336
- };
337
- }
338
- },
339
-
340
- getQueriedEligibleFunding: {
341
- type: 'function',
342
- value: () => {
343
- return () => queriedEligibleFunding;
344
- }
345
- },
346
-
347
- clientID: {
348
- type: 'string',
349
- value: getClientID,
350
- queryParam: true
351
- },
352
-
353
- clientAccessToken: {
354
- type: 'string',
355
- required: false,
356
- queryParam: true,
357
- value: getClientAccessToken
358
- },
359
-
360
- partnerAttributionID: {
361
- type: 'string',
362
- required: false,
363
- value: getPartnerAttributionID
364
- },
365
-
366
- merchantRequestedPopupsDisabled: {
367
- type: 'boolean',
368
- required: false,
369
- value: getMerchantRequestedPopupsDisabled
370
- },
371
-
372
- enableThreeDomainSecure: {
373
- type: 'boolean',
374
- value: getEnableThreeDomainSecure
375
- },
376
-
377
- sdkCorrelationID: {
378
- type: 'string',
379
- required: false,
380
- value: getCorrelationID,
381
- queryParam: true
382
- },
383
-
384
- storageID: {
385
- type: 'string',
386
- value: getStorageID,
387
- queryParam: true
388
- },
389
-
390
- sessionID: {
391
- type: 'string',
392
- value: getSessionID,
393
- queryParam: true
394
- },
395
-
396
- buttonLocation: {
397
- type: 'string',
398
- value: () => window.location.hostname,
399
- queryParam: false
400
- },
401
-
402
- buttonSessionID: {
403
- type: 'string',
404
- value: uniqueID,
405
- queryParam: true
406
- },
407
-
408
- enableVault: {
409
- type: 'boolean',
410
- required: false,
411
- queryParam: true
412
- },
413
-
414
- env: {
415
- type: 'string',
416
- queryParam: true,
417
- value: getEnv
418
- },
419
-
420
- amount: {
421
- type: 'string',
422
- required: false,
423
- queryParam: true,
424
- value: getAmount
425
- },
426
-
427
- stageHost: {
428
- type: 'string',
429
- value: getStageHost,
430
- required: false
431
- },
432
-
433
- buttonSize: {
434
- type: 'string',
435
- required: false,
436
- value: ({ props, container }) => {
437
- return getButtonSize(props, container);
438
- },
439
- queryParam: true
440
- },
441
-
442
- apiStageHost: {
443
- type: 'string',
444
- value: getAPIStageHost,
445
- required: false
446
- },
447
-
448
- fundingEligibility: {
449
- type: 'object',
450
- default: getRefinedFundingEligibility,
451
- value: (__ENV__ === ENV.LOCAL) ? undefined : getRefinedFundingEligibility,
452
- queryParam: true,
453
- serialization: 'base64'
454
- },
455
-
456
- platform: {
457
- type: 'string',
458
- queryParam: true,
459
- value: getPlatform
460
- },
461
-
462
- remembered: {
463
- type: 'array',
464
- queryParam: true,
465
- value: getRememberedFunding
466
- },
467
-
468
- experiment: {
469
- type: 'object',
470
- queryParam: true,
471
- value: () => {
472
- const experiments = getButtonExperiments();
473
- return experiments;
474
- }
475
- },
476
-
477
- paymentRequest: {
478
- type: 'object',
479
- queryParam: false,
480
- required: false
481
- },
482
-
483
- flow: {
484
- type: 'string',
485
- queryParam: true,
486
- value: ({ props }) => {
487
- const { createBillingAgreement, createSubscription } = props;
488
- return determineFlow({ createBillingAgreement, createSubscription });
489
- }
490
- },
491
-
492
- remember: {
493
- type: 'function',
494
- value: () => {
495
- return (fundingSources : $ReadOnlyArray<$Values<typeof FUNDING>>) =>
496
- rememberFunding(fundingSources, { cookie: false });
497
- }
498
- },
499
-
500
- currency: {
501
- type: 'string',
502
- queryParam: true,
503
- value: getCurrency
504
- },
505
-
506
- intent: {
507
- type: 'string',
508
- queryParam: true,
509
- value: getIntent
510
- },
511
-
512
- buyerCountry: {
513
- type: 'string',
514
- queryParam: true,
515
- required: false,
516
- value: getBuyerCountry
517
- },
518
-
519
- commit: {
520
- type: 'boolean',
521
- queryParam: true,
522
- value: getCommit
523
- },
524
-
525
- vault: {
526
- type: 'boolean',
527
- queryParam: true,
528
- value: getVault
529
- },
530
-
531
- enableFunding: {
532
- type: 'array',
533
- queryParam: true,
534
- value: getEnableFunding
535
- },
536
-
537
- disableFunding: {
538
- type: 'array',
539
- queryParam: true,
540
- value: getDisableFunding
541
- },
542
-
543
- disableCard: {
544
- type: 'array',
545
- queryParam: true,
546
- value: getDisableCard
547
- },
548
-
549
- merchantID: {
550
- type: 'array',
551
- queryParam: true,
552
- value: getMerchantID
553
- },
554
-
555
- renderedButtons: {
556
- type: 'array',
557
- queryParam: true,
558
- value: ({ props }) => getRenderedButtons(props)
559
- },
560
-
561
- csp: {
562
- type: 'object',
563
- required: false,
564
- value: () => {
565
- return {
566
- nonce: getCSPNonce()
567
- };
568
- }
569
- },
570
-
571
- nonce: {
572
- type: 'string',
573
- default: getCSPNonce
574
- },
575
-
576
- getPageUrl: {
577
- type: 'function',
578
- value: () => {
579
- return () => window.location.href;
580
- }
581
- },
582
-
583
- userIDToken: {
584
- type: 'string',
585
- default: getUserIDToken,
586
- required: false,
587
- queryParam: (getEnv() !== ENV.LOCAL && getEnv() !== ENV.STAGE),
588
- bodyParam: (getEnv() === ENV.LOCAL || getEnv() === ENV.STAGE)
589
- },
590
-
591
- clientMetadataID: {
592
- type: 'string',
593
- required: false,
594
- default: getClientMetadataID,
595
- queryParam: true
596
- },
597
-
598
- debug: {
599
- type: 'boolean',
600
- value: getDebug,
601
- queryParam: true
602
- },
603
-
604
- test: {
605
- type: 'object',
606
- default() : Object {
607
- return {
608
- action: 'checkout'
609
- };
610
- }
611
- },
612
-
613
- wallet: {
614
- type: 'object',
615
- required: false,
616
- default: () => window.__TEST_WALLET__
617
- },
618
-
619
- paymentMethodNonce: {
620
- type: 'string',
621
- queryParam: true,
622
- required: false
623
- },
624
-
625
- paymentMethodToken: {
626
- type: 'string',
627
- queryParam: true,
628
- required: false
629
- },
630
-
631
- branded: {
632
- type: 'boolean',
633
- queryParam: true,
634
- required: false
635
- },
636
-
637
- applePaySupport: {
638
- type: 'boolean',
639
- value: ({ props }) => {
640
- return props?.fundingEligibility?.applepay?.eligible ? isApplePaySupported() : false;
641
- },
642
- queryParam: true
643
- },
644
-
645
- supportsPopups: {
646
- type: 'boolean',
647
- value: () => userAgentSupportsPopups(),
648
- queryParam: true
649
- },
650
-
651
- supportedNativeBrowser: {
652
- type: 'boolean',
653
- value: isSupportedNativeBrowser,
654
- queryParam: true
655
- },
656
-
657
- userExperienceFlow: {
658
- type: 'string',
659
- required: false,
660
- value: getUserExperienceFlow
661
- },
662
-
663
- applePay: {
664
- type: 'function',
665
- required: false,
666
- value: applePaySession
667
- },
668
-
669
- experience: {
670
- queryParam: true,
671
- required: false,
672
- type: 'string',
673
- value: ({ props }) => {
674
- const { commit, createBillingAgreement, currency, disableFunding = [], experience, fundingEligibility, onComplete, style : { custom = {}, layout }, vault } = props || {};
675
-
676
- if (experience === 'accelerated') {
677
- return EXPERIENCE.INLINE;
678
- }
679
-
680
- const inlineCheckoutEligibility : InlineXOEligibilityType = __INLINE_CHECKOUT_ELIGIBILITY__ || {
681
- eligible: false
682
- };
683
-
684
- const eligible = inlineCheckoutEligibility && inlineCheckoutEligibility.eligible && isInlineXOEligible({ props: {
685
- commit,
686
- createBillingAgreement,
687
- currency,
688
- custom,
689
- disableFunding,
690
- fundingEligibility,
691
- layout,
692
- onComplete,
693
- vault
694
- } });
695
-
696
- return eligible ? EXPERIENCE.INLINE : '';
697
- }
698
- },
699
-
700
- // allowBillingPayments prop is used by Honey Extension to render the one-click button
701
- // with payment methods & to use the payment methods instead of the Billing Agreement
702
- allowBillingPayments: {
703
- type: 'boolean',
704
- queryParam: true,
705
- required: false,
706
- default: () => true
707
- }
708
- }
709
- });
846
+ },
847
+
848
+ // allowBillingPayments prop is used by Honey Extension to render the one-click button
849
+ // with payment methods & to use the payment methods instead of the Billing Agreement
850
+ allowBillingPayments: {
851
+ type: "boolean",
852
+ queryParam: true,
853
+ required: false,
854
+ default: () => true,
855
+ },
856
+ createVaultSetupToken: {
857
+ type: "function",
858
+ required: false,
859
+ },
860
+ },
861
+ });
710
862
  });