@paypal/checkout-components 5.0.340 → 5.0.341
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/dist/button.js +1 -1
- package/dist/test/button.js +1 -1
- package/package.json +2 -2
- package/src/connect/component.jsx +20 -4
- package/src/connect/component.test.js +15 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paypal/checkout-components",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.341",
|
|
4
4
|
"description": "PayPal Checkout components, for integrating checkout products.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@krakenjs/beaver-logger": "^5.7.0",
|
|
108
108
|
"@krakenjs/belter": "^2.0.0",
|
|
109
109
|
"@krakenjs/cross-domain-utils": "^3.0.0",
|
|
110
|
-
"@krakenjs/jsx-pragmatic": "3
|
|
110
|
+
"@krakenjs/jsx-pragmatic": "^3",
|
|
111
111
|
"@krakenjs/post-robot": "^11.0.0",
|
|
112
112
|
"@krakenjs/zalgo-promise": "^2.0.0",
|
|
113
113
|
"@krakenjs/zoid": "^10.3.1",
|
|
@@ -17,19 +17,35 @@ import { FPTI_KEY } from "@paypal/sdk-constants";
|
|
|
17
17
|
|
|
18
18
|
const MIN_MAJOR_VERSION = 3;
|
|
19
19
|
const MIN_MINOR_VERSION = 97;
|
|
20
|
-
|
|
20
|
+
const MIN_PATCH_VERSION = 3;
|
|
21
|
+
export const MIN_BT_VERSION = `${MIN_MAJOR_VERSION}.${MIN_MINOR_VERSION}.${MIN_PATCH_VERSION}-connect-alpha.6.1`; // Minimum for supporting AXO
|
|
22
|
+
|
|
23
|
+
export const DEFAULT_BT_VERSION = `3.107.1`;
|
|
21
24
|
|
|
22
25
|
export function getSdkVersion(version: string | null): string {
|
|
23
26
|
if (!version) {
|
|
24
|
-
return
|
|
27
|
+
return DEFAULT_BT_VERSION;
|
|
25
28
|
}
|
|
26
29
|
const versionSplit = version.split(".");
|
|
30
|
+
// patch could have an alpha tag
|
|
31
|
+
const patchSplit = versionSplit[2].split("-");
|
|
32
|
+
|
|
27
33
|
const majorVersion = Number(versionSplit[0]);
|
|
28
34
|
const minorVersion = Number(versionSplit[1]);
|
|
35
|
+
const patchVersion = Number(patchSplit[0]);
|
|
36
|
+
|
|
37
|
+
const isMajorVersionSmaller = majorVersion < MIN_MAJOR_VERSION;
|
|
38
|
+
const isMajorVersionEqual = majorVersion === MIN_MAJOR_VERSION;
|
|
39
|
+
|
|
40
|
+
const isMinorVersionSmaller = minorVersion < MIN_MINOR_VERSION;
|
|
41
|
+
const isMinorVersionEqual = minorVersion === MIN_MINOR_VERSION;
|
|
42
|
+
|
|
43
|
+
const isPatchVersionSmaller = patchVersion < MIN_PATCH_VERSION;
|
|
29
44
|
|
|
30
45
|
if (
|
|
31
|
-
|
|
32
|
-
(
|
|
46
|
+
isMajorVersionSmaller ||
|
|
47
|
+
(isMajorVersionEqual && isMinorVersionSmaller) ||
|
|
48
|
+
(isMajorVersionEqual && isMinorVersionEqual && isPatchVersionSmaller)
|
|
33
49
|
) {
|
|
34
50
|
getLogger().metricCounter({
|
|
35
51
|
namespace: "connect.init.count",
|
|
@@ -7,7 +7,7 @@ import { describe, expect, test, vi } from "vitest";
|
|
|
7
7
|
import {
|
|
8
8
|
getConnectComponent,
|
|
9
9
|
getSdkVersion,
|
|
10
|
-
|
|
10
|
+
DEFAULT_BT_VERSION,
|
|
11
11
|
} from "./component";
|
|
12
12
|
|
|
13
13
|
vi.mock("@paypal/sdk-client/src", () => {
|
|
@@ -113,11 +113,11 @@ describe("getConnectComponent: returns ConnectComponent", () => {
|
|
|
113
113
|
);
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
test("
|
|
116
|
+
test("loadAxo is call with default values", async () => {
|
|
117
117
|
await getConnectComponent(mockProps);
|
|
118
118
|
expect(loadAxo).toHaveBeenCalledWith({
|
|
119
119
|
minified: true,
|
|
120
|
-
btSdkVersion: "3.
|
|
120
|
+
btSdkVersion: "3.107.1",
|
|
121
121
|
metadata: undefined,
|
|
122
122
|
platform: "PPCP",
|
|
123
123
|
});
|
|
@@ -128,23 +128,26 @@ describe("getSdkVersion", () => {
|
|
|
128
128
|
test("returns minimum supported braintree version for AXO if input version is null", () => {
|
|
129
129
|
const version = getSdkVersion(null);
|
|
130
130
|
|
|
131
|
-
expect(version).toEqual(
|
|
131
|
+
expect(version).toEqual(DEFAULT_BT_VERSION);
|
|
132
132
|
});
|
|
133
133
|
test("returns the version passed if it is supported for AXO", () => {
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const result3 = getSdkVersion("4.34.beta-test");
|
|
134
|
+
const result2 = getSdkVersion("3.97.3-alpha-test");
|
|
135
|
+
const result3 = getSdkVersion("4.34.3-beta-test");
|
|
137
136
|
const result4 = getSdkVersion("4.34.47");
|
|
137
|
+
const result5 = getSdkVersion("3.98.3");
|
|
138
|
+
const result6 = getSdkVersion("3.97.6");
|
|
138
139
|
|
|
139
|
-
expect(
|
|
140
|
-
expect(
|
|
141
|
-
expect(result3).toEqual("4.34.beta-test");
|
|
140
|
+
expect(result2).toEqual("3.97.3-alpha-test");
|
|
141
|
+
expect(result3).toEqual("4.34.3-beta-test");
|
|
142
142
|
expect(result4).toEqual("4.34.47");
|
|
143
|
+
expect(result5).toEqual("3.98.3");
|
|
144
|
+
expect(result6).toEqual("3.97.6");
|
|
143
145
|
});
|
|
144
146
|
|
|
145
147
|
test("throws error if the version passed is not supported for AXO and is not null", () => {
|
|
146
148
|
expect(() => getSdkVersion("3.96.00")).toThrowError();
|
|
147
|
-
expect(() => getSdkVersion("
|
|
148
|
-
expect(() => getSdkVersion("
|
|
149
|
+
expect(() => getSdkVersion("3.97.00")).toThrowError();
|
|
150
|
+
expect(() => getSdkVersion("2.87.1-alpha-test")).toThrowError();
|
|
151
|
+
expect(() => getSdkVersion("3.34.2-beta-test")).toThrowError();
|
|
149
152
|
});
|
|
150
153
|
});
|