@fat-zebra/sdk 1.4.6 → 1.4.7

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/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import "ts-polyfill";
2
2
  import "custom-event-polyfill";
3
3
  import { type PaymentIntent, type Payment, PublicEvent, type PaymentConfig, type Handlers } from "./shared/types";
4
+ import { Environment } from "./shared/env";
4
5
  export type { PaymentIntent, Payment, PaymentConfig, Handlers };
5
- export { PublicEvent };
6
+ export { PublicEvent, Environment };
package/dist/index.js CHANGED
@@ -2,7 +2,8 @@ import "ts-polyfill";
2
2
  import "custom-event-polyfill";
3
3
  import { FatZebra } from "./main";
4
4
  import { PublicEvent } from "./shared/types";
5
- export { PublicEvent };
5
+ import { Environment } from "./shared/env";
6
+ export { PublicEvent, Environment };
6
7
  if (typeof window !== "undefined") {
7
8
  window.FatZebra = FatZebra;
8
9
  }
@@ -1,8 +1,9 @@
1
- import React from "react";
1
+ import React, { HTMLProps } from "react";
2
2
  import * as FatZebra from "../shared/types";
3
3
  type FrameProps = {
4
4
  handlers: FatZebra.Handlers;
5
5
  config: FatZebra.PaymentConfig;
6
+ iframeProps?: HTMLProps<HTMLIFrameElement>;
6
7
  };
7
- declare const Frame: ({ handlers, config }: FrameProps) => React.JSX.Element;
8
+ declare const Frame: ({ handlers, config, iframeProps }: FrameProps) => React.JSX.Element;
8
9
  export default Frame;
@@ -1,16 +1,11 @@
1
1
  import React from "react";
2
2
  import useFatZebra from "./useFatZebra";
3
- import env, { Environment } from "../shared/env";
4
- const Frame = ({ handlers, config }) => {
5
- const bridgeRef = React.useRef(null);
3
+ const Frame = ({ handlers, config, iframeProps }) => {
6
4
  const { url } = useFatZebra({
7
5
  config,
8
6
  handlers: handlers,
9
7
  });
10
- console.log("config", config);
11
- const environmentConfig = env[config.environment || Environment.production];
12
8
  return (React.createElement("div", null,
13
- React.createElement("iframe", { src: url, width: "100%", height: "700px", title: "verification-form" }),
14
- React.createElement("iframe", { title: "bridge-form", src: environmentConfig.bridgeUrl, width: "100%", height: "700px", ref: bridgeRef })));
9
+ React.createElement("iframe", Object.assign({ src: url, title: "verification-form" }, iframeProps))));
15
10
  };
16
11
  export default Frame;
@@ -19,34 +19,6 @@ const useFatZebra = ({ config, handlers }) => {
19
19
  handler(new CustomEvent(event, { detail: data }));
20
20
  }
21
21
  };
22
- const handleCreatePaymentResponse = (data) => {
23
- const transactionPayload = {
24
- transactionId: data.transaction_id,
25
- responseCode: data.response_code,
26
- message: data.message,
27
- amount: data.amount,
28
- currency: data.currency,
29
- reference: data.reference,
30
- cardNumber: data.card_number,
31
- cardHolder: data.card_holder,
32
- cardExpiry: data.card_expiry,
33
- cardType: data.card_type,
34
- verification: data.v,
35
- };
36
- if (data.errors) {
37
- emit(FatZebra.PublicEvent.PAYMENT_ERROR, {
38
- message: 'Payment failed.',
39
- errors: data.errors,
40
- data: transactionPayload,
41
- });
42
- }
43
- else {
44
- emit(FatZebra.PublicEvent.PAYMENT_SUCCESS, {
45
- message: 'Payment successful.',
46
- data: transactionPayload,
47
- });
48
- }
49
- };
50
22
  const handleTokenizeCardResponse = (data) => {
51
23
  if (data.errors) {
52
24
  emit(FatZebra.PublicEvent.TOKENIZATION_ERROR, {
@@ -89,9 +61,6 @@ const useFatZebra = ({ config, handlers }) => {
89
61
  });
90
62
  return;
91
63
  }
92
- if (event.data.subject === FatZebra.BridgeEvent.CREATE_PAYMENT_RESPONSE) {
93
- handleCreatePaymentResponse(event.data.data);
94
- }
95
64
  if (event.data.subject === FatZebra.BridgeEvent.TOKENIZE_CARD_RESPONSE) {
96
65
  handleTokenizeCardResponse(event.data.data);
97
66
  }
package/dist/sca/index.js CHANGED
@@ -16,25 +16,22 @@ import { toFzSli } from './eci-mappings';
16
16
  import env, { Environment } from "../shared/env";
17
17
  class Sca {
18
18
  constructor({ gatewayClient, successCallback, failureCallback, environment }) {
19
- console.log("scaEnvironment", environment);
20
19
  this.gatewayClient = gatewayClient;
21
20
  this.successCallback = successCallback;
22
21
  this.failureCallback = failureCallback;
23
22
  this.environmentConfig = env[environment || Environment.production];
24
23
  }
25
24
  loadScript() {
26
- if (document) {
27
- if (!document.getElementById("songbird-script")) {
28
- const script = document.createElement('script');
29
- script.type = 'text/javascript';
30
- script.id = "songbird-script";
31
- script.src = this.environmentConfig.songbirdUrl;
32
- script.async = true;
33
- script.onload = () => {
34
- this._cardinal = new CardinalManager();
35
- };
36
- document.body.appendChild(script);
37
- }
25
+ if (!document.getElementById("songbird-script")) {
26
+ const script = document.createElement('script');
27
+ script.type = 'text/javascript';
28
+ script.id = "songbird-script";
29
+ script.src = this.environmentConfig.songbirdUrl;
30
+ script.async = true;
31
+ script.onload = () => {
32
+ this._cardinal = new CardinalManager();
33
+ };
34
+ document.body.appendChild(script);
38
35
  }
39
36
  }
40
37
  get cardinal() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fat-zebra/sdk",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {