@paypal/checkout-components 5.0.344-alpha-1f4f70b.0 → 5.0.344
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/__sdk__.js +3 -0
- package/dist/button.js +1 -1
- package/dist/test/button.js +1 -1
- package/package.json +5 -3
- package/src/three-domain-secure/component.jsx +48 -24
- package/src/three-domain-secure/component.test.js +48 -33
- package/src/three-domain-secure/interface.js +20 -7
- package/src/zoid/card-fields/component.jsx +12 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paypal/checkout-components",
|
|
3
|
-
"version": "5.0.344
|
|
3
|
+
"version": "5.0.344",
|
|
4
4
|
"description": "PayPal Checkout components, for integrating checkout products.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -101,7 +101,9 @@
|
|
|
101
101
|
"puppeteer": "^1.20.0",
|
|
102
102
|
"serve": "^14.0.0",
|
|
103
103
|
"vite": "^3.2.4",
|
|
104
|
-
"vitest": "^1.3.1"
|
|
104
|
+
"vitest": "^1.3.1",
|
|
105
|
+
"flow-remove-types": "2.246.0",
|
|
106
|
+
"hermes-parser": "0.23.1"
|
|
105
107
|
},
|
|
106
108
|
"dependencies": {
|
|
107
109
|
"@krakenjs/beaver-logger": "^5.7.0",
|
|
@@ -111,7 +113,7 @@
|
|
|
111
113
|
"@krakenjs/post-robot": "^11.0.0",
|
|
112
114
|
"@krakenjs/zalgo-promise": "^2.0.0",
|
|
113
115
|
"@krakenjs/zoid": "^10.3.1",
|
|
114
|
-
"@paypal/accelerated-checkout-loader": "
|
|
116
|
+
"@paypal/accelerated-checkout-loader": "^1.0.1",
|
|
115
117
|
"@paypal/common-components": "^1.0.35",
|
|
116
118
|
"@paypal/funding-components": "^1.0.31",
|
|
117
119
|
"@paypal/sdk-client": "^4.0.194",
|
|
@@ -1,30 +1,54 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
import {
|
|
2
|
+
import { type LoggerType } from "@krakenjs/beaver-logger/src";
|
|
3
|
+
import { ZalgoPromise } from "@krakenjs/zalgo-promise/src";
|
|
4
|
+
import { create, type ZoidComponent } from "@krakenjs/zoid/src";
|
|
3
5
|
import { FPTI_KEY } from "@paypal/sdk-constants/src";
|
|
4
6
|
|
|
5
7
|
import { ValidationError } from "../lib";
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
throw new ValidationError(
|
|
24
|
-
`script data attribute sdk-client-token is required but was not passed`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return ThreeDomainSecureAuth;
|
|
9
|
+
type SdkConfig = {|
|
|
10
|
+
sdkToken: ?string,
|
|
11
|
+
|};
|
|
12
|
+
|
|
13
|
+
const parseSdkConfig = ({ sdkConfig, logger }): SdkConfig => {
|
|
14
|
+
if (!sdkConfig.sdkToken) {
|
|
15
|
+
throw new ValidationError(
|
|
16
|
+
`script data attribute sdk-client-token is required but was not passed`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
logger.info("three domain secure v2 invoked").track({
|
|
21
|
+
[FPTI_KEY.TRANSITION]: "three_DS_auth_v2",
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return sdkConfig;
|
|
30
25
|
};
|
|
26
|
+
export interface ThreeDomainSecureComponentInterface {
|
|
27
|
+
isEligible(): ZalgoPromise<boolean>;
|
|
28
|
+
show(): ZoidComponent<void>;
|
|
29
|
+
}
|
|
30
|
+
export class ThreeDomainSecureComponent {
|
|
31
|
+
logger: LoggerType;
|
|
32
|
+
sdkConfig: SdkConfig;
|
|
33
|
+
|
|
34
|
+
constructor({
|
|
35
|
+
logger,
|
|
36
|
+
sdkConfig,
|
|
37
|
+
}: {|
|
|
38
|
+
logger: LoggerType,
|
|
39
|
+
sdkConfig: SdkConfig,
|
|
40
|
+
|}) {
|
|
41
|
+
this.logger = logger;
|
|
42
|
+
this.sdkConfig = parseSdkConfig({ sdkConfig, logger });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
isEligible(): ZalgoPromise<boolean> {
|
|
46
|
+
return new ZalgoPromise((resolve) => {
|
|
47
|
+
resolve(false);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
show() {
|
|
52
|
+
create({ tag: "", url: "" });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,44 +1,59 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
import { describe, expect,
|
|
3
|
-
import { getSDKToken } from "@paypal/sdk-client/src";
|
|
2
|
+
import { describe, expect, vi } from "vitest";
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import { ThreeDomainSecureComponent } from "./component";
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
const defaultSdkConfig = {
|
|
7
|
+
sdkToken: "sdk-client-token",
|
|
8
|
+
};
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const createThreeDomainSecureComponent = ({
|
|
11
|
+
sdkConfig = defaultSdkConfig,
|
|
12
|
+
logger = {
|
|
12
13
|
info: vi.fn().mockReturnThis(),
|
|
14
|
+
warn: vi.fn().mockReturnThis(),
|
|
15
|
+
error: vi.fn().mockReturnThis(),
|
|
13
16
|
track: vi.fn().mockReturnThis(),
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
it("should throw an error if sdkToken is not present", () => {
|
|
22
|
-
// $FlowFixMe prop missing error
|
|
23
|
-
getSDKToken.mockReturnValue(undefined);
|
|
24
|
-
const ThreeDomainSecureComponent = getThreeDomainSecure();
|
|
25
|
-
expect(() => ThreeDomainSecureComponent()).toThrowError(ValidationError);
|
|
26
|
-
expect(ValidationError).toHaveBeenCalledWith(
|
|
27
|
-
`script data attribute sdk-client-token is required but was not passed`
|
|
28
|
-
);
|
|
17
|
+
metricCounter: vi.fn().mockReturnThis(),
|
|
18
|
+
},
|
|
19
|
+
} = {}) =>
|
|
20
|
+
new ThreeDomainSecureComponent({
|
|
21
|
+
sdkConfig,
|
|
22
|
+
// $FlowIssue
|
|
23
|
+
logger,
|
|
29
24
|
});
|
|
30
|
-
it("should return the ThreeDomainSecure component and log the correct message", async () => {
|
|
31
|
-
// eslint-disable-next-line no-empty-function
|
|
32
|
-
const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {});
|
|
33
|
-
// $FlowFixMe prop missing error
|
|
34
|
-
getSDKToken.mockReturnValue("84ghb8984");
|
|
35
|
-
const ThreeDomainSecureComponent = getThreeDomainSecure();
|
|
36
|
-
expect(typeof ThreeDomainSecureComponent).toBe("function");
|
|
37
25
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
vi.clearAllMocks();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("three domain secure component - isEligible method", () => {
|
|
31
|
+
test("should return false", async () => {
|
|
32
|
+
const threeDomainSecuretClient = createThreeDomainSecureComponent();
|
|
33
|
+
const eligibility = await threeDomainSecuretClient.isEligible();
|
|
34
|
+
expect(eligibility).toEqual(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
describe("three domain descure component - show method", () => {
|
|
39
|
+
test.skip("should return a zoid component", () => {
|
|
40
|
+
const threeDomainSecuretClient = createThreeDomainSecureComponent();
|
|
41
|
+
threeDomainSecuretClient.show();
|
|
42
|
+
// create test for zoid component
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("three domain secure component - initialization", () => {
|
|
47
|
+
test("should throw an error if sdkToken is not present", () => {
|
|
48
|
+
expect(() =>
|
|
49
|
+
createThreeDomainSecureComponent({
|
|
50
|
+
sdkConfig: {
|
|
51
|
+
...defaultSdkConfig,
|
|
52
|
+
sdkToken: "",
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
).toThrowError(
|
|
56
|
+
`script data attribute sdk-client-token is required but was not passed`
|
|
57
|
+
);
|
|
43
58
|
});
|
|
44
59
|
});
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
import {
|
|
2
|
+
import { getLogger, getSDKToken } from "@paypal/sdk-client/src";
|
|
3
3
|
|
|
4
4
|
import type { LazyExport } from "../types";
|
|
5
5
|
import { protectedExport } from "../lib";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ThreeDomainSecureComponent,
|
|
9
|
+
type ThreeDomainSecureComponentInterface,
|
|
10
|
+
} from "./component";
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
export const ThreeDomainSecureClient: LazyExport<ThreeDomainSecureComponentInterface> =
|
|
13
|
+
{
|
|
14
|
+
__get__: () => {
|
|
15
|
+
const threeDomainSecureInstance = new ThreeDomainSecureComponent({
|
|
16
|
+
logger: getLogger(),
|
|
17
|
+
sdkConfig: {
|
|
18
|
+
sdkToken: getSDKToken(),
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
return protectedExport({
|
|
22
|
+
isEligible: () => threeDomainSecureInstance.isEligible(),
|
|
23
|
+
show: () => threeDomainSecureInstance.show(),
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -48,11 +48,11 @@ const CARD_FIELD_TYPE = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
type InstallmentsConfiguration = {|
|
|
51
|
-
financingCountryCode
|
|
52
|
-
currencyCode
|
|
53
|
-
billingCountryCode
|
|
54
|
-
amount
|
|
55
|
-
includeBuyerInstallments
|
|
51
|
+
financingCountryCode: string,
|
|
52
|
+
currencyCode: string,
|
|
53
|
+
billingCountryCode: string,
|
|
54
|
+
amount: string,
|
|
55
|
+
includeBuyerInstallments?: boolean,
|
|
56
56
|
|};
|
|
57
57
|
|
|
58
58
|
type CardFieldsProps = {|
|
|
@@ -109,10 +109,12 @@ type CardFieldsProps = {|
|
|
|
109
109
|
hcfSessionID: string,
|
|
110
110
|
partnerAttributionID: string,
|
|
111
111
|
merchantID: $ReadOnlyArray<string>,
|
|
112
|
-
installments
|
|
113
|
-
onInstallmentsRequested
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
installments?: {|
|
|
113
|
+
onInstallmentsRequested: () =>
|
|
114
|
+
| InstallmentsConfiguration
|
|
115
|
+
| ZalgoPromise<InstallmentsConfiguration>,
|
|
116
|
+
onInstallmentsAvailable: (Object) => void,
|
|
117
|
+
onInstallmentsError?: (Object) => void,
|
|
116
118
|
|},
|
|
117
119
|
|};
|
|
118
120
|
|
|
@@ -445,7 +447,7 @@ export const getCardFieldsComponent: () => CardFieldsComponent = memoize(
|
|
|
445
447
|
installments: {
|
|
446
448
|
type: "object",
|
|
447
449
|
required: false,
|
|
448
|
-
value: ({ props }) => props.parent.props.installments
|
|
450
|
+
value: ({ props }) => props.parent.props.installments,
|
|
449
451
|
},
|
|
450
452
|
},
|
|
451
453
|
});
|