@paypal/checkout-components 5.0.212 → 5.0.215
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/CHANGELOG.md +21 -0
- package/dist/button.js +1 -1
- package/package.json +2 -2
- package/src/declarations.js +5 -0
- package/src/funding/card/config.jsx +12 -2
- package/src/types.js +5 -0
- package/src/ui/buttons/button.jsx +3 -4
- package/src/ui/buttons/buttons.jsx +3 -3
- package/src/ui/buttons/props.js +3 -0
- package/src/ui/buttons/styles/custom.js +3 -3
- package/src/zoid/buttons/component.jsx +30 -5
- package/src/zoid/buttons/util.js +39 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paypal/checkout-components",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.215",
|
|
4
4
|
"description": "PayPal Checkout components, for integrating checkout products.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"license": "Apache-2.0",
|
|
63
63
|
"readmeFilename": "README.md",
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@krakenjs/grumbler-scripts": "^
|
|
65
|
+
"@krakenjs/grumbler-scripts": "^7.0.0",
|
|
66
66
|
"@krakenjs/sync-browser-mocks": "^3.0.0",
|
|
67
67
|
"babel-core": "^7.0.0-bridge.0",
|
|
68
68
|
"bundlemon": "^1.1.0",
|
package/src/declarations.js
CHANGED
|
@@ -122,10 +122,20 @@ export function getCardConfig() : FundingSourceConfig {
|
|
|
122
122
|
},
|
|
123
123
|
|
|
124
124
|
Label: ({ logo, locale, content, custom }) => {
|
|
125
|
-
if (custom
|
|
125
|
+
if (custom) {
|
|
126
|
+
const validLabels = {
|
|
127
|
+
checkout: 'Checkout'
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
let label = 'Checkout';
|
|
131
|
+
|
|
132
|
+
if (custom.label && typeof custom.label === 'string' && validLabels[custom.label.toLowerCase()]) {
|
|
133
|
+
label = validLabels[custom.label];
|
|
134
|
+
}
|
|
135
|
+
|
|
126
136
|
return (
|
|
127
137
|
<Fragment>
|
|
128
|
-
<Text>{
|
|
138
|
+
<Text>{ label }</Text>
|
|
129
139
|
<Space />
|
|
130
140
|
</Fragment>
|
|
131
141
|
);
|
package/src/types.js
CHANGED
|
@@ -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
|
|
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
|
|
|
@@ -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;
|
|
@@ -204,7 +204,7 @@ export function Buttons(props : ButtonsProps) : ElementNode {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
{
|
|
207
|
-
(layout === BUTTON_LAYOUT.VERTICAL && fundingSources.indexOf(FUNDING.CARD) !== -1)
|
|
207
|
+
(layout === BUTTON_LAYOUT.VERTICAL && fundingSources.indexOf(FUNDING.CARD) !== -1 && !inlineExperience)
|
|
208
208
|
? <PoweredByPayPal
|
|
209
209
|
locale={ locale }
|
|
210
210
|
nonce={ nonce }
|
package/src/ui/buttons/props.js
CHANGED
|
@@ -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>,
|
|
@@ -4,12 +4,12 @@ import type { CustomStyle } from '../../../types';
|
|
|
4
4
|
import { CLASS } from '../../../constants';
|
|
5
5
|
|
|
6
6
|
export const customStyle = ({ custom } : {| custom? : CustomStyle |}) : string => {
|
|
7
|
-
|
|
7
|
+
const { css } = custom || {};
|
|
8
|
+
|
|
9
|
+
if (!css) {
|
|
8
10
|
return '';
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
const { css } = custom || {};
|
|
12
|
-
|
|
13
13
|
let heightStyle = '';
|
|
14
14
|
let marginStyle = '';
|
|
15
15
|
let style = Object.keys(css).reduce((acc, key) => {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { getLogger, getLocale, getClientID, getEnv, getIntent, getCommit, getVault, getDisableFunding, getDisableCard,
|
|
6
6
|
getMerchantID, getPayPalDomainRegex, getCurrency, getSDKMeta, getCSPNonce, getBuyerCountry, getClientAccessToken, getPlatform,
|
|
7
7
|
getPartnerAttributionID, getCorrelationID, getEnableThreeDomainSecure, getDebug, getComponents, getStageHost, getAPIStageHost, getPayPalDomain,
|
|
8
|
-
getUserIDToken, getClientMetadataID, getAmount, getEnableFunding, getStorageID, getUserExperienceFlow, getMerchantRequestedPopupsDisabled } from '@paypal/sdk-client/src';
|
|
8
|
+
getUserIDToken, getClientMetadataID, getAmount, getEnableFunding, getStorageID, getUserExperienceFlow, getMerchantRequestedPopupsDisabled, getVersion } from '@paypal/sdk-client/src';
|
|
9
9
|
import { rememberFunding, getRememberedFunding, getRefinedFundingEligibility } from '@paypal/funding-components/src';
|
|
10
10
|
import { ZalgoPromise } from '@krakenjs/zalgo-promise/src';
|
|
11
11
|
import { create, type ZoidComponent } from '@krakenjs/zoid/src';
|
|
@@ -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
|
|
|
@@ -116,6 +118,17 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
|
|
|
116
118
|
},
|
|
117
119
|
|
|
118
120
|
props: {
|
|
121
|
+
/**
|
|
122
|
+
* Version of the SDK used in first render.
|
|
123
|
+
* This is passed to the `/smart/buttons` endpoint in order for the second render
|
|
124
|
+
* to be aware of what sdk version to load during SSR of the buttons
|
|
125
|
+
*/
|
|
126
|
+
sdkVersion: {
|
|
127
|
+
type: 'string',
|
|
128
|
+
queryParam: true,
|
|
129
|
+
sendToChild: false,
|
|
130
|
+
value: getVersion
|
|
131
|
+
},
|
|
119
132
|
fundingSource: {
|
|
120
133
|
type: 'string',
|
|
121
134
|
queryParam: true,
|
|
@@ -608,10 +621,22 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
|
|
|
608
621
|
required: false,
|
|
609
622
|
type: 'string',
|
|
610
623
|
value: ({ props }) => {
|
|
611
|
-
const { style: {
|
|
612
|
-
const isInlineXO = (custom && (custom.label || custom.css)) && fundingEligibility[FUNDING.CARD]?.eligible;
|
|
624
|
+
const { commit, createBillingAgreement, currency, disableFunding = [], fundingEligibility, locale, merchantID = [], style: { layout }, vault } = props || {};
|
|
613
625
|
|
|
614
|
-
|
|
626
|
+
const inlineCheckoutEligibility : InlineXOEligibilityType = __INLINE_CHECKOUT_ELIGIBILITY__ || {
|
|
627
|
+
eligible: false
|
|
628
|
+
};
|
|
629
|
+
return inlineCheckoutEligibility && inlineCheckoutEligibility.eligible && isInlineXOEligible({ props: {
|
|
630
|
+
commit,
|
|
631
|
+
createBillingAgreement,
|
|
632
|
+
currency,
|
|
633
|
+
disableFunding,
|
|
634
|
+
fundingEligibility,
|
|
635
|
+
layout,
|
|
636
|
+
locale,
|
|
637
|
+
merchantID,
|
|
638
|
+
vault
|
|
639
|
+
} }) ? EXPERIENCE.INLINE : '';
|
|
615
640
|
}
|
|
616
641
|
},
|
|
617
642
|
|
package/src/zoid/buttons/util.js
CHANGED
|
@@ -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
|
+
}
|