@paypal/checkout-components 5.0.194 → 5.0.197-alpha.2
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 +18 -0
- package/README.md +2 -2
- package/dist/button.js +1 -1
- package/package.json +2 -5
- package/src/funding/common.jsx +1 -1
- package/src/funding/paylater/config.jsx +45 -38
- package/src/lib/security.js +1 -1
- package/src/ui/buttons/button.jsx +1 -1
- package/src/ui/buttons/props.js +2 -1
- package/src/zoid/buttons/component.jsx +27 -1
- package/src/zoid/buttons/prerender.jsx +3 -3
- package/src/zoid/card-fields/component.jsx +1 -1
- package/src/zoid/card-form/component.js +1 -1
- package/src/zoid/wallet/component.jsx +10 -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.197-alpha.2",
|
|
4
4
|
"description": "PayPal Checkout components, for integrating checkout products.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
"webpack-size": "babel-node $(npm bin)/webpack --progress --config webpack.config.size",
|
|
15
15
|
"build": "npm run test && npm run webpack",
|
|
16
16
|
"release": "./scripts/publish.sh",
|
|
17
|
-
"release:patch": "./scripts/publish.sh patch",
|
|
18
|
-
"release:minor": "./scripts/publish.sh minor",
|
|
19
|
-
"release:major": "./scripts/publish.sh major",
|
|
20
17
|
"preversion": "./scripts/preversion.sh",
|
|
21
18
|
"version": "./scripts/version.sh",
|
|
22
19
|
"postversion": "./scripts/postversion.sh",
|
|
@@ -80,13 +77,13 @@
|
|
|
80
77
|
"sync-browser-mocks": "^2.0.8"
|
|
81
78
|
},
|
|
82
79
|
"dependencies": {
|
|
80
|
+
"@krakenjs/cross-domain-utils": "^3.0.2",
|
|
83
81
|
"@paypal/common-components": "^1.0.16",
|
|
84
82
|
"@paypal/funding-components": "^1.0.17",
|
|
85
83
|
"@paypal/sdk-client": "^4.0.156",
|
|
86
84
|
"@paypal/sdk-constants": "^1.0.107",
|
|
87
85
|
"@paypal/sdk-logos": "^1.0.26",
|
|
88
86
|
"belter": "^1.0.2",
|
|
89
|
-
"cross-domain-utils": "^2.0.1",
|
|
90
87
|
"jsx-pragmatic": "^2",
|
|
91
88
|
"post-robot": "^10.0.0",
|
|
92
89
|
"zalgo-promise": "^1.0.10",
|
package/src/funding/common.jsx
CHANGED
|
@@ -118,7 +118,7 @@ export type FundingSourceConfig = {|
|
|
|
118
118
|
secondaryVaultColors : { [$Values<typeof BUTTON_COLOR>] : $Values<typeof BUTTON_COLOR> },
|
|
119
119
|
logoColors : { [$Values<typeof BUTTON_COLOR>] : $Values<typeof LOGO_COLOR> },
|
|
120
120
|
shapes : $ReadOnlyArray<$Values<typeof BUTTON_SHAPE>>,
|
|
121
|
-
labelText? : string | (({| content : ?ContentType |}) => string),
|
|
121
|
+
labelText? : string | (({| content : ?ContentType, fundingEligibility : ?FundingEligibilityType |}) => string),
|
|
122
122
|
showWalletMenu : ({| instrument : WalletInstrument |}) => boolean
|
|
123
123
|
|};
|
|
124
124
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
/** @jsx node */
|
|
3
3
|
|
|
4
|
+
import type { FundingEligibilityType } from '@paypal/sdk-client/src';
|
|
4
5
|
import { FUNDING } from '@paypal/sdk-constants/src';
|
|
5
6
|
import { node, Style } from 'jsx-pragmatic/src';
|
|
6
7
|
import { PPLogo, LOGO_COLOR } from '@paypal/sdk-logos/src';
|
|
@@ -11,6 +12,46 @@ import { Text, Space } from '../../ui/text';
|
|
|
11
12
|
|
|
12
13
|
import css from './style.scoped.scss';
|
|
13
14
|
|
|
15
|
+
function getLabelText(fundingEligibility : FundingEligibilityType) : ?string {
|
|
16
|
+
const { paylater } = fundingEligibility;
|
|
17
|
+
|
|
18
|
+
let labelText;
|
|
19
|
+
|
|
20
|
+
if (
|
|
21
|
+
paylater?.products?.paylater?.eligible &&
|
|
22
|
+
paylater?.products?.paylater?.variant === 'DE'
|
|
23
|
+
) {
|
|
24
|
+
labelText = 'Später Bezahlen';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (
|
|
28
|
+
paylater?.products?.payIn3?.eligible &&
|
|
29
|
+
paylater?.products?.payIn3?.variant === 'ES'
|
|
30
|
+
) {
|
|
31
|
+
labelText = 'Paga en 3 plazos';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (
|
|
35
|
+
paylater?.products?.payIn3?.eligible &&
|
|
36
|
+
paylater?.products?.payIn3?.variant === 'IT'
|
|
37
|
+
) {
|
|
38
|
+
labelText = 'Paga in 3 rate';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (paylater?.products?.payIn4?.eligible) {
|
|
42
|
+
labelText = 'Pay in 4';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (
|
|
46
|
+
paylater?.products?.payIn4?.eligible &&
|
|
47
|
+
paylater?.products?.payIn4?.variant === 'FR'
|
|
48
|
+
) {
|
|
49
|
+
labelText = '4X PayPal';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return labelText;
|
|
53
|
+
}
|
|
54
|
+
|
|
14
55
|
export function getPaylaterConfig() : FundingSourceConfig {
|
|
15
56
|
return {
|
|
16
57
|
...DEFAULT_FUNDING_CONFIG,
|
|
@@ -34,47 +75,11 @@ export function getPaylaterConfig() : FundingSourceConfig {
|
|
|
34
75
|
Label: ({ logo }) => logo,
|
|
35
76
|
|
|
36
77
|
Logo: ({ logoColor, nonce, fundingEligibility }) => {
|
|
37
|
-
const { paylater } = fundingEligibility;
|
|
38
|
-
|
|
39
|
-
let label = <Text>Pay Later</Text>;
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
paylater?.products?.paylater?.eligible &&
|
|
43
|
-
paylater?.products?.paylater?.variant === 'DE'
|
|
44
|
-
) {
|
|
45
|
-
label = <Text>Später Bezahlen</Text>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
paylater?.products?.payIn3?.eligible &&
|
|
50
|
-
paylater?.products?.payIn3?.variant === 'ES'
|
|
51
|
-
) {
|
|
52
|
-
label = <Text>Paga en 3 plazos</Text>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
paylater?.products?.payIn3?.eligible &&
|
|
57
|
-
paylater?.products?.payIn3?.variant === 'IT'
|
|
58
|
-
) {
|
|
59
|
-
label = <Text>Paga in 3 rate</Text>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (paylater?.products?.payIn4?.eligible) {
|
|
63
|
-
label = <Text>Pay in 4</Text>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
paylater?.products?.payIn4?.eligible &&
|
|
68
|
-
paylater?.products?.payIn4?.variant === 'FR'
|
|
69
|
-
) {
|
|
70
|
-
label = <Text>4X PayPal</Text>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
78
|
return (
|
|
74
79
|
<Style css={ css } nonce={ nonce }>
|
|
75
80
|
<PPLogo logoColor={ logoColor } />
|
|
76
81
|
<Space />
|
|
77
|
-
{
|
|
82
|
+
<Text>{ getLabelText(fundingEligibility) || 'Pay Later' }</Text>
|
|
78
83
|
</Style>
|
|
79
84
|
);
|
|
80
85
|
},
|
|
@@ -104,6 +109,8 @@ export function getPaylaterConfig() : FundingSourceConfig {
|
|
|
104
109
|
[BUTTON_COLOR.WHITE]: LOGO_COLOR.BLUE
|
|
105
110
|
},
|
|
106
111
|
|
|
107
|
-
labelText:
|
|
112
|
+
labelText: ({ fundingEligibility }) => {
|
|
113
|
+
return (fundingEligibility && getLabelText(fundingEligibility)) || `${ FUNDING.PAYPAL } ${ FUNDING.PAYLATER }`;
|
|
114
|
+
}
|
|
108
115
|
};
|
|
109
116
|
}
|
package/src/lib/security.js
CHANGED
|
@@ -96,7 +96,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
96
96
|
|
|
97
97
|
const { layout, shape } = style;
|
|
98
98
|
|
|
99
|
-
const labelText = typeof fundingConfig.labelText === 'function' ? fundingConfig.labelText({ content }) : (fundingConfig.labelText || fundingSource);
|
|
99
|
+
const labelText = typeof fundingConfig.labelText === 'function' ? fundingConfig.labelText({ content, fundingEligibility }) : (fundingConfig.labelText || fundingSource);
|
|
100
100
|
|
|
101
101
|
const logoNode = (
|
|
102
102
|
<Logo
|
package/src/ui/buttons/props.js
CHANGED
|
@@ -7,7 +7,7 @@ import { type OrderCreateRequest, type FundingEligibilityType,
|
|
|
7
7
|
type OrderGetResponse, type OrderCaptureResponse, type OrderAuthorizeResponse } from '@paypal/sdk-client/src';
|
|
8
8
|
import { FUNDING, PLATFORM, INTENT, COMMIT, VAULT,
|
|
9
9
|
ENV, COUNTRY, LANG, COUNTRY_LANGS, type LocaleType, CARD, COMPONENTS } from '@paypal/sdk-constants/src';
|
|
10
|
-
import { type CrossDomainWindowType } from 'cross-domain-utils/src';
|
|
10
|
+
import { type CrossDomainWindowType } from '@krakenjs/cross-domain-utils/src';
|
|
11
11
|
import { LOGO_COLOR } from '@paypal/sdk-logos/src';
|
|
12
12
|
import { SUPPORTED_FUNDING_SOURCES } from '@paypal/funding-components/src';
|
|
13
13
|
import type { ComponentFunctionType } from 'jsx-pragmatic/src';
|
|
@@ -298,6 +298,7 @@ export type ButtonProps = {|
|
|
|
298
298
|
onShippingChange : ?OnShippingChange,
|
|
299
299
|
clientAccessToken? : ?string,
|
|
300
300
|
nonce : string,
|
|
301
|
+
merchantRequestedPopupsDisabled : ?boolean,
|
|
301
302
|
userIDToken : ?string,
|
|
302
303
|
flow : $Values<typeof BUTTON_FLOW>,
|
|
303
304
|
experiment : Experiment,
|
|
@@ -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 } from '@paypal/sdk-client/src';
|
|
8
|
+
getUserIDToken, getClientMetadataID, getAmount, getEnableFunding, getStorageID, getUserExperienceFlow, getMerchantRequestedPopupsDisabled } from '@paypal/sdk-client/src';
|
|
9
9
|
import { rememberFunding, getRememberedFunding, getRefinedFundingEligibility } from '@paypal/funding-components/src';
|
|
10
10
|
import { ZalgoPromise } from 'zalgo-promise/src';
|
|
11
11
|
import { create, type ZoidComponent } from 'zoid/src';
|
|
@@ -268,6 +268,26 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
|
|
|
268
268
|
}
|
|
269
269
|
},
|
|
270
270
|
|
|
271
|
+
onRender: {
|
|
272
|
+
type: 'function',
|
|
273
|
+
required: false,
|
|
274
|
+
default: () => noop,
|
|
275
|
+
decorate: ({ props, value = noop }) => {
|
|
276
|
+
return (...args) => {
|
|
277
|
+
getLogger().track({
|
|
278
|
+
event_name: 'testing',
|
|
279
|
+
[ FPTI_KEY.BUTTON_SESSION_UID ]: props.buttonSessionID,
|
|
280
|
+
[ FPTI_KEY.CONTEXT_CORRID ]: getCorrelationID(),
|
|
281
|
+
[ FPTI_KEY.CONTEXT_ID ]: props.buttonSessionID,
|
|
282
|
+
[ FPTI_KEY.CONTEXT_TYPE ]: 'button_session_id',
|
|
283
|
+
[ FPTI_KEY.FEED ]: 'payments_sdk'// ,
|
|
284
|
+
// [ FPTI_KEY.SDK_LOAD_START ]: (new Date()).toISOString()
|
|
285
|
+
}).flush();
|
|
286
|
+
return value(...args);
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
|
|
271
291
|
getQueriedEligibleFunding: {
|
|
272
292
|
type: 'function',
|
|
273
293
|
value: () => {
|
|
@@ -294,6 +314,12 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
|
|
|
294
314
|
value: getPartnerAttributionID
|
|
295
315
|
},
|
|
296
316
|
|
|
317
|
+
merchantRequestedPopupsDisabled: {
|
|
318
|
+
type: 'boolean',
|
|
319
|
+
required: false,
|
|
320
|
+
value: getMerchantRequestedPopupsDisabled
|
|
321
|
+
},
|
|
322
|
+
|
|
297
323
|
enableThreeDomainSecure: {
|
|
298
324
|
type: 'boolean',
|
|
299
325
|
value: getEnableThreeDomainSecure
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { node, dom, type ChildType } from 'jsx-pragmatic/src';
|
|
5
5
|
import { FUNDING, CARD, FPTI_KEY } from '@paypal/sdk-constants/src';
|
|
6
6
|
import { popup, supportsPopups, writeElementToWindow } from 'belter/src';
|
|
7
|
-
import { assertSameDomain, type CrossDomainWindowType } from 'cross-domain-utils/src';
|
|
7
|
+
import { assertSameDomain, type CrossDomainWindowType } from '@krakenjs/cross-domain-utils/src';
|
|
8
8
|
import { SpinnerPage } from '@paypal/common-components/src';
|
|
9
9
|
import { getLogger } from '@paypal/sdk-client/src';
|
|
10
10
|
import type { ZoidProps } from 'zoid/src';
|
|
@@ -41,9 +41,9 @@ export function PrerenderedButtons({ nonce, onRenderCheckout, props } : Prerende
|
|
|
41
41
|
[ FPTI_KEY.CHOSEN_FUNDING]: fundingSource
|
|
42
42
|
}).flush();
|
|
43
43
|
|
|
44
|
-
if (fundingSource === FUNDING.VENMO) {
|
|
44
|
+
if (fundingSource === FUNDING.VENMO || fundingSource === FUNDING.APPLEPAY) {
|
|
45
45
|
// wait for button to load
|
|
46
|
-
} else if (supportsPopups()) {
|
|
46
|
+
} else if (supportsPopups() && !props.merchantRequestedPopupsDisabled) {
|
|
47
47
|
// remember the popup window to prevent showing a new popup window on every click in the prerender state
|
|
48
48
|
if (!win || win.closed) {
|
|
49
49
|
win = assertSameDomain(popup('', {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { node, dom } from 'jsx-pragmatic/src';
|
|
6
6
|
import { ZalgoPromise } from 'zalgo-promise/src';
|
|
7
7
|
import { create, type ZoidComponent } from 'zoid/src';
|
|
8
|
-
import type { CrossDomainWindowType } from 'cross-domain-utils/src';
|
|
8
|
+
import type { CrossDomainWindowType } from '@krakenjs/cross-domain-utils/src';
|
|
9
9
|
import { memoize, uniqueID } from 'belter/src';
|
|
10
10
|
import { getLocale, getEnv, getSDKMeta, getDisableCard, getPayPalDomain, getClientID, getDebug, getCurrency, getIntent,
|
|
11
11
|
getCommit, getVault } from '@paypal/sdk-client/src';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { LANG } from '@paypal/sdk-constants/src';
|
|
6
6
|
import { ZalgoPromise } from 'zalgo-promise/src';
|
|
7
7
|
import { create, type ZoidComponent } from 'zoid/src';
|
|
8
|
-
import type { CrossDomainWindowType } from 'cross-domain-utils/src';
|
|
8
|
+
import type { CrossDomainWindowType } from '@krakenjs/cross-domain-utils/src';
|
|
9
9
|
import { inlineMemoize } from 'belter/src';
|
|
10
10
|
import { getLocale, getEnv, getCommit, getSDKMeta, getDisableCard, getPayPalDomain } from '@paypal/sdk-client/src';
|
|
11
11
|
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
/* eslint max-lines: 0 */
|
|
4
4
|
|
|
5
5
|
import { node, dom } from 'jsx-pragmatic/src';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getLogger, getPayPalDomainRegex, getSDKMeta, getPayPalDomain, getClientID, getUserAccessToken,
|
|
7
8
|
getClientAccessToken, getUserIDToken, getLocale, getPartnerAttributionID, getCorrelationID, getSessionID,
|
|
8
9
|
getEnv, getStageHost, getAPIStageHost, getPlatform, getCurrency, getIntent, getBuyerCountry, getCommit, getVault,
|
|
9
|
-
getMerchantID, getCSPNonce, getDebug
|
|
10
|
+
getMerchantID, getCSPNonce, getDebug, getMerchantRequestedPopupsDisabled
|
|
11
|
+
} from '@paypal/sdk-client/src';
|
|
10
12
|
import { create, type ZoidComponent } from 'zoid/src';
|
|
11
13
|
import { inlineMemoize, memoize, uniqueID } from 'belter/src';
|
|
12
14
|
import { ZalgoPromise } from 'zalgo-promise/src';
|
|
@@ -132,6 +134,12 @@ export function getWalletComponent() : WalletComponent {
|
|
|
132
134
|
value: getPartnerAttributionID
|
|
133
135
|
},
|
|
134
136
|
|
|
137
|
+
merchantRequestedPopupsDisabled: {
|
|
138
|
+
type: 'boolean',
|
|
139
|
+
required: false,
|
|
140
|
+
value: getMerchantRequestedPopupsDisabled
|
|
141
|
+
},
|
|
142
|
+
|
|
135
143
|
correlationID: {
|
|
136
144
|
type: 'string',
|
|
137
145
|
required: false,
|