@paypal/checkout-components 5.0.211 → 5.0.214
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 +19 -0
- package/dist/button.js +1 -1
- package/package.json +1 -1
- package/src/declarations.js +5 -0
- package/src/funding/boleto/config.jsx +2 -0
- package/src/funding/card/config.jsx +12 -2
- package/src/funding/multibanco/config.jsx +2 -0
- package/src/funding/oxxo/config.jsx +2 -0
- package/src/types.js +5 -0
- package/src/ui/buttons/button.jsx +3 -4
- package/src/ui/buttons/buttons.jsx +2 -2
- package/src/ui/buttons/props.js +3 -0
- package/src/ui/buttons/styles/custom.js +3 -3
- package/src/zoid/buttons/component.jsx +18 -4
- package/src/zoid/buttons/util.js +39 -2
package/package.json
CHANGED
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;
|
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) => {
|
|
@@ -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: {
|
|
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
|
-
|
|
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
|
|
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
|
+
}
|