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