@paystack/checkout-js 1.25.0-dev.8 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkout.js +29 -21385
- package/es/checkout.js +47 -33
- package/lib/checkout.js +47 -33
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -6471,14 +6471,28 @@ addToUnscopables$2('includes');
|
|
|
6471
6471
|
var _excluded = ["message", "status", "errors"],
|
|
6472
6472
|
_excluded2 = ["message", "status", "errors"],
|
|
6473
6473
|
_excluded3 = ["message", "status", "errors"],
|
|
6474
|
-
_excluded4 = ["
|
|
6474
|
+
_excluded4 = ["message", "status", "errors"],
|
|
6475
|
+
_excluded5 = ["status", "message", "otpmessage"];
|
|
6476
|
+
var PREAUTHORIZATION_STATE_AUTHORIZED = 'authorized';
|
|
6475
6477
|
var ChargeResponses = {
|
|
6476
|
-
|
|
6478
|
+
authorized: function authorized(response) {
|
|
6477
6479
|
var message = response.message;
|
|
6478
6480
|
response.status;
|
|
6479
6481
|
response.errors;
|
|
6480
6482
|
var cleanResponse = _objectWithoutProperties(response, _excluded);
|
|
6481
6483
|
|
|
6484
|
+
return {
|
|
6485
|
+
status: PREAUTHORIZATION_STATE_AUTHORIZED,
|
|
6486
|
+
message: message || 'Payment authorized successfully',
|
|
6487
|
+
data: cleanResponse
|
|
6488
|
+
};
|
|
6489
|
+
},
|
|
6490
|
+
success: function success(response) {
|
|
6491
|
+
var message = response.message;
|
|
6492
|
+
response.status;
|
|
6493
|
+
response.errors;
|
|
6494
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded2);
|
|
6495
|
+
|
|
6482
6496
|
return {
|
|
6483
6497
|
status: 'success',
|
|
6484
6498
|
message: message || 'Successful',
|
|
@@ -6489,7 +6503,7 @@ var ChargeResponses = {
|
|
|
6489
6503
|
var message = response.message;
|
|
6490
6504
|
response.status;
|
|
6491
6505
|
response.errors;
|
|
6492
|
-
var cleanResponse = _objectWithoutProperties(response,
|
|
6506
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded3);
|
|
6493
6507
|
|
|
6494
6508
|
return {
|
|
6495
6509
|
status: 'pending',
|
|
@@ -6501,7 +6515,7 @@ var ChargeResponses = {
|
|
|
6501
6515
|
var message = response.message,
|
|
6502
6516
|
status = response.status;
|
|
6503
6517
|
response.errors;
|
|
6504
|
-
var cleanResponse = _objectWithoutProperties(response,
|
|
6518
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded4);
|
|
6505
6519
|
|
|
6506
6520
|
return {
|
|
6507
6521
|
status: status,
|
|
@@ -6513,7 +6527,7 @@ var ChargeResponses = {
|
|
|
6513
6527
|
response.status;
|
|
6514
6528
|
var message = response.message,
|
|
6515
6529
|
otpmessage = response.otpmessage,
|
|
6516
|
-
cleanResponse = _objectWithoutProperties(response,
|
|
6530
|
+
cleanResponse = _objectWithoutProperties(response, _excluded5);
|
|
6517
6531
|
|
|
6518
6532
|
var authMessage = otpmessage || message;
|
|
6519
6533
|
return {
|
|
@@ -6565,10 +6579,14 @@ var ChargeResponses = {
|
|
|
6565
6579
|
delete response.data;
|
|
6566
6580
|
}
|
|
6567
6581
|
|
|
6568
|
-
if (['true', true, 'success'
|
|
6582
|
+
if (['true', true, 'success'].includes(response.status)) {
|
|
6569
6583
|
return this.success(response);
|
|
6570
6584
|
}
|
|
6571
6585
|
|
|
6586
|
+
if (response.status === PREAUTHORIZATION_STATE_AUTHORIZED) {
|
|
6587
|
+
return this.authorized(response);
|
|
6588
|
+
}
|
|
6589
|
+
|
|
6572
6590
|
if (response.status === 'pending') {
|
|
6573
6591
|
return this.pending(response);
|
|
6574
6592
|
}
|
|
@@ -18861,6 +18879,10 @@ var CardAPI$1 = {
|
|
|
18861
18879
|
};
|
|
18862
18880
|
|
|
18863
18881
|
var paymentMethod$4 = 'card';
|
|
18882
|
+
var savedCardMethods = {
|
|
18883
|
+
payment: 'saved card',
|
|
18884
|
+
authentication: 'otp'
|
|
18885
|
+
};
|
|
18864
18886
|
|
|
18865
18887
|
function validate$4(card, isSetter) {
|
|
18866
18888
|
return new Promise(function (resolve, reject) {
|
|
@@ -19048,29 +19070,32 @@ var CardCharge = {
|
|
|
19048
19070
|
switch (_context.prev = _context.next) {
|
|
19049
19071
|
case 0:
|
|
19050
19072
|
_context.prev = 0;
|
|
19051
|
-
|
|
19073
|
+
|
|
19074
|
+
_this9.logAuth(savedCardMethods.authentication);
|
|
19075
|
+
|
|
19076
|
+
_context.next = 4;
|
|
19052
19077
|
return CardAPI$1.sendSavedCardsOTP({
|
|
19053
19078
|
phone: phone,
|
|
19054
19079
|
transaction: _this9.id
|
|
19055
19080
|
});
|
|
19056
19081
|
|
|
19057
|
-
case
|
|
19082
|
+
case 4:
|
|
19058
19083
|
response = _context.sent;
|
|
19059
19084
|
_this9.savedCardsTempAuthToken = response.data.token;
|
|
19060
19085
|
return _context.abrupt("return", response);
|
|
19061
19086
|
|
|
19062
|
-
case
|
|
19063
|
-
_context.prev =
|
|
19087
|
+
case 9:
|
|
19088
|
+
_context.prev = 9;
|
|
19064
19089
|
_context.t0 = _context["catch"](0);
|
|
19065
19090
|
_this9.savedCardsTempAuthToken = null;
|
|
19066
19091
|
throw _context.t0;
|
|
19067
19092
|
|
|
19068
|
-
case
|
|
19093
|
+
case 13:
|
|
19069
19094
|
case "end":
|
|
19070
19095
|
return _context.stop();
|
|
19071
19096
|
}
|
|
19072
19097
|
}
|
|
19073
|
-
}, _callee, null, [[0,
|
|
19098
|
+
}, _callee, null, [[0, 9]]);
|
|
19074
19099
|
}))();
|
|
19075
19100
|
},
|
|
19076
19101
|
verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
|
|
@@ -19124,6 +19149,7 @@ var CardCharge = {
|
|
|
19124
19149
|
},
|
|
19125
19150
|
chargeSavedCard: function chargeSavedCard(_ref5) {
|
|
19126
19151
|
var cardCode = _ref5.cardCode;
|
|
19152
|
+
this.logAttempt(savedCardMethods.payment);
|
|
19127
19153
|
return CardAPI$1.chargeSavedCard({
|
|
19128
19154
|
cardCode: cardCode,
|
|
19129
19155
|
transaction: this.id,
|
|
@@ -20277,6 +20303,14 @@ var AnalyticsFunctions$1 = {
|
|
|
20277
20303
|
});
|
|
20278
20304
|
return this.saveLog();
|
|
20279
20305
|
},
|
|
20306
|
+
logSavedCardSelect: function logSavedCardSelect() {
|
|
20307
|
+
this.log.history.push({
|
|
20308
|
+
type: 'action',
|
|
20309
|
+
message: 'Selected saved card',
|
|
20310
|
+
time: this.getTimeSpent()
|
|
20311
|
+
});
|
|
20312
|
+
return this.saveLog();
|
|
20313
|
+
},
|
|
20280
20314
|
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
20281
20315
|
this.log.history.push({
|
|
20282
20316
|
type: 'action',
|
|
@@ -20797,21 +20831,6 @@ var ToolkitAPI = {
|
|
|
20797
20831
|
resolvedCardBins[bin] = data;
|
|
20798
20832
|
return data;
|
|
20799
20833
|
});
|
|
20800
|
-
},
|
|
20801
|
-
resolveIPAddress: function resolveIPAddress(ipAddress) {
|
|
20802
|
-
var url = new URL("decision/resolve_ip/".concat(ipAddress), configToUse.paystackApiUrl).toString();
|
|
20803
|
-
var language = getLanguage();
|
|
20804
|
-
|
|
20805
|
-
var headers = _objectSpread2({}, language && {
|
|
20806
|
-
'Accept-Language': language
|
|
20807
|
-
});
|
|
20808
|
-
|
|
20809
|
-
return axiosInstance.get(url, {
|
|
20810
|
-
headers: headers
|
|
20811
|
-
}).then(function (_ref2) {
|
|
20812
|
-
var data = _ref2.data;
|
|
20813
|
-
return data;
|
|
20814
|
-
});
|
|
20815
20834
|
}
|
|
20816
20835
|
};
|
|
20817
20836
|
|
|
@@ -20877,11 +20896,6 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20877
20896
|
value: function resolveCardBin(bin) {
|
|
20878
20897
|
return ToolkitAPI.resolveCardBin(bin);
|
|
20879
20898
|
}
|
|
20880
|
-
}, {
|
|
20881
|
-
key: "resolveIPAddress",
|
|
20882
|
-
value: function resolveIPAddress(ipAddress) {
|
|
20883
|
-
return ToolkitAPI.resolveIPAddress(ipAddress);
|
|
20884
|
-
}
|
|
20885
20899
|
}]);
|
|
20886
20900
|
|
|
20887
20901
|
return Toolkit;
|
|
@@ -20989,7 +21003,7 @@ var CardAPI = {
|
|
|
20989
21003
|
last4 = _ref.last4,
|
|
20990
21004
|
preauthorizationId = _ref.preauthorizationId,
|
|
20991
21005
|
publicKey = _ref.publicKey;
|
|
20992
|
-
var url = new URL('preauthorization/
|
|
21006
|
+
var url = new URL('preauthorization/create', configToUse.paystackApiUrl).toString();
|
|
20993
21007
|
var language = getLanguage();
|
|
20994
21008
|
|
|
20995
21009
|
var headers = _objectSpread2({
|
package/lib/checkout.js
CHANGED
|
@@ -6475,14 +6475,28 @@ addToUnscopables$2('includes');
|
|
|
6475
6475
|
var _excluded = ["message", "status", "errors"],
|
|
6476
6476
|
_excluded2 = ["message", "status", "errors"],
|
|
6477
6477
|
_excluded3 = ["message", "status", "errors"],
|
|
6478
|
-
_excluded4 = ["
|
|
6478
|
+
_excluded4 = ["message", "status", "errors"],
|
|
6479
|
+
_excluded5 = ["status", "message", "otpmessage"];
|
|
6480
|
+
var PREAUTHORIZATION_STATE_AUTHORIZED = 'authorized';
|
|
6479
6481
|
var ChargeResponses = {
|
|
6480
|
-
|
|
6482
|
+
authorized: function authorized(response) {
|
|
6481
6483
|
var message = response.message;
|
|
6482
6484
|
response.status;
|
|
6483
6485
|
response.errors;
|
|
6484
6486
|
var cleanResponse = _objectWithoutProperties(response, _excluded);
|
|
6485
6487
|
|
|
6488
|
+
return {
|
|
6489
|
+
status: PREAUTHORIZATION_STATE_AUTHORIZED,
|
|
6490
|
+
message: message || 'Payment authorized successfully',
|
|
6491
|
+
data: cleanResponse
|
|
6492
|
+
};
|
|
6493
|
+
},
|
|
6494
|
+
success: function success(response) {
|
|
6495
|
+
var message = response.message;
|
|
6496
|
+
response.status;
|
|
6497
|
+
response.errors;
|
|
6498
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded2);
|
|
6499
|
+
|
|
6486
6500
|
return {
|
|
6487
6501
|
status: 'success',
|
|
6488
6502
|
message: message || 'Successful',
|
|
@@ -6493,7 +6507,7 @@ var ChargeResponses = {
|
|
|
6493
6507
|
var message = response.message;
|
|
6494
6508
|
response.status;
|
|
6495
6509
|
response.errors;
|
|
6496
|
-
var cleanResponse = _objectWithoutProperties(response,
|
|
6510
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded3);
|
|
6497
6511
|
|
|
6498
6512
|
return {
|
|
6499
6513
|
status: 'pending',
|
|
@@ -6505,7 +6519,7 @@ var ChargeResponses = {
|
|
|
6505
6519
|
var message = response.message,
|
|
6506
6520
|
status = response.status;
|
|
6507
6521
|
response.errors;
|
|
6508
|
-
var cleanResponse = _objectWithoutProperties(response,
|
|
6522
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded4);
|
|
6509
6523
|
|
|
6510
6524
|
return {
|
|
6511
6525
|
status: status,
|
|
@@ -6517,7 +6531,7 @@ var ChargeResponses = {
|
|
|
6517
6531
|
response.status;
|
|
6518
6532
|
var message = response.message,
|
|
6519
6533
|
otpmessage = response.otpmessage,
|
|
6520
|
-
cleanResponse = _objectWithoutProperties(response,
|
|
6534
|
+
cleanResponse = _objectWithoutProperties(response, _excluded5);
|
|
6521
6535
|
|
|
6522
6536
|
var authMessage = otpmessage || message;
|
|
6523
6537
|
return {
|
|
@@ -6569,10 +6583,14 @@ var ChargeResponses = {
|
|
|
6569
6583
|
delete response.data;
|
|
6570
6584
|
}
|
|
6571
6585
|
|
|
6572
|
-
if (['true', true, 'success'
|
|
6586
|
+
if (['true', true, 'success'].includes(response.status)) {
|
|
6573
6587
|
return this.success(response);
|
|
6574
6588
|
}
|
|
6575
6589
|
|
|
6590
|
+
if (response.status === PREAUTHORIZATION_STATE_AUTHORIZED) {
|
|
6591
|
+
return this.authorized(response);
|
|
6592
|
+
}
|
|
6593
|
+
|
|
6576
6594
|
if (response.status === 'pending') {
|
|
6577
6595
|
return this.pending(response);
|
|
6578
6596
|
}
|
|
@@ -18865,6 +18883,10 @@ var CardAPI$1 = {
|
|
|
18865
18883
|
};
|
|
18866
18884
|
|
|
18867
18885
|
var paymentMethod$4 = 'card';
|
|
18886
|
+
var savedCardMethods = {
|
|
18887
|
+
payment: 'saved card',
|
|
18888
|
+
authentication: 'otp'
|
|
18889
|
+
};
|
|
18868
18890
|
|
|
18869
18891
|
function validate$4(card, isSetter) {
|
|
18870
18892
|
return new Promise(function (resolve, reject) {
|
|
@@ -19052,29 +19074,32 @@ var CardCharge = {
|
|
|
19052
19074
|
switch (_context.prev = _context.next) {
|
|
19053
19075
|
case 0:
|
|
19054
19076
|
_context.prev = 0;
|
|
19055
|
-
|
|
19077
|
+
|
|
19078
|
+
_this9.logAuth(savedCardMethods.authentication);
|
|
19079
|
+
|
|
19080
|
+
_context.next = 4;
|
|
19056
19081
|
return CardAPI$1.sendSavedCardsOTP({
|
|
19057
19082
|
phone: phone,
|
|
19058
19083
|
transaction: _this9.id
|
|
19059
19084
|
});
|
|
19060
19085
|
|
|
19061
|
-
case
|
|
19086
|
+
case 4:
|
|
19062
19087
|
response = _context.sent;
|
|
19063
19088
|
_this9.savedCardsTempAuthToken = response.data.token;
|
|
19064
19089
|
return _context.abrupt("return", response);
|
|
19065
19090
|
|
|
19066
|
-
case
|
|
19067
|
-
_context.prev =
|
|
19091
|
+
case 9:
|
|
19092
|
+
_context.prev = 9;
|
|
19068
19093
|
_context.t0 = _context["catch"](0);
|
|
19069
19094
|
_this9.savedCardsTempAuthToken = null;
|
|
19070
19095
|
throw _context.t0;
|
|
19071
19096
|
|
|
19072
|
-
case
|
|
19097
|
+
case 13:
|
|
19073
19098
|
case "end":
|
|
19074
19099
|
return _context.stop();
|
|
19075
19100
|
}
|
|
19076
19101
|
}
|
|
19077
|
-
}, _callee, null, [[0,
|
|
19102
|
+
}, _callee, null, [[0, 9]]);
|
|
19078
19103
|
}))();
|
|
19079
19104
|
},
|
|
19080
19105
|
verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
|
|
@@ -19128,6 +19153,7 @@ var CardCharge = {
|
|
|
19128
19153
|
},
|
|
19129
19154
|
chargeSavedCard: function chargeSavedCard(_ref5) {
|
|
19130
19155
|
var cardCode = _ref5.cardCode;
|
|
19156
|
+
this.logAttempt(savedCardMethods.payment);
|
|
19131
19157
|
return CardAPI$1.chargeSavedCard({
|
|
19132
19158
|
cardCode: cardCode,
|
|
19133
19159
|
transaction: this.id,
|
|
@@ -20281,6 +20307,14 @@ var AnalyticsFunctions$1 = {
|
|
|
20281
20307
|
});
|
|
20282
20308
|
return this.saveLog();
|
|
20283
20309
|
},
|
|
20310
|
+
logSavedCardSelect: function logSavedCardSelect() {
|
|
20311
|
+
this.log.history.push({
|
|
20312
|
+
type: 'action',
|
|
20313
|
+
message: 'Selected saved card',
|
|
20314
|
+
time: this.getTimeSpent()
|
|
20315
|
+
});
|
|
20316
|
+
return this.saveLog();
|
|
20317
|
+
},
|
|
20284
20318
|
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
20285
20319
|
this.log.history.push({
|
|
20286
20320
|
type: 'action',
|
|
@@ -20801,21 +20835,6 @@ var ToolkitAPI = {
|
|
|
20801
20835
|
resolvedCardBins[bin] = data;
|
|
20802
20836
|
return data;
|
|
20803
20837
|
});
|
|
20804
|
-
},
|
|
20805
|
-
resolveIPAddress: function resolveIPAddress(ipAddress) {
|
|
20806
|
-
var url = new URL("decision/resolve_ip/".concat(ipAddress), configToUse.paystackApiUrl).toString();
|
|
20807
|
-
var language = getLanguage();
|
|
20808
|
-
|
|
20809
|
-
var headers = _objectSpread2({}, language && {
|
|
20810
|
-
'Accept-Language': language
|
|
20811
|
-
});
|
|
20812
|
-
|
|
20813
|
-
return axiosInstance.get(url, {
|
|
20814
|
-
headers: headers
|
|
20815
|
-
}).then(function (_ref2) {
|
|
20816
|
-
var data = _ref2.data;
|
|
20817
|
-
return data;
|
|
20818
|
-
});
|
|
20819
20838
|
}
|
|
20820
20839
|
};
|
|
20821
20840
|
|
|
@@ -20881,11 +20900,6 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20881
20900
|
value: function resolveCardBin(bin) {
|
|
20882
20901
|
return ToolkitAPI.resolveCardBin(bin);
|
|
20883
20902
|
}
|
|
20884
|
-
}, {
|
|
20885
|
-
key: "resolveIPAddress",
|
|
20886
|
-
value: function resolveIPAddress(ipAddress) {
|
|
20887
|
-
return ToolkitAPI.resolveIPAddress(ipAddress);
|
|
20888
|
-
}
|
|
20889
20903
|
}]);
|
|
20890
20904
|
|
|
20891
20905
|
return Toolkit;
|
|
@@ -20993,7 +21007,7 @@ var CardAPI = {
|
|
|
20993
21007
|
last4 = _ref.last4,
|
|
20994
21008
|
preauthorizationId = _ref.preauthorizationId,
|
|
20995
21009
|
publicKey = _ref.publicKey;
|
|
20996
|
-
var url = new URL('preauthorization/
|
|
21010
|
+
var url = new URL('preauthorization/create', configToUse.paystackApiUrl).toString();
|
|
20997
21011
|
var language = getLanguage();
|
|
20998
21012
|
|
|
20999
21013
|
var headers = _objectSpread2({
|