@paypal/checkout-components 5.0.256-alpha.1 → 5.0.257

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