@paystack/inline-js 2.23.0-dev.2 → 2.23.0-dev.3
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 +119 -399
- package/es/inline.js +119 -399
- package/lib/inline.js +119 -399
- 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,7 +938,6 @@ 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');
|
|
@@ -1096,7 +974,6 @@ function showErrorInPreCheckoutModal(modal) {
|
|
|
1096
974
|
if (!modal) {
|
|
1097
975
|
return;
|
|
1098
976
|
}
|
|
1099
|
-
|
|
1100
977
|
var appleIcon = modal.querySelector('#apple-pay-mark--light');
|
|
1101
978
|
appleIcon.innerHTML = errorIcon;
|
|
1102
979
|
var applePayDescription = modal.querySelector('#apple-pay-description');
|
|
@@ -1333,33 +1210,32 @@ function validate(args) {
|
|
|
1333
1210
|
this.message = message;
|
|
1334
1211
|
this.issues = issues || [];
|
|
1335
1212
|
}
|
|
1336
|
-
|
|
1337
1213
|
if (!args || _typeof(args) !== 'object') {
|
|
1338
1214
|
throw new ValidationError('Transaction parameters should be a non-empty object');
|
|
1339
1215
|
}
|
|
1216
|
+
var transactionParameters = args;
|
|
1340
1217
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1218
|
+
// If it's a transaction resumption, move on
|
|
1343
1219
|
if ('accessCode' in transactionParameters) {
|
|
1344
1220
|
var accessCode = transactionParameters.accessCode;
|
|
1345
1221
|
return {
|
|
1346
1222
|
accessCode: accessCode
|
|
1347
1223
|
};
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1224
|
+
}
|
|
1350
1225
|
|
|
1226
|
+
// Filter unneeded parameters
|
|
1351
1227
|
Object.keys(transactionParameters).forEach(function (key) {
|
|
1352
1228
|
var usedParameter = allParameters.find(function (parameter) {
|
|
1353
1229
|
return parameter.value === key;
|
|
1354
1230
|
}) !== undefined;
|
|
1355
|
-
|
|
1356
1231
|
if (!usedParameter) {
|
|
1357
1232
|
delete transactionParameters[key];
|
|
1358
1233
|
}
|
|
1359
1234
|
});
|
|
1360
1235
|
var transactionKeys = Object.keys(transactionParameters);
|
|
1361
|
-
var validationErrors = [];
|
|
1236
|
+
var validationErrors = [];
|
|
1362
1237
|
|
|
1238
|
+
// Check for required parameters
|
|
1363
1239
|
var requiredParameters = allParameters.filter(function (param) {
|
|
1364
1240
|
return param.required;
|
|
1365
1241
|
});
|
|
@@ -1368,50 +1244,44 @@ function validate(args) {
|
|
|
1368
1244
|
var parameterHasAlternative = key.or ? key.or.some(function (option) {
|
|
1369
1245
|
return transactionParameters[option];
|
|
1370
1246
|
}) : null;
|
|
1371
|
-
|
|
1372
1247
|
if (parameterIsMissing && !parameterHasAlternative) {
|
|
1373
1248
|
validationErrors.push({
|
|
1374
1249
|
message: "Required parameter missing: ".concat(key.value)
|
|
1375
1250
|
});
|
|
1376
1251
|
}
|
|
1377
|
-
});
|
|
1252
|
+
});
|
|
1378
1253
|
|
|
1254
|
+
// Check for validity
|
|
1379
1255
|
transactionKeys.forEach(function (key) {
|
|
1380
1256
|
var parameterValue = transactionParameters[key];
|
|
1381
1257
|
var parameterObject = allParameters.find(function (parameter) {
|
|
1382
1258
|
return parameter.value === key;
|
|
1383
1259
|
});
|
|
1384
|
-
|
|
1385
1260
|
var providedType = _typeof(parameterValue);
|
|
1386
|
-
|
|
1387
1261
|
if (providedType === 'object' && Array.isArray(parameterValue)) {
|
|
1388
1262
|
providedType = 'array';
|
|
1389
1263
|
}
|
|
1390
|
-
|
|
1391
1264
|
var invalidType = parameterObject.types.indexOf(providedType) <= -1;
|
|
1392
|
-
|
|
1393
1265
|
if (invalidType) {
|
|
1394
1266
|
validationErrors.push({
|
|
1395
1267
|
message: "Invalid parameter type: ".concat(key),
|
|
1396
1268
|
validTypes: parameterObject.types
|
|
1397
1269
|
});
|
|
1398
1270
|
}
|
|
1399
|
-
});
|
|
1271
|
+
});
|
|
1400
1272
|
|
|
1273
|
+
// Override keys where necessary
|
|
1401
1274
|
transactionKeys.forEach(function (key) {
|
|
1402
1275
|
var parameterObject = allParameters.find(function (parameter) {
|
|
1403
1276
|
return parameter.value === key;
|
|
1404
1277
|
});
|
|
1405
|
-
|
|
1406
1278
|
if (parameterObject.override) {
|
|
1407
1279
|
delete transactionParameters[parameterObject.override];
|
|
1408
1280
|
}
|
|
1409
1281
|
});
|
|
1410
|
-
|
|
1411
1282
|
if (validationErrors.length) {
|
|
1412
1283
|
throw new ValidationError('Invalid transaction parameters', validationErrors);
|
|
1413
1284
|
}
|
|
1414
|
-
|
|
1415
1285
|
return transactionParameters;
|
|
1416
1286
|
}
|
|
1417
1287
|
|
|
@@ -1420,31 +1290,26 @@ function splitURL(url) {
|
|
|
1420
1290
|
if ((url === null || url === void 0 ? void 0 : url.length) > 500) {
|
|
1421
1291
|
return url.split('?')[0];
|
|
1422
1292
|
}
|
|
1423
|
-
|
|
1424
1293
|
return url;
|
|
1425
1294
|
}
|
|
1426
|
-
|
|
1427
1295
|
function getReferrer() {
|
|
1428
1296
|
var _window$location = window.location,
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1297
|
+
_window$location$href = _window$location.href,
|
|
1298
|
+
href = _window$location$href === void 0 ? '' : _window$location$href,
|
|
1299
|
+
_window$location$ance = _window$location.ancestorOrigins,
|
|
1300
|
+
ancestorOrigins = _window$location$ance === void 0 ? [] : _window$location$ance;
|
|
1433
1301
|
return [href].concat(_toConsumableArray(ancestorOrigins)).map(splitURL).join(',');
|
|
1434
1302
|
}
|
|
1435
1303
|
|
|
1436
1304
|
function buildQuery(parameters) {
|
|
1437
1305
|
var formattedParameters = _objectSpread2({}, parameters);
|
|
1438
|
-
|
|
1439
1306
|
formattedParameters.metadata = parameters.metadata || {};
|
|
1440
1307
|
formattedParameters.metadata.referrer = getReferrer();
|
|
1441
1308
|
formattedParameters.metadata = JSON.stringify(formattedParameters.metadata);
|
|
1442
1309
|
formattedParameters.mode = 'popup';
|
|
1443
|
-
|
|
1444
1310
|
if (parameters.split && typeof parameters.split !== 'string') {
|
|
1445
1311
|
formattedParameters.split = JSON.stringify(formattedParameters.split);
|
|
1446
1312
|
}
|
|
1447
|
-
|
|
1448
1313
|
var parametersToChange = [{
|
|
1449
1314
|
to: 'firstname',
|
|
1450
1315
|
from: 'firstName'
|
|
@@ -1481,21 +1346,20 @@ function buildQuery(parameters) {
|
|
|
1481
1346
|
}, {
|
|
1482
1347
|
to: 'ref',
|
|
1483
1348
|
from: 'reference'
|
|
1484
|
-
}];
|
|
1349
|
+
}];
|
|
1350
|
+
|
|
1351
|
+
// handle very old case of people disabling channels by sending card/bank params
|
|
1485
1352
|
|
|
1486
1353
|
if (formattedParameters.card !== undefined && ['false', false].indexOf(formattedParameters.card) > -1) {
|
|
1487
1354
|
formattedParameters.channels = ['bank'];
|
|
1488
1355
|
delete formattedParameters.card;
|
|
1489
1356
|
}
|
|
1490
|
-
|
|
1491
1357
|
if (formattedParameters.bank !== undefined && ['false', false].indexOf(formattedParameters.bank) > -1) {
|
|
1492
1358
|
formattedParameters.channels = ['card'];
|
|
1493
1359
|
delete formattedParameters.bank;
|
|
1494
1360
|
}
|
|
1495
|
-
|
|
1496
1361
|
parametersToChange.forEach(function (key) {
|
|
1497
1362
|
var hasValue = formattedParameters[key.from];
|
|
1498
|
-
|
|
1499
1363
|
if (hasValue) {
|
|
1500
1364
|
formattedParameters[key.to] = formattedParameters[key.from];
|
|
1501
1365
|
delete formattedParameters[key.from];
|
|
@@ -1511,22 +1375,23 @@ function buildQuery(parameters) {
|
|
|
1511
1375
|
}
|
|
1512
1376
|
|
|
1513
1377
|
/* eslint-env browser */
|
|
1378
|
+
|
|
1514
1379
|
var iOSDevices = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'];
|
|
1380
|
+
|
|
1515
1381
|
/**
|
|
1516
1382
|
* navigator.platform is deprecated and will eventually be removed
|
|
1517
1383
|
* but the recommended alternative `navigator.userAgentData` has limited browser support
|
|
1518
1384
|
* so it is used as a fallback here.
|
|
1519
1385
|
*/
|
|
1520
|
-
|
|
1521
1386
|
var DEVICE_PLATFORM = window && window.navigator && (window.navigator.platform || window.navigator.userAgentData && window.navigator.userAgentData.platform);
|
|
1522
1387
|
var isIOS = function isIOS() {
|
|
1523
1388
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1389
|
+
platform = _ref.platform,
|
|
1390
|
+
_ref$userAgent = _ref.userAgent,
|
|
1391
|
+
userAgent = _ref$userAgent === void 0 ? window && window.navigator && window.navigator.userAgent : _ref$userAgent;
|
|
1528
1392
|
var devicePlatform = platform || DEVICE_PLATFORM;
|
|
1529
|
-
return iOSDevices.includes(devicePlatform) ||
|
|
1393
|
+
return iOSDevices.includes(devicePlatform) ||
|
|
1394
|
+
// iPAD os safari detection. iPad OS uses the same version of safari as Mac OS
|
|
1530
1395
|
userAgent.includes('Mac') && 'ontouchend' in document;
|
|
1531
1396
|
};
|
|
1532
1397
|
|
|
@@ -1560,11 +1425,10 @@ var AnalyticsAPI = {
|
|
|
1560
1425
|
var AnalyticsFunctions = {
|
|
1561
1426
|
initializeLog: function initializeLog(log) {
|
|
1562
1427
|
var _ref = log || {},
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1428
|
+
attempts = _ref.attempts,
|
|
1429
|
+
authentication = _ref.authentication,
|
|
1430
|
+
errors = _ref.errors,
|
|
1431
|
+
history = _ref.history;
|
|
1568
1432
|
this.log = {
|
|
1569
1433
|
start_time: Math.round(Date.now() / 1000),
|
|
1570
1434
|
time_spent: 0,
|
|
@@ -1586,10 +1450,8 @@ var AnalyticsFunctions = {
|
|
|
1586
1450
|
switch (response.status) {
|
|
1587
1451
|
case 'success':
|
|
1588
1452
|
return this.logApiSuccess(channel);
|
|
1589
|
-
|
|
1590
1453
|
case 'failed':
|
|
1591
1454
|
return this.logApiError(response.message);
|
|
1592
|
-
|
|
1593
1455
|
default:
|
|
1594
1456
|
return false;
|
|
1595
1457
|
}
|
|
@@ -1604,11 +1466,9 @@ var AnalyticsFunctions = {
|
|
|
1604
1466
|
},
|
|
1605
1467
|
logAttempt: function logAttempt(channel) {
|
|
1606
1468
|
var message = 'Attempted to pay';
|
|
1607
|
-
|
|
1608
1469
|
if (channel) {
|
|
1609
1470
|
message += " with ".concat(channel);
|
|
1610
1471
|
}
|
|
1611
|
-
|
|
1612
1472
|
this.log.attempts += 1;
|
|
1613
1473
|
this.log.history.push({
|
|
1614
1474
|
type: 'action',
|
|
@@ -1619,11 +1479,9 @@ var AnalyticsFunctions = {
|
|
|
1619
1479
|
},
|
|
1620
1480
|
logApiError: function logApiError(error) {
|
|
1621
1481
|
var message = 'Error';
|
|
1622
|
-
|
|
1623
1482
|
if (error) {
|
|
1624
1483
|
message += ": ".concat(error);
|
|
1625
1484
|
}
|
|
1626
|
-
|
|
1627
1485
|
this.log.errors += 1;
|
|
1628
1486
|
this.log.history.push({
|
|
1629
1487
|
type: 'error',
|
|
@@ -1634,11 +1492,9 @@ var AnalyticsFunctions = {
|
|
|
1634
1492
|
},
|
|
1635
1493
|
logApiSuccess: function logApiSuccess(channel) {
|
|
1636
1494
|
var message = 'Successfully paid';
|
|
1637
|
-
|
|
1638
1495
|
if (channel) {
|
|
1639
1496
|
message += " with ".concat(channel);
|
|
1640
1497
|
}
|
|
1641
|
-
|
|
1642
1498
|
this.log.success = true;
|
|
1643
1499
|
this.log.history.push({
|
|
1644
1500
|
type: 'success',
|
|
@@ -1652,9 +1508,9 @@ var AnalyticsFunctions = {
|
|
|
1652
1508
|
if (this.response) {
|
|
1653
1509
|
return AnalyticsAPI.saveLog(this.id, this.response.merchant_key, this.log);
|
|
1654
1510
|
}
|
|
1655
|
-
} catch (error) {
|
|
1511
|
+
} catch (error) {
|
|
1512
|
+
// we don't need to do anything since this should not affect the transaction
|
|
1656
1513
|
}
|
|
1657
|
-
|
|
1658
1514
|
return undefined;
|
|
1659
1515
|
},
|
|
1660
1516
|
saveIpAddress: function saveIpAddress() {
|
|
@@ -1662,9 +1518,9 @@ var AnalyticsFunctions = {
|
|
|
1662
1518
|
if (this.response) {
|
|
1663
1519
|
return AnalyticsAPI.saveIp(this.id, this.response.merchant_key);
|
|
1664
1520
|
}
|
|
1665
|
-
} catch (error) {
|
|
1521
|
+
} catch (error) {
|
|
1522
|
+
// we don't need to do anything since this should not affect the transaction
|
|
1666
1523
|
}
|
|
1667
|
-
|
|
1668
1524
|
return undefined;
|
|
1669
1525
|
}
|
|
1670
1526
|
};
|
|
@@ -1673,20 +1529,16 @@ var _excluded$1 = ["language", "connect_account"];
|
|
|
1673
1529
|
var TransactionApi = {
|
|
1674
1530
|
requestInline: function requestInline() {
|
|
1675
1531
|
var inlineTransactionInstance = this;
|
|
1676
|
-
|
|
1677
1532
|
var _this$urlParameters = this.urlParameters,
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1533
|
+
language = _this$urlParameters.language,
|
|
1534
|
+
connectAccount = _this$urlParameters.connect_account,
|
|
1535
|
+
params = _objectWithoutProperties(_this$urlParameters, _excluded$1);
|
|
1682
1536
|
var request;
|
|
1683
|
-
|
|
1684
1537
|
var headers = _objectSpread2({
|
|
1685
1538
|
'Content-Type': 'application/json'
|
|
1686
1539
|
}, language && {
|
|
1687
1540
|
'Accept-Language': language
|
|
1688
1541
|
});
|
|
1689
|
-
|
|
1690
1542
|
if (this.accessCode) {
|
|
1691
1543
|
request = fetch(new URL("transaction/verify_access_code/".concat(this.accessCode), config.paystackApiUrl).toString(), {
|
|
1692
1544
|
headers: headers
|
|
@@ -1700,19 +1552,18 @@ var TransactionApi = {
|
|
|
1700
1552
|
})
|
|
1701
1553
|
});
|
|
1702
1554
|
}
|
|
1703
|
-
|
|
1704
1555
|
return request.then(function (res) {
|
|
1705
1556
|
return res.json();
|
|
1706
1557
|
}).then(function (res) {
|
|
1707
1558
|
if (res.status === false) {
|
|
1708
1559
|
throw new Error(res.message);
|
|
1709
1560
|
}
|
|
1710
|
-
|
|
1711
1561
|
inlineTransactionInstance.response = res.data;
|
|
1712
1562
|
inlineTransactionInstance.id = res.data.id;
|
|
1713
1563
|
inlineTransactionInstance.status = res.data.transaction_status;
|
|
1714
|
-
inlineTransactionInstance.accessCode = res.data.access_code;
|
|
1564
|
+
inlineTransactionInstance.accessCode = res.data.access_code;
|
|
1715
1565
|
|
|
1566
|
+
// Analytics
|
|
1716
1567
|
inlineTransactionInstance.log = null;
|
|
1717
1568
|
Object.assign(inlineTransactionInstance, AnalyticsFunctions);
|
|
1718
1569
|
inlineTransactionInstance.initializeLog(res.data.log);
|
|
@@ -1725,7 +1576,6 @@ var TransactionApi = {
|
|
|
1725
1576
|
var InlineTransaction = /*#__PURE__*/function () {
|
|
1726
1577
|
function InlineTransaction(data) {
|
|
1727
1578
|
_classCallCheck(this, InlineTransaction);
|
|
1728
|
-
|
|
1729
1579
|
validate(data);
|
|
1730
1580
|
this.parameters = data;
|
|
1731
1581
|
this.urlParameters = buildQuery(data);
|
|
@@ -1737,12 +1587,12 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1737
1587
|
this.response = null;
|
|
1738
1588
|
this.isActive = true;
|
|
1739
1589
|
var onError = data.onError,
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1590
|
+
onLoad = data.onLoad,
|
|
1591
|
+
onSuccess = data.onSuccess,
|
|
1592
|
+
onCancel = data.onCancel,
|
|
1593
|
+
callback = data.callback,
|
|
1594
|
+
onClose = data.onClose,
|
|
1595
|
+
onBankTransferConfirmationPending = data.onBankTransferConfirmationPending;
|
|
1746
1596
|
this.callbacks = {
|
|
1747
1597
|
onError: onError,
|
|
1748
1598
|
onLoad: onLoad,
|
|
@@ -1756,12 +1606,10 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1756
1606
|
};
|
|
1757
1607
|
Object.assign(this, TransactionApi);
|
|
1758
1608
|
}
|
|
1759
|
-
|
|
1760
|
-
_createClass(InlineTransaction, [{
|
|
1609
|
+
return _createClass(InlineTransaction, [{
|
|
1761
1610
|
key: "onSetupError",
|
|
1762
1611
|
value: function onSetupError(response) {
|
|
1763
1612
|
this.logError(response);
|
|
1764
|
-
|
|
1765
1613
|
if (this.callbacks.onError) {
|
|
1766
1614
|
this.callbacks.onError(response);
|
|
1767
1615
|
}
|
|
@@ -1770,15 +1618,14 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1770
1618
|
key: "onLoad",
|
|
1771
1619
|
value: function onLoad(response) {
|
|
1772
1620
|
var id = response.id,
|
|
1773
|
-
|
|
1774
|
-
|
|
1621
|
+
customer = response.customer,
|
|
1622
|
+
accessCode = response.accessCode;
|
|
1775
1623
|
Object.assign(this, {
|
|
1776
1624
|
id: id,
|
|
1777
1625
|
customer: customer,
|
|
1778
1626
|
accessCode: accessCode
|
|
1779
1627
|
});
|
|
1780
1628
|
this.authorizationUrl = "".concat(config.checkoutUrl).concat(accessCode);
|
|
1781
|
-
|
|
1782
1629
|
if (this.callbacks.onLoad) {
|
|
1783
1630
|
this.callbacks.onLoad({
|
|
1784
1631
|
id: id,
|
|
@@ -1793,12 +1640,10 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1793
1640
|
this.isActive = false;
|
|
1794
1641
|
this.response = response;
|
|
1795
1642
|
this.status = response.status;
|
|
1796
|
-
|
|
1797
1643
|
if (this.callbacks.onSuccess) {
|
|
1798
1644
|
this.callbacks.onSuccess(response);
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1645
|
+
}
|
|
1646
|
+
// Added for backwards compatibility
|
|
1802
1647
|
if (this.deprecatedCallbacks.callback) {
|
|
1803
1648
|
this.deprecatedCallbacks.callback(response);
|
|
1804
1649
|
}
|
|
@@ -1813,9 +1658,8 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1813
1658
|
value: function onCancel() {
|
|
1814
1659
|
if (this.callbacks.onCancel) {
|
|
1815
1660
|
this.callbacks.onCancel();
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
|
|
1661
|
+
}
|
|
1662
|
+
// Added for backwards compatibility
|
|
1819
1663
|
if (this.deprecatedCallbacks.onClose) {
|
|
1820
1664
|
this.deprecatedCallbacks.onClose();
|
|
1821
1665
|
}
|
|
@@ -1830,7 +1674,6 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1830
1674
|
key: "onBankTransferConfirmationPending",
|
|
1831
1675
|
value: function onBankTransferConfirmationPending() {
|
|
1832
1676
|
this.cancel();
|
|
1833
|
-
|
|
1834
1677
|
if (this.callbacks.onBankTransferConfirmationPending) {
|
|
1835
1678
|
this.callbacks.onBankTransferConfirmationPending();
|
|
1836
1679
|
}
|
|
@@ -1841,13 +1684,10 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1841
1684
|
this.errors.push(error);
|
|
1842
1685
|
}
|
|
1843
1686
|
}]);
|
|
1844
|
-
|
|
1845
|
-
return InlineTransaction;
|
|
1846
1687
|
}();
|
|
1847
1688
|
|
|
1848
1689
|
var canUseVault = function canUseVault() {
|
|
1849
1690
|
var _transaction$link_con, _transaction$link_con2;
|
|
1850
|
-
|
|
1851
1691
|
var transaction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1852
1692
|
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
1693
|
};
|
|
@@ -1859,14 +1699,12 @@ function printDeprecationNotice(oldName, newName, extraMessage) {
|
|
|
1859
1699
|
}
|
|
1860
1700
|
|
|
1861
1701
|
var _excluded = ["preload", "inlineTransaction", "transactionData"],
|
|
1862
|
-
|
|
1702
|
+
_excluded2 = ["container", "styles", "onElementsMount"];
|
|
1863
1703
|
var inlineInstance;
|
|
1864
|
-
|
|
1865
1704
|
function findResumableTransaction(transactions, parameters) {
|
|
1866
1705
|
if (!transactions.length) {
|
|
1867
1706
|
return null;
|
|
1868
1707
|
}
|
|
1869
|
-
|
|
1870
1708
|
var similarAbandonedTransactions = transactions.filter(function (transaction) {
|
|
1871
1709
|
var isAbandoned = !transaction.status || transaction.status === 'abandoned';
|
|
1872
1710
|
var hasSimilarParameters = similarObjects(transaction.parameters, parameters);
|
|
@@ -1875,39 +1713,32 @@ function findResumableTransaction(transactions, parameters) {
|
|
|
1875
1713
|
var resumableTransaction = similarAbandonedTransactions.length ? similarAbandonedTransactions[similarAbandonedTransactions.length - 1] : null;
|
|
1876
1714
|
return resumableTransaction;
|
|
1877
1715
|
}
|
|
1878
|
-
|
|
1879
1716
|
function notifyIframeToUpdateURL(options) {
|
|
1880
1717
|
var checkoutIframe = options.checkoutIframe,
|
|
1881
|
-
|
|
1882
|
-
|
|
1718
|
+
urlParameters = options.urlParameters;
|
|
1883
1719
|
if (!checkoutIframe || !urlParameters) {
|
|
1884
1720
|
return;
|
|
1885
1721
|
}
|
|
1886
|
-
|
|
1887
1722
|
checkoutIframe.contentWindow.postMessage({
|
|
1888
1723
|
type: 'inline:url',
|
|
1889
1724
|
path: 'newTransaction',
|
|
1890
1725
|
params: urlParameters
|
|
1891
1726
|
}, '*');
|
|
1892
1727
|
}
|
|
1893
|
-
|
|
1894
1728
|
var analyticsActions = {
|
|
1895
1729
|
TRACK_CHECKOUT_CLOSED: 'trackCheckoutClosed',
|
|
1896
1730
|
TRACK_PAYMENT_ERROR: 'trackPaymentError',
|
|
1897
1731
|
TRACK_PAYMENT_ATTEMPT: 'trackPaymentAttempt',
|
|
1898
1732
|
TRACK_PAYMENT_COMPLETION: 'trackPaymentCompletion'
|
|
1899
1733
|
};
|
|
1900
|
-
|
|
1901
1734
|
function handleError(message) {
|
|
1902
1735
|
logWarning(message);
|
|
1903
1736
|
throw new Error(message);
|
|
1904
1737
|
}
|
|
1905
|
-
|
|
1906
1738
|
function transactionCanUseApplePay(response, container) {
|
|
1907
1739
|
if (!(response && response.channels && response.channels.includes('apple_pay'))) {
|
|
1908
1740
|
return Promise.resolve(false);
|
|
1909
1741
|
}
|
|
1910
|
-
|
|
1911
1742
|
return ensureApplePaySdkLoaded(container).catch(function () {
|
|
1912
1743
|
// Native Apple Pay support can still be available even if the SDK fails to load.
|
|
1913
1744
|
return null;
|
|
@@ -1915,44 +1746,36 @@ function transactionCanUseApplePay(response, container) {
|
|
|
1915
1746
|
return canUseApplePay(response.channels);
|
|
1916
1747
|
});
|
|
1917
1748
|
}
|
|
1918
|
-
|
|
1919
1749
|
var Inline = /*#__PURE__*/function () {
|
|
1920
1750
|
function Inline(params) {
|
|
1921
1751
|
_classCallCheck(this, Inline);
|
|
1922
|
-
|
|
1923
1752
|
this.id = randomId();
|
|
1924
1753
|
this.transactions = [];
|
|
1925
1754
|
this.isOpen = false;
|
|
1926
1755
|
this.isLoaded = false;
|
|
1927
1756
|
this.isDeprecatedApi = params && params.isDeprecatedApi; // track deprecatedApi
|
|
1928
|
-
|
|
1929
1757
|
if (params && params.isEmbed) {
|
|
1930
1758
|
this.isEmbed = true;
|
|
1931
1759
|
} else if (params && params.isPaymentRequest) {
|
|
1932
1760
|
if (!(params.container && getPaymentRequestContainer(params.container))) {
|
|
1933
1761
|
handleError('A container is required to mount the payment request button');
|
|
1934
1762
|
}
|
|
1935
|
-
|
|
1936
1763
|
this.paymentRequestContainer = getPaymentRequestContainer(params.container);
|
|
1937
1764
|
this.paymentRequestTransaction = null;
|
|
1938
1765
|
}
|
|
1939
|
-
|
|
1940
1766
|
this.preCheckoutModal = null;
|
|
1941
1767
|
this.backgroundIframe = mountBackgroundIframe(this.id);
|
|
1942
1768
|
this.checkoutIframe = mountCheckoutIframe(this.id);
|
|
1943
1769
|
this.registerListeners();
|
|
1944
1770
|
}
|
|
1945
|
-
|
|
1946
|
-
_createClass(Inline, [{
|
|
1771
|
+
return _createClass(Inline, [{
|
|
1947
1772
|
key: "registerListeners",
|
|
1948
1773
|
value: function registerListeners() {
|
|
1949
1774
|
var _this = this;
|
|
1950
|
-
|
|
1951
1775
|
window.addEventListener('message', function (event) {
|
|
1952
1776
|
var isCheckoutIframe = "".concat(event.origin, "/") === config.checkoutUrl;
|
|
1953
1777
|
var isThisInline = _this.checkoutIframe && _this.checkoutIframe.contentWindow === event.source;
|
|
1954
1778
|
var isEmbed = _this.isEmbed;
|
|
1955
|
-
|
|
1956
1779
|
if (isCheckoutIframe || isThisInline) {
|
|
1957
1780
|
_this.respondToEvent(event);
|
|
1958
1781
|
} else if (isEmbed) {
|
|
@@ -1975,7 +1798,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1975
1798
|
if (this.activeTransaction()) {
|
|
1976
1799
|
this.activeTransaction().cancel();
|
|
1977
1800
|
}
|
|
1978
|
-
|
|
1979
1801
|
inlineInstance = this;
|
|
1980
1802
|
var resumableTransaction = findResumableTransaction(this.transactions, params);
|
|
1981
1803
|
var transaction = resumableTransaction || new InlineTransaction(params);
|
|
@@ -1989,10 +1811,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1989
1811
|
});
|
|
1990
1812
|
}).then(function (_ref) {
|
|
1991
1813
|
var response = _ref.response,
|
|
1992
|
-
|
|
1814
|
+
canPayWithApplePay = _ref.canPayWithApplePay;
|
|
1993
1815
|
var canPayWithVault = canUseVault(response);
|
|
1994
1816
|
var shouldLoadPreCheckoutModal = canPayWithVault || canPayWithApplePay;
|
|
1995
|
-
|
|
1996
1817
|
if (!shouldLoadPreCheckoutModal) {
|
|
1997
1818
|
inlineInstance.newTransaction({
|
|
1998
1819
|
inlineTransaction: transaction,
|
|
@@ -2008,11 +1829,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2008
1829
|
canPayWithVault: canPayWithVault,
|
|
2009
1830
|
canPayWithApplePay: canPayWithApplePay
|
|
2010
1831
|
});
|
|
1832
|
+
|
|
2011
1833
|
/**
|
|
2012
1834
|
* We attempt to mount the apple pay button only
|
|
2013
1835
|
* when the customer can pay with apple pay.
|
|
2014
1836
|
*/
|
|
2015
|
-
|
|
2016
1837
|
if (canPayWithApplePay) {
|
|
2017
1838
|
inlineInstance.paymentRequestContainer = getPreCheckoutModalPaymentRequestContainer(inlineInstance.preCheckoutModal);
|
|
2018
1839
|
mountPaymentRequestButtons(inlineInstance.paymentRequestContainer, {
|
|
@@ -2067,15 +1888,12 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2067
1888
|
key: "registerPreCheckoutModalEventListeners",
|
|
2068
1889
|
value: function registerPreCheckoutModalEventListeners() {
|
|
2069
1890
|
var _this2 = this;
|
|
2070
|
-
|
|
2071
1891
|
var timer;
|
|
2072
1892
|
var isShortTouch = false;
|
|
2073
1893
|
var shortTouchDurationInMs = 125;
|
|
2074
1894
|
var activeTransaction = this.activeTransaction();
|
|
2075
|
-
|
|
2076
1895
|
var handleTouchStart = function handleTouchStart(event) {
|
|
2077
1896
|
event.preventDefault();
|
|
2078
|
-
|
|
2079
1897
|
if (!isShortTouch) {
|
|
2080
1898
|
isShortTouch = true;
|
|
2081
1899
|
timer = setTimeout(function () {
|
|
@@ -2083,51 +1901,38 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2083
1901
|
}, shortTouchDurationInMs);
|
|
2084
1902
|
}
|
|
2085
1903
|
};
|
|
2086
|
-
|
|
2087
1904
|
var handleClosePreCheckoutModal = function handleClosePreCheckoutModal(event) {
|
|
2088
1905
|
if (event.target && event.target.isSameNode(inlineInstance.preCheckoutModal) && isShortTouch) {
|
|
2089
1906
|
clearTimeout(timer);
|
|
2090
1907
|
inlineInstance.closePreCheckoutModal();
|
|
2091
|
-
|
|
2092
1908
|
if (activeTransaction) {
|
|
2093
1909
|
activeTransaction.cancel();
|
|
2094
1910
|
}
|
|
2095
1911
|
}
|
|
2096
|
-
|
|
2097
1912
|
isShortTouch = false;
|
|
2098
1913
|
};
|
|
2099
|
-
|
|
2100
1914
|
document.addEventListener('touchstart', handleTouchStart, true);
|
|
2101
1915
|
document.addEventListener('touchend', handleClosePreCheckoutModal, true);
|
|
2102
1916
|
var openPaystackPopButton = getPreCheckoutModalOpenPaystackPopButton(this.preCheckoutModal);
|
|
2103
|
-
|
|
2104
1917
|
if (openPaystackPopButton) {
|
|
2105
1918
|
openPaystackPopButton.onclick = function () {
|
|
2106
1919
|
_this2.closePreCheckoutModal();
|
|
2107
|
-
|
|
2108
1920
|
_this2.animateCheckoutIn();
|
|
2109
1921
|
};
|
|
2110
1922
|
}
|
|
2111
|
-
|
|
2112
1923
|
var payWithVaultButton = getPreCheckoutModalPayWithVaultButton(this.preCheckoutModal);
|
|
2113
|
-
|
|
2114
1924
|
if (payWithVaultButton) {
|
|
2115
1925
|
payWithVaultButton.onclick = function () {
|
|
2116
1926
|
_this2.closePreCheckoutModal();
|
|
2117
|
-
|
|
2118
1927
|
_this2.animateCheckoutIn();
|
|
2119
|
-
|
|
2120
1928
|
_this2.checkoutIframe.contentWindow.postMessage({
|
|
2121
1929
|
type: 'inline:pay-with-vault'
|
|
2122
1930
|
}, '*');
|
|
2123
1931
|
};
|
|
2124
1932
|
}
|
|
2125
|
-
|
|
2126
1933
|
var preCheckoutModalCloseButton = getPreCheckoutModalCloseButton(this.preCheckoutModal);
|
|
2127
|
-
|
|
2128
1934
|
preCheckoutModalCloseButton.onclick = function () {
|
|
2129
1935
|
_this2.sendAnalyticsEventToCheckout(analyticsActions.TRACK_CHECKOUT_CLOSED);
|
|
2130
|
-
|
|
2131
1936
|
_this2.closePreCheckoutModalAndCancelTransaction();
|
|
2132
1937
|
};
|
|
2133
1938
|
}
|
|
@@ -2137,7 +1942,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2137
1942
|
if (!this.preCheckoutModal) {
|
|
2138
1943
|
return;
|
|
2139
1944
|
}
|
|
2140
|
-
|
|
2141
1945
|
if (transactionStatus === 'failed') {
|
|
2142
1946
|
showErrorInPreCheckoutModal(this.preCheckoutModal);
|
|
2143
1947
|
animatePreCheckoutModalIn(this.preCheckoutModal);
|
|
@@ -2152,11 +1956,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2152
1956
|
value: function closePreCheckoutModalAndCancelTransaction() {
|
|
2153
1957
|
if (this.preCheckoutModal) {
|
|
2154
1958
|
this.cancelTransaction();
|
|
2155
|
-
|
|
2156
1959
|
if (this.checkoutIframe && this.checkoutIframe.contentWindow) {
|
|
2157
1960
|
this.checkoutIframe.contentWindow.postMessage('close', '*');
|
|
2158
1961
|
}
|
|
2159
|
-
|
|
2160
1962
|
this.closePreCheckoutModal();
|
|
2161
1963
|
}
|
|
2162
1964
|
}
|
|
@@ -2164,19 +1966,15 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2164
1966
|
key: "newTransaction",
|
|
2165
1967
|
value: function newTransaction(_ref2) {
|
|
2166
1968
|
var preload = _ref2.preload,
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
1969
|
+
inlineTransaction = _ref2.inlineTransaction,
|
|
1970
|
+
transactionData = _ref2.transactionData,
|
|
1971
|
+
options = _objectWithoutProperties(_ref2, _excluded);
|
|
2171
1972
|
var hasPaymentRequestButtons = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2172
|
-
|
|
2173
1973
|
if (this.activeTransaction() && !hasPaymentRequestButtons) {
|
|
2174
1974
|
this.activeTransaction().cancel();
|
|
2175
1975
|
}
|
|
2176
|
-
|
|
2177
1976
|
if (inlineTransaction && transactionData) {
|
|
2178
1977
|
this.transactions.push(inlineTransaction);
|
|
2179
|
-
|
|
2180
1978
|
if (!this.isDeprecatedApi) {
|
|
2181
1979
|
// TODO: reintroduce this when we resolve checkout caching issues
|
|
2182
1980
|
// this.open({ transactionData }, preload);
|
|
@@ -2185,15 +1983,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2185
1983
|
language: inlineTransaction.urlParameters.language
|
|
2186
1984
|
}, preload);
|
|
2187
1985
|
}
|
|
2188
|
-
|
|
2189
1986
|
return inlineTransaction;
|
|
2190
1987
|
}
|
|
2191
|
-
|
|
2192
1988
|
var resumableTransaction = findResumableTransaction(this.transactions, inlineTransaction ? inlineTransaction.parameters : options);
|
|
2193
|
-
|
|
2194
1989
|
if (resumableTransaction) {
|
|
2195
1990
|
resumableTransaction.isActive = true;
|
|
2196
|
-
|
|
2197
1991
|
if (!this.isDeprecatedApi) {
|
|
2198
1992
|
// We could potentially optimize this also by checking if there is a `response` property on `resumableTransaction`
|
|
2199
1993
|
this.open({
|
|
@@ -2201,58 +1995,47 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2201
1995
|
language: resumableTransaction.urlParameters.language
|
|
2202
1996
|
}, preload);
|
|
2203
1997
|
}
|
|
2204
|
-
|
|
2205
1998
|
return resumableTransaction;
|
|
2206
1999
|
}
|
|
2207
|
-
|
|
2208
2000
|
var transaction = inlineTransaction || new InlineTransaction(options);
|
|
2209
2001
|
var params = transaction.accessCode ? {
|
|
2210
2002
|
accessCode: transaction.accessCode,
|
|
2211
2003
|
language: transaction.urlParameters.language
|
|
2212
2004
|
} : transaction.urlParameters;
|
|
2213
2005
|
this.transactions.push(transaction);
|
|
2214
|
-
|
|
2215
2006
|
if (!this.isDeprecatedApi) {
|
|
2216
2007
|
this.open(params, preload);
|
|
2217
2008
|
}
|
|
2218
|
-
|
|
2219
2009
|
return transaction;
|
|
2220
2010
|
}
|
|
2221
2011
|
}, {
|
|
2222
2012
|
key: "preloadTransaction",
|
|
2223
2013
|
value: function preloadTransaction(options) {
|
|
2224
2014
|
var _this3 = this;
|
|
2225
|
-
|
|
2226
2015
|
this.newTransaction(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
2227
2016
|
preload: true
|
|
2228
2017
|
}));
|
|
2229
|
-
|
|
2230
2018
|
var loadPopup = function loadPopup() {
|
|
2231
2019
|
return _this3.animateCheckoutIn();
|
|
2232
2020
|
};
|
|
2233
|
-
|
|
2234
2021
|
return loadPopup;
|
|
2235
2022
|
}
|
|
2236
2023
|
}, {
|
|
2237
2024
|
key: "paymentRequest",
|
|
2238
2025
|
value: function paymentRequest(parameters) {
|
|
2239
2026
|
var container = parameters.container,
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2027
|
+
styles = parameters.styles,
|
|
2028
|
+
onElementsMount = parameters.onElementsMount,
|
|
2029
|
+
transactionParams = _objectWithoutProperties(parameters, _excluded2);
|
|
2244
2030
|
inlineInstance = this;
|
|
2245
2031
|
return new Promise(function (resolve, reject) {
|
|
2246
2032
|
var loadPaystackCheckoutButton = document.querySelector("#".concat(parameters.loadPaystackCheckoutButton));
|
|
2247
|
-
|
|
2248
2033
|
if (inlineInstance.activeTransaction()) {
|
|
2249
2034
|
inlineInstance.activeTransaction().cancel();
|
|
2250
2035
|
}
|
|
2251
|
-
|
|
2252
2036
|
if (!(container && getPaymentRequestContainer(container))) {
|
|
2253
2037
|
handleError('A container is required to mount the payment request button');
|
|
2254
2038
|
}
|
|
2255
|
-
|
|
2256
2039
|
inlineInstance.paymentRequestContainer = getPaymentRequestContainer(container);
|
|
2257
2040
|
var resumableTransaction = findResumableTransaction(inlineInstance.transactions, transactionParams);
|
|
2258
2041
|
var transaction = resumableTransaction || new InlineTransaction(transactionParams);
|
|
@@ -2274,9 +2057,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2274
2057
|
} else {
|
|
2275
2058
|
inlineInstance.transactions.push(transaction);
|
|
2276
2059
|
}
|
|
2277
|
-
|
|
2278
2060
|
inlineInstance.registerPaymentRequestEventListeners();
|
|
2279
|
-
|
|
2280
2061
|
if (loadPaystackCheckoutButton) {
|
|
2281
2062
|
var loadPopup = inlineInstance.preloadTransaction({
|
|
2282
2063
|
inlineTransaction: transaction,
|
|
@@ -2284,7 +2065,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2284
2065
|
});
|
|
2285
2066
|
loadPaystackCheckoutButton.onclick = loadPopup;
|
|
2286
2067
|
}
|
|
2287
|
-
|
|
2288
2068
|
resolve(transaction);
|
|
2289
2069
|
});
|
|
2290
2070
|
}).catch(function (error) {
|
|
@@ -2300,9 +2080,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2300
2080
|
key: "registerApplePayEventListener",
|
|
2301
2081
|
value: function registerApplePayEventListener() {
|
|
2302
2082
|
var _this4 = this;
|
|
2303
|
-
|
|
2304
2083
|
var applePayButton = getApplePayButton(this.paymentRequestContainer);
|
|
2305
|
-
|
|
2306
2084
|
if (applePayButton) {
|
|
2307
2085
|
applePayButton.onclick = function () {
|
|
2308
2086
|
return _this4.startApplePay();
|
|
@@ -2314,7 +2092,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2314
2092
|
value: function registerPaymentRequestEventListeners() {
|
|
2315
2093
|
var transaction = this.activeTransaction();
|
|
2316
2094
|
var applePayButton = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2317
|
-
|
|
2318
2095
|
if (transaction && applePayButton) {
|
|
2319
2096
|
this.registerApplePayEventListener();
|
|
2320
2097
|
} else if (this.paymentRequestContainer) {
|
|
@@ -2325,10 +2102,8 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2325
2102
|
key: "startApplePay",
|
|
2326
2103
|
value: function startApplePay() {
|
|
2327
2104
|
var _this5 = this;
|
|
2328
|
-
|
|
2329
2105
|
var paymentMethod = 'apple pay';
|
|
2330
2106
|
var transaction = this.activeTransaction();
|
|
2331
|
-
|
|
2332
2107
|
if (transaction) {
|
|
2333
2108
|
var paymentAttemptAnalyticsPayload = {
|
|
2334
2109
|
channel: 'apple_pay',
|
|
@@ -2343,7 +2118,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2343
2118
|
timeSpent: transaction.getTimeSpent()
|
|
2344
2119
|
};
|
|
2345
2120
|
var pendingPreCheckoutModalStatus = null;
|
|
2346
|
-
|
|
2347
2121
|
try {
|
|
2348
2122
|
transaction.logAttempt(paymentMethod);
|
|
2349
2123
|
this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, paymentAttemptAnalyticsPayload);
|
|
@@ -2354,11 +2128,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2354
2128
|
interval: transaction.response.plan_details && transaction.response.plan_details.interval
|
|
2355
2129
|
});
|
|
2356
2130
|
var applePaySession = new window.ApplePaySession(config.applePayVersion, applePayPaymentRequest);
|
|
2357
|
-
|
|
2358
2131
|
if (inlineInstance.preCheckoutModal) {
|
|
2359
2132
|
hidePreCheckoutModal(inlineInstance.preCheckoutModal);
|
|
2360
2133
|
}
|
|
2361
|
-
|
|
2362
2134
|
applePaySession.onvalidatemerchant = function (_ref3) {
|
|
2363
2135
|
var validationURL = _ref3.validationURL;
|
|
2364
2136
|
var validateSession = validateApplePaySession({
|
|
@@ -2373,14 +2145,12 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2373
2145
|
} else {
|
|
2374
2146
|
applePaySession.completeMerchantValidation(response.data);
|
|
2375
2147
|
}
|
|
2376
|
-
|
|
2377
2148
|
transaction.logValidationResponse(response.message);
|
|
2378
2149
|
}).catch(function (error) {
|
|
2379
2150
|
transaction.onSetupError(error);
|
|
2380
2151
|
pendingPreCheckoutModalStatus = 'failed';
|
|
2381
2152
|
});
|
|
2382
2153
|
};
|
|
2383
|
-
|
|
2384
2154
|
applePaySession.oncancel = function () {
|
|
2385
2155
|
if (inlineInstance.preCheckoutModal) {
|
|
2386
2156
|
if (pendingPreCheckoutModalStatus) {
|
|
@@ -2393,7 +2163,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2393
2163
|
transaction.onCancel();
|
|
2394
2164
|
}
|
|
2395
2165
|
};
|
|
2396
|
-
|
|
2397
2166
|
applePaySession.onpaymentauthorized = function (_ref4) {
|
|
2398
2167
|
var payment = _ref4.payment;
|
|
2399
2168
|
var charge = chargeApplePay({
|
|
@@ -2402,23 +2171,19 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2402
2171
|
});
|
|
2403
2172
|
charge.then(function (response) {
|
|
2404
2173
|
transaction.logAPIResponse(response, paymentMethod);
|
|
2405
|
-
|
|
2406
2174
|
if (response.status === 'success') {
|
|
2407
2175
|
applePaySession.completePayment(applePaySession.STATUS_SUCCESS);
|
|
2408
2176
|
transaction.onSuccess(response);
|
|
2409
|
-
|
|
2410
2177
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, paymentCompleteAnalyticsPayload);
|
|
2411
2178
|
} else {
|
|
2412
2179
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2413
2180
|
transaction.onSetupError(response);
|
|
2414
2181
|
pendingPreCheckoutModalStatus = 'failed';
|
|
2415
|
-
|
|
2416
2182
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2417
2183
|
channel: 'apple_pay',
|
|
2418
2184
|
message: response && response.message || 'Transaction attempt failed'
|
|
2419
2185
|
});
|
|
2420
2186
|
}
|
|
2421
|
-
|
|
2422
2187
|
if (response.status === 'success') {
|
|
2423
2188
|
inlineInstance.closePreCheckoutModal(response.status);
|
|
2424
2189
|
}
|
|
@@ -2426,14 +2191,12 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2426
2191
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2427
2192
|
transaction.onSetupError(error);
|
|
2428
2193
|
pendingPreCheckoutModalStatus = 'failed';
|
|
2429
|
-
|
|
2430
2194
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2431
2195
|
channel: 'apple_pay',
|
|
2432
2196
|
message: error && error.message || 'Error occurred'
|
|
2433
2197
|
});
|
|
2434
2198
|
});
|
|
2435
2199
|
};
|
|
2436
|
-
|
|
2437
2200
|
applePaySession.begin();
|
|
2438
2201
|
} catch (error) {
|
|
2439
2202
|
transaction.onSetupError(error);
|
|
@@ -2448,9 +2211,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2448
2211
|
value: function resumeTransaction(accessCode) {
|
|
2449
2212
|
var callbacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2450
2213
|
var onSuccess = callbacks.onSuccess,
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2214
|
+
onCancel = callbacks.onCancel,
|
|
2215
|
+
onLoad = callbacks.onLoad,
|
|
2216
|
+
onError = callbacks.onError;
|
|
2454
2217
|
return this.newTransaction({
|
|
2455
2218
|
accessCode: accessCode,
|
|
2456
2219
|
onSuccess: onSuccess,
|
|
@@ -2474,7 +2237,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2474
2237
|
var transaction = this.transactions.find(function (t) {
|
|
2475
2238
|
return t.id === id;
|
|
2476
2239
|
}) || this.activeTransaction();
|
|
2477
|
-
|
|
2478
2240
|
if (transaction) {
|
|
2479
2241
|
transaction.cancel();
|
|
2480
2242
|
this.close();
|
|
@@ -2486,23 +2248,20 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2486
2248
|
if (!event) {
|
|
2487
2249
|
return;
|
|
2488
2250
|
}
|
|
2489
|
-
|
|
2490
2251
|
var activeTransaction = this.activeTransaction();
|
|
2491
|
-
|
|
2492
2252
|
try {
|
|
2493
2253
|
var actualEvent = event.data || event.message;
|
|
2494
2254
|
var eventType = actualEvent.event,
|
|
2495
|
-
|
|
2496
|
-
|
|
2255
|
+
eventData = actualEvent.data;
|
|
2497
2256
|
if (eventType) {
|
|
2498
2257
|
switch (eventType) {
|
|
2499
2258
|
case 'loaded:checkout':
|
|
2500
2259
|
this.isLoaded = true;
|
|
2501
|
-
|
|
2502
2260
|
if (activeTransaction) {
|
|
2503
2261
|
var checkoutIframe = this.checkoutIframe;
|
|
2504
2262
|
var urlParameters = activeTransaction.urlParameters,
|
|
2505
|
-
|
|
2263
|
+
response = activeTransaction.response;
|
|
2264
|
+
// TODO: reintroduce this when we resolve checkout caching issues
|
|
2506
2265
|
// const params = response
|
|
2507
2266
|
// ? { transactionData: response }
|
|
2508
2267
|
// : urlParameters;
|
|
@@ -2516,77 +2275,60 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2516
2275
|
urlParameters: params
|
|
2517
2276
|
});
|
|
2518
2277
|
}
|
|
2519
|
-
|
|
2520
2278
|
break;
|
|
2521
|
-
|
|
2522
2279
|
case 'loaded:transaction':
|
|
2523
2280
|
hideLoader(this.backgroundIframe);
|
|
2524
|
-
|
|
2525
2281
|
if (this.preCheckoutModal) {
|
|
2526
2282
|
this.openPreCheckoutModal();
|
|
2527
2283
|
}
|
|
2528
|
-
|
|
2529
2284
|
activeTransaction.onLoad(eventData);
|
|
2530
2285
|
break;
|
|
2531
|
-
|
|
2532
2286
|
case 'error':
|
|
2533
2287
|
{
|
|
2534
2288
|
var error = eventData;
|
|
2535
|
-
|
|
2536
2289
|
if (error.type === 'setup') {
|
|
2537
2290
|
activeTransaction.onSetupError(eventData);
|
|
2538
2291
|
} else {
|
|
2539
2292
|
activeTransaction.logError(eventData);
|
|
2540
2293
|
}
|
|
2541
|
-
|
|
2542
2294
|
break;
|
|
2543
2295
|
}
|
|
2544
|
-
|
|
2545
2296
|
case 'cancel':
|
|
2546
2297
|
case 'close':
|
|
2547
2298
|
{
|
|
2548
2299
|
this.close();
|
|
2549
2300
|
var status = eventData && eventData.status;
|
|
2550
|
-
|
|
2551
2301
|
if (status) {
|
|
2552
2302
|
activeTransaction.setStatus(status);
|
|
2553
2303
|
}
|
|
2554
|
-
|
|
2555
2304
|
var hasPaymentRequestButtons = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2556
2305
|
var shouldSetCurrentTransactionAsInactive = !(hasPaymentRequestButtons && !this.preCheckoutModal);
|
|
2557
|
-
|
|
2558
2306
|
if (shouldSetCurrentTransactionAsInactive) {
|
|
2559
2307
|
activeTransaction.isActive = false;
|
|
2560
2308
|
}
|
|
2561
|
-
|
|
2562
2309
|
activeTransaction.onCancel();
|
|
2563
2310
|
break;
|
|
2564
2311
|
}
|
|
2565
|
-
|
|
2566
2312
|
case 'transfer:pending':
|
|
2567
2313
|
{
|
|
2568
2314
|
this.close();
|
|
2569
|
-
|
|
2570
2315
|
var _status = eventData && eventData.status;
|
|
2571
|
-
|
|
2572
2316
|
if (_status) {
|
|
2573
2317
|
activeTransaction.setStatus(_status);
|
|
2574
2318
|
}
|
|
2575
|
-
|
|
2576
2319
|
activeTransaction.onBankTransferConfirmationPending();
|
|
2577
2320
|
break;
|
|
2578
2321
|
}
|
|
2579
|
-
|
|
2580
2322
|
case 'success':
|
|
2581
2323
|
this.close();
|
|
2582
2324
|
activeTransaction.onSuccess(eventData);
|
|
2583
2325
|
break;
|
|
2584
|
-
|
|
2585
2326
|
default:
|
|
2586
2327
|
break;
|
|
2587
2328
|
}
|
|
2588
2329
|
}
|
|
2589
|
-
} catch (error) {
|
|
2330
|
+
} catch (error) {
|
|
2331
|
+
// do nothing
|
|
2590
2332
|
}
|
|
2591
2333
|
}
|
|
2592
2334
|
}, {
|
|
@@ -2594,19 +2336,15 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2594
2336
|
value: function respondToEmbedEvents(event) {
|
|
2595
2337
|
var activeTransaction = this.activeTransaction();
|
|
2596
2338
|
var eventData = event.data || event.message;
|
|
2597
|
-
|
|
2598
2339
|
if (eventData && (typeof eventData === 'string' || eventData instanceof String)) {
|
|
2599
2340
|
var response = parseResponse(eventData);
|
|
2600
2341
|
var oldCheckoutCloseResponse = response && response.action === 'PaystackClose';
|
|
2601
|
-
|
|
2602
2342
|
if (oldCheckoutCloseResponse) {
|
|
2603
2343
|
var chargeResponse = response.data;
|
|
2604
|
-
|
|
2605
2344
|
if (chargeResponse) {
|
|
2606
2345
|
activeTransaction.onSuccess(eventData);
|
|
2607
2346
|
}
|
|
2608
2347
|
}
|
|
2609
|
-
|
|
2610
2348
|
if (response.action === 'PaystackTLSClose') {
|
|
2611
2349
|
activeTransaction.cancel();
|
|
2612
2350
|
}
|
|
@@ -2616,18 +2354,15 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2616
2354
|
key: "animateCheckoutIn",
|
|
2617
2355
|
value: function animateCheckoutIn$1() {
|
|
2618
2356
|
var _this6 = this;
|
|
2619
|
-
|
|
2620
2357
|
if (!this.isOpen) {
|
|
2621
2358
|
var checkoutIframe = this.checkoutIframe,
|
|
2622
|
-
|
|
2623
|
-
|
|
2359
|
+
backgroundIframe = this.backgroundIframe;
|
|
2624
2360
|
animateCheckoutIn({
|
|
2625
2361
|
checkoutIframe: checkoutIframe,
|
|
2626
2362
|
backgroundIframe: backgroundIframe
|
|
2627
2363
|
}).then(function () {
|
|
2628
2364
|
_this6.checkoutIframe.contentWindow.postMessage('render', '*');
|
|
2629
2365
|
});
|
|
2630
|
-
|
|
2631
2366
|
this.isOpen = true;
|
|
2632
2367
|
}
|
|
2633
2368
|
}
|
|
@@ -2637,13 +2372,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2637
2372
|
if (!urlParameters) {
|
|
2638
2373
|
return;
|
|
2639
2374
|
}
|
|
2640
|
-
|
|
2641
2375
|
var checkoutIframe = this.checkoutIframe;
|
|
2642
2376
|
notifyIframeToUpdateURL({
|
|
2643
2377
|
checkoutIframe: checkoutIframe,
|
|
2644
2378
|
urlParameters: urlParameters
|
|
2645
2379
|
});
|
|
2646
|
-
|
|
2647
2380
|
if (!preload) {
|
|
2648
2381
|
this.animateCheckoutIn();
|
|
2649
2382
|
}
|
|
@@ -2652,13 +2385,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2652
2385
|
key: "close",
|
|
2653
2386
|
value: function close() {
|
|
2654
2387
|
var _this7 = this;
|
|
2655
|
-
|
|
2656
2388
|
if (!this.isOpen) {
|
|
2657
2389
|
return;
|
|
2658
2390
|
}
|
|
2659
|
-
|
|
2660
2391
|
var checkoutIframe = this.checkoutIframe,
|
|
2661
|
-
|
|
2392
|
+
backgroundIframe = this.backgroundIframe;
|
|
2662
2393
|
animateCheckoutOut({
|
|
2663
2394
|
checkoutIframe: checkoutIframe,
|
|
2664
2395
|
backgroundIframe: backgroundIframe
|
|
@@ -2677,23 +2408,19 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2677
2408
|
value: function setup(parameters) {
|
|
2678
2409
|
var isDeprecatedApi = true;
|
|
2679
2410
|
var isEmbed = parameters && parameters.container;
|
|
2680
|
-
|
|
2681
2411
|
if (!inlineInstance) {
|
|
2682
2412
|
inlineInstance = new Inline({
|
|
2683
2413
|
isDeprecatedApi: isDeprecatedApi,
|
|
2684
2414
|
isEmbed: isEmbed
|
|
2685
2415
|
});
|
|
2686
2416
|
}
|
|
2687
|
-
|
|
2688
2417
|
printDeprecationNotice('PaystackPop.setup()', 'new PaystackPop()', 'Please consult our documentation at https://developers.paystack.co/docs/paystack-inline');
|
|
2689
2418
|
var transaction = inlineInstance.newTransaction(parameters, 'deprecated');
|
|
2690
2419
|
var urlParameters = transaction.urlParameters;
|
|
2691
|
-
|
|
2692
2420
|
if (isEmbed) {
|
|
2693
2421
|
var inlineUrl = "".concat(config.siteUrl, "/assets/payment/production/inline.html?").concat(serialize(urlParameters));
|
|
2694
2422
|
var iframe = mountEmbedCheckoutIframe(inlineInstance.id, inlineUrl);
|
|
2695
2423
|
appendIframeToContainer(parameters.container, iframe);
|
|
2696
|
-
|
|
2697
2424
|
iframe.onload = function onLoad() {
|
|
2698
2425
|
iframe.contentWindow.postMessage("PaystackOpen ".concat(inlineInstance.id), '*');
|
|
2699
2426
|
animateEmbedCheckoutIn(iframe);
|
|
@@ -2705,22 +2432,16 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2705
2432
|
inlineInstance.open(urlParameters);
|
|
2706
2433
|
};
|
|
2707
2434
|
}
|
|
2708
|
-
|
|
2709
2435
|
return transaction;
|
|
2710
2436
|
}
|
|
2711
2437
|
}]);
|
|
2712
|
-
|
|
2713
|
-
return Inline;
|
|
2714
2438
|
}();
|
|
2715
|
-
|
|
2716
2439
|
if (scriptCanUseDataAttributes()) {
|
|
2717
2440
|
var parameters = getDataAttributesAsParameters();
|
|
2718
2441
|
var parentForm = getSourceScript().parentElement;
|
|
2719
|
-
|
|
2720
2442
|
if (!inlineInstance) {
|
|
2721
2443
|
inlineInstance = new Inline();
|
|
2722
2444
|
}
|
|
2723
|
-
|
|
2724
2445
|
var transaction;
|
|
2725
2446
|
var inlineButton = mountLazyInlineButton({
|
|
2726
2447
|
inlineId: inlineInstance.id,
|
|
@@ -2734,7 +2455,6 @@ if (scriptCanUseDataAttributes()) {
|
|
|
2734
2455
|
});
|
|
2735
2456
|
inlineButton.addEventListener('click', function (e) {
|
|
2736
2457
|
e.preventDefault();
|
|
2737
|
-
|
|
2738
2458
|
if (!transaction) {
|
|
2739
2459
|
transaction = inlineInstance.newTransaction(_objectSpread2(_objectSpread2({}, parameters), {}, {
|
|
2740
2460
|
onSuccess: function onSuccess(response) {
|