@paypal/checkout-components 5.0.210 → 5.0.213

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.210",
3
+ "version": "5.0.213",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -19,3 +19,8 @@ declare var __PAYPAL_CHECKOUT__ : {|
19
19
  __PAYMENT_FIELDS__ : string
20
20
  |}
21
21
  |};
22
+
23
+ declare var __INLINE_CHECKOUT_ELIGIBILITY__ : {|
24
+ eligible : boolean,
25
+ ineligibilityReason : string
26
+ |};
@@ -10,6 +10,8 @@ export function getBoletoConfig() : FundingSourceConfig {
10
10
  return {
11
11
  ...DEFAULT_FUNDING_CONFIG,
12
12
 
13
+ automatic: false,
14
+
13
15
  shippingChange: false,
14
16
 
15
17
  layouts: [
@@ -9,6 +9,8 @@ import { DEFAULT_FUNDING_CONFIG, type FundingSourceConfig } from '../common';
9
9
  export function getMultibancoConfig() : FundingSourceConfig {
10
10
  return {
11
11
  ...DEFAULT_FUNDING_CONFIG,
12
+
13
+ automatic: false,
12
14
 
13
15
  shippingChange: false,
14
16
 
@@ -9,6 +9,8 @@ import { DEFAULT_FUNDING_CONFIG, type FundingSourceConfig } from '../common';
9
9
  export function getOxxoConfig() : FundingSourceConfig {
10
10
  return {
11
11
  ...DEFAULT_FUNDING_CONFIG,
12
+
13
+ automatic: false,
12
14
 
13
15
  shippingChange: false,
14
16
 
package/src/types.js CHANGED
@@ -67,3 +67,8 @@ export type LazyExport<T> = {|
67
67
  export type LazyProtectedExport<T> = {|
68
68
  __get__ : () => ?T
69
69
  |};
70
+
71
+ export type InlineXOEligibilityType = {|
72
+ eligible : boolean,
73
+ ineligibilityReason : string
74
+ |};
@@ -44,8 +44,9 @@ type IndividualButtonProps = {|
44
44
 
45
45
  export function Button({ fundingSource, style, multiple, locale, env, fundingEligibility, i, nonce, flow, vault,
46
46
  userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument, experience } : IndividualButtonProps) : ElementNode {
47
-
48
- const inlineExperience = experience === EXPERIENCE.INLINE;
47
+
48
+ const { custom, layout, shape } = style;
49
+ const inlineExperience = experience === EXPERIENCE.INLINE && custom;
49
50
  const fundingConfig = getFundingConfig()[fundingSource];
50
51
 
51
52
  if (!fundingConfig) {
@@ -95,8 +96,6 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
95
96
  preventClickFocus(el);
96
97
  }
97
98
  };
98
-
99
- const { custom, layout, shape } = style;
100
99
 
101
100
  const labelText = typeof fundingConfig.labelText === 'function' ? fundingConfig.labelText({ content, fundingEligibility }) : (fundingConfig.labelText || fundingSource);
102
101
 
@@ -215,7 +214,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
215
214
  ].join(' ') }
216
215
  >
217
216
  <div
218
- role='button'
217
+ role='link'
219
218
  { ...{
220
219
  [ ATTRIBUTE.BUTTON ]: true,
221
220
  [ ATTRIBUTE.FUNDING_SOURCE ]: fundingSource,
@@ -101,8 +101,8 @@ export function Buttons(props : ButtonsProps) : ElementNode {
101
101
  const { wallet, fundingSource, style, locale, remembered, env, fundingEligibility, platform, commit, vault,
102
102
  nonce, components, onShippingChange, personalization, userIDToken, content, flow, experiment, applePaySupport,
103
103
  supportsPopups, supportedNativeBrowser, experience } = normalizeButtonProps(props);
104
- const { layout, shape, tagline } = style;
105
- const inlineExperience = experience === EXPERIENCE.INLINE;
104
+ const { custom, layout, shape, tagline } = style;
105
+ const inlineExperience = experience === EXPERIENCE.INLINE && custom;
106
106
 
107
107
  let fundingSources = determineEligibleFunding({ fundingSource, layout, remembered, platform, fundingEligibility, components, onShippingChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser, experiment });
108
108
  const multiple = fundingSources.length > 1;
@@ -285,6 +285,8 @@ export type ButtonProps = {|
285
285
  createOrder : CreateOrder,
286
286
  createBillingAgreement : CreateBillingAgreement,
287
287
  createSubscription : CreateSubscription,
288
+ currency : string,
289
+ disableFunding? : $ReadOnlyArray<$Values<typeof FUNDING>>,
288
290
  oncancel : OnCancel,
289
291
  onApprove : OnApprove,
290
292
  onComplete : OnComplete,
@@ -306,6 +308,7 @@ export type ButtonProps = {|
306
308
  onShippingChange : ?OnShippingChange,
307
309
  clientAccessToken? : ?string,
308
310
  nonce : string,
311
+ merchantID? : $ReadOnlyArray<string>,
309
312
  merchantRequestedPopupsDisabled : ?boolean,
310
313
  userIDToken : ?string,
311
314
  flow : $Values<typeof BUTTON_FLOW>,
@@ -17,11 +17,13 @@ import { getSessionID, storageState, sessionState } from '../../lib';
17
17
  import { normalizeButtonStyle, type ButtonProps } from '../../ui/buttons/props';
18
18
  import { isFundingEligible } from '../../funding';
19
19
  import { EXPERIENCE } from '../../constants';
20
+ import { type InlineXOEligibilityType } from '../../types';
20
21
 
21
22
  import { containerTemplate } from './container';
22
23
  import { PrerenderedButtons } from './prerender';
23
24
  import { applePaySession, determineFlow, isSupportedNativeBrowser, createVenmoExperiment,
24
- createNoPaylaterExperiment, getRenderedButtons, getButtonSize, getButtonExperiments } from './util';
25
+ createNoPaylaterExperiment, getRenderedButtons, getButtonSize, getButtonExperiments, isInlineXOEligible } from './util';
26
+
25
27
 
26
28
  export type ButtonsComponent = ZoidComponent<ButtonProps>;
27
29
 
@@ -608,10 +610,22 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
608
610
  required: false,
609
611
  type: 'string',
610
612
  value: ({ props }) => {
611
- const { style: { custom }, fundingEligibility } = props;
612
- const isInlineXO = (custom && (custom.label || custom.css)) && fundingEligibility[FUNDING.CARD]?.eligible;
613
+ const { commit, createBillingAgreement, currency, disableFunding = [], fundingEligibility, locale, merchantID = [], style: { layout }, vault } = props || {};
613
614
 
614
- return isInlineXO ? EXPERIENCE.INLINE : '';
615
+ const inlineCheckoutEligibility : InlineXOEligibilityType = __INLINE_CHECKOUT_ELIGIBILITY__ || {
616
+ eligible: false
617
+ };
618
+ return inlineCheckoutEligibility && inlineCheckoutEligibility.eligible && isInlineXOEligible({ props: {
619
+ commit,
620
+ createBillingAgreement,
621
+ currency,
622
+ disableFunding,
623
+ fundingEligibility,
624
+ layout,
625
+ locale,
626
+ merchantID,
627
+ vault
628
+ } }) ? EXPERIENCE.INLINE : '';
615
629
  }
616
630
  },
617
631
 
@@ -1,7 +1,7 @@
1
1
  /* @flow */
2
2
  import { supportsPopups as userAgentSupportsPopups, isAndroid, isChrome, isIos, isSafari, isSFVC, type Experiment, isDevice, isTablet, getElement, isLocalStorageEnabled } from '@krakenjs/belter/src';
3
- import { ENV, FUNDING } from '@paypal/sdk-constants/src';
4
- import { getEnableFunding, getDisableFunding, createExperiment, getFundingEligibility, getPlatform, getComponents, getEnv } from '@paypal/sdk-client/src';
3
+ import { COUNTRY, CURRENCY, ENV, FPTI_KEY, FUNDING, type LocaleType } from '@paypal/sdk-constants/src';
4
+ import { getEnableFunding, getDisableFunding, getLogger, createExperiment, getFundingEligibility, getPlatform, getComponents, getEnv, type FundingEligibilityType } from '@paypal/sdk-client/src';
5
5
  import { getRefinedFundingEligibility } from '@paypal/funding-components/src';
6
6
 
7
7
  import type { Experiment as EligibilityExperiment } from '../../types';
@@ -296,3 +296,40 @@ export function getButtonSize (props : ButtonProps, container : string | HTMLEle
296
296
  }
297
297
  }
298
298
  }
299
+
300
+ type InlineCheckoutEligibilityProps = {|
301
+ commit : boolean,
302
+ createBillingAgreement? : Function,
303
+ currency : string,
304
+ disableFunding : $ReadOnlyArray<$Values<typeof FUNDING>>,
305
+ fundingEligibility : FundingEligibilityType,
306
+ layout : $Values<typeof BUTTON_LAYOUT>,
307
+ locale : LocaleType,
308
+ merchantID? : $ReadOnlyArray<string>,
309
+ vault : boolean
310
+ |};
311
+
312
+ export function isInlineXOEligible({ props } : {| props : InlineCheckoutEligibilityProps |}) : boolean {
313
+ const { commit, currency, createBillingAgreement, disableFunding, fundingEligibility, layout, locale, merchantID, vault } = props;
314
+
315
+ const isEligible = (
316
+ locale.country === COUNTRY.US &&
317
+ commit === true &&
318
+ !createBillingAgreement &&
319
+ currency === CURRENCY.USD &&
320
+ (disableFunding?.indexOf(FUNDING.CARD) === -1) &&
321
+ (fundingEligibility?.card?.eligible || false) &&
322
+ layout === BUTTON_LAYOUT.VERTICAL &&
323
+ merchantID?.length === 0 &&
324
+ vault === false
325
+ );
326
+
327
+ getLogger()
328
+ .info('isInlineXOEligible props', { props: JSON.stringify(props) })
329
+ .info('isInlineXOEligible eligible', { eligible: String(isEligible) })
330
+ .track({
331
+ [ FPTI_KEY.TRANSITION ]: `inline_xo_eligibility_${ String(isEligible) }`
332
+ }).flush();
333
+
334
+ return isEligible;
335
+ }