@paypal/checkout-components 5.0.229 → 5.0.231

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,19 +1,15 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.229",
3
+ "version": "5.0.231",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
- "engines": {
7
- "node": ">=14.13.1 <16",
8
- "npm": ">=6"
9
- },
10
6
  "scripts": {
11
- "dev": "babel-node $(npm bin)/webpack-dev-server --config webpack.config.dev.js --port 9001 --host localhost.paypal.com --open-page demo/dev/index.htm --https --hot=false --inline=false",
7
+ "dev": "npm run check-node-version && babel-node $(npm bin)/webpack-dev-server --config webpack.config.dev.js --port 9001 --host localhost.paypal.com --open-page demo/dev/index.htm --https --hot=false --inline=false",
12
8
  "lint": "eslint --ext .js --ext .jsx src/ test/ *.js",
13
9
  "flow-typed": "rm -rf flow-typed && flow-typed install && rm flow-typed/npm/puppeteer_*",
14
10
  "flow": "flow",
15
11
  "karma": "cross-env NODE_ENV=test babel-node $(npm bin)/karma start",
16
- "test": "if [ ! $SKIP_TEST ]; then npm run lint && npm run flow-typed && npm run flow && npm run jest-ssr && npm run karma && npm run jest-screenshot; fi;",
12
+ "test": "npm run check-node-version && npm run lint && npm run flow-typed && npm run flow && npm run jest-ssr && npm run karma && npm run jest-screenshot",
17
13
  "webpack": "babel-node $(npm bin)/webpack --progress",
18
14
  "webpack-size": "babel-node $(npm bin)/webpack --progress --config webpack.config.size",
19
15
  "build": "npm run test && npm run webpack",
@@ -31,7 +27,8 @@
31
27
  "jest-e2e": "rm -f ./test/e2e/screenshots/*.png && jest test/e2e",
32
28
  "check-size": "npm run webpack-size && bundlemon && npm run delete-size",
33
29
  "delete-size": "rm dist/size.* dist/report.html",
34
- "prepare": "husky install"
30
+ "prepare": "husky install",
31
+ "check-node-version": "node scripts/check-node-version.js"
35
32
  },
36
33
  "files": [
37
34
  "src/",
@@ -48,7 +45,7 @@
48
45
  ],
49
46
  "repository": {
50
47
  "type": "git",
51
- "url": "git://github.com/paypal/paypal-checkout-components.git"
48
+ "url": "https://github.com/paypal/paypal-checkout-components.git"
52
49
  },
53
50
  "homepage": "https://developer.paypal.com/",
54
51
  "keywords": [
@@ -29,8 +29,8 @@ import { type InlineXOEligibilityType } from '../../types';
29
29
  import { containerTemplate } from './container';
30
30
  import { PrerenderedButtons } from './prerender';
31
31
  import { applePaySession, determineFlow, isSupportedNativeBrowser, createVenmoExperiment,
32
- createNoPaylaterExperiment, getRenderedButtons, getButtonSize, getButtonExperiments, isInlineXOEligible } from './util';
33
-
32
+ getRenderedButtons, getButtonSize, getButtonExperiments, isInlineXOEligible } from './util';
33
+
34
34
 
35
35
  export type ButtonsComponent = ZoidComponent<ButtonProps>;
36
36
 
@@ -53,7 +53,7 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
53
53
 
