File tree 6 files changed +782
-270
lines changed
6 files changed +782
-270
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
+ export * from "./api" ;
3
4
export * from "./errors" ;
4
5
export * from "./isRTLLanguage" ;
5
6
export * from "./security" ;
Original file line number Diff line number Diff line change
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
+ } ;
You can’t perform that action at this time.
0 commit comments