@fat-zebra/sdk 1.4.14 → 1.4.15
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/hpp/hpp.js +1 -3
- package/dist/main.d.ts +0 -2
- package/dist/main.js +1 -19
- package/dist/react/useFatZebra.js +1 -3
- package/dist/sca/index.js +2 -2
- package/dist/sca/types.d.ts +2 -2
- package/dist/shared/api-gateway-client.d.ts +4 -3
- package/dist/shared/api-gateway-client.js +12 -4
- package/dist/shared/env.d.ts +4 -0
- package/dist/shared/env.js +4 -0
- package/dist/shared/post-message-client.d.ts +1 -0
- package/dist/shared/post-message-client.js +8 -13
- package/dist/shared/types.d.ts +1 -8
- package/dist/shared/types.js +1 -9
- package/dist/validation/index.d.ts +0 -1
- package/dist/validation/index.js +0 -1
- package/dist/validation/schemas/hpp-options.json +45 -93
- package/package.json +1 -1
package/dist/hpp/hpp.js
CHANGED
package/dist/main.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Customer, PaymentIntent, PaymentMethod, PublicEvent } from './shared/ty
|
|
|
2
2
|
import { HppLoadParams } from './hpp';
|
|
3
3
|
import { PayPalConfig } from './paypal/types';
|
|
4
4
|
import { ChallengeWindowSize } from './sca/types';
|
|
5
|
-
import { HppClickToPayParams } from './click_to_pay/types';
|
|
6
5
|
export interface FZConfig {
|
|
7
6
|
username: string;
|
|
8
7
|
test?: boolean;
|
|
@@ -32,7 +31,6 @@ export default class FatZebra {
|
|
|
32
31
|
cardDidTokenize(headless: HTMLIFrameElement, callback: (data: any) => void): void;
|
|
33
32
|
verifyCard(params: VerifyCardParams): Promise<void>;
|
|
34
33
|
renderPaymentsPage(params: HppLoadParams): void;
|
|
35
|
-
renderClickToPay(params: HppClickToPayParams): void;
|
|
36
34
|
checkout(): void;
|
|
37
35
|
setupPayPal(config: PayPalConfig): void;
|
|
38
36
|
on(event: PublicEvent, callback: (e: any) => void): void;
|
package/dist/main.js
CHANGED
|
@@ -13,17 +13,15 @@ import { BridgeEvent, PaymentMethodType, PublicEvent, } from './shared/types';
|
|
|
13
13
|
import { LocalStorageAccessTokenKey } from './shared/constants';
|
|
14
14
|
import { emit, on } from './shared/event-manager';
|
|
15
15
|
import * as bridge from './shared/bridge-client';
|
|
16
|
-
import { validateHppLoadParams, validateVerifyCardParams, toHumanizedErrors,
|
|
16
|
+
import { validateHppLoadParams, validateVerifyCardParams, toHumanizedErrors, } from './validation';
|
|
17
17
|
import GatewayClient from './shared/api-gateway-client';
|
|
18
18
|
import { Hpp } from './hpp';
|
|
19
19
|
import { PayPalCheckout } from './paypal/paypal-checkout';
|
|
20
|
-
import ClickToPay from './click_to_pay';
|
|
21
20
|
export default class FatZebra {
|
|
22
21
|
constructor(config) {
|
|
23
22
|
this.fzConfig = config;
|
|
24
23
|
window.MerchantUsername = config.username;
|
|
25
24
|
this.gatewayClient = new GatewayClient({
|
|
26
|
-
accessToken: window.localStorage.getItem(LocalStorageAccessTokenKey),
|
|
27
25
|
username: config.username,
|
|
28
26
|
environment: process.env.API_ENV,
|
|
29
27
|
});
|
|
@@ -122,22 +120,6 @@ export default class FatZebra {
|
|
|
122
120
|
});
|
|
123
121
|
window.HPP.load(params);
|
|
124
122
|
}
|
|
125
|
-
renderClickToPay(params) {
|
|
126
|
-
const valid = validateClickToPayLoadParams(params);
|
|
127
|
-
if (!valid) {
|
|
128
|
-
emit(PublicEvent.VALIDATION_ERROR, {
|
|
129
|
-
errors: toHumanizedErrors(validateClickToPayLoadParams.errors),
|
|
130
|
-
data: null
|
|
131
|
-
});
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
window.HPP = new ClickToPay({
|
|
135
|
-
paymentIntent: params.paymentIntent,
|
|
136
|
-
username: this.fzConfig.username,
|
|
137
|
-
test: this.fzConfig.test,
|
|
138
|
-
});
|
|
139
|
-
window.HPP.load(params);
|
|
140
|
-
}
|
|
141
123
|
checkout() {
|
|
142
124
|
window.HPP.purchase();
|
|
143
125
|
}
|
package/dist/sca/index.js
CHANGED
|
@@ -225,8 +225,8 @@ const threedsResponseData = (response) => {
|
|
|
225
225
|
sli: toFzSli(response.eci),
|
|
226
226
|
xid: response.xid,
|
|
227
227
|
ver: response.enrolled,
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
directoryServerTxnId: response.directory_server_txn_id,
|
|
229
|
+
threedsVersion: response.version,
|
|
230
230
|
};
|
|
231
231
|
};
|
|
232
232
|
const getEnrollmentResult = (enrollment) => {
|
package/dist/sca/types.d.ts
CHANGED
|
@@ -3,14 +3,15 @@ import { Environment } from "../shared/env";
|
|
|
3
3
|
import * as sca from "../sca/types";
|
|
4
4
|
import * as paypal from "../paypal/types";
|
|
5
5
|
export type GatewayClientProps = {
|
|
6
|
-
accessToken: string;
|
|
7
6
|
username: string;
|
|
8
7
|
environment?: Environment;
|
|
8
|
+
accessToken?: string;
|
|
9
9
|
};
|
|
10
10
|
declare class GatewayClient {
|
|
11
|
-
|
|
11
|
+
username: string;
|
|
12
12
|
environment?: Environment;
|
|
13
|
-
|
|
13
|
+
client: AxiosInstance;
|
|
14
|
+
constructor({ username, environment, accessToken }: GatewayClientProps);
|
|
14
15
|
/**************** SCA/3DS2 /****************/
|
|
15
16
|
createSCASession(data: sca.CreateSCASessionRequest): Promise<AxiosResponse>;
|
|
16
17
|
decodeSCASession(data: sca.DecodeSCASessionRequest): Promise<AxiosResponse>;
|
|
@@ -7,18 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { RequestHeaderSdkVersion, RequestHeaderMerchantUsername, RequestTimeout, LongRequestTimeout, } from "./constants";
|
|
10
|
+
import { RequestHeaderSdkVersion, RequestHeaderMerchantUsername, RequestTimeout, LongRequestTimeout, LocalStorageAccessTokenKey, } from "./constants";
|
|
11
11
|
import axios from "axios";
|
|
12
12
|
import { getSdkVersionNumber } from "./util";
|
|
13
13
|
import env, { Environment } from "../shared/env";
|
|
14
14
|
class GatewayClient {
|
|
15
|
-
constructor({
|
|
15
|
+
constructor({ username, environment, accessToken }) {
|
|
16
|
+
this.username = username;
|
|
16
17
|
this.environment = environment || Environment.sandbox;
|
|
17
18
|
const headers = {};
|
|
18
19
|
headers["Authorization"] = `Bearer ${accessToken}`;
|
|
19
20
|
headers[RequestHeaderSdkVersion] = getSdkVersionNumber();
|
|
20
|
-
headers[RequestHeaderMerchantUsername] = username;
|
|
21
|
-
|
|
21
|
+
headers[RequestHeaderMerchantUsername] = this.username;
|
|
22
|
+
const client = axios.create({
|
|
22
23
|
baseURL: env[this.environment].apiUrl,
|
|
23
24
|
timeout: RequestTimeout,
|
|
24
25
|
headers,
|
|
@@ -30,6 +31,13 @@ class GatewayClient {
|
|
|
30
31
|
},
|
|
31
32
|
],
|
|
32
33
|
});
|
|
34
|
+
client.interceptors.request.use(function (config) {
|
|
35
|
+
const localStorageAccessToken = window.localStorage.getItem(LocalStorageAccessTokenKey);
|
|
36
|
+
config.headers["Authorization"] = `Bearer ${accessToken || localStorageAccessToken}`;
|
|
37
|
+
// Do something before request is sent
|
|
38
|
+
return config;
|
|
39
|
+
});
|
|
40
|
+
this.client = client;
|
|
33
41
|
}
|
|
34
42
|
/**************** SCA/3DS2 /****************/
|
|
35
43
|
createSCASession(data) {
|
package/dist/shared/env.d.ts
CHANGED
|
@@ -4,12 +4,16 @@ import * as sandbox from "./envs/sandbox";
|
|
|
4
4
|
import * as production from "./envs/production";
|
|
5
5
|
export declare enum Environment {
|
|
6
6
|
local = "local",
|
|
7
|
+
test = "test",
|
|
8
|
+
development = "development",
|
|
7
9
|
staging = "staging",
|
|
8
10
|
sandbox = "sandbox",
|
|
9
11
|
production = "production"
|
|
10
12
|
}
|
|
11
13
|
declare const env: {
|
|
14
|
+
test: typeof local;
|
|
12
15
|
local: typeof local;
|
|
16
|
+
development: typeof local;
|
|
13
17
|
staging: typeof staging;
|
|
14
18
|
sandbox: typeof sandbox;
|
|
15
19
|
production: typeof production;
|
package/dist/shared/env.js
CHANGED
|
@@ -5,12 +5,16 @@ import * as production from "./envs/production";
|
|
|
5
5
|
export var Environment;
|
|
6
6
|
(function (Environment) {
|
|
7
7
|
Environment["local"] = "local";
|
|
8
|
+
Environment["test"] = "test";
|
|
9
|
+
Environment["development"] = "development";
|
|
8
10
|
Environment["staging"] = "staging";
|
|
9
11
|
Environment["sandbox"] = "sandbox";
|
|
10
12
|
Environment["production"] = "production";
|
|
11
13
|
})(Environment || (Environment = {}));
|
|
12
14
|
const env = {
|
|
15
|
+
[Environment.test]: local,
|
|
13
16
|
[Environment.local]: local,
|
|
17
|
+
[Environment.development]: local,
|
|
14
18
|
[Environment.staging]: staging,
|
|
15
19
|
[Environment.sandbox]: sandbox,
|
|
16
20
|
[Environment.production]: production,
|
|
@@ -39,6 +39,7 @@ declare class PostMessageClient {
|
|
|
39
39
|
private channel;
|
|
40
40
|
private fzEnv;
|
|
41
41
|
private target;
|
|
42
|
+
private domain;
|
|
42
43
|
constructor(config: PostMessageClientConfig);
|
|
43
44
|
setEventListeners(handlers: EventHandlers): void;
|
|
44
45
|
setEventListenersLegacy(handlers: EventHandlers): void;
|
|
@@ -7,25 +7,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
11
|
-
import env from './env';
|
|
12
|
-
const domain = process.env.PAYNOW_BASE_URL;
|
|
13
|
-
// NODE_ENV is introduced to PostMessageClient purely for the purpose of bypassing security
|
|
14
|
-
// check on the postMessage event between parent and child frames. Unforunately there is
|
|
15
|
-
// no workaround to override event origin due to lack of support in existing test framework.
|
|
10
|
+
import env, { Environment } from "./env";
|
|
16
11
|
class PostMessageClient {
|
|
17
12
|
constructor(config) {
|
|
18
13
|
this.channel = config.channel;
|
|
19
|
-
this.fzEnv = process.env.
|
|
14
|
+
this.fzEnv = process.env.API_ENV;
|
|
15
|
+
this.domain = env[this.fzEnv].payNowUrl;
|
|
20
16
|
this.target = config.target;
|
|
21
|
-
this.domain = env[this.fzEnv];
|
|
22
17
|
}
|
|
23
18
|
// Handle event messages that conform to PostMessage format.
|
|
24
19
|
setEventListeners(handlers) {
|
|
25
20
|
window.addEventListener("message", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const validationEnabled = ![
|
|
21
|
+
const validationEnabled = ![Environment.test, Environment.local, Environment.development].includes(this.fzEnv);
|
|
27
22
|
const isChannelValid = event.data.channel === this.channel;
|
|
28
|
-
const isOriginValid = event.origin === domain;
|
|
23
|
+
const isOriginValid = event.origin === this.domain;
|
|
29
24
|
if (validationEnabled && (!isOriginValid || !isChannelValid)) {
|
|
30
25
|
console.log('[WARNING] unmatched event origin or incorrect message channel');
|
|
31
26
|
return;
|
|
@@ -46,8 +41,8 @@ class PostMessageClient {
|
|
|
46
41
|
// Handle event messages that do not conform to PostMessage format.
|
|
47
42
|
setEventListenersLegacy(handlers) {
|
|
48
43
|
window.addEventListener("message", (event) => {
|
|
49
|
-
const validationEnabled = ![
|
|
50
|
-
const isOriginValid = event.origin === domain;
|
|
44
|
+
const validationEnabled = ![Environment.test, Environment.local, Environment.development].includes(this.fzEnv);
|
|
45
|
+
const isOriginValid = event.origin === this.domain;
|
|
51
46
|
if (validationEnabled && !isOriginValid) {
|
|
52
47
|
console.log('[WARNING] unmatched event origin or incorrect message channel');
|
|
53
48
|
return;
|
|
@@ -65,7 +60,7 @@ class PostMessageClient {
|
|
|
65
60
|
});
|
|
66
61
|
}
|
|
67
62
|
send(message) {
|
|
68
|
-
this.target.contentWindow.postMessage(message, domain);
|
|
63
|
+
this.target.contentWindow.postMessage(message, this.domain);
|
|
69
64
|
}
|
|
70
65
|
}
|
|
71
66
|
export { PostMessageClient, };
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { PayPalPaymentMethod } from '../paypal/types';
|
|
2
2
|
import { Environment } from './env';
|
|
3
|
-
declare enum NODE_ENV {
|
|
4
|
-
LOCALDEV = "localdev",
|
|
5
|
-
PRODUCTION = "production",
|
|
6
|
-
SANDBOX = "sandbox",
|
|
7
|
-
STAGING = "staging",
|
|
8
|
-
TEST = "test"
|
|
9
|
-
}
|
|
10
3
|
declare enum PublicEvent {
|
|
11
4
|
FORM_VALIDATION_ERROR = "fz.form_validation.error",
|
|
12
5
|
FORM_VALIDATION_SUCCESS = "fz.form_validation.success",
|
|
@@ -149,5 +142,5 @@ type TokenizeCardResponse = {
|
|
|
149
142
|
token: string;
|
|
150
143
|
errors?: Array<string>;
|
|
151
144
|
};
|
|
152
|
-
export { BridgeEvent, PublicEvent,
|
|
145
|
+
export { BridgeEvent, PublicEvent, PaymentMethodType, };
|
|
153
146
|
export type { PaymentMethod, PaymentIntent, Payment, Card, CardOnFile, CustomerSnakeCase, Customer, Handlers, ValidationResult, TokenizeCardResponse, };
|
package/dist/shared/types.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var NODE_ENV;
|
|
2
|
-
(function (NODE_ENV) {
|
|
3
|
-
NODE_ENV["LOCALDEV"] = "localdev";
|
|
4
|
-
NODE_ENV["PRODUCTION"] = "production";
|
|
5
|
-
NODE_ENV["SANDBOX"] = "sandbox";
|
|
6
|
-
NODE_ENV["STAGING"] = "staging";
|
|
7
|
-
NODE_ENV["TEST"] = "test";
|
|
8
|
-
})(NODE_ENV || (NODE_ENV = {}));
|
|
9
1
|
var PublicEvent;
|
|
10
2
|
(function (PublicEvent) {
|
|
11
3
|
PublicEvent["FORM_VALIDATION_ERROR"] = "fz.form_validation.error";
|
|
@@ -41,4 +33,4 @@ var PaymentMethodType;
|
|
|
41
33
|
PaymentMethodType["PAYPAL_ORDER"] = "paypal_order";
|
|
42
34
|
PaymentMethodType["PAYPAL_BILLING"] = "paypal_billing";
|
|
43
35
|
})(PaymentMethodType || (PaymentMethodType = {}));
|
|
44
|
-
export { BridgeEvent, PublicEvent,
|
|
36
|
+
export { BridgeEvent, PublicEvent, PaymentMethodType, };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { validateHppLoadParams } from './validators/hpp-load-params-validator';
|
|
2
|
-
export { validateClickToPayLoadParams } from './validators/click-to-pay-load-params-validator';
|
|
3
2
|
export { validateVerifyCardParams } from './validators/verify-card-params-validator';
|
|
4
3
|
export { toHumanizedErrors } from './validation-helper';
|
package/dist/validation/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { validateHppLoadParams } from './validators/hpp-load-params-validator';
|
|
2
|
-
export { validateClickToPayLoadParams } from './validators/click-to-pay-load-params-validator';
|
|
3
2
|
export { validateVerifyCardParams } from './validators/verify-card-params-validator';
|
|
4
3
|
export { toHumanizedErrors } from './validation-helper';
|
|
@@ -1,96 +1,48 @@
|
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$id": "https://www.fatzebra.com/schemas/hpp-options.json",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"HppOptions": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"buttonText": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"cards": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"challengeWindowSize": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": ["01", "02", "03", "04", "05"]
|
|
17
|
+
},
|
|
18
|
+
"css": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
},
|
|
21
|
+
"cssSignature": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"enableSca": {
|
|
25
|
+
"type": "boolean"
|
|
26
|
+
},
|
|
27
|
+
"hideButton": {
|
|
28
|
+
"type": "boolean"
|
|
29
|
+
},
|
|
30
|
+
"hideLogos": {
|
|
31
|
+
"type": "boolean"
|
|
32
|
+
},
|
|
33
|
+
"logoUrl": {
|
|
34
|
+
"type": "string"
|
|
35
|
+
},
|
|
36
|
+
"showEmail": {
|
|
37
|
+
"type": "boolean"
|
|
38
|
+
},
|
|
39
|
+
"showExtras": {
|
|
40
|
+
"type": "boolean"
|
|
41
|
+
},
|
|
42
|
+
"tokenizeOnly": {
|
|
43
|
+
"type": "boolean"
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
"$id": "https://www.fatzebra.com/schemas/hpp-options.json",
|
|
51
|
-
"type": "object",
|
|
52
|
-
"definitions": {
|
|
53
|
-
"HppOptions": {
|
|
54
|
-
"type": "object",
|
|
55
|
-
"properties": {
|
|
56
|
-
"buttonText": {
|
|
57
|
-
"type": "string"
|
|
58
|
-
},
|
|
59
|
-
"cards": {
|
|
60
|
-
"type": "string"
|
|
61
|
-
},
|
|
62
|
-
"challengeWindowSize": {
|
|
63
|
-
"type": "string",
|
|
64
|
-
"enum": ["01", "02", "03", "04", "05"]
|
|
65
|
-
},
|
|
66
|
-
"css": {
|
|
67
|
-
"type": "string"
|
|
68
|
-
},
|
|
69
|
-
"cssSignature": {
|
|
70
|
-
"type": "string"
|
|
71
|
-
},
|
|
72
|
-
"enableSca": {
|
|
73
|
-
"type": "boolean"
|
|
74
|
-
},
|
|
75
|
-
"hideButton": {
|
|
76
|
-
"type": "boolean"
|
|
77
|
-
},
|
|
78
|
-
"hideLogos": {
|
|
79
|
-
"type": "boolean"
|
|
80
|
-
},
|
|
81
|
-
"logoUrl": {
|
|
82
|
-
"type": "string"
|
|
83
|
-
},
|
|
84
|
-
"showEmail": {
|
|
85
|
-
"type": "boolean"
|
|
86
|
-
},
|
|
87
|
-
"showExtras": {
|
|
88
|
-
"type": "boolean"
|
|
89
|
-
},
|
|
90
|
-
"tokenizeOnly": {
|
|
91
|
-
"type": "boolean"
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}]
|
|
47
|
+
}
|
|
48
|
+
}
|