@fat-zebra/sdk 1.4.11 → 1.4.12
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/clicktopay/index.d.ts +1 -0
- package/dist/clicktopay/index.js +50 -0
- package/dist/local/fatzebra.js.map +1 -0
- package/dist/local/index.html +247 -0
- package/dist/production/fatzebra.js.LICENSE.txt +1 -0
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/react/submitForm.d.ts +2 -0
- package/dist/react/submitForm.js +10 -0
- package/dist/react/url.js +3 -0
- package/dist/sandbox/fatzebra.js.LICENSE.txt +1 -0
- package/dist/sca/index.js +1 -3
- package/dist/shared/types.d.ts +2 -1
- package/package.json +1 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as bridge from '../shared/bridge-client';
|
|
2
|
+
import { PostMessageClient } from "../shared/post-message-client";
|
|
3
|
+
class ClickToPay {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.paymentIntent = config.paymentIntent;
|
|
6
|
+
this.customer = config.customer;
|
|
7
|
+
this.username = config.username;
|
|
8
|
+
this.postMessageClient = new PostMessageClient({
|
|
9
|
+
channel: 'sca',
|
|
10
|
+
target: this.iframe
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
load(config) {
|
|
14
|
+
this.clickToPayOptions = config.options;
|
|
15
|
+
this.headless = bridge.load(process.env.PAYNOW_BRIDGE_URL);
|
|
16
|
+
this.iframe = document.createElement('iframe');
|
|
17
|
+
document.getElementById(config.containerId).appendChild(this.iframe);
|
|
18
|
+
this.headless.onload = () => {
|
|
19
|
+
this.iframe.onload = () => {
|
|
20
|
+
// this.setCrossFramesEventListeners()
|
|
21
|
+
// this.setPublicEventListeners()
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const payNowUrl = this.getPayNowUrl(config.options);
|
|
25
|
+
this.iframe.setAttribute("src", payNowUrl);
|
|
26
|
+
}
|
|
27
|
+
getPayNowUrl(options) {
|
|
28
|
+
const { payment } = this.paymentIntent;
|
|
29
|
+
const base = [
|
|
30
|
+
process.env.PAYNOW_BASE_URL,
|
|
31
|
+
'sdk',
|
|
32
|
+
this.version == 3 ? 'v3' : null,
|
|
33
|
+
this.username,
|
|
34
|
+
payment.reference,
|
|
35
|
+
payment.currency,
|
|
36
|
+
payment.amount,
|
|
37
|
+
this.paymentIntent.verification
|
|
38
|
+
].filter(part => part).join('/');
|
|
39
|
+
let queryString;
|
|
40
|
+
if (options) {
|
|
41
|
+
const _options = Object.assign(Object.assign({}, HPP_DEFAULT_OPTIONS), options);
|
|
42
|
+
queryString = Object.keys(_options).map(key => util.toSnakeCase(key) + '=' + _options[key]).join('&');
|
|
43
|
+
}
|
|
44
|
+
let searchParams = new URLSearchParams(queryString);
|
|
45
|
+
if (payment.hide_card_holder) {
|
|
46
|
+
searchParams.append('hide_card_holder', 'true');
|
|
47
|
+
}
|
|
48
|
+
return queryString ? `${base}?${searchParams.toString()}` : `${base}`;
|
|
49
|
+
}
|
|
50
|
+
}
|