54
54
  prerenderTemplate: ({ state, props, doc, event }) => {
55
55
  const { buttonSessionID } = props;
56
-
56
+
57
57
  if (!isLocalStorageEnabled()) {
58
58
  getLogger().info('localstorage_inaccessible_possible_private_browsing').track({
59
59
  [ FPTI_KEY.BUTTON_SESSION_UID ]: buttonSessionID,
@@ -114,7 +114,7 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
114
114
  fundingEligibility = getRefinedFundingEligibility(),
115
115
  supportsPopups = userAgentSupportsPopups(),
116
116
  supportedNativeBrowser = isSupportedNativeBrowser(),
117
- experiment = getButtonExperiments(fundingSource),
117
+ experiment = getButtonExperiments(),
118
118
  createBillingAgreement, createSubscription
119
119
  } = props;
120
120
 
@@ -319,23 +319,12 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
319
319
  logLatencyInstrumentationPhase({ buttonSessionID: props.buttonSessionID, phase: 'buttons-first-render' });
320
320
 
321
321
  return (...args) => {
322
- const { fundingSource } = props;
323
322
  const venmoExperiment = createVenmoExperiment();
324
323
 
325
324
  if (venmoExperiment) {
326
325
  venmoExperiment.logStart({ [ FPTI_KEY.BUTTON_SESSION_UID ]: props.buttonSessionID });
327
326
  }
328
327
 
329
- const enableNoPaylaterExperiment = createNoPaylaterExperiment(fundingSource);
330
-
331
- if (enableNoPaylaterExperiment) {
332
- enableNoPaylaterExperiment.logStart({
333
- [ FPTI_KEY.BUTTON_SESSION_UID ]: props.buttonSessionID,
334
- [ FPTI_KEY.CONTEXT_ID ]: props.buttonSessionID,
335
- [ FPTI_KEY.CONTEXT_TYPE ]: 'button_session_id'
336
- });
337
- }
338
-
339
328
  return value(...args);
340
329
  };
341
330
  }
@@ -466,9 +455,8 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
466
455
  experiment: {
467
456
  type: 'object',
468
457
  queryParam: true,
469
- value: ({ props }) => {
470
- const { fundingSource } = props;
471
- const experiments = getButtonExperiments(fundingSource);
458
+ value: () => {
459
+ const experiments = getButtonExperiments();
472
460
  return experiments;
473
461
  }
474
462
  },
@@ -664,7 +652,7 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
664
652
  required: false,
665
653
  type: 'string',
666
654
  value: ({ props }) => {
667
- const { env, clientID, merchantID, commit, createBillingAgreement, currency, disableFunding = [], experience, fundingEligibility, locale, style: { layout }, vault } = props || {};
655
+ const { commit, createBillingAgreement, currency, disableFunding = [], experience, fundingEligibility, locale, onComplete, style : { custom = {}, layout }, vault } = props || {};
668
656
 
669
657
  if (experience === 'inline') {
670
658
  return EXPERIENCE.INLINE;
@@ -674,47 +662,19 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
674
662
  eligible: false
675
663
  };
676
664
 
677
- let alphaEligible = true;
678
- if (env === 'sandbox') {
679
- const validMerchantIDs = [
680
- 'PJEHAEK4YBEDJ',
681
- 'RMADGM9SZGSPJ',
682
- '5AZBQ2LU7HVE6',
683
- 'SMJKX2JD3V27L',
684
- 'RB28JB2TP9RA4'
685
- ];
686
- const eligibleMerchantID = merchantID && merchantID.length && merchantID.reduce((acc, id) => {
687
- return acc && validMerchantIDs.indexOf(id) !== -1;
688
- }, true);
689
-
690
- alphaEligible = clientID === 'AbUf2xGyVtp8HedZjyx9we1V2eRV9-Q7bLTVfr9Y-FFpG8dbWAaQ0AFqeh2dq_HYHrV_1GUPXGv6GMKp'
691
- && eligibleMerchantID;
692
- } else if (env === 'production') {
693
- const validMerchantIDs = [
694
- 'G4Z8SJD6PEZ2G'
695
- ];
696
-
697
- const eligibleMerchantID = merchantID && merchantID.length && merchantID.reduce((acc, id) => {
698
- return acc && validMerchantIDs.indexOf(id) !== -1;
699
- }, true);
700
-
701
- if (clientID === 'AT2hsh6PFa_pvqYVni64Ik2Ojaluh_l9DU3KwXuHb-sgj8q9zZrmob2TUsmvu4rjJ869oHUAlIAqJf9R') {
702
- alphaEligible = eligibleMerchantID;
703
-
704
- }
705
- }
706
-
707
- const eligible = inlineCheckoutEligibility && inlineCheckoutEligibility.eligible && alphaEligible && isInlineXOEligible({ props: {
665
+ const eligible = inlineCheckoutEligibility && inlineCheckoutEligibility.eligible && isInlineXOEligible({ props: {
708
666
  commit,
709
667
  createBillingAgreement,
710
668
  currency,
669
+ custom,
711
670
  disableFunding,
712
671
  fundingEligibility,
713
672
  layout,
714
673
  locale,
674
+ onComplete,
715
675
  vault
716
676
  } });
717
-
677
+
718
678
  const logger = getLogger();
719
679
 
720
680
  logger
@@ -724,7 +684,7 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
724
684
  [ FPTI_KEY.TRANSITION ]: `inline_xo_eligibility_${ String(eligible) }`
725
685
  }).flush();
726
686
 
727
- return eligible ? EXPERIENCE.INLINE : '';
687
+ return eligible ? EXPERIENCE.INLINE : '';
728
688
  }
729
689
  },
730
690
 
@@ -1,7 +1,7 @@
1
1
  /* @flow */
2
2
  import { supportsPopups as userAgentSupportsPopups, isAndroid, isChrome, isIos, isIOS14, isSafari, isSFVC, type Experiment, isDevice, isTablet, getElement, isLocalStorageEnabled, isStandAlone, once } from '@krakenjs/belter/src';
3
3
  import { COUNTRY, CURRENCY, ENV, 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';
4
+ import { getEnableFunding, 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';
@@ -126,39 +126,6 @@ export function getVenmoExperiment() : EligibilityExperiment {
126
126
  }
127
127
  }
128
128
 
129
- export function createNoPaylaterExperiment(fundingSource : ?$Values<typeof FUNDING>) : Experiment | void {
130
- const disableFunding = getDisableFunding();
131
- const isDisableFundingPaylater = disableFunding && disableFunding.indexOf(FUNDING.PAYLATER) !== -1;
132
- const enableFunding = getEnableFunding();
133
- const isEnableFundingPaylater = enableFunding && enableFunding.indexOf(FUNDING.PAYLATER) !== -1;
134
-
135
- const { paylater } = getFundingEligibility();
136
- const isEligibleForPaylater = paylater?.eligible;
137
- const isExperimentable = paylater?.products?.paylater?.variant === 'experimentable' || paylater?.products?.payIn4?.variant === 'experimentable';
138
- // No experiment because ineligible, already forced on or off
139
- if (!isEligibleForPaylater
140
- || !isExperimentable
141
- || isDisableFundingPaylater
142
- || isEnableFundingPaylater
143
- || fundingSource
144
- ) {
145
- return;
146
- }
147
-
148
- return createExperiment('disable_paylater', 0);
149
- }
150
-
151
- export function getNoPaylaterExperiment(fundingSource : ?$Values<typeof FUNDING>) : EligibilityExperiment {
152
- const experiment = createNoPaylaterExperiment(fundingSource);
153
-
154
- const disableFunding = getDisableFunding();
155
- const isDisableFundingPaylater = disableFunding && disableFunding.indexOf(FUNDING.PAYLATER) !== -1;
156
- const isExperimentEnabled = experiment && experiment.isEnabled();
157
- return {
158
- disablePaylater: Boolean((isExperimentEnabled || isDisableFundingPaylater))
159
- };
160
- }
161
-
162
129
  export function getVenmoAppLabelExperiment() : EligibilityExperiment {
163
130
  const isEnvForTest = getEnv() === ENV.LOCAL || getEnv() === ENV.TEST || getEnv() === ENV.STAGE;
164
131
 
@@ -259,10 +226,9 @@ export function applePaySession() : ?ApplePaySessionConfigRequest {
259
226
  }
260
227
  }
261
228
 
262
- export function getButtonExperiments (fundingSource : ?$Values<typeof FUNDING>) : EligibilityExperiment {
229
+ export function getButtonExperiments () : EligibilityExperiment {
263
230
  return {
264
231
  ...getVenmoExperiment(),
265
- ...getNoPaylaterExperiment(fundingSource),
266
232
  ...getVenmoAppLabelExperiment()
267
233
  };
268
234
  }
@@ -329,14 +295,22 @@ type InlineCheckoutEligibilityProps = {|
329
295
  layout : $Values<typeof BUTTON_LAYOUT>,
330
296
  locale : LocaleType,
331
297
  merchantID? : $ReadOnlyArray<string>,
332
- onComplete? : Function,
298
+ onComplete : Function,
299
+ custom? : ?{|
300
+ css? : {|
301
+ [string] : string
302
+ |},
303
+ label? : string
304
+ |},
333
305
  vault : boolean
334
306
  |};
335
307
 
336
308
  export function isInlineXOEligible({ props } : {| props : InlineCheckoutEligibilityProps |}) : boolean {
337
- const { commit, currency, createBillingAgreement, disableFunding, fundingEligibility, layout, locale, vault } = props;
309
+ const { commit, currency, custom, createBillingAgreement, disableFunding, fundingEligibility, layout, locale, onComplete, vault } = props;
338
310
 
339
311
  const isEligible = (
312
+ custom?.label && custom.label.length > 0,
313
+ onComplete &&
340
314
  locale.country === COUNTRY.US &&
341
315
  commit === true &&
342
316
  !createBillingAgreement &&
@@ -67,20 +67,20 @@ export function PaymentFieldsContainer({ uid, frame, prerenderFrame, event, nonc
67
67
  min-width: 250px;
68
68
  max-width: 100%;
69
69
  font-size: 0;
70
- height: 150px;
71
- min-height: 150px;
70
+ height: 91px;
71
+ min-height: 91px;
72
72
  transition: all 0.5s ease-in-out;
73
73
  }
74
74
 
75
75
  @media only screen and (min-width: 0px) {
76
76
  #${ uid } {
77
- min-height: 150px;
77
+ min-height: 91px;
78
78
  }
79
79
  }
80
80
 
81
81
  @media only screen and (min-width: 600px) {
82
82
  #${ uid } {
83
- min-height: 150px;
83
+ min-height: 91px;
84
84
  }
85
85
  }
86
86