@paystack/inline-js 2.23.0-dev.2 → 2.23.0-dev.4
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/README.md +36 -0
- package/dist/inline.js +147 -401
- package/es/inline.js +147 -401
- package/lib/inline.js +147 -401
- package/package.json +11 -2
package/es/inline.js
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
function _arrayLikeToArray(r, a) {
|
|
2
2
|
(null == a || a > r.length) && (a = r.length);
|
|
3
|
-
|
|
4
3
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
5
|
-
|
|
6
4
|
return n;
|
|
7
5
|
}
|
|
8
|
-
|
|
9
6
|
function _arrayWithHoles(r) {
|
|
10
7
|
if (Array.isArray(r)) return r;
|
|
11
8
|
}
|
|
12
|
-
|
|
13
9
|
function _arrayWithoutHoles(r) {
|
|
14
10
|
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
15
11
|
}
|
|
16
|
-
|
|
17
12
|
function _classCallCheck(a, n) {
|
|
18
13
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
function _defineProperties(e, r) {
|
|
22
16
|
for (var t = 0; t < r.length; t++) {
|
|
23
17
|
var o = r[t];
|
|
24
18
|
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _createClass(e, r, t) {
|
|
29
22
|
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
30
23
|
writable: !1
|
|
31
24
|
}), e;
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
function _defineProperty(e, r, t) {
|
|
35
27
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
36
28
|
value: t,
|
|
@@ -39,23 +31,19 @@ function _defineProperty(e, r, t) {
|
|
|
39
31
|
writable: !0
|
|
40
32
|
}) : e[r] = t, e;
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
function _iterableToArray(r) {
|
|
44
35
|
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
function _iterableToArrayLimit(r, l) {
|
|
48
38
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
49
|
-
|
|
50
39
|
if (null != t) {
|
|
51
40
|
var e,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
n,
|
|
42
|
+
i,
|
|
43
|
+
u,
|
|
44
|
+
a = [],
|
|
45
|
+
f = !0,
|
|
46
|
+
o = !1;
|
|
59
47
|
try {
|
|
60
48
|
if (i = (t = t.call(r)).next, 0 === l) {
|
|
61
49
|
if (Object(t) !== t) return;
|
|
@@ -70,32 +58,25 @@ function _iterableToArrayLimit(r, l) {
|
|
|
70
58
|
if (o) throw n;
|
|
71
59
|
}
|
|
72
60
|
}
|
|
73
|
-
|
|
74
61
|
return a;
|
|
75
62
|
}
|
|
76
63
|
}
|
|
77
|
-
|
|
78
64
|
function _nonIterableRest() {
|
|
79
65
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
80
66
|
}
|
|
81
|
-
|
|
82
67
|
function _nonIterableSpread() {
|
|
83
68
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
84
69
|
}
|
|
85
|
-
|
|
86
70
|
function ownKeys(e, r) {
|
|
87
71
|
var t = Object.keys(e);
|
|
88
|
-
|
|
89
72
|
if (Object.getOwnPropertySymbols) {
|
|
90
73
|
var o = Object.getOwnPropertySymbols(e);
|
|
91
74
|
r && (o = o.filter(function (r) {
|
|
92
75
|
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
93
76
|
})), t.push.apply(t, o);
|
|
94
77
|
}
|
|
95
|
-
|
|
96
78
|
return t;
|
|
97
79
|
}
|
|
98
|
-
|
|
99
80
|
function _objectSpread2(e) {
|
|
100
81
|
for (var r = 1; r < arguments.length; r++) {
|
|
101
82
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
@@ -105,65 +86,48 @@ function _objectSpread2(e) {
|
|
|
105
86
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
106
87
|
});
|
|
107
88
|
}
|
|
108
|
-
|
|
109
89
|
return e;
|
|
110
90
|
}
|
|
111
|
-
|
|
112
91
|
function _objectWithoutProperties(e, t) {
|
|
113
92
|
if (null == e) return {};
|
|
114
|
-
|
|
115
93
|
var o,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
94
|
+
r,
|
|
95
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
119
96
|
if (Object.getOwnPropertySymbols) {
|
|
120
97
|
var n = Object.getOwnPropertySymbols(e);
|
|
121
|
-
|
|
122
98
|
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
123
99
|
}
|
|
124
|
-
|
|
125
100
|
return i;
|
|
126
101
|
}
|
|
127
|
-
|
|
128
102
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
129
103
|
if (null == r) return {};
|
|
130
104
|
var t = {};
|
|
131
|
-
|
|
132
105
|
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
133
106
|
if (-1 !== e.indexOf(n)) continue;
|
|
134
107
|
t[n] = r[n];
|
|
135
108
|
}
|
|
136
|
-
|
|
137
109
|
return t;
|
|
138
110
|
}
|
|
139
|
-
|
|
140
111
|
function _slicedToArray(r, e) {
|
|
141
112
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
142
113
|
}
|
|
143
|
-
|
|
144
114
|
function _toConsumableArray(r) {
|
|
145
115
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
146
116
|
}
|
|
147
|
-
|
|
148
117
|
function _toPrimitive(t, r) {
|
|
149
118
|
if ("object" != typeof t || !t) return t;
|
|
150
119
|
var e = t[Symbol.toPrimitive];
|
|
151
|
-
|
|
152
120
|
if (void 0 !== e) {
|
|
153
121
|
var i = e.call(t, r || "default");
|
|
154
122
|
if ("object" != typeof i) return i;
|
|
155
123
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
156
124
|
}
|
|
157
|
-
|
|
158
125
|
return ("string" === r ? String : Number)(t);
|
|
159
126
|
}
|
|
160
|
-
|
|
161
127
|
function _toPropertyKey(t) {
|
|
162
128
|
var i = _toPrimitive(t, "string");
|
|
163
|
-
|
|
164
129
|
return "symbol" == typeof i ? i : i + "";
|
|
165
130
|
}
|
|
166
|
-
|
|
167
131
|
function _typeof(o) {
|
|
168
132
|
"@babel/helpers - typeof";
|
|
169
133
|
|
|
@@ -173,7 +137,6 @@ function _typeof(o) {
|
|
|
173
137
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
174
138
|
}, _typeof(o);
|
|
175
139
|
}
|
|
176
|
-
|
|
177
140
|
function _unsupportedIterableToArray(r, a) {
|
|
178
141
|
if (r) {
|
|
179
142
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
@@ -219,18 +182,16 @@ var configurations = {
|
|
|
219
182
|
staging: stagingConfig,
|
|
220
183
|
production: productionConfig
|
|
221
184
|
};
|
|
222
|
-
/* eslint-disable */
|
|
223
185
|
|
|
186
|
+
/* eslint-disable */
|
|
224
187
|
var config = configurations['staging'] || stagingConfig;
|
|
225
188
|
|
|
226
189
|
function randomId() {
|
|
227
190
|
var text = '';
|
|
228
191
|
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
229
|
-
|
|
230
192
|
for (var i = 0; i < 5; i += 1) {
|
|
231
193
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
232
194
|
}
|
|
233
|
-
|
|
234
195
|
return text;
|
|
235
196
|
}
|
|
236
197
|
|
|
@@ -264,15 +225,12 @@ function getLastScript() {
|
|
|
264
225
|
var scripts = document.getElementsByTagName('script');
|
|
265
226
|
return scripts[scripts.length - 1];
|
|
266
227
|
}
|
|
267
|
-
|
|
268
228
|
function getSourceScript() {
|
|
269
229
|
return document.currentScript || getLastScript();
|
|
270
230
|
}
|
|
271
|
-
|
|
272
231
|
function getDataAttributes() {
|
|
273
232
|
var dataAttributes = [];
|
|
274
233
|
var sourceScript = getSourceScript();
|
|
275
|
-
|
|
276
234
|
if (sourceScript) {
|
|
277
235
|
var attributes = Array.prototype.slice.call(sourceScript.attributes);
|
|
278
236
|
dataAttributes = Object.keys(attributes).filter(function (key) {
|
|
@@ -282,10 +240,8 @@ function getDataAttributes() {
|
|
|
282
240
|
return attributes[index].nodeName;
|
|
283
241
|
});
|
|
284
242
|
}
|
|
285
|
-
|
|
286
243
|
return dataAttributes;
|
|
287
244
|
}
|
|
288
|
-
|
|
289
245
|
function scriptCanUseDataAttributes() {
|
|
290
246
|
var hasDataAttributes = getDataAttributes().length > 0;
|
|
291
247
|
var hasParentForm = getSourceScript() && getSourceScript().parentElement.tagName === 'FORM';
|
|
@@ -297,30 +253,23 @@ function getDataAttributesAsParameters() {
|
|
|
297
253
|
return g[1].toUpperCase();
|
|
298
254
|
});
|
|
299
255
|
}
|
|
300
|
-
|
|
301
256
|
function validateLazyParameters(parameters) {
|
|
302
257
|
if (parameters.buttonId && !document.getElementById(parameters.buttonId)) {
|
|
303
258
|
throw new Error('Please make sure the buttonId is an element available in the DOM');
|
|
304
259
|
}
|
|
305
|
-
|
|
306
260
|
var updatedParameters = _objectSpread2({}, parameters);
|
|
307
|
-
|
|
308
261
|
updatedParameters.buttonText = parameters.buttonText || 'Pay';
|
|
309
262
|
updatedParameters.buttonVariant = 'normal';
|
|
310
263
|
updatedParameters.buttonWordmarkVariant = 'normal';
|
|
311
264
|
var allowedVariants = ['normal', 'light'];
|
|
312
|
-
|
|
313
265
|
if (parameters.buttonVariant && allowedVariants.indexOf(parameters.buttonVariant) > -1) {
|
|
314
266
|
updatedParameters.buttonVariant = parameters.buttonVariant;
|
|
315
267
|
}
|
|
316
|
-
|
|
317
268
|
if (parameters.buttonWordmarkVariant && allowedVariants.indexOf(parameters.buttonWordmarkVariant) > -1) {
|
|
318
269
|
updatedParameters.buttonWordmarkVariant = parameters.buttonWordmarkVariant;
|
|
319
270
|
}
|
|
320
|
-
|
|
321
271
|
return updatedParameters;
|
|
322
272
|
}
|
|
323
|
-
|
|
324
273
|
var parameters = {};
|
|
325
274
|
var sourceScript = getSourceScript();
|
|
326
275
|
var dataAttributes = getDataAttributes();
|
|
@@ -345,7 +294,6 @@ var loaderHTML = "\n <!DOCTYPE html>\n <html lang=\"en\">\n\n <head>\n <me
|
|
|
345
294
|
var backgroundCSS = "\n z-index: 999999999999999;\n background: transparent;\n background: rgba(0, 0, 0, 0.75); \n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n margin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n transition: opacity 0.3s;\n -webkit-transition: opacity 0.3s;\n visibility: hidden;\n display: none;\n";
|
|
346
295
|
var checkoutCSS = "\n z-index: 999999999999999;\n background: transparent;\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n margin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n visibility: hidden;\n display: none;\n height: 100%;\n";
|
|
347
296
|
var embedCSS = "\n background: transparent;\n background: rgba(0,0,0,0);\n border: 0px none transparent;\n overflow-x: hidden;\n overflow-y: hidden;\n nmargin: 0;\n padding: 0;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n visibility: hidden;\n display: none;\n";
|
|
348
|
-
|
|
349
297
|
function generateInlineButtonCSS(variant) {
|
|
350
298
|
var baseCSS = "\n box-sizing: border-box;\n display: inline-block;\n line-height: 1;\n white-space: nowrap;\n margin: 0 0 10px;\n text-align: center;\n -webkit-appearance: none;\n outline: none;\n font-size: 14px;\n font-weight: 600;\n border-radius: 6px;\n cursor: pointer;\n padding: 16px 24px;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.15);\n transition: all .3s ease;\n border: none;\n min-width: 190px;\n ";
|
|
351
299
|
var greenCSS = "\n background: linear-gradient(180deg,#44b669 0,#40ad57);\n text-shadow: 1px 1px 1px rgba(0,0,0,.1);\n color: #ffffff;\n ";
|
|
@@ -356,7 +304,6 @@ function generateInlineButtonCSS(variant) {
|
|
|
356
304
|
};
|
|
357
305
|
return "".concat(baseCSS).concat(colorVariants[variant]);
|
|
358
306
|
}
|
|
359
|
-
|
|
360
307
|
function generateInlineButtonHTML(options) {
|
|
361
308
|
var wordmarkVariants = {
|
|
362
309
|
normal: secureByPaystack,
|
|
@@ -377,7 +324,6 @@ var parseApplePayCustomStyles = function parseApplePayCustomStyles(styles) {
|
|
|
377
324
|
if (!(styles && _typeof(styles) === 'object')) {
|
|
378
325
|
return defaultCustomApplePayStyles;
|
|
379
326
|
}
|
|
380
|
-
|
|
381
327
|
var customStyles = Object.keys(defaultCustomApplePayStyles).reduce(function (newDefaultStyles, key) {
|
|
382
328
|
return _objectSpread2(_objectSpread2({}, newDefaultStyles), {}, _defineProperty({}, key, styles[key] || defaultCustomApplePayStyles[key]));
|
|
383
329
|
}, {});
|
|
@@ -385,18 +331,18 @@ var parseApplePayCustomStyles = function parseApplePayCustomStyles(styles) {
|
|
|
385
331
|
};
|
|
386
332
|
var generateApplePayCSS = function generateApplePayCSS(_ref) {
|
|
387
333
|
var height = _ref.height,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
334
|
+
width = _ref.width,
|
|
335
|
+
borderRadius = _ref.borderRadius,
|
|
336
|
+
padding = _ref.padding;
|
|
391
337
|
return "\n apple-pay-button {\n --apple-pay-button-width: ".concat(width, ";\n --apple-pay-button-height: ").concat(height, ";\n --apple-pay-button-border-radius: ").concat(borderRadius, ";\n --apple-pay-button-padding: ").concat(padding, ";\n --apple-pay-button-box-sizing: border-box;\n width: ").concat(width, ";\n }\n");
|
|
392
338
|
};
|
|
393
339
|
var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
|
|
394
340
|
var height = _ref2.height,
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
341
|
+
width = _ref2.width,
|
|
342
|
+
borderRadius = _ref2.borderRadius,
|
|
343
|
+
padding = _ref2.padding,
|
|
344
|
+
type = _ref2.type,
|
|
345
|
+
locale = _ref2.locale;
|
|
400
346
|
return "\n @supports (-webkit-appearance: -apple-pay-button) { \n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n width: ".concat(width, ";\n height: ").concat(height, ";\n border-radius: ").concat(borderRadius, ";\n padding: ").concat(padding, ";\n -apple-pay-button-type: ").concat(type, ";\n -webkit-locale: ").concat(locale, ";\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n");
|
|
401
347
|
};
|
|
402
348
|
var preCheckoutModalCSS = "\n .pre-checkout-modal {\n display: none;\n position: fixed;\n z-index: 1;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100%;\n overflow: auto;\n background-color: rgba(0, 0, 0, 0.75);\n transition: all 0.2s ease;\n }\n\n .pre-checkout-modal.show {\n display: block;\n }\n\n .pre-checkout-modal__content {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n background-color: #fefefe;\n padding: 20px;\n padding-bottom: max(30px, env(safe-area-inset-bottom));\n width: 100%;\n border-radius: 6px 6px 0 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n max-width: 350px;\n\n box-sizing: border-box;\n transform: translateY(238px);\n transition: transform 0.3s cubic-bezier(.16,.81,.32,1);\n }\n\n .modal-wrapper {\n width: 100%;\n }\n\n .payment-info {\n position: relative;\n padding-bottom: 15px;\n border-bottom: solid 1px whitesmoke;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n width: 100%;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n }\n\n .customer-email {\n color: #737373;\n font-size: 13px;\n line-height: 16px;\n }\n\n .customer-info {\n flex: 1;\n text-align: right;\n }\n\n .merchant-logo {\n display: flex;\n align-items: center;\n height: 30px;\n }\n .transaction-amount {\n margin-top: 5px;\n font-size: 13px;\n line-height: 16px;\n color: #737373;\n }\n\n .amount {\n color: #29b263;\n font-weight: bold;\n }\n\n @media only screen and (min-width: 500px) {\n .pre-checkout-modal__content {\n bottom: 0;\n top: 0;\n margin: auto;\n border-radius: 6px;\n height: fit-content;\n }\n }\n\n .pre-checkout-modal__content.show {\n transform: translateY(0);\n margin: 0 auto;\n margin-top: 100px;\n }\n\n .pre-checkout-modal__content > * {\n margin-top: 0;\n margin-bottom: 40px;\n }\n .pre-checkout-modal__content > *:last-child {\n margin-bottom: 0;\n }\n\n .pre-checkout-modal__content svg {\n margin: auto;\n width: 100%;\n }\n\n #inline-button-wordmark--white {\n position: absolute;\n bottom: -50px;\n margin: auto;\n left: 0;\n right: 0;\n width: fit-content;\n }\n\n #inline-button-wordmark--grey {\n display: none;\n }\n\n .pre-checkout-modal__content #apple-pay-mark--light {\n margin-bottom: 16px;\n }\n\n .pre-checkout-modal p {\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n color: #4E4E4E;\n line-height: 140%;\n font-size: 14px;\n font-weight: 500;\n margin: 0;\n padding: 0 20px;\n text-align: center;\n letter-spacing: -0.3px;\n }\n\n .pre-checkout-modal button {\n height: 42px;\n width: 100%;\n \n box-sizing: border-box;\n border-radius: 3px;\n font-size: 14px;\n line-height: 24px;\n cursor: pointer;\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n }\n\n .pre-checkout-modal .open-paystack-pop-button {\n background: #FAFAFA;\n border: 1px solid #F2F3F3;\n color: #4E4E4E;\n font-weight: 500;\n }\n\n .pre-checkout-modal .open-paystack-pop-button:hover, \n .pre-checkout-modal .open-paystack-pop-button:active, \n .pre-checkout-modal .open-paystack-pop-button:focus {\n background: #F2F3F3;\n }\n\n .pre-checkout-modal .pay-with-vault-button {\n font-weight: 700;\n background: #44b669;\n background: linear-gradient(to bottom, #44b669 0%, #40ad57 100%);\n border: solid 1px #49a861;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n outline: none;\n color: white;\n transition: all 300ms;\n }\n\n .pre-checkout-modal .vault-instruction {\n color: #2f3d4d;\n font-size: 14px;\n letter-spacing: normal;\n line-height: 1.4;\n margin: 0 auto 24px;\n padding: 0;\n }\n .vault-logo-container {\n width: 74px;\n height: 20px;\n margin: 0 auto 24px\n }\n .vault-logo-container img {\n height: 100%;\n width: 100%;\n border-radius: 8px;\n }\n .vault-divider {\n margin-bottom: 16px;\n margin-top: 24px;\n position: relative;\n }\n .vault-divider__container {\n align-items: center;\n bottom: 0;\n display: flex;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n }\n .vault-divider__line {\n border: 1px dashed #ccced0;\n width: 100%;\n }\n .vault-divider__text-container {\n display: flex;\n justify-content: center;\n position: relative;\n }\n .vault-divider__text {\n background-color: #fff;\n color: #999da1;\n font-size: 14px;\n font-weight: 500;\n letter-spacing: -.3px;\n line-height: 19.6px;\n margin-bottom: 2px;\n padding: 0 8px;\n }\n\n #payment-request-button {\n width: 100%;\n height: fit-content;\n margin: 24px 0 16px 0;\n }\n\n #paystackpop-button {\n padding: 0 16px;\n }\n\n #apple-pay-close-button {\n position: absolute;\n text-align: center;\n top: 0;\n right: -26px;\n height: 16px;\n width: 16px;\n padding: 0;\n display: inline-block;\n z-index: 3;\n border-radius: 50%;\n background: transparent;\n transition: all 300ms;\n outline: none;\n cursor: pointer;\n border: none;\n }\n\n #apple-pay-close-button svg {\n width: initial;\n }\n \n #apple-pay-close-button:hover {\n background-color: #e22b28;\n }\n\n @media only screen and (max-width: 500px) {\n .pre-checkout-modal__content {\n max-width: 500px;\n border-radius: 0;\n padding-bottom: 0;\n }\n\n .modal-wrapper {\n padding: 0;\n }\n\n .vault-logo-container {\n width: 74px;\n height: 20px;\n }\n\n #inline-button-wordmark--white {\n display: none\n }\n \n #inline-button-wordmark--grey {\n display: block;\n width: 100%;\n margin: 16px 0;\n height: 13px;\n }\n\n #apple-pay-close-button {\n display: none;\n }\n }\n";
|
|
@@ -436,7 +382,6 @@ var APPLE_PAY_CAPABILITY_STATUS = {
|
|
|
436
382
|
UNKNOWN: 'paymentCredentialStatusUnknown',
|
|
437
383
|
UNSUPPORTED: 'applePayUnsupported'
|
|
438
384
|
};
|
|
439
|
-
|
|
440
385
|
var formatIntervalString = function formatIntervalString(interval) {
|
|
441
386
|
var plans = {
|
|
442
387
|
biannually: 'BIANNUAL PLAN',
|
|
@@ -444,12 +389,11 @@ var formatIntervalString = function formatIntervalString(interval) {
|
|
|
444
389
|
};
|
|
445
390
|
return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
|
|
446
391
|
};
|
|
447
|
-
|
|
448
392
|
var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
|
|
449
393
|
var currency = _ref.currency,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
394
|
+
amount = _ref.amount,
|
|
395
|
+
merchantName = _ref.merchantName,
|
|
396
|
+
interval = _ref.interval;
|
|
453
397
|
return _objectSpread2({
|
|
454
398
|
countryCode: 'NG',
|
|
455
399
|
currencyCode: currency,
|
|
@@ -470,10 +414,10 @@ var generateApplePaymentRequestObject = function generateApplePaymentRequestObje
|
|
|
470
414
|
};
|
|
471
415
|
var validateApplePaySession = function validateApplePaySession(_ref2) {
|
|
472
416
|
var transactionId = _ref2.transactionId,
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
417
|
+
validationURL = _ref2.validationURL,
|
|
418
|
+
merchantName = _ref2.merchantName,
|
|
419
|
+
_ref2$domainName = _ref2.domainName,
|
|
420
|
+
domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
|
|
477
421
|
var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
|
|
478
422
|
var params = {
|
|
479
423
|
transaction: transactionId,
|
|
@@ -491,7 +435,7 @@ var validateApplePaySession = function validateApplePaySession(_ref2) {
|
|
|
491
435
|
};
|
|
492
436
|
var chargeApplePay = function chargeApplePay(_ref3) {
|
|
493
437
|
var transactionId = _ref3.transactionId,
|
|
494
|
-
|
|
438
|
+
payment = _ref3.payment;
|
|
495
439
|
var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
|
|
496
440
|
var params = {
|
|
497
441
|
transaction: transactionId,
|
|
@@ -512,32 +456,25 @@ var deviceSupportsApplePay = function deviceSupportsApplePay() {
|
|
|
512
456
|
return false;
|
|
513
457
|
}
|
|
514
458
|
};
|
|
515
|
-
|
|
516
459
|
var getApplePayCapabilityStatusFromResponse = function getApplePayCapabilityStatusFromResponse(capabilities) {
|
|
517
460
|
if (!capabilities) {
|
|
518
461
|
return null;
|
|
519
462
|
}
|
|
520
|
-
|
|
521
463
|
if (typeof capabilities === 'string') {
|
|
522
464
|
return capabilities;
|
|
523
465
|
}
|
|
524
|
-
|
|
525
466
|
if (typeof capabilities.paymentCredentialStatus === 'string') {
|
|
526
467
|
return capabilities.paymentCredentialStatus;
|
|
527
468
|
}
|
|
528
|
-
|
|
529
469
|
return null;
|
|
530
470
|
};
|
|
531
|
-
|
|
532
471
|
var getApplePayCapabilityStatus = function getApplePayCapabilityStatus() {
|
|
533
472
|
try {
|
|
534
473
|
if (!deviceSupportsApplePay()) {
|
|
535
474
|
return Promise.resolve(null);
|
|
536
475
|
}
|
|
537
|
-
|
|
538
476
|
var _window = window,
|
|
539
|
-
|
|
540
|
-
|
|
477
|
+
ApplePaySession = _window.ApplePaySession;
|
|
541
478
|
if (typeof ApplePaySession.applePayCapabilities === 'function') {
|
|
542
479
|
return Promise.resolve(ApplePaySession.applePayCapabilities()).then(function (capabilities) {
|
|
543
480
|
return getApplePayCapabilityStatusFromResponse(capabilities);
|
|
@@ -549,17 +486,14 @@ var getApplePayCapabilityStatus = function getApplePayCapabilityStatus() {
|
|
|
549
486
|
} catch (fallbackError) {
|
|
550
487
|
return null;
|
|
551
488
|
}
|
|
552
|
-
|
|
553
489
|
return APPLE_PAY_CAPABILITY_STATUS.UNSUPPORTED;
|
|
554
490
|
});
|
|
555
491
|
}
|
|
556
|
-
|
|
557
492
|
if (typeof ApplePaySession.canMakePayments === 'function') {
|
|
558
493
|
return Promise.resolve(ApplePaySession.canMakePayments()).then(function (canMakePayments) {
|
|
559
494
|
return canMakePayments ? APPLE_PAY_CAPABILITY_STATUS.UNKNOWN : APPLE_PAY_CAPABILITY_STATUS.UNSUPPORTED;
|
|
560
495
|
});
|
|
561
496
|
}
|
|
562
|
-
|
|
563
497
|
return Promise.resolve(null);
|
|
564
498
|
} catch (error) {
|
|
565
499
|
try {
|
|
@@ -569,7 +503,6 @@ var getApplePayCapabilityStatus = function getApplePayCapabilityStatus() {
|
|
|
569
503
|
} catch (fallbackError) {
|
|
570
504
|
return Promise.resolve(null);
|
|
571
505
|
}
|
|
572
|
-
|
|
573
506
|
return Promise.resolve(APPLE_PAY_CAPABILITY_STATUS.UNSUPPORTED);
|
|
574
507
|
}
|
|
575
508
|
};
|
|
@@ -578,11 +511,9 @@ var applePayCapabilityCanShowButton = function applePayCapabilityCanShowButton(s
|
|
|
578
511
|
};
|
|
579
512
|
var canUseApplePay = function canUseApplePay(channels) {
|
|
580
513
|
var availableChannels = channels || [];
|
|
581
|
-
|
|
582
514
|
if (!availableChannels.includes('apple_pay')) {
|
|
583
515
|
return Promise.resolve(false);
|
|
584
516
|
}
|
|
585
|
-
|
|
586
517
|
return getApplePayCapabilityStatus().then(function (capabilityStatus) {
|
|
587
518
|
return applePayCapabilityCanShowButton(capabilityStatus);
|
|
588
519
|
});
|
|
@@ -595,7 +526,6 @@ function findHighestZIndex() {
|
|
|
595
526
|
elements.forEach(function (element) {
|
|
596
527
|
var computedStyle = window.getComputedStyle(element);
|
|
597
528
|
var zIndex = parseFloat(computedStyle.zIndex);
|
|
598
|
-
|
|
599
529
|
if (!Number.isNaN(zIndex) && zIndex > highestZIndex) {
|
|
600
530
|
highestZIndex = zIndex;
|
|
601
531
|
}
|
|
@@ -614,7 +544,6 @@ function createIframe(id) {
|
|
|
614
544
|
iframe.style.display = 'none';
|
|
615
545
|
return iframe;
|
|
616
546
|
}
|
|
617
|
-
|
|
618
547
|
function mountCheckoutIframe(id) {
|
|
619
548
|
var iframe = createIframe("inline-checkout-".concat(id));
|
|
620
549
|
iframe.src = "".concat(config.checkoutUrl, "popup");
|
|
@@ -650,20 +579,17 @@ function getApplePayButton(container) {
|
|
|
650
579
|
var applePaySdkPromise;
|
|
651
580
|
var loadScript = function loadScript(url, _ref) {
|
|
652
581
|
var container = _ref.container,
|
|
653
|
-
|
|
582
|
+
integrity = _ref.integrity;
|
|
654
583
|
return new Promise(function (resolve, reject) {
|
|
655
584
|
if (!url) {
|
|
656
585
|
reject('No script url');
|
|
657
586
|
}
|
|
658
|
-
|
|
659
587
|
var script = document.createElement('script');
|
|
660
588
|
script.src = url;
|
|
661
589
|
script.crossOrigin = 'anonymous';
|
|
662
|
-
|
|
663
590
|
if (integrity) {
|
|
664
591
|
script.integrity = integrity;
|
|
665
592
|
}
|
|
666
|
-
|
|
667
593
|
script.addEventListener('load', function () {
|
|
668
594
|
resolve(true);
|
|
669
595
|
});
|
|
@@ -671,7 +597,6 @@ var loadScript = function loadScript(url, _ref) {
|
|
|
671
597
|
script.remove();
|
|
672
598
|
reject(false);
|
|
673
599
|
});
|
|
674
|
-
|
|
675
600
|
if (container) {
|
|
676
601
|
container.appendChild(script);
|
|
677
602
|
} else {
|
|
@@ -679,20 +604,16 @@ var loadScript = function loadScript(url, _ref) {
|
|
|
679
604
|
}
|
|
680
605
|
});
|
|
681
606
|
};
|
|
682
|
-
|
|
683
607
|
var applePayButtonComponentIsAvailable = function applePayButtonComponentIsAvailable() {
|
|
684
608
|
return !!(window && window.customElements && window.customElements.get('apple-pay-button'));
|
|
685
609
|
};
|
|
686
|
-
|
|
687
610
|
var ensureApplePaySdkLoaded = function ensureApplePaySdkLoaded(container) {
|
|
688
611
|
if (applePayButtonComponentIsAvailable()) {
|
|
689
612
|
return Promise.resolve(true);
|
|
690
613
|
}
|
|
691
|
-
|
|
692
614
|
if (applePaySdkPromise) {
|
|
693
615
|
return applePaySdkPromise;
|
|
694
616
|
}
|
|
695
|
-
|
|
696
617
|
applePaySdkPromise = loadScript(APPLE_PAY_SDK_SOURCE, {
|
|
697
618
|
container: container,
|
|
698
619
|
integrity: APPLE_PAY_SDK_INTEGRITY_HASH
|
|
@@ -715,7 +636,6 @@ function appendIframeToContainer(containerId, iframe) {
|
|
|
715
636
|
}
|
|
716
637
|
function hideLoader(iframe) {
|
|
717
638
|
var bgWindow = iframe.contentWindow.document;
|
|
718
|
-
|
|
719
639
|
if (bgWindow) {
|
|
720
640
|
bgWindow.getElementById('app-loader').style.display = 'none';
|
|
721
641
|
}
|
|
@@ -725,14 +645,11 @@ function animateCheckoutIn(domElements) {
|
|
|
725
645
|
if (!domElements) {
|
|
726
646
|
reject('No dom element provided');
|
|
727
647
|
}
|
|
728
|
-
|
|
729
648
|
var checkoutIframe = domElements.checkoutIframe,
|
|
730
|
-
|
|
731
|
-
|
|
649
|
+
backgroundIframe = domElements.backgroundIframe;
|
|
732
650
|
if (!checkoutIframe || !backgroundIframe) {
|
|
733
651
|
reject('No dom element provided');
|
|
734
652
|
}
|
|
735
|
-
|
|
736
653
|
checkoutIframe.style.display = '';
|
|
737
654
|
checkoutIframe.style.visibility = 'visible';
|
|
738
655
|
backgroundIframe.style.display = '';
|
|
@@ -745,14 +662,11 @@ function animateCheckoutOut(domElements) {
|
|
|
745
662
|
if (!domElements) {
|
|
746
663
|
reject('No dom element provided');
|
|
747
664
|
}
|
|
748
|
-
|
|
749
665
|
var checkoutIframe = domElements.checkoutIframe,
|
|
750
|
-
|
|
751
|
-
|
|
666
|
+
backgroundIframe = domElements.backgroundIframe;
|
|
752
667
|
if (!checkoutIframe || !backgroundIframe) {
|
|
753
668
|
reject('No dom element provided');
|
|
754
669
|
}
|
|
755
|
-
|
|
756
670
|
backgroundIframe.style.opacity = 0;
|
|
757
671
|
checkoutIframe.style.display = 'none';
|
|
758
672
|
checkoutIframe.style.visibility = 'hidden';
|
|
@@ -766,7 +680,6 @@ function animateCheckoutOut(domElements) {
|
|
|
766
680
|
}
|
|
767
681
|
function mountLazyInlineButton(options) {
|
|
768
682
|
var inlineButton;
|
|
769
|
-
|
|
770
683
|
if (options.id) {
|
|
771
684
|
inlineButton = document.getElementById(options.id);
|
|
772
685
|
inlineButton.setAttribute('data-inline-id', options.id);
|
|
@@ -775,34 +688,29 @@ function mountLazyInlineButton(options) {
|
|
|
775
688
|
inlineDiv.id = "inline-button-".concat(options.inlineId);
|
|
776
689
|
inlineDiv.innerHTML = generateInlineButtonHTML(options);
|
|
777
690
|
options.parent.parentNode.insertBefore(inlineDiv, options.parent.nextSibling);
|
|
778
|
-
|
|
779
691
|
var _inlineDiv$getElement = inlineDiv.getElementsByTagName('button');
|
|
780
|
-
|
|
781
692
|
var _inlineDiv$getElement2 = _slicedToArray(_inlineDiv$getElement, 1);
|
|
782
|
-
|
|
783
693
|
inlineButton = _inlineDiv$getElement2[0];
|
|
784
694
|
}
|
|
785
|
-
|
|
786
695
|
return inlineButton;
|
|
787
696
|
}
|
|
788
697
|
function animateEmbedCheckoutIn(checkoutIframe) {
|
|
789
698
|
return new Promise(function (resolve, reject) {
|
|
790
699
|
if (!checkoutIframe) {
|
|
791
700
|
reject('No dom element provided');
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
701
|
+
}
|
|
702
|
+
// eslint-disable-next-line no-param-reassign
|
|
703
|
+
checkoutIframe.style.display = '';
|
|
704
|
+
// eslint-disable-next-line no-param-reassign
|
|
797
705
|
checkoutIframe.style.visibility = 'visible';
|
|
798
706
|
resolve();
|
|
799
707
|
});
|
|
800
708
|
}
|
|
801
709
|
function mountInput(options) {
|
|
802
710
|
var type = options.type,
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
711
|
+
value = options.value,
|
|
712
|
+
name = options.name,
|
|
713
|
+
parent = options.parent;
|
|
806
714
|
var input = document.createElement('input');
|
|
807
715
|
input.type = type;
|
|
808
716
|
input.value = value;
|
|
@@ -811,17 +719,15 @@ function mountInput(options) {
|
|
|
811
719
|
}
|
|
812
720
|
function mountApplePayButton(container, _ref2) {
|
|
813
721
|
var styles = _ref2.styles,
|
|
814
|
-
|
|
722
|
+
theme = _ref2.theme;
|
|
815
723
|
var style = document.createElement('style');
|
|
816
724
|
var applePayCSS = generateApplePayCSS(styles);
|
|
817
725
|
style.type = 'text/css';
|
|
818
|
-
|
|
819
726
|
if (style.styleSheet) {
|
|
820
727
|
style.styleSheet.cssText = applePayCSS;
|
|
821
728
|
} else {
|
|
822
729
|
style.appendChild(document.createTextNode(applePayCSS));
|
|
823
730
|
}
|
|
824
|
-
|
|
825
731
|
container.appendChild(style);
|
|
826
732
|
var button = document.createElement('apple-pay-button');
|
|
827
733
|
button.setAttribute('buttonstyle', theme === 'light' ? 'white' : 'black');
|
|
@@ -831,17 +737,15 @@ function mountApplePayButton(container, _ref2) {
|
|
|
831
737
|
}
|
|
832
738
|
function mountApplePayFallbackButton(container, _ref3) {
|
|
833
739
|
var styles = _ref3.styles,
|
|
834
|
-
|
|
740
|
+
theme = _ref3.theme;
|
|
835
741
|
var style = document.createElement('style');
|
|
836
742
|
var applePayCSS = generateApplePayFallbackCSS(styles);
|
|
837
743
|
style.type = 'text/css';
|
|
838
|
-
|
|
839
744
|
if (style.styleSheet) {
|
|
840
745
|
style.styleSheet.cssText = applePayCSS;
|
|
841
746
|
} else {
|
|
842
747
|
style.appendChild(document.createTextNode(applePayCSS));
|
|
843
748
|
}
|
|
844
|
-
|
|
845
749
|
container.appendChild(style);
|
|
846
750
|
var button = document.createElement('button');
|
|
847
751
|
button.classList.add('apple-pay-button', theme === 'light' ? 'apple-pay-button-white' : 'apple-pay-button-black');
|
|
@@ -856,21 +760,18 @@ function getPaymentRequestContainer(container) {
|
|
|
856
760
|
}
|
|
857
761
|
function mountPaymentRequestButtons(container, _ref4) {
|
|
858
762
|
var _ref4$channels = _ref4.channels,
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
763
|
+
channels = _ref4$channels === void 0 ? [] : _ref4$channels,
|
|
764
|
+
_ref4$styles = _ref4.styles,
|
|
765
|
+
styles = _ref4$styles === void 0 ? {} : _ref4$styles;
|
|
862
766
|
var mountedElements = {
|
|
863
767
|
applePay: false
|
|
864
768
|
};
|
|
865
|
-
|
|
866
769
|
if (!container) {
|
|
867
770
|
return Promise.reject(new Error('Container to mount elements was not provided'));
|
|
868
771
|
}
|
|
869
|
-
|
|
870
772
|
if (!channels.includes('apple_pay')) {
|
|
871
773
|
return Promise.reject(new Error('No wallet payment method is available on this device'));
|
|
872
774
|
}
|
|
873
|
-
|
|
874
775
|
return ensureApplePaySdkLoaded(container).catch(function () {
|
|
875
776
|
// Safari can still render the fallback button using the native ApplePaySession.
|
|
876
777
|
return null;
|
|
@@ -880,12 +781,10 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
880
781
|
if (!applePayAvailable) {
|
|
881
782
|
throw new Error('No wallet payment method is available on this device');
|
|
882
783
|
}
|
|
883
|
-
|
|
884
784
|
if (getApplePayButton(container)) {
|
|
885
785
|
mountedElements.applePay = true;
|
|
886
786
|
return mountedElements;
|
|
887
787
|
}
|
|
888
|
-
|
|
889
788
|
try {
|
|
890
789
|
mountApplePayButton(container, {
|
|
891
790
|
styles: parseApplePayCustomStyles(styles.applePay),
|
|
@@ -898,7 +797,6 @@ function mountPaymentRequestButtons(container, _ref4) {
|
|
|
898
797
|
theme: styles.theme
|
|
899
798
|
});
|
|
900
799
|
}
|
|
901
|
-
|
|
902
800
|
mountedElements.applePay = true;
|
|
903
801
|
return mountedElements;
|
|
904
802
|
});
|
|
@@ -913,7 +811,6 @@ var preCheckoutModalButtonId = {
|
|
|
913
811
|
PAYSTACK_POP_BUTTON: 'paystackpop-button',
|
|
914
812
|
PAY_WITH_VAULT_BUTTON: 'pay-with-vault-button'
|
|
915
813
|
};
|
|
916
|
-
|
|
917
814
|
function createOpenPaystackPopButton(buttonText) {
|
|
918
815
|
var openPaystackPopButton = document.createElement('button');
|
|
919
816
|
openPaystackPopButton.id = preCheckoutModalButtonId.PAYSTACK_POP_BUTTON;
|
|
@@ -921,17 +818,14 @@ function createOpenPaystackPopButton(buttonText) {
|
|
|
921
818
|
openPaystackPopButton.innerText = buttonText;
|
|
922
819
|
return openPaystackPopButton;
|
|
923
820
|
}
|
|
924
|
-
|
|
925
821
|
function getPreCheckoutModalOpenPaystackPopButton(modal) {
|
|
926
822
|
return modal.querySelector("#".concat(preCheckoutModalButtonId.PAYSTACK_POP_BUTTON));
|
|
927
823
|
}
|
|
928
|
-
|
|
929
824
|
function createPaymentRequestContainer() {
|
|
930
825
|
var paymentRequestContainer = document.createElement('div');
|
|
931
826
|
paymentRequestContainer.id = preCheckoutModalButtonId.PAYMENT_REQUEST_BUTTON;
|
|
932
827
|
return paymentRequestContainer;
|
|
933
828
|
}
|
|
934
|
-
|
|
935
829
|
function getPreCheckoutModalPaymentRequestContainer(modal) {
|
|
936
830
|
return modal.querySelector("#".concat(preCheckoutModalButtonId.PAYMENT_REQUEST_BUTTON));
|
|
937
831
|
}
|
|
@@ -939,7 +833,6 @@ function removePreCheckoutModalPaymentRequestContainer(modal) {
|
|
|
939
833
|
var paymentRequestContainer = getPreCheckoutModalPaymentRequestContainer(modal);
|
|
940
834
|
paymentRequestContainer.remove();
|
|
941
835
|
}
|
|
942
|
-
|
|
943
836
|
function createPayWithVaultButton() {
|
|
944
837
|
var payWithVaultButton = document.createElement('button');
|
|
945
838
|
payWithVaultButton.className = 'pay-with-vault-button';
|
|
@@ -947,11 +840,9 @@ function createPayWithVaultButton() {
|
|
|
947
840
|
payWithVaultButton.innerText = 'Pay with Vault';
|
|
948
841
|
return payWithVaultButton;
|
|
949
842
|
}
|
|
950
|
-
|
|
951
843
|
function getPreCheckoutModalPayWithVaultButton(modal) {
|
|
952
844
|
return modal.querySelector("#".concat(preCheckoutModalButtonId.PAY_WITH_VAULT_BUTTON));
|
|
953
845
|
}
|
|
954
|
-
|
|
955
846
|
function vaultPreCheckoutModalView(container) {
|
|
956
847
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
957
848
|
var logoContainer = document.createElement('div');
|
|
@@ -969,18 +860,15 @@ function vaultPreCheckoutModalView(container) {
|
|
|
969
860
|
divider.className = 'vault-divider';
|
|
970
861
|
divider.innerHTML = '<div id="vault-divider" class="vault-divider__container"><div class="vault-divider__line"></div></div><div class="vault-divider__text-container"><span class="vault-divider__text">or</span></div>';
|
|
971
862
|
container.appendChild(divider);
|
|
972
|
-
|
|
973
863
|
if (options.canPayWithApplePay) {
|
|
974
864
|
var paymentRequestContainer = createPaymentRequestContainer();
|
|
975
865
|
container.appendChild(paymentRequestContainer);
|
|
976
866
|
}
|
|
977
|
-
|
|
978
867
|
if (options.hasOtherPaymentMethods) {
|
|
979
868
|
var openPaystackPopButton = createOpenPaystackPopButton('Use other payment methods');
|
|
980
869
|
container.appendChild(openPaystackPopButton);
|
|
981
870
|
}
|
|
982
871
|
}
|
|
983
|
-
|
|
984
872
|
function defaultPreCheckoutModalView(container, _ref5) {
|
|
985
873
|
var hasOtherPaymentMethods = _ref5.hasOtherPaymentMethods;
|
|
986
874
|
var applePayIcon = document.createElement('div');
|
|
@@ -992,31 +880,25 @@ function defaultPreCheckoutModalView(container, _ref5) {
|
|
|
992
880
|
container.appendChild(instruction);
|
|
993
881
|
var paymentRequestContainer = createPaymentRequestContainer();
|
|
994
882
|
container.appendChild(paymentRequestContainer);
|
|
995
|
-
|
|
996
883
|
if (hasOtherPaymentMethods) {
|
|
997
884
|
var openPaystackPopButton = createOpenPaystackPopButton('More payment options');
|
|
998
885
|
container.appendChild(openPaystackPopButton);
|
|
999
886
|
}
|
|
1000
887
|
}
|
|
1001
|
-
|
|
1002
888
|
function hasNonPrecheckoutPaymentMethods(channels) {
|
|
1003
889
|
return channels.some(function (channel) {
|
|
1004
890
|
return channel !== 'apple_pay';
|
|
1005
891
|
});
|
|
1006
892
|
}
|
|
1007
|
-
|
|
1008
893
|
function mountPreCheckoutModal(id, transaction) {
|
|
1009
894
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1010
895
|
var mountedModal = document.querySelector("#pre-checkout-modal-".concat(id));
|
|
1011
|
-
|
|
1012
896
|
if (mountedModal) {
|
|
1013
897
|
if (getPreCheckoutModalOpenPaystackPopButton(mountedModal) && getPreCheckoutModalPaymentRequestContainer(mountedModal)) {
|
|
1014
898
|
return mountedModal;
|
|
1015
899
|
}
|
|
1016
|
-
|
|
1017
900
|
mountedModal.remove();
|
|
1018
901
|
}
|
|
1019
|
-
|
|
1020
902
|
var modal = document.createElement('div');
|
|
1021
903
|
modal.classList.add('pre-checkout-modal');
|
|
1022
904
|
modal.id = "pre-checkout-modal-".concat(id);
|
|
@@ -1024,16 +906,14 @@ function mountPreCheckoutModal(id, transaction) {
|
|
|
1024
906
|
var content = document.createElement('div');
|
|
1025
907
|
content.classList.add('pre-checkout-modal__content');
|
|
1026
908
|
modal.appendChild(content);
|
|
1027
|
-
|
|
1028
909
|
var _ref6 = transaction || {},
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
910
|
+
merchantLogo = _ref6.merchant_logo,
|
|
911
|
+
merchantName = _ref6.merchant_name,
|
|
912
|
+
email = _ref6.email,
|
|
913
|
+
amount = _ref6.amount,
|
|
914
|
+
currency = _ref6.currency,
|
|
915
|
+
label = _ref6.label,
|
|
916
|
+
channels = _ref6.channels;
|
|
1037
917
|
var formattedAmount = new Intl.NumberFormat('en', {
|
|
1038
918
|
style: 'currency',
|
|
1039
919
|
currency: currency,
|
|
@@ -1048,7 +928,6 @@ function mountPreCheckoutModal(id, transaction) {
|
|
|
1048
928
|
content.innerHTML += closeButton;
|
|
1049
929
|
var wrapper = document.createElement('div');
|
|
1050
930
|
wrapper.classList.add('modal-wrapper');
|
|
1051
|
-
|
|
1052
931
|
if (options.canPayWithVault) {
|
|
1053
932
|
vaultPreCheckoutModalView(wrapper, {
|
|
1054
933
|
canPayWithApplePay: options.canPayWithApplePay,
|
|
@@ -1059,13 +938,38 @@ function mountPreCheckoutModal(id, transaction) {
|
|
|
1059
938
|
hasOtherPaymentMethods: hasNonPrecheckoutPaymentMethods(channels)
|
|
1060
939
|
});
|
|
1061
940
|
}
|
|
1062
|
-
|
|
1063
941
|
wrapper.innerHTML = wrapper.innerHTML + secureByPaystackWhite + secureByPaystackGrey;
|
|
1064
942
|
content.appendChild(wrapper);
|
|
1065
943
|
var style = document.createElement('style');
|
|
1066
944
|
style.textContent = preCheckoutModalCSS;
|
|
1067
|
-
|
|
1068
|
-
|
|
945
|
+
|
|
946
|
+
// === TEMP (test): render the precheckout modal inside an iframe for ONE merchant — revert before commit ===
|
|
947
|
+
// Only the merchant whose request_inline response carries this merchant_id gets the iframe
|
|
948
|
+
// treatment; every other merchant keeps the original behaviour (modal appended to document.body).
|
|
949
|
+
var IFRAME_MODAL_MERCHANT_ID = 550652; // target merchant_id from the request inline response
|
|
950
|
+
var renderInIframe = transaction && String(transaction.merchant_id) === String(IFRAME_MODAL_MERCHANT_ID);
|
|
951
|
+
if (renderInIframe) {
|
|
952
|
+
// Host the modal + style in a full-viewport, same-origin (about:blank) iframe.
|
|
953
|
+
var hostIframe = document.createElement('iframe');
|
|
954
|
+
hostIframe.id = "pre-checkout-modal-iframe-".concat(id);
|
|
955
|
+
hostIframe.setAttribute('allow', 'payment');
|
|
956
|
+
hostIframe.style.cssText = ['position: fixed', 'top: 0', 'left: 0', 'width: 100%', 'height: 100%', 'border: 0', 'margin: 0', 'background: transparent', "z-index: ".concat(findHighestZIndex() + 1)].join(';');
|
|
957
|
+
document.body.appendChild(hostIframe);
|
|
958
|
+
var frameDocument = hostIframe.contentDocument || hostIframe.contentWindow.document;
|
|
959
|
+
frameDocument.body.style.margin = '0';
|
|
960
|
+
frameDocument.head.appendChild(style);
|
|
961
|
+
frameDocument.body.appendChild(modal);
|
|
962
|
+
|
|
963
|
+
// closePreCheckoutModal() calls modal.remove(); make that tear down the host iframe too.
|
|
964
|
+
modal.remove = function () {
|
|
965
|
+
return hostIframe.remove();
|
|
966
|
+
};
|
|
967
|
+
} else {
|
|
968
|
+
document.body.appendChild(style);
|
|
969
|
+
document.body.appendChild(modal);
|
|
970
|
+
}
|
|
971
|
+
// === END TEMP ===
|
|
972
|
+
|
|
1069
973
|
return modal;
|
|
1070
974
|
}
|
|
1071
975
|
function getPreCheckoutModalCloseButton(modal) {
|
|
@@ -1096,7 +1000,6 @@ function showErrorInPreCheckoutModal(modal) {
|
|
|
1096
1000
|
if (!modal) {
|
|
1097
1001
|
return;
|
|
1098
1002
|
}
|
|
1099
|
-
|
|
1100
1003
|
var appleIcon = modal.querySelector('#apple-pay-mark--light');
|
|
1101
1004
|
appleIcon.innerHTML = errorIcon;
|
|
1102
1005
|
var applePayDescription = modal.querySelector('#apple-pay-description');
|
|
@@ -1333,33 +1236,32 @@ function validate(args) {
|
|
|
1333
1236
|
this.message = message;
|
|
1334
1237
|
this.issues = issues || [];
|
|
1335
1238
|
}
|
|
1336
|
-
|
|
1337
1239
|
if (!args || _typeof(args) !== 'object') {
|
|
1338
1240
|
throw new ValidationError('Transaction parameters should be a non-empty object');
|
|
1339
1241
|
}
|
|
1242
|
+
var transactionParameters = args;
|
|
1340
1243
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1244
|
+
// If it's a transaction resumption, move on
|
|
1343
1245
|
if ('accessCode' in transactionParameters) {
|
|
1344
1246
|
var accessCode = transactionParameters.accessCode;
|
|
1345
1247
|
return {
|
|
1346
1248
|
accessCode: accessCode
|
|
1347
1249
|
};
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1250
|
+
}
|
|
1350
1251
|
|
|
1252
|
+
// Filter unneeded parameters
|
|
1351
1253
|
Object.keys(transactionParameters).forEach(function (key) {
|
|
1352
1254
|
var usedParameter = allParameters.find(function (parameter) {
|
|
1353
1255
|
return parameter.value === key;
|
|
1354
1256
|
}) !== undefined;
|
|
1355
|
-
|
|
1356
1257
|
if (!usedParameter) {
|
|
1357
1258
|
delete transactionParameters[key];
|
|
1358
1259
|
}
|
|
1359
1260
|
});
|
|
1360
1261
|
var transactionKeys = Object.keys(transactionParameters);
|
|
1361
|
-
var validationErrors = [];
|
|
1262
|
+
var validationErrors = [];
|
|
1362
1263
|
|
|
1264
|
+
// Check for required parameters
|
|
1363
1265
|
var requiredParameters = allParameters.filter(function (param) {
|
|
1364
1266
|
return param.required;
|
|
1365
1267
|
});
|
|
@@ -1368,50 +1270,44 @@ function validate(args) {
|
|
|
1368
1270
|
var parameterHasAlternative = key.or ? key.or.some(function (option) {
|
|
1369
1271
|
return transactionParameters[option];
|
|
1370
1272
|
}) : null;
|
|
1371
|
-
|
|
1372
1273
|
if (parameterIsMissing && !parameterHasAlternative) {
|
|
1373
1274
|
validationErrors.push({
|
|
1374
1275
|
message: "Required parameter missing: ".concat(key.value)
|
|
1375
1276
|
});
|
|
1376
1277
|
}
|
|
1377
|
-
});
|
|
1278
|
+
});
|
|
1378
1279
|
|
|
1280
|
+
// Check for validity
|
|
1379
1281
|
transactionKeys.forEach(function (key) {
|
|
1380
1282
|
var parameterValue = transactionParameters[key];
|
|
1381
1283
|
var parameterObject = allParameters.find(function (parameter) {
|
|
1382
1284
|
return parameter.value === key;
|
|
1383
1285
|
});
|
|
1384
|
-
|
|
1385
1286
|
var providedType = _typeof(parameterValue);
|
|
1386
|
-
|
|
1387
1287
|
if (providedType === 'object' && Array.isArray(parameterValue)) {
|
|
1388
1288
|
providedType = 'array';
|
|
1389
1289
|
}
|
|
1390
|
-
|
|
1391
1290
|
var invalidType = parameterObject.types.indexOf(providedType) <= -1;
|
|
1392
|
-
|
|
1393
1291
|
if (invalidType) {
|
|
1394
1292
|
validationErrors.push({
|
|
1395
1293
|
message: "Invalid parameter type: ".concat(key),
|
|
1396
1294
|
validTypes: parameterObject.types
|
|
1397
1295
|
});
|
|
1398
1296
|
}
|
|
1399
|
-
});
|
|
1297
|
+
});
|
|
1400
1298
|
|
|
1299
|
+
// Override keys where necessary
|
|
1401
1300
|
transactionKeys.forEach(function (key) {
|
|
1402
1301
|
var parameterObject = allParameters.find(function (parameter) {
|
|
1403
1302
|
return parameter.value === key;
|
|
1404
1303
|
});
|
|
1405
|
-
|
|
1406
1304
|
if (parameterObject.override) {
|
|
1407
1305
|
delete transactionParameters[parameterObject.override];
|
|
1408
1306
|
}
|
|
1409
1307
|
});
|
|
1410
|
-
|
|
1411
1308
|
if (validationErrors.length) {
|
|
1412
1309
|
throw new ValidationError('Invalid transaction parameters', validationErrors);
|
|
1413
1310
|
}
|
|
1414
|
-
|
|
1415
1311
|
return transactionParameters;
|
|
1416
1312
|
}
|
|
1417
1313
|
|
|
@@ -1420,31 +1316,26 @@ function splitURL(url) {
|
|
|
1420
1316
|
if ((url === null || url === void 0 ? void 0 : url.length) > 500) {
|
|
1421
1317
|
return url.split('?')[0];
|
|
1422
1318
|
}
|
|
1423
|
-
|
|
1424
1319
|
return url;
|
|
1425
1320
|
}
|
|
1426
|
-
|
|
1427
1321
|
function getReferrer() {
|
|
1428
1322
|
var _window$location = window.location,
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1323
|
+
_window$location$href = _window$location.href,
|
|
1324
|
+
href = _window$location$href === void 0 ? '' : _window$location$href,
|
|
1325
|
+
_window$location$ance = _window$location.ancestorOrigins,
|
|
1326
|
+
ancestorOrigins = _window$location$ance === void 0 ? [] : _window$location$ance;
|
|
1433
1327
|
return [href].concat(_toConsumableArray(ancestorOrigins)).map(splitURL).join(',');
|
|
1434
1328
|
}
|
|
1435
1329
|
|
|
1436
1330
|
function buildQuery(parameters) {
|
|
1437
1331
|
var formattedParameters = _objectSpread2({}, parameters);
|
|
1438
|
-
|
|
1439
1332
|
formattedParameters.metadata = parameters.metadata || {};
|
|
1440
1333
|
formattedParameters.metadata.referrer = getReferrer();
|
|
1441
1334
|
formattedParameters.metadata = JSON.stringify(formattedParameters.metadata);
|
|
1442
1335
|
formattedParameters.mode = 'popup';
|
|
1443
|
-
|
|
1444
1336
|
if (parameters.split && typeof parameters.split !== 'string') {
|
|
1445
1337
|
formattedParameters.split = JSON.stringify(formattedParameters.split);
|
|
1446
1338
|
}
|
|
1447
|
-
|
|
1448
1339
|
var parametersToChange = [{
|
|
1449
1340
|
to: 'firstname',
|
|
1450
1341
|
from: 'firstName'
|
|
@@ -1481,21 +1372,20 @@ function buildQuery(parameters) {
|
|
|
1481
1372
|
}, {
|
|
1482
1373
|
to: 'ref',
|
|
1483
1374
|
from: 'reference'
|
|
1484
|
-
}];
|
|
1375
|
+
}];
|
|
1376
|
+
|
|
1377
|
+
// handle very old case of people disabling channels by sending card/bank params
|
|
1485
1378
|
|
|
1486
1379
|
if (formattedParameters.card !== undefined && ['false', false].indexOf(formattedParameters.card) > -1) {
|
|
1487
1380
|
formattedParameters.channels = ['bank'];
|
|
1488
1381
|
delete formattedParameters.card;
|
|
1489
1382
|
}
|
|
1490
|
-
|
|
1491
1383
|
if (formattedParameters.bank !== undefined && ['false', false].indexOf(formattedParameters.bank) > -1) {
|
|
1492
1384
|
formattedParameters.channels = ['card'];
|
|
1493
1385
|
delete formattedParameters.bank;
|
|
1494
1386
|
}
|
|
1495
|
-
|
|
1496
1387
|
parametersToChange.forEach(function (key) {
|
|
1497
1388
|
var hasValue = formattedParameters[key.from];
|
|
1498
|
-
|
|
1499
1389
|
if (hasValue) {
|
|
1500
1390
|
formattedParameters[key.to] = formattedParameters[key.from];
|
|
1501
1391
|
delete formattedParameters[key.from];
|
|
@@ -1511,22 +1401,23 @@ function buildQuery(parameters) {
|
|
|
1511
1401
|
}
|
|
1512
1402
|
|
|
1513
1403
|
/* eslint-env browser */
|
|
1404
|
+
|
|
1514
1405
|
var iOSDevices = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'];
|
|
1406
|
+
|
|
1515
1407
|
/**
|
|
1516
1408
|
* navigator.platform is deprecated and will eventually be removed
|
|
1517
1409
|
* but the recommended alternative `navigator.userAgentData` has limited browser support
|
|
1518
1410
|
* so it is used as a fallback here.
|
|
1519
1411
|
*/
|
|
1520
|
-
|
|
1521
1412
|
var DEVICE_PLATFORM = window && window.navigator && (window.navigator.platform || window.navigator.userAgentData && window.navigator.userAgentData.platform);
|
|
1522
1413
|
var isIOS = function isIOS() {
|
|
1523
1414
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1415
|
+
platform = _ref.platform,
|
|
1416
|
+
_ref$userAgent = _ref.userAgent,
|
|
1417
|
+
userAgent = _ref$userAgent === void 0 ? window && window.navigator && window.navigator.userAgent : _ref$userAgent;
|
|
1528
1418
|
var devicePlatform = platform || DEVICE_PLATFORM;
|
|
1529
|
-
return iOSDevices.includes(devicePlatform) ||
|
|
1419
|
+
return iOSDevices.includes(devicePlatform) ||
|
|
1420
|
+
// iPAD os safari detection. iPad OS uses the same version of safari as Mac OS
|
|
1530
1421
|
userAgent.includes('Mac') && 'ontouchend' in document;
|
|
1531
1422
|
};
|
|
1532
1423
|
|
|
@@ -1560,11 +1451,10 @@ var AnalyticsAPI = {
|
|
|
1560
1451
|
var AnalyticsFunctions = {
|
|
1561
1452
|
initializeLog: function initializeLog(log) {
|
|
1562
1453
|
var _ref = log || {},
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1454
|
+
attempts = _ref.attempts,
|
|
1455
|
+
authentication = _ref.authentication,
|
|
1456
|
+
errors = _ref.errors,
|
|
1457
|
+
history = _ref.history;
|
|
1568
1458
|
this.log = {
|
|
1569
1459
|
start_time: Math.round(Date.now() / 1000),
|
|
1570
1460
|
time_spent: 0,
|
|
@@ -1586,10 +1476,8 @@ var AnalyticsFunctions = {
|
|
|
1586
1476
|
switch (response.status) {
|
|
1587
1477
|
case 'success':
|
|
1588
1478
|
return this.logApiSuccess(channel);
|
|
1589
|
-
|
|
1590
1479
|
case 'failed':
|
|
1591
1480
|
return this.logApiError(response.message);
|
|
1592
|
-
|
|
1593
1481
|
default:
|
|
1594
1482
|
return false;
|
|
1595
1483
|
}
|
|
@@ -1604,11 +1492,9 @@ var AnalyticsFunctions = {
|
|
|
1604
1492
|
},
|
|
1605
1493
|
logAttempt: function logAttempt(channel) {
|
|
1606
1494
|
var message = 'Attempted to pay';
|
|
1607
|
-
|
|
1608
1495
|
if (channel) {
|
|
1609
1496
|
message += " with ".concat(channel);
|
|
1610
1497
|
}
|
|
1611
|
-
|
|
1612
1498
|
this.log.attempts += 1;
|
|
1613
1499
|
this.log.history.push({
|
|
1614
1500
|
type: 'action',
|
|
@@ -1619,11 +1505,9 @@ var AnalyticsFunctions = {
|
|
|
1619
1505
|
},
|
|
1620
1506
|
logApiError: function logApiError(error) {
|
|
1621
1507
|
var message = 'Error';
|
|
1622
|
-
|
|
1623
1508
|
if (error) {
|
|
1624
1509
|
message += ": ".concat(error);
|
|
1625
1510
|
}
|
|
1626
|
-
|
|
1627
1511
|
this.log.errors += 1;
|
|
1628
1512
|
this.log.history.push({
|
|
1629
1513
|
type: 'error',
|
|
@@ -1634,11 +1518,9 @@ var AnalyticsFunctions = {
|
|
|
1634
1518
|
},
|
|
1635
1519
|
logApiSuccess: function logApiSuccess(channel) {
|
|
1636
1520
|
var message = 'Successfully paid';
|
|
1637
|
-
|
|
1638
1521
|
if (channel) {
|
|
1639
1522
|
message += " with ".concat(channel);
|
|
1640
1523
|
}
|
|
1641
|
-
|
|
1642
1524
|
this.log.success = true;
|
|
1643
1525
|
this.log.history.push({
|
|
1644
1526
|
type: 'success',
|
|
@@ -1652,9 +1534,9 @@ var AnalyticsFunctions = {
|
|
|
1652
1534
|
if (this.response) {
|
|
1653
1535
|
return AnalyticsAPI.saveLog(this.id, this.response.merchant_key, this.log);
|
|
1654
1536
|
}
|
|
1655
|
-
} catch (error) {
|
|
1537
|
+
} catch (error) {
|
|
1538
|
+
// we don't need to do anything since this should not affect the transaction
|
|
1656
1539
|
}
|
|
1657
|
-
|
|
1658
1540
|
return undefined;
|
|
1659
1541
|
},
|
|
1660
1542
|
saveIpAddress: function saveIpAddress() {
|
|
@@ -1662,9 +1544,9 @@ var AnalyticsFunctions = {
|
|
|
1662
1544
|
if (this.response) {
|
|
1663
1545
|
return AnalyticsAPI.saveIp(this.id, this.response.merchant_key);
|
|
1664
1546
|
}
|
|
1665
|
-
} catch (error) {
|
|
1547
|
+
} catch (error) {
|
|
1548
|
+
// we don't need to do anything since this should not affect the transaction
|
|
1666
1549
|
}
|
|
1667
|
-
|
|
1668
1550
|
return undefined;
|
|
1669
1551
|
}
|
|
1670
1552
|
};
|
|
@@ -1673,20 +1555,16 @@ var _excluded$1 = ["language", "connect_account"];
|
|
|
1673
1555
|
var TransactionApi = {
|
|
1674
1556
|
requestInline: function requestInline() {
|
|
1675
1557
|
var inlineTransactionInstance = this;
|
|
1676
|
-
|
|
1677
1558
|
var _this$urlParameters = this.urlParameters,
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1559
|
+
language = _this$urlParameters.language,
|
|
1560
|
+
connectAccount = _this$urlParameters.connect_account,
|
|
1561
|
+
params = _objectWithoutProperties(_this$urlParameters, _excluded$1);
|
|
1682
1562
|
var request;
|
|
1683
|
-
|
|
1684
1563
|
var headers = _objectSpread2({
|
|
1685
1564
|
'Content-Type': 'application/json'
|
|
1686
1565
|
}, language && {
|
|
1687
1566
|
'Accept-Language': language
|
|
1688
1567
|
});
|
|
1689
|
-
|
|
1690
1568
|
if (this.accessCode) {
|
|
1691
1569
|
request = fetch(new URL("transaction/verify_access_code/".concat(this.accessCode), config.paystackApiUrl).toString(), {
|
|
1692
1570
|
headers: headers
|
|
@@ -1700,19 +1578,18 @@ var TransactionApi = {
|
|
|
1700
1578
|
})
|
|
1701
1579
|
});
|
|
1702
1580
|
}
|
|
1703
|
-
|
|
1704
1581
|
return request.then(function (res) {
|
|
1705
1582
|
return res.json();
|
|
1706
1583
|
}).then(function (res) {
|
|
1707
1584
|
if (res.status === false) {
|
|
1708
1585
|
throw new Error(res.message);
|
|
1709
1586
|
}
|
|
1710
|
-
|
|
1711
1587
|
inlineTransactionInstance.response = res.data;
|
|
1712
1588
|
inlineTransactionInstance.id = res.data.id;
|
|
1713
1589
|
inlineTransactionInstance.status = res.data.transaction_status;
|
|
1714
|
-
inlineTransactionInstance.accessCode = res.data.access_code;
|
|
1590
|
+
inlineTransactionInstance.accessCode = res.data.access_code;
|
|
1715
1591
|
|
|
1592
|
+
// Analytics
|
|
1716
1593
|
inlineTransactionInstance.log = null;
|
|
1717
1594
|
Object.assign(inlineTransactionInstance, AnalyticsFunctions);
|
|
1718
1595
|
inlineTransactionInstance.initializeLog(res.data.log);
|
|
@@ -1725,7 +1602,6 @@ var TransactionApi = {
|
|
|
1725
1602
|
var InlineTransaction = /*#__PURE__*/function () {
|
|
1726
1603
|
function InlineTransaction(data) {
|
|
1727
1604
|
_classCallCheck(this, InlineTransaction);
|
|
1728
|
-
|
|
1729
1605
|
validate(data);
|
|
1730
1606
|
this.parameters = data;
|
|
1731
1607
|
this.urlParameters = buildQuery(data);
|
|
@@ -1737,12 +1613,12 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1737
1613
|
this.response = null;
|
|
1738
1614
|
this.isActive = true;
|
|
1739
1615
|
var onError = data.onError,
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1616
|
+
onLoad = data.onLoad,
|
|
1617
|
+
onSuccess = data.onSuccess,
|
|
1618
|
+
onCancel = data.onCancel,
|
|
1619
|
+
callback = data.callback,
|
|
1620
|
+
onClose = data.onClose,
|
|
1621
|
+
onBankTransferConfirmationPending = data.onBankTransferConfirmationPending;
|
|
1746
1622
|
this.callbacks = {
|
|
1747
1623
|
onError: onError,
|
|
1748
1624
|
onLoad: onLoad,
|
|
@@ -1756,12 +1632,10 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1756
1632
|
};
|
|
1757
1633
|
Object.assign(this, TransactionApi);
|
|
1758
1634
|
}
|
|
1759
|
-
|
|
1760
|
-
_createClass(InlineTransaction, [{
|
|
1635
|
+
return _createClass(InlineTransaction, [{
|
|
1761
1636
|
key: "onSetupError",
|
|
1762
1637
|
value: function onSetupError(response) {
|
|
1763
1638
|
this.logError(response);
|
|
1764
|
-
|
|
1765
1639
|
if (this.callbacks.onError) {
|
|
1766
1640
|
this.callbacks.onError(response);
|
|
1767
1641
|
}
|
|
@@ -1770,15 +1644,14 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1770
1644
|
key: "onLoad",
|
|
1771
1645
|
value: function onLoad(response) {
|
|
1772
1646
|
var id = response.id,
|
|
1773
|
-
|
|
1774
|
-
|
|
1647
|
+
customer = response.customer,
|
|
1648
|
+
accessCode = response.accessCode;
|
|
1775
1649
|
Object.assign(this, {
|
|
1776
1650
|
id: id,
|
|
1777
1651
|
customer: customer,
|
|
1778
1652
|
accessCode: accessCode
|
|
1779
1653
|
});
|
|
1780
1654
|
this.authorizationUrl = "".concat(config.checkoutUrl).concat(accessCode);
|
|
1781
|
-
|
|
1782
1655
|
if (this.callbacks.onLoad) {
|
|
1783
1656
|
this.callbacks.onLoad({
|
|
1784
1657
|
id: id,
|
|
@@ -1793,12 +1666,10 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1793
1666
|
this.isActive = false;
|
|
1794
1667
|
this.response = response;
|
|
1795
1668
|
this.status = response.status;
|
|
1796
|
-
|
|
1797
1669
|
if (this.callbacks.onSuccess) {
|
|
1798
1670
|
this.callbacks.onSuccess(response);
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1671
|
+
}
|
|
1672
|
+
// Added for backwards compatibility
|
|
1802
1673
|
if (this.deprecatedCallbacks.callback) {
|
|
1803
1674
|
this.deprecatedCallbacks.callback(response);
|
|
1804
1675
|
}
|
|
@@ -1813,9 +1684,8 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1813
1684
|
value: function onCancel() {
|
|
1814
1685
|
if (this.callbacks.onCancel) {
|
|
1815
1686
|
this.callbacks.onCancel();
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
|
|
1687
|
+
}
|
|
1688
|
+
// Added for backwards compatibility
|
|
1819
1689
|
if (this.deprecatedCallbacks.onClose) {
|
|
1820
1690
|
this.deprecatedCallbacks.onClose();
|
|
1821
1691
|
}
|
|
@@ -1830,7 +1700,6 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1830
1700
|
key: "onBankTransferConfirmationPending",
|
|
1831
1701
|
value: function onBankTransferConfirmationPending() {
|
|
1832
1702
|
this.cancel();
|
|
1833
|
-
|
|
1834
1703
|
if (this.callbacks.onBankTransferConfirmationPending) {
|
|
1835
1704
|
this.callbacks.onBankTransferConfirmationPending();
|
|
1836
1705
|
}
|
|
@@ -1841,13 +1710,10 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1841
1710
|
this.errors.push(error);
|
|
1842
1711
|
}
|
|
1843
1712
|
}]);
|
|
1844
|
-
|
|
1845
|
-
return InlineTransaction;
|
|
1846
1713
|
}();
|
|
1847
1714
|
|
|
1848
1715
|
var canUseVault = function canUseVault() {
|
|
1849
1716
|
var _transaction$link_con, _transaction$link_con2;
|
|
1850
|
-
|
|
1851
1717
|
var transaction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1852
1718
|
return !!((_transaction$link_con = transaction.link_config) !== null && _transaction$link_con !== void 0 && _transaction$link_con.enabled && (_transaction$link_con2 = transaction.link_config) !== null && _transaction$link_con2 !== void 0 && _transaction$link_con2.has_payment_instruments);
|
|
1853
1719
|
};
|
|
@@ -1859,14 +1725,12 @@ function printDeprecationNotice(oldName, newName, extraMessage) {
|
|
|
1859
1725
|
}
|
|
1860
1726
|
|
|
1861
1727
|
var _excluded = ["preload", "inlineTransaction", "transactionData"],
|
|
1862
|
-
|
|
1728
|
+
_excluded2 = ["container", "styles", "onElementsMount"];
|
|
1863
1729
|
var inlineInstance;
|
|
1864
|
-
|
|
1865
1730
|
function findResumableTransaction(transactions, parameters) {
|
|
1866
1731
|
if (!transactions.length) {
|
|
1867
1732
|
return null;
|
|
1868
1733
|
}
|
|
1869
|
-
|
|
1870
1734
|
var similarAbandonedTransactions = transactions.filter(function (transaction) {
|
|
1871
1735
|
var isAbandoned = !transaction.status || transaction.status === 'abandoned';
|
|
1872
1736
|
var hasSimilarParameters = similarObjects(transaction.parameters, parameters);
|
|
@@ -1875,39 +1739,32 @@ function findResumableTransaction(transactions, parameters) {
|
|
|
1875
1739
|
var resumableTransaction = similarAbandonedTransactions.length ? similarAbandonedTransactions[similarAbandonedTransactions.length - 1] : null;
|
|
1876
1740
|
return resumableTransaction;
|
|
1877
1741
|
}
|
|
1878
|
-
|
|
1879
1742
|
function notifyIframeToUpdateURL(options) {
|
|
1880
1743
|
var checkoutIframe = options.checkoutIframe,
|
|
1881
|
-
|
|
1882
|
-
|
|
1744
|
+
urlParameters = options.urlParameters;
|
|
1883
1745
|
if (!checkoutIframe || !urlParameters) {
|
|
1884
1746
|
return;
|
|
1885
1747
|
}
|
|
1886
|
-
|
|
1887
1748
|
checkoutIframe.contentWindow.postMessage({
|
|
1888
1749
|
type: 'inline:url',
|
|
1889
1750
|
path: 'newTransaction',
|
|
1890
1751
|
params: urlParameters
|
|
1891
1752
|
}, '*');
|
|
1892
1753
|
}
|
|
1893
|
-
|
|
1894
1754
|
var analyticsActions = {
|
|
1895
1755
|
TRACK_CHECKOUT_CLOSED: 'trackCheckoutClosed',
|
|
1896
1756
|
TRACK_PAYMENT_ERROR: 'trackPaymentError',
|
|
1897
1757
|
TRACK_PAYMENT_ATTEMPT: 'trackPaymentAttempt',
|
|
1898
1758
|
TRACK_PAYMENT_COMPLETION: 'trackPaymentCompletion'
|
|
1899
1759
|
};
|
|
1900
|
-
|
|
1901
1760
|
function handleError(message) {
|
|
1902
1761
|
logWarning(message);
|
|
1903
1762
|
throw new Error(message);
|
|
1904
1763
|
}
|
|
1905
|
-
|
|
1906
1764
|
function transactionCanUseApplePay(response, container) {
|
|
1907
1765
|
if (!(response && response.channels && response.channels.includes('apple_pay'))) {
|
|
1908
1766
|
return Promise.resolve(false);
|
|
1909
1767
|
}
|
|
1910
|
-
|
|
1911
1768
|
return ensureApplePaySdkLoaded(container).catch(function () {
|
|
1912
1769
|
// Native Apple Pay support can still be available even if the SDK fails to load.
|
|
1913
1770
|
return null;
|
|
@@ -1915,44 +1772,36 @@ function transactionCanUseApplePay(response, container) {
|
|
|
1915
1772
|
return canUseApplePay(response.channels);
|
|
1916
1773
|
});
|
|
1917
1774
|
}
|
|
1918
|
-
|
|
1919
1775
|
var Inline = /*#__PURE__*/function () {
|
|
1920
1776
|
function Inline(params) {
|
|
1921
1777
|
_classCallCheck(this, Inline);
|
|
1922
|
-
|
|
1923
1778
|
this.id = randomId();
|
|
1924
1779
|
this.transactions = [];
|
|
1925
1780
|
this.isOpen = false;
|
|
1926
1781
|
this.isLoaded = false;
|
|
1927
1782
|
this.isDeprecatedApi = params && params.isDeprecatedApi; // track deprecatedApi
|
|
1928
|
-
|
|
1929
1783
|
if (params && params.isEmbed) {
|
|
1930
1784
|
this.isEmbed = true;
|
|
1931
1785
|
} else if (params && params.isPaymentRequest) {
|
|
1932
1786
|
if (!(params.container && getPaymentRequestContainer(params.container))) {
|
|
1933
1787
|
handleError('A container is required to mount the payment request button');
|
|
1934
1788
|
}
|
|
1935
|
-
|
|
1936
1789
|
this.paymentRequestContainer = getPaymentRequestContainer(params.container);
|
|
1937
1790
|
this.paymentRequestTransaction = null;
|
|
1938
1791
|
}
|
|
1939
|
-
|
|
1940
1792
|
this.preCheckoutModal = null;
|
|
1941
1793
|
this.backgroundIframe = mountBackgroundIframe(this.id);
|
|
1942
1794
|
this.checkoutIframe = mountCheckoutIframe(this.id);
|
|
1943
1795
|
this.registerListeners();
|
|
1944
1796
|
}
|
|
1945
|
-
|
|
1946
|
-
_createClass(Inline, [{
|
|
1797
|
+
return _createClass(Inline, [{
|
|
1947
1798
|
key: "registerListeners",
|
|
1948
1799
|
value: function registerListeners() {
|
|
1949
1800
|
var _this = this;
|
|
1950
|
-
|
|
1951
1801
|
window.addEventListener('message', function (event) {
|
|
1952
1802
|
var isCheckoutIframe = "".concat(event.origin, "/") === config.checkoutUrl;
|
|
1953
1803
|
var isThisInline = _this.checkoutIframe && _this.checkoutIframe.contentWindow === event.source;
|
|
1954
1804
|
var isEmbed = _this.isEmbed;
|
|
1955
|
-
|
|
1956
1805
|
if (isCheckoutIframe || isThisInline) {
|
|
1957
1806
|
_this.respondToEvent(event);
|
|
1958
1807
|
} else if (isEmbed) {
|
|
@@ -1975,7 +1824,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1975
1824
|
if (this.activeTransaction()) {
|
|
1976
1825
|
this.activeTransaction().cancel();
|
|
1977
1826
|
}
|
|
1978
|
-
|
|
1979
1827
|
inlineInstance = this;
|
|
1980
1828
|
var resumableTransaction = findResumableTransaction(this.transactions, params);
|
|
1981
1829
|
var transaction = resumableTransaction || new InlineTransaction(params);
|
|
@@ -1989,10 +1837,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1989
1837
|
});
|
|
1990
1838
|
}).then(function (_ref) {
|
|
1991
1839
|
var response = _ref.response,
|
|
1992
|
-
|
|
1840
|
+
canPayWithApplePay = _ref.canPayWithApplePay;
|
|
1993
1841
|
var canPayWithVault = canUseVault(response);
|
|
1994
1842
|
var shouldLoadPreCheckoutModal = canPayWithVault || canPayWithApplePay;
|
|
1995
|
-
|
|
1996
1843
|
if (!shouldLoadPreCheckoutModal) {
|
|
1997
1844
|
inlineInstance.newTransaction({
|
|
1998
1845
|
inlineTransaction: transaction,
|
|
@@ -2008,11 +1855,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2008
1855
|
canPayWithVault: canPayWithVault,
|
|
2009
1856
|
canPayWithApplePay: canPayWithApplePay
|
|
2010
1857
|
});
|
|
1858
|
+
|
|
2011
1859
|
/**
|
|
2012
1860
|
* We attempt to mount the apple pay button only
|
|
2013
1861
|
* when the customer can pay with apple pay.
|
|
2014
1862
|
*/
|
|
2015
|
-
|
|
2016
1863
|
if (canPayWithApplePay) {
|
|
2017
1864
|
inlineInstance.paymentRequestContainer = getPreCheckoutModalPaymentRequestContainer(inlineInstance.preCheckoutModal);
|
|
2018
1865
|
mountPaymentRequestButtons(inlineInstance.paymentRequestContainer, {
|
|
@@ -2067,15 +1914,12 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2067
1914
|
key: "registerPreCheckoutModalEventListeners",
|
|
2068
1915
|
value: function registerPreCheckoutModalEventListeners() {
|
|
2069
1916
|
var _this2 = this;
|
|
2070
|
-
|
|
2071
1917
|
var timer;
|
|
2072
1918
|
var isShortTouch = false;
|
|
2073
1919
|
var shortTouchDurationInMs = 125;
|
|
2074
1920
|
var activeTransaction = this.activeTransaction();
|
|
2075
|
-
|
|
2076
1921
|
var handleTouchStart = function handleTouchStart(event) {
|
|
2077
1922
|
event.preventDefault();
|
|
2078
|
-
|
|
2079
1923
|
if (!isShortTouch) {
|
|
2080
1924
|
isShortTouch = true;
|
|
2081
1925
|
timer = setTimeout(function () {
|
|
@@ -2083,51 +1927,38 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2083
1927
|
}, shortTouchDurationInMs);
|
|
2084
1928
|
}
|
|
2085
1929
|
};
|
|
2086
|
-
|
|
2087
1930
|
var handleClosePreCheckoutModal = function handleClosePreCheckoutModal(event) {
|
|
2088
1931
|
if (event.target && event.target.isSameNode(inlineInstance.preCheckoutModal) && isShortTouch) {
|
|
2089
1932
|
clearTimeout(timer);
|
|
2090
1933
|
inlineInstance.closePreCheckoutModal();
|
|
2091
|
-
|
|
2092
1934
|
if (activeTransaction) {
|
|
2093
1935
|
activeTransaction.cancel();
|
|
2094
1936
|
}
|
|
2095
1937
|
}
|
|
2096
|
-
|
|
2097
1938
|
isShortTouch = false;
|
|
2098
1939
|
};
|
|
2099
|
-
|
|
2100
1940
|
document.addEventListener('touchstart', handleTouchStart, true);
|
|
2101
1941
|
document.addEventListener('touchend', handleClosePreCheckoutModal, true);
|
|
2102
1942
|
var openPaystackPopButton = getPreCheckoutModalOpenPaystackPopButton(this.preCheckoutModal);
|
|
2103
|
-
|
|
2104
1943
|
if (openPaystackPopButton) {
|
|
2105
1944
|
openPaystackPopButton.onclick = function () {
|
|
2106
1945
|
_this2.closePreCheckoutModal();
|
|
2107
|
-
|
|
2108
1946
|
_this2.animateCheckoutIn();
|
|
2109
1947
|
};
|
|
2110
1948
|
}
|
|
2111
|
-
|
|
2112
1949
|
var payWithVaultButton = getPreCheckoutModalPayWithVaultButton(this.preCheckoutModal);
|
|
2113
|
-
|
|
2114
1950
|
if (payWithVaultButton) {
|
|
2115
1951
|
payWithVaultButton.onclick = function () {
|
|
2116
1952
|
_this2.closePreCheckoutModal();
|
|
2117
|
-
|
|
2118
1953
|
_this2.animateCheckoutIn();
|
|
2119
|
-
|
|
2120
1954
|
_this2.checkoutIframe.contentWindow.postMessage({
|
|
2121
1955
|
type: 'inline:pay-with-vault'
|
|
2122
1956
|
}, '*');
|
|
2123
1957
|
};
|
|
2124
1958
|
}
|
|
2125
|
-
|
|
2126
1959
|
var preCheckoutModalCloseButton = getPreCheckoutModalCloseButton(this.preCheckoutModal);
|
|
2127
|
-
|
|
2128
1960
|
preCheckoutModalCloseButton.onclick = function () {
|
|
2129
1961
|
_this2.sendAnalyticsEventToCheckout(analyticsActions.TRACK_CHECKOUT_CLOSED);
|
|
2130
|
-
|
|
2131
1962
|
_this2.closePreCheckoutModalAndCancelTransaction();
|
|
2132
1963
|
};
|
|
2133
1964
|
}
|
|
@@ -2137,7 +1968,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2137
1968
|
if (!this.preCheckoutModal) {
|
|
2138
1969
|
return;
|
|
2139
1970
|
}
|
|
2140
|
-
|
|
2141
1971
|
if (transactionStatus === 'failed') {
|
|
2142
1972
|
showErrorInPreCheckoutModal(this.preCheckoutModal);
|
|
2143
1973
|
animatePreCheckoutModalIn(this.preCheckoutModal);
|
|
@@ -2152,11 +1982,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2152
1982
|
value: function closePreCheckoutModalAndCancelTransaction() {
|
|
2153
1983
|
if (this.preCheckoutModal) {
|
|
2154
1984
|
this.cancelTransaction();
|
|
2155
|
-
|
|
2156
1985
|
if (this.checkoutIframe && this.checkoutIframe.contentWindow) {
|
|
2157
1986
|
this.checkoutIframe.contentWindow.postMessage('close', '*');
|
|
2158
1987
|
}
|
|
2159
|
-
|
|
2160
1988
|
this.closePreCheckoutModal();
|
|
2161
1989
|
}
|
|
2162
1990
|
}
|
|
@@ -2164,19 +1992,15 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2164
1992
|
key: "newTransaction",
|
|
2165
1993
|
value: function newTransaction(_ref2) {
|
|
2166
1994
|
var preload = _ref2.preload,
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
1995
|
+
inlineTransaction = _ref2.inlineTransaction,
|
|
1996
|
+
transactionData = _ref2.transactionData,
|
|
1997
|
+
options = _objectWithoutProperties(_ref2, _excluded);
|
|
2171
1998
|
var hasPaymentRequestButtons = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2172
|
-
|
|
2173
1999
|
if (this.activeTransaction() && !hasPaymentRequestButtons) {
|
|
2174
2000
|
this.activeTransaction().cancel();
|
|
2175
2001
|
}
|
|
2176
|
-
|
|
2177
2002
|
if (inlineTransaction && transactionData) {
|
|
2178
2003
|
this.transactions.push(inlineTransaction);
|
|
2179
|
-
|
|
2180
2004
|
if (!this.isDeprecatedApi) {
|
|
2181
2005
|
// TODO: reintroduce this when we resolve checkout caching issues
|
|
2182
2006
|
// this.open({ transactionData }, preload);
|
|
@@ -2185,15 +2009,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2185
2009
|
language: inlineTransaction.urlParameters.language
|
|
2186
2010
|
}, preload);
|
|
2187
2011
|
}
|
|
2188
|
-
|
|
2189
2012
|
return inlineTransaction;
|
|
2190
2013
|
}
|
|
2191
|
-
|
|
2192
2014
|
var resumableTransaction = findResumableTransaction(this.transactions, inlineTransaction ? inlineTransaction.parameters : options);
|
|
2193
|
-
|
|
2194
2015
|
if (resumableTransaction) {
|
|
2195
2016
|
resumableTransaction.isActive = true;
|
|
2196
|
-
|
|
2197
2017
|
if (!this.isDeprecatedApi) {
|
|
2198
2018
|
// We could potentially optimize this also by checking if there is a `response` property on `resumableTransaction`
|
|
2199
2019
|
this.open({
|
|
@@ -2201,58 +2021,47 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2201
2021
|
language: resumableTransaction.urlParameters.language
|
|
2202
2022
|
}, preload);
|
|
2203
2023
|
}
|
|
2204
|
-
|
|
2205
2024
|
return resumableTransaction;
|
|
2206
2025
|
}
|
|
2207
|
-
|
|
2208
2026
|
var transaction = inlineTransaction || new InlineTransaction(options);
|
|
2209
2027
|
var params = transaction.accessCode ? {
|
|
2210
2028
|
accessCode: transaction.accessCode,
|
|
2211
2029
|
language: transaction.urlParameters.language
|
|
2212
2030
|
} : transaction.urlParameters;
|
|
2213
2031
|
this.transactions.push(transaction);
|
|
2214
|
-
|
|
2215
2032
|
if (!this.isDeprecatedApi) {
|
|
2216
2033
|
this.open(params, preload);
|
|
2217
2034
|
}
|
|
2218
|
-
|
|
2219
2035
|
return transaction;
|
|
2220
2036
|
}
|
|
2221
2037
|
}, {
|
|
2222
2038
|
key: "preloadTransaction",
|
|
2223
2039
|
value: function preloadTransaction(options) {
|
|
2224
2040
|
var _this3 = this;
|
|
2225
|
-
|
|
2226
2041
|
this.newTransaction(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
2227
2042
|
preload: true
|
|
2228
2043
|
}));
|
|
2229
|
-
|
|
2230
2044
|
var loadPopup = function loadPopup() {
|
|
2231
2045
|
return _this3.animateCheckoutIn();
|
|
2232
2046
|
};
|
|
2233
|
-
|
|
2234
2047
|
return loadPopup;
|
|
2235
2048
|
}
|
|
2236
2049
|
}, {
|
|
2237
2050
|
key: "paymentRequest",
|
|
2238
2051
|
value: function paymentRequest(parameters) {
|
|
2239
2052
|
var container = parameters.container,
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2053
|
+
styles = parameters.styles,
|
|
2054
|
+
onElementsMount = parameters.onElementsMount,
|
|
2055
|
+
transactionParams = _objectWithoutProperties(parameters, _excluded2);
|
|
2244
2056
|
inlineInstance = this;
|
|
2245
2057
|
return new Promise(function (resolve, reject) {
|
|
2246
2058
|
var loadPaystackCheckoutButton = document.querySelector("#".concat(parameters.loadPaystackCheckoutButton));
|
|
2247
|
-
|
|
2248
2059
|
if (inlineInstance.activeTransaction()) {
|
|
2249
2060
|
inlineInstance.activeTransaction().cancel();
|
|
2250
2061
|
}
|
|
2251
|
-
|
|
2252
2062
|
if (!(container && getPaymentRequestContainer(container))) {
|
|
2253
2063
|
handleError('A container is required to mount the payment request button');
|
|
2254
2064
|
}
|
|
2255
|
-
|
|
2256
2065
|
inlineInstance.paymentRequestContainer = getPaymentRequestContainer(container);
|
|
2257
2066
|
var resumableTransaction = findResumableTransaction(inlineInstance.transactions, transactionParams);
|
|
2258
2067
|
var transaction = resumableTransaction || new InlineTransaction(transactionParams);
|
|
@@ -2274,9 +2083,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2274
2083
|
} else {
|
|
2275
2084
|
inlineInstance.transactions.push(transaction);
|
|
2276
2085
|
}
|
|
2277
|
-
|
|
2278
2086
|
inlineInstance.registerPaymentRequestEventListeners();
|
|
2279
|
-
|
|
2280
2087
|
if (loadPaystackCheckoutButton) {
|
|
2281
2088
|
var loadPopup = inlineInstance.preloadTransaction({
|
|
2282
2089
|
inlineTransaction: transaction,
|
|
@@ -2284,7 +2091,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2284
2091
|
});
|
|
2285
2092
|
loadPaystackCheckoutButton.onclick = loadPopup;
|
|
2286
2093
|
}
|
|
2287
|
-
|
|
2288
2094
|
resolve(transaction);
|
|
2289
2095
|
});
|
|
2290
2096
|
}).catch(function (error) {
|
|
@@ -2300,9 +2106,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2300
2106
|
key: "registerApplePayEventListener",
|
|
2301
2107
|
value: function registerApplePayEventListener() {
|
|
2302
2108
|
var _this4 = this;
|
|
2303
|
-
|
|
2304
2109
|
var applePayButton = getApplePayButton(this.paymentRequestContainer);
|
|
2305
|
-
|
|
2306
2110
|
if (applePayButton) {
|
|
2307
2111
|
applePayButton.onclick = function () {
|
|
2308
2112
|
return _this4.startApplePay();
|
|
@@ -2314,7 +2118,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2314
2118
|
value: function registerPaymentRequestEventListeners() {
|
|
2315
2119
|
var transaction = this.activeTransaction();
|
|
2316
2120
|
var applePayButton = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2317
|
-
|
|
2318
2121
|
if (transaction && applePayButton) {
|
|
2319
2122
|
this.registerApplePayEventListener();
|
|
2320
2123
|
} else if (this.paymentRequestContainer) {
|
|
@@ -2325,10 +2128,8 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2325
2128
|
key: "startApplePay",
|
|
2326
2129
|
value: function startApplePay() {
|
|
2327
2130
|
var _this5 = this;
|
|
2328
|
-
|
|
2329
2131
|
var paymentMethod = 'apple pay';
|
|
2330
2132
|
var transaction = this.activeTransaction();
|
|
2331
|
-
|
|
2332
2133
|
if (transaction) {
|
|
2333
2134
|
var paymentAttemptAnalyticsPayload = {
|
|
2334
2135
|
channel: 'apple_pay',
|
|
@@ -2343,7 +2144,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2343
2144
|
timeSpent: transaction.getTimeSpent()
|
|
2344
2145
|
};
|
|
2345
2146
|
var pendingPreCheckoutModalStatus = null;
|
|
2346
|
-
|
|
2347
2147
|
try {
|
|
2348
2148
|
transaction.logAttempt(paymentMethod);
|
|
2349
2149
|
this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, paymentAttemptAnalyticsPayload);
|
|
@@ -2354,11 +2154,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2354
2154
|
interval: transaction.response.plan_details && transaction.response.plan_details.interval
|
|
2355
2155
|
});
|
|
2356
2156
|
var applePaySession = new window.ApplePaySession(config.applePayVersion, applePayPaymentRequest);
|
|
2357
|
-
|
|
2358
2157
|
if (inlineInstance.preCheckoutModal) {
|
|
2359
2158
|
hidePreCheckoutModal(inlineInstance.preCheckoutModal);
|
|
2360
2159
|
}
|
|
2361
|
-
|
|
2362
2160
|
applePaySession.onvalidatemerchant = function (_ref3) {
|
|
2363
2161
|
var validationURL = _ref3.validationURL;
|
|
2364
2162
|
var validateSession = validateApplePaySession({
|
|
@@ -2373,14 +2171,12 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2373
2171
|
} else {
|
|
2374
2172
|
applePaySession.completeMerchantValidation(response.data);
|
|
2375
2173
|
}
|
|
2376
|
-
|
|
2377
2174
|
transaction.logValidationResponse(response.message);
|
|
2378
2175
|
}).catch(function (error) {
|
|
2379
2176
|
transaction.onSetupError(error);
|
|
2380
2177
|
pendingPreCheckoutModalStatus = 'failed';
|
|
2381
2178
|
});
|
|
2382
2179
|
};
|
|
2383
|
-
|
|
2384
2180
|
applePaySession.oncancel = function () {
|
|
2385
2181
|
if (inlineInstance.preCheckoutModal) {
|
|
2386
2182
|
if (pendingPreCheckoutModalStatus) {
|
|
@@ -2393,7 +2189,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2393
2189
|
transaction.onCancel();
|
|
2394
2190
|
}
|
|
2395
2191
|
};
|
|
2396
|
-
|
|
2397
2192
|
applePaySession.onpaymentauthorized = function (_ref4) {
|
|
2398
2193
|
var payment = _ref4.payment;
|
|
2399
2194
|
var charge = chargeApplePay({
|
|
@@ -2402,23 +2197,19 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2402
2197
|
});
|
|
2403
2198
|
charge.then(function (response) {
|
|
2404
2199
|
transaction.logAPIResponse(response, paymentMethod);
|
|
2405
|
-
|
|
2406
2200
|
if (response.status === 'success') {
|
|
2407
2201
|
applePaySession.completePayment(applePaySession.STATUS_SUCCESS);
|
|
2408
2202
|
transaction.onSuccess(response);
|
|
2409
|
-
|
|
2410
2203
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, paymentCompleteAnalyticsPayload);
|
|
2411
2204
|
} else {
|
|
2412
2205
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2413
2206
|
transaction.onSetupError(response);
|
|
2414
2207
|
pendingPreCheckoutModalStatus = 'failed';
|
|
2415
|
-
|
|
2416
2208
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2417
2209
|
channel: 'apple_pay',
|
|
2418
2210
|
message: response && response.message || 'Transaction attempt failed'
|
|
2419
2211
|
});
|
|
2420
2212
|
}
|
|
2421
|
-
|
|
2422
2213
|
if (response.status === 'success') {
|
|
2423
2214
|
inlineInstance.closePreCheckoutModal(response.status);
|
|
2424
2215
|
}
|
|
@@ -2426,14 +2217,12 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2426
2217
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2427
2218
|
transaction.onSetupError(error);
|
|
2428
2219
|
pendingPreCheckoutModalStatus = 'failed';
|
|
2429
|
-
|
|
2430
2220
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2431
2221
|
channel: 'apple_pay',
|
|
2432
2222
|
message: error && error.message || 'Error occurred'
|
|
2433
2223
|
});
|
|
2434
2224
|
});
|
|
2435
2225
|
};
|
|
2436
|
-
|
|
2437
2226
|
applePaySession.begin();
|
|
2438
2227
|
} catch (error) {
|
|
2439
2228
|
transaction.onSetupError(error);
|
|
@@ -2448,9 +2237,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2448
2237
|
value: function resumeTransaction(accessCode) {
|
|
2449
2238
|
var callbacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2450
2239
|
var onSuccess = callbacks.onSuccess,
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2240
|
+
onCancel = callbacks.onCancel,
|
|
2241
|
+
onLoad = callbacks.onLoad,
|
|
2242
|
+
onError = callbacks.onError;
|
|
2454
2243
|
return this.newTransaction({
|
|
2455
2244
|
accessCode: accessCode,
|
|
2456
2245
|
onSuccess: onSuccess,
|
|
@@ -2474,7 +2263,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2474
2263
|
var transaction = this.transactions.find(function (t) {
|
|
2475
2264
|
return t.id === id;
|
|
2476
2265
|
}) || this.activeTransaction();
|
|
2477
|
-
|
|
2478
2266
|
if (transaction) {
|
|
2479
2267
|
transaction.cancel();
|
|
2480
2268
|
this.close();
|
|
@@ -2486,23 +2274,20 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2486
2274
|
if (!event) {
|
|
2487
2275
|
return;
|
|
2488
2276
|
}
|
|
2489
|
-
|
|
2490
2277
|
var activeTransaction = this.activeTransaction();
|
|
2491
|
-
|
|
2492
2278
|
try {
|
|
2493
2279
|
var actualEvent = event.data || event.message;
|
|
2494
2280
|
var eventType = actualEvent.event,
|
|
2495
|
-
|
|
2496
|
-
|
|
2281
|
+
eventData = actualEvent.data;
|
|
2497
2282
|
if (eventType) {
|
|
2498
2283
|
switch (eventType) {
|
|
2499
2284
|
case 'loaded:checkout':
|
|
2500
2285
|
this.isLoaded = true;
|
|
2501
|
-
|
|
2502
2286
|
if (activeTransaction) {
|
|
2503
2287
|
var checkoutIframe = this.checkoutIframe;
|
|
2504
2288
|
var urlParameters = activeTransaction.urlParameters,
|
|
2505
|
-
|
|
2289
|
+
response = activeTransaction.response;
|
|
2290
|
+
// TODO: reintroduce this when we resolve checkout caching issues
|
|
2506
2291
|
// const params = response
|
|
2507
2292
|
// ? { transactionData: response }
|
|
2508
2293
|
// : urlParameters;
|
|
@@ -2516,77 +2301,60 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2516
2301
|
urlParameters: params
|
|
2517
2302
|
});
|
|
2518
2303
|
}
|
|
2519
|
-
|
|
2520
2304
|
break;
|
|
2521
|
-
|
|
2522
2305
|
case 'loaded:transaction':
|
|
2523
2306
|
hideLoader(this.backgroundIframe);
|
|
2524
|
-
|
|
2525
2307
|
if (this.preCheckoutModal) {
|
|
2526
2308
|
this.openPreCheckoutModal();
|
|
2527
2309
|
}
|
|
2528
|
-
|
|
2529
2310
|
activeTransaction.onLoad(eventData);
|
|
2530
2311
|
break;
|
|
2531
|
-
|
|
2532
2312
|
case 'error':
|
|
2533
2313
|
{
|
|
2534
2314
|
var error = eventData;
|
|
2535
|
-
|
|
2536
2315
|
if (error.type === 'setup') {
|
|
2537
2316
|
activeTransaction.onSetupError(eventData);
|
|
2538
2317
|
} else {
|
|
2539
2318
|
activeTransaction.logError(eventData);
|
|
2540
2319
|
}
|
|
2541
|
-
|
|
2542
2320
|
break;
|
|
2543
2321
|
}
|
|
2544
|
-
|
|
2545
2322
|
case 'cancel':
|
|
2546
2323
|
case 'close':
|
|
2547
2324
|
{
|
|
2548
2325
|
this.close();
|
|
2549
2326
|
var status = eventData && eventData.status;
|
|
2550
|
-
|
|
2551
2327
|
if (status) {
|
|
2552
2328
|
activeTransaction.setStatus(status);
|
|
2553
2329
|
}
|
|
2554
|
-
|
|
2555
2330
|
var hasPaymentRequestButtons = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2556
2331
|
var shouldSetCurrentTransactionAsInactive = !(hasPaymentRequestButtons && !this.preCheckoutModal);
|
|
2557
|
-
|
|
2558
2332
|
if (shouldSetCurrentTransactionAsInactive) {
|
|
2559
2333
|
activeTransaction.isActive = false;
|
|
2560
2334
|
}
|
|
2561
|
-
|
|
2562
2335
|
activeTransaction.onCancel();
|
|
2563
2336
|
break;
|
|
2564
2337
|
}
|
|
2565
|
-
|
|
2566
2338
|
case 'transfer:pending':
|
|
2567
2339
|
{
|
|
2568
2340
|
this.close();
|
|
2569
|
-
|
|
2570
2341
|
var _status = eventData && eventData.status;
|
|
2571
|
-
|
|
2572
2342
|
if (_status) {
|
|
2573
2343
|
activeTransaction.setStatus(_status);
|
|
2574
2344
|
}
|
|
2575
|
-
|
|
2576
2345
|
activeTransaction.onBankTransferConfirmationPending();
|
|
2577
2346
|
break;
|
|
2578
2347
|
}
|
|
2579
|
-
|
|
2580
2348
|
case 'success':
|
|
2581
2349
|
this.close();
|
|
2582
2350
|
activeTransaction.onSuccess(eventData);
|
|
2583
2351
|
break;
|
|
2584
|
-
|
|
2585
2352
|
default:
|
|
2586
2353
|
break;
|
|
2587
2354
|
}
|
|
2588
2355
|
}
|
|
2589
|
-
} catch (error) {
|
|
2356
|
+
} catch (error) {
|
|
2357
|
+
// do nothing
|
|
2590
2358
|
}
|
|
2591
2359
|
}
|
|
2592
2360
|
}, {
|
|
@@ -2594,19 +2362,15 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2594
2362
|
value: function respondToEmbedEvents(event) {
|
|
2595
2363
|
var activeTransaction = this.activeTransaction();
|
|
2596
2364
|
var eventData = event.data || event.message;
|
|
2597
|
-
|
|
2598
2365
|
if (eventData && (typeof eventData === 'string' || eventData instanceof String)) {
|
|
2599
2366
|
var response = parseResponse(eventData);
|
|
2600
2367
|
var oldCheckoutCloseResponse = response && response.action === 'PaystackClose';
|
|
2601
|
-
|
|
2602
2368
|
if (oldCheckoutCloseResponse) {
|
|
2603
2369
|
var chargeResponse = response.data;
|
|
2604
|
-
|
|
2605
2370
|
if (chargeResponse) {
|
|
2606
2371
|
activeTransaction.onSuccess(eventData);
|
|
2607
2372
|
}
|
|
2608
2373
|
}
|
|
2609
|
-
|
|
2610
2374
|
if (response.action === 'PaystackTLSClose') {
|
|
2611
2375
|
activeTransaction.cancel();
|
|
2612
2376
|
}
|
|
@@ -2616,18 +2380,15 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2616
2380
|
key: "animateCheckoutIn",
|
|
2617
2381
|
value: function animateCheckoutIn$1() {
|
|
2618
2382
|
var _this6 = this;
|
|
2619
|
-
|
|
2620
2383
|
if (!this.isOpen) {
|
|
2621
2384
|
var checkoutIframe = this.checkoutIframe,
|
|
2622
|
-
|
|
2623
|
-
|
|
2385
|
+
backgroundIframe = this.backgroundIframe;
|
|
2624
2386
|
animateCheckoutIn({
|
|
2625
2387
|
checkoutIframe: checkoutIframe,
|
|
2626
2388
|
backgroundIframe: backgroundIframe
|
|
2627
2389
|
}).then(function () {
|
|
2628
2390
|
_this6.checkoutIframe.contentWindow.postMessage('render', '*');
|
|
2629
2391
|
});
|
|
2630
|
-
|
|
2631
2392
|
this.isOpen = true;
|
|
2632
2393
|
}
|
|
2633
2394
|
}
|
|
@@ -2637,13 +2398,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2637
2398
|
if (!urlParameters) {
|
|
2638
2399
|
return;
|
|
2639
2400
|
}
|
|
2640
|
-
|
|
2641
2401
|
var checkoutIframe = this.checkoutIframe;
|
|
2642
2402
|
notifyIframeToUpdateURL({
|
|
2643
2403
|
checkoutIframe: checkoutIframe,
|
|
2644
2404
|
urlParameters: urlParameters
|
|
2645
2405
|
});
|
|
2646
|
-
|
|
2647
2406
|
if (!preload) {
|
|
2648
2407
|
this.animateCheckoutIn();
|
|
2649
2408
|
}
|
|
@@ -2652,13 +2411,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2652
2411
|
key: "close",
|
|
2653
2412
|
value: function close() {
|
|
2654
2413
|
var _this7 = this;
|
|
2655
|
-
|
|
2656
2414
|
if (!this.isOpen) {
|
|
2657
2415
|
return;
|
|
2658
2416
|
}
|
|
2659
|
-
|
|
2660
2417
|
var checkoutIframe = this.checkoutIframe,
|
|
2661
|
-
|
|
2418
|
+
backgroundIframe = this.backgroundIframe;
|
|
2662
2419
|
animateCheckoutOut({
|
|
2663
2420
|
checkoutIframe: checkoutIframe,
|
|
2664
2421
|
backgroundIframe: backgroundIframe
|
|
@@ -2677,23 +2434,19 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2677
2434
|
value: function setup(parameters) {
|
|
2678
2435
|
var isDeprecatedApi = true;
|
|
2679
2436
|
var isEmbed = parameters && parameters.container;
|
|
2680
|
-
|
|
2681
2437
|
if (!inlineInstance) {
|
|
2682
2438
|
inlineInstance = new Inline({
|
|
2683
2439
|
isDeprecatedApi: isDeprecatedApi,
|
|
2684
2440
|
isEmbed: isEmbed
|
|
2685
2441
|
});
|
|
2686
2442
|
}
|
|
2687
|
-
|
|
2688
2443
|
printDeprecationNotice('PaystackPop.setup()', 'new PaystackPop()', 'Please consult our documentation at https://developers.paystack.co/docs/paystack-inline');
|
|
2689
2444
|
var transaction = inlineInstance.newTransaction(parameters, 'deprecated');
|
|
2690
2445
|
var urlParameters = transaction.urlParameters;
|
|
2691
|
-
|
|
2692
2446
|
if (isEmbed) {
|
|
2693
2447
|
var inlineUrl = "".concat(config.siteUrl, "/assets/payment/production/inline.html?").concat(serialize(urlParameters));
|
|
2694
2448
|
var iframe = mountEmbedCheckoutIframe(inlineInstance.id, inlineUrl);
|
|
2695
2449
|
appendIframeToContainer(parameters.container, iframe);
|
|
2696
|
-
|
|
2697
2450
|
iframe.onload = function onLoad() {
|
|
2698
2451
|
iframe.contentWindow.postMessage("PaystackOpen ".concat(inlineInstance.id), '*');
|
|
2699
2452
|
animateEmbedCheckoutIn(iframe);
|
|
@@ -2705,22 +2458,16 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2705
2458
|
inlineInstance.open(urlParameters);
|
|
2706
2459
|
};
|
|
2707
2460
|
}
|
|
2708
|
-
|
|
2709
2461
|
return transaction;
|
|
2710
2462
|
}
|
|
2711
2463
|
}]);
|
|
2712
|
-
|
|
2713
|
-
return Inline;
|
|
2714
2464
|
}();
|
|
2715
|
-
|
|
2716
2465
|
if (scriptCanUseDataAttributes()) {
|
|
2717
2466
|
var parameters = getDataAttributesAsParameters();
|
|
2718
2467
|
var parentForm = getSourceScript().parentElement;
|
|
2719
|
-
|
|
2720
2468
|
if (!inlineInstance) {
|
|
2721
2469
|
inlineInstance = new Inline();
|
|
2722
2470
|
}
|
|
2723
|
-
|
|
2724
2471
|
var transaction;
|
|
2725
2472
|
var inlineButton = mountLazyInlineButton({
|
|
2726
2473
|
inlineId: inlineInstance.id,
|
|
@@ -2734,7 +2481,6 @@ if (scriptCanUseDataAttributes()) {
|
|
|
2734
2481
|
});
|
|
2735
2482
|
inlineButton.addEventListener('click', function (e) {
|
|
2736
2483
|
e.preventDefault();
|
|
2737
|
-
|
|
2738
2484
|
if (!transaction) {
|
|
2739
2485
|
transaction = inlineInstance.newTransaction(_objectSpread2(_objectSpread2({}, parameters), {}, {
|
|
2740
2486
|
onSuccess: function onSuccess(response) {
|