@paystack/checkout-js 1.25.0-dev.9 → 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 -21386
- package/es/checkout.js +45 -32
- package/lib/checkout.js +45 -32
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -6471,15 +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"];
|
|
6475
6476
|
var PREAUTHORIZATION_STATE_AUTHORIZED = 'authorized';
|
|
6476
6477
|
var ChargeResponses = {
|
|
6477
|
-
|
|
6478
|
+
authorized: function authorized(response) {
|
|
6478
6479
|
var message = response.message;
|
|
6479
6480
|
response.status;
|
|
6480
6481
|
response.errors;
|
|
6481
6482
|
var cleanResponse = _objectWithoutProperties(response, _excluded);
|
|
6482
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
|
+
|
|
6483
6496
|
return {
|
|
6484
6497
|
status: 'success',
|
|
6485
6498
|
message: message || 'Successful',
|
|
@@ -6490,7 +6503,7 @@ var ChargeResponses = {
|
|
|
6490
6503
|
var message = response.message;
|
|
6491
6504
|
response.status;
|
|
6492
6505
|
response.errors;
|
|
6493
|
-
var cleanResponse = _objectWithoutProperties(response,
|
|
6506
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded3);
|
|
6494
6507
|
|
|
6495
6508
|
return {
|
|
6496
6509
|
status: 'pending',
|
|
@@ -6502,7 +6515,7 @@ var ChargeResponses = {
|
|
|
6502
6515
|
var message = response.message,
|
|
6503
6516
|
status = response.status;
|
|
6504
6517
|
response.errors;
|
|
6505
|
-
var cleanResponse = _objectWithoutProperties(response,
|
|
6518
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded4);
|
|
6506
6519
|
|
|
6507
6520
|
return {
|
|
6508
6521
|
status: status,
|
|
@@ -6514,7 +6527,7 @@ var ChargeResponses = {
|
|
|
6514
6527
|
response.status;
|
|
6515
6528
|
var message = response.message,
|
|
6516
6529
|
otpmessage = response.otpmessage,
|
|
6517
|
-
cleanResponse = _objectWithoutProperties(response,
|
|
6530
|
+
cleanResponse = _objectWithoutProperties(response, _excluded5);
|
|
6518
6531
|
|
|
6519
6532
|
var authMessage = otpmessage || message;
|
|
6520
6533
|
return {
|
|
@@ -6566,10 +6579,14 @@ var ChargeResponses = {
|
|
|
6566
6579
|
delete response.data;
|
|
6567
6580
|
}
|
|
6568
6581
|
|
|
6569
|
-
if (['true', true, 'success'
|
|
6582
|
+
if (['true', true, 'success'].includes(response.status)) {
|
|
6570
6583
|
return this.success(response);
|
|
6571
6584
|
}
|
|
6572
6585
|
|
|
6586
|
+
if (response.status === PREAUTHORIZATION_STATE_AUTHORIZED) {
|
|
6587
|
+
return this.authorized(response);
|
|
6588
|
+
}
|
|
6589
|
+
|
|
6573
6590
|
if (response.status === 'pending') {
|
|
6574
6591
|
return this.pending(response);
|
|
6575
6592
|
}
|
|
@@ -18862,6 +18879,10 @@ var CardAPI$1 = {
|
|
|
18862
18879
|
};
|
|
18863
18880
|
|
|
18864
18881
|
var paymentMethod$4 = 'card';
|
|
18882
|
+
var savedCardMethods = {
|
|
18883
|
+
payment: 'saved card',
|
|
18884
|
+
authentication: 'otp'
|
|
18885
|
+
};
|
|
18865
18886
|
|
|
18866
18887
|
function validate$4(card, isSetter) {
|
|
18867
18888
|
return new Promise(function (resolve, reject) {
|
|
@@ -19049,29 +19070,32 @@ var CardCharge = {
|
|
|
19049
19070
|
switch (_context.prev = _context.next) {
|
|
19050
19071
|
case 0:
|
|
19051
19072
|
_context.prev = 0;
|
|
19052
|
-
|
|
19073
|
+
|
|
19074
|
+
_this9.logAuth(savedCardMethods.authentication);
|
|
19075
|
+
|
|
19076
|
+
_context.next = 4;
|
|
19053
19077
|
return CardAPI$1.sendSavedCardsOTP({
|
|
19054
19078
|
phone: phone,
|
|
19055
19079
|
transaction: _this9.id
|
|
19056
19080
|
});
|
|
19057
19081
|
|
|
19058
|
-
case
|
|
19082
|
+
case 4:
|
|
19059
19083
|
response = _context.sent;
|
|
19060
19084
|
_this9.savedCardsTempAuthToken = response.data.token;
|
|
19061
19085
|
return _context.abrupt("return", response);
|
|
19062
19086
|
|
|
19063
|
-
case
|
|
19064
|
-
_context.prev =
|
|
19087
|
+
case 9:
|
|
19088
|
+
_context.prev = 9;
|
|
19065
19089
|
_context.t0 = _context["catch"](0);
|
|
19066
19090
|
_this9.savedCardsTempAuthToken = null;
|
|
19067
19091
|
throw _context.t0;
|
|
19068
19092
|
|
|
19069
|
-
case
|
|
19093
|
+
case 13:
|
|
19070
19094
|
case "end":
|
|
19071
19095
|
return _context.stop();
|
|
19072
19096
|
}
|
|
19073
19097
|
}
|
|
19074
|
-
}, _callee, null, [[0,
|
|
19098
|
+
}, _callee, null, [[0, 9]]);
|
|
19075
19099
|
}))();
|
|
19076
19100
|
},
|
|
19077
19101
|
verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
|
|
@@ -19125,6 +19149,7 @@ var CardCharge = {
|
|
|
19125
19149
|
},
|
|
19126
19150
|
chargeSavedCard: function chargeSavedCard(_ref5) {
|
|
19127
19151
|
var cardCode = _ref5.cardCode;
|
|
19152
|
+
this.logAttempt(savedCardMethods.payment);
|
|
19128
19153
|
return CardAPI$1.chargeSavedCard({
|
|
19129
19154
|
cardCode: cardCode,
|
|
19130
19155
|
transaction: this.id,
|
|
@@ -20278,6 +20303,14 @@ var AnalyticsFunctions$1 = {
|
|
|
20278
20303
|
});
|
|
20279
20304
|
return this.saveLog();
|
|
20280
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
|
+
},
|
|
20281
20314
|
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
20282
20315
|
this.log.history.push({
|
|
20283
20316
|
type: 'action',
|
|
@@ -20798,21 +20831,6 @@ var ToolkitAPI = {
|
|
|
20798
20831
|
resolvedCardBins[bin] = data;
|
|
20799
20832
|
return data;
|
|
20800
20833
|
});
|
|
20801
|
-
},
|
|
20802
|
-
resolveIPAddress: function resolveIPAddress(ipAddress) {
|
|
20803
|
-
var url = new URL("decision/resolve_ip/".concat(ipAddress), configToUse.paystackApiUrl).toString();
|
|
20804
|
-
var language = getLanguage();
|
|
20805
|
-
|
|
20806
|
-
var headers = _objectSpread2({}, language && {
|
|
20807
|
-
'Accept-Language': language
|
|
20808
|
-
});
|
|
20809
|
-
|
|
20810
|
-
return axiosInstance.get(url, {
|
|
20811
|
-
headers: headers
|
|
20812
|
-
}).then(function (_ref2) {
|
|
20813
|
-
var data = _ref2.data;
|
|
20814
|
-
return data;
|
|
20815
|
-
});
|
|
20816
20834
|
}
|
|
20817
20835
|
};
|
|
20818
20836
|
|
|
@@ -20878,11 +20896,6 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20878
20896
|
value: function resolveCardBin(bin) {
|
|
20879
20897
|
return ToolkitAPI.resolveCardBin(bin);
|
|
20880
20898
|
}
|
|
20881
|
-
}, {
|
|
20882
|
-
key: "resolveIPAddress",
|
|
20883
|
-
value: function resolveIPAddress(ipAddress) {
|
|
20884
|
-
return ToolkitAPI.resolveIPAddress(ipAddress);
|
|
20885
|
-
}
|
|
20886
20899
|
}]);
|
|
20887
20900
|
|
|
20888
20901
|
return Toolkit;
|
package/lib/checkout.js
CHANGED
|
@@ -6475,15 +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"];
|
|
6479
6480
|
var PREAUTHORIZATION_STATE_AUTHORIZED = 'authorized';
|
|
6480
6481
|
var ChargeResponses = {
|
|
6481
|
-
|
|
6482
|
+
authorized: function authorized(response) {
|
|
6482
6483
|
var message = response.message;
|
|
6483
6484
|
response.status;
|
|
6484
6485
|
response.errors;
|
|
6485
6486
|
var cleanResponse = _objectWithoutProperties(response, _excluded);
|
|
6486
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
|
+
|
|
6487
6500
|
return {
|
|
6488
6501
|
status: 'success',
|
|
6489
6502
|
message: message || 'Successful',
|
|
@@ -6494,7 +6507,7 @@ var ChargeResponses = {
|
|
|
6494
6507
|
var message = response.message;
|
|
6495
6508
|
response.status;
|
|
6496
6509
|
response.errors;
|
|
6497
|
-
var cleanResponse = _objectWithoutProperties(response,
|
|
6510
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded3);
|
|
6498
6511
|
|
|
6499
6512
|
return {
|
|
6500
6513
|
status: 'pending',
|
|
@@ -6506,7 +6519,7 @@ var ChargeResponses = {
|
|
|
6506
6519
|
var message = response.message,
|
|
6507
6520
|
status = response.status;
|
|
6508
6521
|
response.errors;
|
|
6509
|
-
var cleanResponse = _objectWithoutProperties(response,
|
|
6522
|
+
var cleanResponse = _objectWithoutProperties(response, _excluded4);
|
|
6510
6523
|
|
|
6511
6524
|
return {
|
|
6512
6525
|
status: status,
|
|
@@ -6518,7 +6531,7 @@ var ChargeResponses = {
|
|
|
6518
6531
|
response.status;
|
|
6519
6532
|
var message = response.message,
|
|
6520
6533
|
otpmessage = response.otpmessage,
|
|
6521
|
-
cleanResponse = _objectWithoutProperties(response,
|
|
6534
|
+
cleanResponse = _objectWithoutProperties(response, _excluded5);
|
|
6522
6535
|
|
|
6523
6536
|
var authMessage = otpmessage || message;
|
|
6524
6537
|
return {
|
|
@@ -6570,10 +6583,14 @@ var ChargeResponses = {
|
|
|
6570
6583
|
delete response.data;
|
|
6571
6584
|
}
|
|
6572
6585
|
|
|
6573
|
-
if (['true', true, 'success'
|
|
6586
|
+
if (['true', true, 'success'].includes(response.status)) {
|
|
6574
6587
|
return this.success(response);
|
|
6575
6588
|
}
|
|
6576
6589
|
|
|
6590
|
+
if (response.status === PREAUTHORIZATION_STATE_AUTHORIZED) {
|
|
6591
|
+
return this.authorized(response);
|
|
6592
|
+
}
|
|
6593
|
+
|
|
6577
6594
|
if (response.status === 'pending') {
|
|
6578
6595
|
return this.pending(response);
|
|
6579
6596
|
}
|
|
@@ -18866,6 +18883,10 @@ var CardAPI$1 = {
|
|
|
18866
18883
|
};
|
|
18867
18884
|
|
|
18868
18885
|
var paymentMethod$4 = 'card';
|
|
18886
|
+
var savedCardMethods = {
|
|
18887
|
+
payment: 'saved card',
|
|
18888
|
+
authentication: 'otp'
|
|
18889
|
+
};
|
|
18869
18890
|
|
|
18870
18891
|
function validate$4(card, isSetter) {
|
|
18871
18892
|
return new Promise(function (resolve, reject) {
|
|
@@ -19053,29 +19074,32 @@ var CardCharge = {
|
|
|
19053
19074
|
switch (_context.prev = _context.next) {
|
|
19054
19075
|
case 0:
|
|
19055
19076
|
_context.prev = 0;
|
|
19056
|
-
|
|
19077
|
+
|
|
19078
|
+
_this9.logAuth(savedCardMethods.authentication);
|
|
19079
|
+
|
|
19080
|
+
_context.next = 4;
|
|
19057
19081
|
return CardAPI$1.sendSavedCardsOTP({
|
|
19058
19082
|
phone: phone,
|
|
19059
19083
|
transaction: _this9.id
|
|
19060
19084
|
});
|
|
19061
19085
|
|
|
19062
|
-
case
|
|
19086
|
+
case 4:
|
|
19063
19087
|
response = _context.sent;
|
|
19064
19088
|
_this9.savedCardsTempAuthToken = response.data.token;
|
|
19065
19089
|
return _context.abrupt("return", response);
|
|
19066
19090
|
|
|
19067
|
-
case
|
|
19068
|
-
_context.prev =
|
|
19091
|
+
case 9:
|
|
19092
|
+
_context.prev = 9;
|
|
19069
19093
|
_context.t0 = _context["catch"](0);
|
|
19070
19094
|
_this9.savedCardsTempAuthToken = null;
|
|
19071
19095
|
throw _context.t0;
|
|
19072
19096
|
|
|
19073
|
-
case
|
|
19097
|
+
case 13:
|
|
19074
19098
|
case "end":
|
|
19075
19099
|
return _context.stop();
|
|
19076
19100
|
}
|
|
19077
19101
|
}
|
|
19078
|
-
}, _callee, null, [[0,
|
|
19102
|
+
}, _callee, null, [[0, 9]]);
|
|
19079
19103
|
}))();
|
|
19080
19104
|
},
|
|
19081
19105
|
verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
|
|
@@ -19129,6 +19153,7 @@ var CardCharge = {
|
|
|
19129
19153
|
},
|
|
19130
19154
|
chargeSavedCard: function chargeSavedCard(_ref5) {
|
|
19131
19155
|
var cardCode = _ref5.cardCode;
|
|
19156
|
+
this.logAttempt(savedCardMethods.payment);
|
|
19132
19157
|
return CardAPI$1.chargeSavedCard({
|
|
19133
19158
|
cardCode: cardCode,
|
|
19134
19159
|
transaction: this.id,
|
|
@@ -20282,6 +20307,14 @@ var AnalyticsFunctions$1 = {
|
|
|
20282
20307
|
});
|
|
20283
20308
|
return this.saveLog();
|
|
20284
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
|
+
},
|
|
20285
20318
|
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
20286
20319
|
this.log.history.push({
|
|
20287
20320
|
type: 'action',
|
|
@@ -20802,21 +20835,6 @@ var ToolkitAPI = {
|
|
|
20802
20835
|
resolvedCardBins[bin] = data;
|
|
20803
20836
|
return data;
|
|
20804
20837
|
});
|
|
20805
|
-
},
|
|
20806
|
-
resolveIPAddress: function resolveIPAddress(ipAddress) {
|
|
20807
|
-
var url = new URL("decision/resolve_ip/".concat(ipAddress), configToUse.paystackApiUrl).toString();
|
|
20808
|
-
var language = getLanguage();
|
|
20809
|
-
|
|
20810
|
-
var headers = _objectSpread2({}, language && {
|
|
20811
|
-
'Accept-Language': language
|
|
20812
|
-
});
|
|
20813
|
-
|
|
20814
|
-
return axiosInstance.get(url, {
|
|
20815
|
-
headers: headers
|
|
20816
|
-
}).then(function (_ref2) {
|
|
20817
|
-
var data = _ref2.data;
|
|
20818
|
-
return data;
|
|
20819
|
-
});
|
|
20820
20838
|
}
|
|
20821
20839
|
};
|
|
20822
20840
|
|
|
@@ -20882,11 +20900,6 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20882
20900
|
value: function resolveCardBin(bin) {
|
|
20883
20901
|
return ToolkitAPI.resolveCardBin(bin);
|
|
20884
20902
|
}
|
|
20885
|
-
}, {
|
|
20886
|
-
key: "resolveIPAddress",
|
|
20887
|
-
value: function resolveIPAddress(ipAddress) {
|
|
20888
|
-
return ToolkitAPI.resolveIPAddress(ipAddress);
|
|
20889
|
-
}
|
|
20890
20903
|
}]);
|
|
20891
20904
|
|
|
20892
20905
|
return Toolkit;
|