@fat-zebra/sdk 1.0.5 → 1.0.6

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.
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import useFatZebra from "./useFatZebra";
3
+ import * as env from "../shared/env";
3
4
  const Frame = ({ username, handlers, config }) => {
4
5
  const bridgeRef = React.useRef(null);
5
6
  const { url } = useFatZebra({
@@ -10,6 +11,6 @@ const Frame = ({ username, handlers, config }) => {
10
11
  });
11
12
  return (React.createElement("div", null,
12
13
  React.createElement("iframe", { src: url, width: "100%", height: "700px", title: "verification-form" }),
13
- React.createElement("iframe", { title: "bridge-form", src: "http://paynow.test:3004/sdk/bridge", width: "100%", height: "700px", ref: bridgeRef })));
14
+ React.createElement("iframe", { title: "bridge-form", src: env.bridgeUrl, width: "100%", height: "700px", ref: bridgeRef })));
14
15
  };
15
16
  export default Frame;
@@ -5,11 +5,6 @@ type RequiredURLValues = {
5
5
  amount: number;
6
6
  currency: string;
7
7
  };
8
- type VerificationURLValues = OptionalURLValues & {
9
- merchant: string;
10
- timestamp: string;
11
- verification: string;
12
- };
13
8
  type OptionalURLValues = Partial<{
14
9
  hide_card_holder: string;
15
10
  return_path: string;
@@ -22,5 +17,4 @@ type OptionalURLValues = Partial<{
22
17
  }>;
23
18
  type UrlValues = RequiredURLValues & OptionalURLValues;
24
19
  declare const generatePaymentURL: (values: UrlValues) => string;
25
- declare const generateVerificationURL: (values: VerificationURLValues) => string;
26
- export { generatePaymentURL, generateVerificationURL };
20
+ export { generatePaymentURL };
package/dist/react/url.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { parseTemplate } from 'url-template';
2
+ import * as env from "../shared/env";
2
3
  const generatePaymentURL = (values) => {
3
4
  const queryParts = [
4
5
  "tokenize_only",
@@ -12,7 +13,7 @@ const generatePaymentURL = (values) => {
12
13
  "surcharge_enabled",
13
14
  "sca_enabled",
14
15
  ];
15
- const urlTemplate = parseTemplate(`http://paynow.test:3004/sdk/v3/{merchant}/{reference}/{currency}/{amount}/{verification}{?${queryParts.join(",")}}`);
16
+ const urlTemplate = parseTemplate(`${env.payNowUrl}/sdk/v3/{merchant}/{reference}/{currency}/{amount}/{verification}{?${queryParts.join(",")}}`);
16
17
  const url = urlTemplate.expand({
17
18
  merchant: values.merchant,
18
19
  reference: values.reference,
@@ -28,31 +29,4 @@ const generatePaymentURL = (values) => {
28
29
  });
29
30
  return url;
30
31
  };
31
- const generateVerificationURL = (values) => {
32
- const queryParts = [
33
- "tokenize_only",
34
- "css",
35
- "css_signature",
36
- "iframe",
37
- "postmessage",
38
- "hide_card_holder",
39
- "return_path",
40
- "card_types",
41
- "surcharge_enabled",
42
- "sca_enabled",
43
- ];
44
- const urlTemplate = parseTemplate(`http://paynow.test:3004/sdk/v3/{merchant}/verification/{timestamp}/{verification}{?${queryParts.join(",")}}`);
45
- const url = urlTemplate.expand({
46
- merchant: values.merchant,
47
- timestamp: values.timestamp,
48
- verification: values.verification,
49
- sca_enabled: values.sca_enabled,
50
- css: values.css,
51
- css_signature: values.css_signature,
52
- iframe: true,
53
- postmessage: true,
54
- tokenize_only: values.tokenize_only,
55
- });
56
- return url;
57
- };
58
- export { generatePaymentURL, generateVerificationURL };
32
+ export { generatePaymentURL };
package/dist/sca/index.js CHANGED
@@ -13,6 +13,7 @@ import { PublicEvent, } from '../shared/types';
13
13
  import { CardinalManager, } from './cardinal';
14
14
  import { emit, } from '../shared/event-manager';
15
15
  import { toFzSli } from './eci-mappings';
16
+ import * as env from "../shared/env";
16
17
  class Sca {
17
18
  constructor({ gatewayClient }) {
18
19
  this._eventEmitTarget = window;
@@ -22,10 +23,11 @@ class Sca {
22
23
  }
23
24
  loadScript() {
24
25
  if (!document.getElementById("songbird-script")) {
26
+ console.log(env);
25
27
  const script = document.createElement('script');
26
28
  script.type = 'text/javascript';
27
29
  script.id = "songbird-script";
28
- script.src = process.env.SONGBIRD_URL;
30
+ script.src = env.songbirdUrl;
29
31
  script.async = true;
30
32
  script.onload = () => {
31
33
  this._cardinal = new CardinalManager();
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { RequestHeaderSdkVersion, RequestHeaderMerchantUsername, RequestTimeout, } from "./constants";
11
11
  import axios from "axios";
12
12
  import { getSdkVersionNumber } from "./util";
13
- const baseUrl = process.env.API_GATEWAY_URL;
13
+ import * as env from "../shared/env";
14
14
  class GatewayClient {
15
15
  constructor({ accessToken, username }) {
16
16
  const headers = {};
@@ -18,7 +18,7 @@ class GatewayClient {
18
18
  headers[RequestHeaderSdkVersion] = getSdkVersionNumber();
19
19
  headers[RequestHeaderMerchantUsername] = username;
20
20
  this.client = axios.create({
21
- baseURL: baseUrl,
21
+ baseURL: env.apiUrl,
22
22
  timeout: RequestTimeout,
23
23
  headers,
24
24
  responseType: "json",
@@ -0,0 +1,5 @@
1
+ declare const bridgeUrl = "http://paynow.test";
2
+ declare const apiUrl = "http://api.test:3002/sdk";
3
+ declare const payNowUrl = "http://paynow.test";
4
+ declare const songbirdUrl = "https://songbirdstag.cardinalcommerce.com/edge/v1/songbird.js";
5
+ export { bridgeUrl, apiUrl, payNowUrl, songbirdUrl };
@@ -0,0 +1,5 @@
1
+ const bridgeUrl = "http://paynow.test";
2
+ const apiUrl = "http://api.test:3002/sdk";
3
+ const payNowUrl = "http://paynow.test";
4
+ const songbirdUrl = "https://songbirdstag.cardinalcommerce.com/edge/v1/songbird.js";
5
+ export { bridgeUrl, apiUrl, payNowUrl, songbirdUrl };
@@ -8,7 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { NODE_ENV } from '../shared/types';
11
- const domain = process.env.PAYNOW_BASE_URL;
11
+ import * as env from "./env";
12
+ const domain = env.payNowUrl;
12
13
  // NODE_ENV is introduced to PostMessageClient purely for the purpose of bypassing security
13
14
  // check on the postMessage event between parent and child frames. Unforunately there is
14
15
  // no workaround to override event origin due to lack of support in existing test framework.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@fat-zebra/sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "private": false,
8
-
9
8
  "scripts": {
9
+ "prepare": "tsc",
10
10
  "test": "jest --clearCache && jest --passWithNoTests --verbose"
11
11
  },
12
12
  "author": "",
@@ -15,6 +15,8 @@
15
15
  "@types/jest": "^29.5.3",
16
16
  "@types/react": "^18.2.15",
17
17
  "@types/react-dom": "^18.2.7",
18
+ "dotenv": "^16.3.1",
19
+ "esbuild": "^0.18.13",
18
20
  "jest": "^29.6.1",
19
21
  "jest-environment-jsdom": "^29.6.1",
20
22
  "jest-localstorage-mock": "^2.4.26",
Binary file
Binary file