Skip to content

Commit 923bb9e

Browse files
add fingerprint to shopper insights
Co-authored-by: elizabethmv <[email protected]> Co-authored-by: Shane Brunson <[email protected]>
1 parent e67ac87 commit 923bb9e

File tree

6 files changed

+782
-270
lines changed

6 files changed

+782
-270
lines changed

Diff for: src/api/shopper-insights/validation.js

-120
This file was deleted.

Diff for: src/api/shopper-insights/validation.test.js

-150
This file was deleted.

Diff for: src/lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* @flow */
22

3+
export * from "./api";
34
export * from "./errors";
45
export * from "./isRTLLanguage";
56
export * from "./security";

Diff for: src/shopper-insights/interface.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* @flow */
2+
import {
3+
getUserIDToken,
4+
getPageType,
5+
getClientToken,
6+
getSDKToken,
7+
getLogger,
8+
getPayPalAPIDomain,
9+
getCurrency,
10+
getBuyerCountry,
11+
getEnv,
12+
getSessionState,
13+
} from "@paypal/sdk-client/src";
14+
15+
import type { LazyExport } from "../types";
16+
import { callMemoizedRestAPI } from "../lib";
17+
18+
import {
19+
ShopperSession,
20+
type ShopperInsightsInterface,
21+
} from "./shopperSession";
22+
23+
const sessionState = {
24+
get: (key) => {
25+
let value;
26+
getSessionState((state) => {
27+
value = state[key];
28+
return state;
29+
});
30+
return value;
31+
},
32+
set: (key, value) => {
33+
getSessionState((state) => ({
34+
...state,
35+
[key]: value,
36+
}));
37+
},
38+
};
39+
40+
export const ShopperInsights: LazyExport<ShopperInsightsInterface> = {
41+
__get__: () => {
42+
const shopperSession = new ShopperSession({
43+
logger: getLogger(),
44+
// $FlowIssue ZalgoPromise vs Promise
45+
request: callMemoizedRestAPI,
46+
sdkConfig: {
47+
sdkToken: getSDKToken(),
48+
pageType: getPageType(),
49+
userIDToken: getUserIDToken(),
50+
clientToken: getClientToken(),
51+
paypalApiDomain: getPayPalAPIDomain(),
52+
environment: getEnv(),
53+
buyerCountry: getBuyerCountry() || "US",
54+
currency: getCurrency(),
55+
},
56+
sessionState,
57+
});
58+
59+
return {
60+
getRecommendedPaymentMethods: (payload) =>
61+
shopperSession.getRecommendedPaymentMethods(payload),
62+
};
63+
},
64+
};

0 commit comments

Comments
 (0)