-
Notifications
You must be signed in to change notification settings - Fork 576
/
Copy pathinterface.js
54 lines (49 loc) · 1.55 KB
/
interface.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* @flow */
import {
getEnv,
getLogger,
getPayPalAPIDomain,
getSDKToken,
getClientID,
} from "@paypal/sdk-client/src";
import { destroy as zoidDestroy } from "@krakenjs/zoid/src";
import { devEnvOnlyExport } from "../lib";
import type { LazyExport } from "../types";
import {
ThreeDomainSecureComponent,
type ThreeDomainSecureComponentInterface,
} from "./component";
import { GraphQLClient, RestClient } from "./api";
import { getThreeDS } from "./utils";
const BRAINTREE_PROD = "https://payments.braintree-api.com";
const BRAINTREE_SANDBOX = "https://payments.sandbox.braintree-api.com";
export function setup() {
getThreeDS();
}
export function destroy(err?: mixed) {
zoidDestroy(err);
}
export const ThreeDomainSecureClient: LazyExport<ThreeDomainSecureComponentInterface> =
{
__get__: () => {
const threeDomainSecureInstance = new ThreeDomainSecureComponent({
logger: getLogger(),
restClient: new RestClient({ accessToken: getSDKToken() }),
graphQLClient: new GraphQLClient({
baseURL:
getEnv() === "production" ? BRAINTREE_PROD : BRAINTREE_SANDBOX,
accessToken: getSDKToken(),
}),
// $FlowIssue ZalgoPromise vs Promise
sdkConfig: {
authenticationToken: getSDKToken(),
paypalApiDomain: getPayPalAPIDomain(),
clientID: getClientID(),
},
});
return devEnvOnlyExport({
isEligible: (payload) => threeDomainSecureInstance.isEligible(payload),
show: () => threeDomainSecureInstance.show(),
});
},
};