@paypal/checkout-components 5.0.293 → 5.0.294
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/package.json
CHANGED
|
@@ -125,10 +125,9 @@ export function getShopperInsightsComponent(): ShopperInsightsComponent {
|
|
|
125
125
|
[FPTI_KEY.EVENT_NAME]: FPTI_TRANSITION.SHOPPER_INSIGHTS_API_INIT,
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
validateMerchantConfig({ sdkToken, pageType, userIDToken, clientToken });
|
|
129
|
-
|
|
130
128
|
const shopperInsights = {
|
|
131
129
|
getRecommendedPaymentMethods: (merchantPayload) => {
|
|
130
|
+
validateMerchantConfig({ sdkToken, pageType, userIDToken, clientToken });
|
|
132
131
|
validateMerchantPayload(merchantPayload);
|
|
133
132
|
|
|
134
133
|
const requestPayload =
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import { ZalgoPromise } from "@krakenjs/zalgo-promise/src";
|
|
3
|
-
import { getEnv, getBuyerCountry } from "@paypal/sdk-client/src";
|
|
3
|
+
import { getEnv, getBuyerCountry, getSDKToken } from "@paypal/sdk-client/src";
|
|
4
4
|
import { vi, describe, expect } from "vitest";
|
|
5
5
|
import { request } from "@krakenjs/belter/src";
|
|
6
6
|
|
|
7
|
+
import { ValidationError } from "../../lib";
|
|
8
|
+
|
|
7
9
|
import { getShopperInsightsComponent } from "./component";
|
|
8
10
|
|
|
9
11
|
vi.mock("@paypal/sdk-client/src", () => {
|
|
@@ -348,4 +350,27 @@ describe("shopper insights component - getRecommendedPaymentMethods()", () => {
|
|
|
348
350
|
})
|
|
349
351
|
);
|
|
350
352
|
});
|
|
353
|
+
|
|
354
|
+
test("ensure sdk-token is passed when using the getRecommendedPaymentMethods", async () => {
|
|
355
|
+
// $FlowFixMe
|
|
356
|
+
getSDKToken.mockImplementationOnce(() => undefined);
|
|
357
|
+
// $FlowFixMe
|
|
358
|
+
const shopperInsightsComponent = getShopperInsightsComponent();
|
|
359
|
+
const error = new ValidationError(
|
|
360
|
+
`script data attribute sdk-client-token is required but was not passed`
|
|
361
|
+
);
|
|
362
|
+
await expect(
|
|
363
|
+
async () =>
|
|
364
|
+
await shopperInsightsComponent.getRecommendedPaymentMethods({
|
|
365
|
+
customer: {
|
|
366
|
+
email: "email@test.com",
|
|
367
|
+
phone: {
|
|
368
|
+
countryCode: "1",
|
|
369
|
+
nationalNumber: "2345678905",
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
})
|
|
373
|
+
).rejects.toThrowError(error);
|
|
374
|
+
expect.assertions(1);
|
|
375
|
+
});
|
|
351
376
|
});
|
|
@@ -51,7 +51,7 @@ export function getSdkVersion(version: string | null): string {
|
|
|
51
51
|
// $FlowFixMe
|
|
52
52
|
export const getConnectComponent = async (merchantProps = {}) => {
|
|
53
53
|
const cmid = getClientMetadataID() || getSessionID();
|
|
54
|
-
const
|
|
54
|
+
const clientId = getClientID();
|
|
55
55
|
const userIdToken = getUserIDToken();
|
|
56
56
|
const env = getEnv();
|
|
57
57
|
const cspNonce = getCSPNonce();
|
|
@@ -108,7 +108,7 @@ export const getConnectComponent = async (merchantProps = {}) => {
|
|
|
108
108
|
platformOptions: {
|
|
109
109
|
platform: "PPCP",
|
|
110
110
|
userIdToken,
|
|
111
|
-
|
|
111
|
+
clientId,
|
|
112
112
|
fraudnet: collect,
|
|
113
113
|
clientMetadataId: cmid,
|
|
114
114
|
env,
|