@paystack/checkout-js 1.21.1 → 1.22.0-dev.10
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 +21353 -29
- package/es/checkout.js +560 -56
- package/lib/checkout.js +560 -56
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -18664,6 +18664,209 @@ var CardAPI$1 = {
|
|
|
18664
18664
|
}).then(function (response) {
|
|
18665
18665
|
return ChargeResponses.parse(response.data);
|
|
18666
18666
|
});
|
|
18667
|
+
},
|
|
18668
|
+
sendSavedCardsOTP: function sendSavedCardsOTP(transaction) {
|
|
18669
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18670
|
+
var url, language, headers, response;
|
|
18671
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18672
|
+
while (1) {
|
|
18673
|
+
switch (_context.prev = _context.next) {
|
|
18674
|
+
case 0:
|
|
18675
|
+
url = new URL('/saved_cards/authorize', configToUse.paystackApiUrl).toString();
|
|
18676
|
+
language = getLanguage();
|
|
18677
|
+
headers = _objectSpread2({}, language && {
|
|
18678
|
+
'Accept-Language': language
|
|
18679
|
+
});
|
|
18680
|
+
_context.next = 5;
|
|
18681
|
+
return axiosInstance.post(url, {
|
|
18682
|
+
transaction: transaction
|
|
18683
|
+
}, {
|
|
18684
|
+
headers: headers
|
|
18685
|
+
});
|
|
18686
|
+
|
|
18687
|
+
case 5:
|
|
18688
|
+
response = _context.sent;
|
|
18689
|
+
return _context.abrupt("return", response.data);
|
|
18690
|
+
|
|
18691
|
+
case 7:
|
|
18692
|
+
case "end":
|
|
18693
|
+
return _context.stop();
|
|
18694
|
+
}
|
|
18695
|
+
}
|
|
18696
|
+
}, _callee);
|
|
18697
|
+
}))();
|
|
18698
|
+
},
|
|
18699
|
+
addUserToSavedCards: function addUserToSavedCards(_ref6) {
|
|
18700
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18701
|
+
var phone, transaction, url, language, headers, data, response;
|
|
18702
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18703
|
+
while (1) {
|
|
18704
|
+
switch (_context2.prev = _context2.next) {
|
|
18705
|
+
case 0:
|
|
18706
|
+
phone = _ref6.phone, transaction = _ref6.transaction;
|
|
18707
|
+
url = new URL('/saved_cards/user', configToUse.paystackApiUrl).toString();
|
|
18708
|
+
language = getLanguage();
|
|
18709
|
+
headers = _objectSpread2({}, language && {
|
|
18710
|
+
'Accept-Language': language
|
|
18711
|
+
});
|
|
18712
|
+
data = {
|
|
18713
|
+
phone: phone,
|
|
18714
|
+
transaction: transaction
|
|
18715
|
+
};
|
|
18716
|
+
_context2.next = 7;
|
|
18717
|
+
return axiosInstance.post(url, data, {
|
|
18718
|
+
headers: headers
|
|
18719
|
+
});
|
|
18720
|
+
|
|
18721
|
+
case 7:
|
|
18722
|
+
response = _context2.sent;
|
|
18723
|
+
return _context2.abrupt("return", response.data);
|
|
18724
|
+
|
|
18725
|
+
case 9:
|
|
18726
|
+
case "end":
|
|
18727
|
+
return _context2.stop();
|
|
18728
|
+
}
|
|
18729
|
+
}
|
|
18730
|
+
}, _callee2);
|
|
18731
|
+
}))();
|
|
18732
|
+
},
|
|
18733
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref7) {
|
|
18734
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18735
|
+
var code, transaction, url, language, headers, data, response;
|
|
18736
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18737
|
+
while (1) {
|
|
18738
|
+
switch (_context3.prev = _context3.next) {
|
|
18739
|
+
case 0:
|
|
18740
|
+
code = _ref7.code, transaction = _ref7.transaction;
|
|
18741
|
+
url = new URL('/saved_cards/authorize/verify', configToUse.paystackApiUrl).toString();
|
|
18742
|
+
language = getLanguage();
|
|
18743
|
+
headers = _objectSpread2({}, language && {
|
|
18744
|
+
'Accept-Language': language
|
|
18745
|
+
});
|
|
18746
|
+
data = {
|
|
18747
|
+
code: code,
|
|
18748
|
+
transaction: transaction
|
|
18749
|
+
};
|
|
18750
|
+
_context3.next = 7;
|
|
18751
|
+
return axiosInstance.post(url, data, {
|
|
18752
|
+
headers: headers
|
|
18753
|
+
});
|
|
18754
|
+
|
|
18755
|
+
case 7:
|
|
18756
|
+
response = _context3.sent;
|
|
18757
|
+
return _context3.abrupt("return", response.data);
|
|
18758
|
+
|
|
18759
|
+
case 9:
|
|
18760
|
+
case "end":
|
|
18761
|
+
return _context3.stop();
|
|
18762
|
+
}
|
|
18763
|
+
}
|
|
18764
|
+
}, _callee3);
|
|
18765
|
+
}))();
|
|
18766
|
+
},
|
|
18767
|
+
getSavedCards: function getSavedCards(_ref8) {
|
|
18768
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18769
|
+
var token, url, language, headers, response;
|
|
18770
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18771
|
+
while (1) {
|
|
18772
|
+
switch (_context4.prev = _context4.next) {
|
|
18773
|
+
case 0:
|
|
18774
|
+
token = _ref8.token;
|
|
18775
|
+
url = new URL('/saved_cards/cards', configToUse.paystackApiUrl).toString();
|
|
18776
|
+
language = getLanguage();
|
|
18777
|
+
headers = _objectSpread2({
|
|
18778
|
+
Authorization: "Bearer ".concat(token),
|
|
18779
|
+
'jwt-auth': true
|
|
18780
|
+
}, language && {
|
|
18781
|
+
'Accept-Language': language
|
|
18782
|
+
});
|
|
18783
|
+
_context4.next = 6;
|
|
18784
|
+
return axiosInstance.get(url, {
|
|
18785
|
+
headers: headers
|
|
18786
|
+
});
|
|
18787
|
+
|
|
18788
|
+
case 6:
|
|
18789
|
+
response = _context4.sent;
|
|
18790
|
+
return _context4.abrupt("return", response.data);
|
|
18791
|
+
|
|
18792
|
+
case 8:
|
|
18793
|
+
case "end":
|
|
18794
|
+
return _context4.stop();
|
|
18795
|
+
}
|
|
18796
|
+
}
|
|
18797
|
+
}, _callee4);
|
|
18798
|
+
}))();
|
|
18799
|
+
},
|
|
18800
|
+
deleteSavedCard: function deleteSavedCard(_ref9) {
|
|
18801
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
18802
|
+
var cardCode, token, url, language, headers, response;
|
|
18803
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
18804
|
+
while (1) {
|
|
18805
|
+
switch (_context5.prev = _context5.next) {
|
|
18806
|
+
case 0:
|
|
18807
|
+
cardCode = _ref9.cardCode, token = _ref9.token;
|
|
18808
|
+
url = new URL("/saved_cards/cards/".concat(cardCode), configToUse.paystackApiUrl).toString();
|
|
18809
|
+
language = getLanguage();
|
|
18810
|
+
headers = _objectSpread2({
|
|
18811
|
+
Authorization: "Bearer ".concat(token),
|
|
18812
|
+
'jwt-auth': true
|
|
18813
|
+
}, language && {
|
|
18814
|
+
'Accept-Language': language
|
|
18815
|
+
});
|
|
18816
|
+
_context5.next = 6;
|
|
18817
|
+
return axiosInstance.delete(url, {
|
|
18818
|
+
headers: headers
|
|
18819
|
+
});
|
|
18820
|
+
|
|
18821
|
+
case 6:
|
|
18822
|
+
response = _context5.sent;
|
|
18823
|
+
return _context5.abrupt("return", response.data);
|
|
18824
|
+
|
|
18825
|
+
case 8:
|
|
18826
|
+
case "end":
|
|
18827
|
+
return _context5.stop();
|
|
18828
|
+
}
|
|
18829
|
+
}
|
|
18830
|
+
}, _callee5);
|
|
18831
|
+
}))();
|
|
18832
|
+
},
|
|
18833
|
+
chargeSavedCard: function chargeSavedCard(_ref10) {
|
|
18834
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
18835
|
+
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data, response;
|
|
18836
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
18837
|
+
while (1) {
|
|
18838
|
+
switch (_context6.prev = _context6.next) {
|
|
18839
|
+
case 0:
|
|
18840
|
+
token = _ref10.token, device = _ref10.device, cardCode = _ref10.cardCode, transaction = _ref10.transaction, selectedCurrency = _ref10.selectedCurrency;
|
|
18841
|
+
url = new URL("/saved_cards/cards/".concat(cardCode, "/charge"), configToUse.paystackApiUrl).toString();
|
|
18842
|
+
language = getLanguage();
|
|
18843
|
+
headers = _objectSpread2({
|
|
18844
|
+
Authorization: "Bearer ".concat(token),
|
|
18845
|
+
'jwt-auth': true
|
|
18846
|
+
}, language && {
|
|
18847
|
+
'Accept-Language': language
|
|
18848
|
+
});
|
|
18849
|
+
data = {
|
|
18850
|
+
device: device,
|
|
18851
|
+
transaction: transaction,
|
|
18852
|
+
selected_currency: selectedCurrency
|
|
18853
|
+
};
|
|
18854
|
+
_context6.next = 7;
|
|
18855
|
+
return axiosInstance.post(url, data, {
|
|
18856
|
+
headers: headers
|
|
18857
|
+
});
|
|
18858
|
+
|
|
18859
|
+
case 7:
|
|
18860
|
+
response = _context6.sent;
|
|
18861
|
+
return _context6.abrupt("return", ChargeResponses.parse(response.data));
|
|
18862
|
+
|
|
18863
|
+
case 9:
|
|
18864
|
+
case "end":
|
|
18865
|
+
return _context6.stop();
|
|
18866
|
+
}
|
|
18867
|
+
}
|
|
18868
|
+
}, _callee6);
|
|
18869
|
+
}))();
|
|
18667
18870
|
}
|
|
18668
18871
|
};
|
|
18669
18872
|
|
|
@@ -18844,6 +19047,74 @@ var CardCharge = {
|
|
|
18844
19047
|
paymentMethod: paymentMethod$4
|
|
18845
19048
|
};
|
|
18846
19049
|
return this.listenForCharge(listenerOptions, callback);
|
|
19050
|
+
},
|
|
19051
|
+
sendSavedCardsOTP: function sendSavedCardsOTP() {
|
|
19052
|
+
return CardAPI$1.sendSavedCardsOTP(this.id);
|
|
19053
|
+
},
|
|
19054
|
+
addUserToSavedCards: function addUserToSavedCards(_ref4) {
|
|
19055
|
+
var phone = _ref4.phone;
|
|
19056
|
+
return CardAPI$1.addUserToSavedCards({
|
|
19057
|
+
phone: phone,
|
|
19058
|
+
transaction: this.id
|
|
19059
|
+
});
|
|
19060
|
+
},
|
|
19061
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
|
|
19062
|
+
var _this9 = this;
|
|
19063
|
+
|
|
19064
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
19065
|
+
var code, payload, response;
|
|
19066
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19067
|
+
while (1) {
|
|
19068
|
+
switch (_context.prev = _context.next) {
|
|
19069
|
+
case 0:
|
|
19070
|
+
code = _ref5.code;
|
|
19071
|
+
payload = {
|
|
19072
|
+
code: code,
|
|
19073
|
+
transaction: _this9.id
|
|
19074
|
+
};
|
|
19075
|
+
_context.prev = 2;
|
|
19076
|
+
_context.next = 5;
|
|
19077
|
+
return CardAPI$1.verifySavedCardsOtp(payload);
|
|
19078
|
+
|
|
19079
|
+
case 5:
|
|
19080
|
+
response = _context.sent;
|
|
19081
|
+
_this9.savedCardsToken = response.data.token;
|
|
19082
|
+
return _context.abrupt("return", response);
|
|
19083
|
+
|
|
19084
|
+
case 10:
|
|
19085
|
+
_context.prev = 10;
|
|
19086
|
+
_context.t0 = _context["catch"](2);
|
|
19087
|
+
_this9.savedCardsToken = null;
|
|
19088
|
+
throw _context.t0;
|
|
19089
|
+
|
|
19090
|
+
case 14:
|
|
19091
|
+
case "end":
|
|
19092
|
+
return _context.stop();
|
|
19093
|
+
}
|
|
19094
|
+
}
|
|
19095
|
+
}, _callee, null, [[2, 10]]);
|
|
19096
|
+
}))();
|
|
19097
|
+
},
|
|
19098
|
+
getSavedCards: function getSavedCards() {
|
|
19099
|
+
return CardAPI$1.getSavedCards({
|
|
19100
|
+
token: this.savedCardsToken
|
|
19101
|
+
});
|
|
19102
|
+
},
|
|
19103
|
+
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
19104
|
+
return CardAPI$1.deleteSavedCard({
|
|
19105
|
+
cardCode: cardCode,
|
|
19106
|
+
token: this.savedCardsToken
|
|
19107
|
+
});
|
|
19108
|
+
},
|
|
19109
|
+
chargeSavedCard: function chargeSavedCard(_ref6) {
|
|
19110
|
+
var cardCode = _ref6.cardCode;
|
|
19111
|
+
return CardAPI$1.chargeSavedCard({
|
|
19112
|
+
cardCode: cardCode,
|
|
19113
|
+
transaction: this.id,
|
|
19114
|
+
token: this.savedCardsToken,
|
|
19115
|
+
device: this.deviceFingerprint,
|
|
19116
|
+
selectedCurrency: this.currency
|
|
19117
|
+
});
|
|
18847
19118
|
}
|
|
18848
19119
|
};
|
|
18849
19120
|
|
|
@@ -19766,6 +20037,32 @@ function isMobile (ua) {
|
|
|
19766
20037
|
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(ua) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(ua.substr(0,4));
|
|
19767
20038
|
}
|
|
19768
20039
|
|
|
20040
|
+
var AnalyticsUtils = {
|
|
20041
|
+
initializeLog: function initializeLog(log) {
|
|
20042
|
+
var _ref = log || {},
|
|
20043
|
+
attempts = _ref.attempts,
|
|
20044
|
+
authentication = _ref.authentication,
|
|
20045
|
+
errors = _ref.errors,
|
|
20046
|
+
history = _ref.history;
|
|
20047
|
+
|
|
20048
|
+
return {
|
|
20049
|
+
start_time: Math.round(Date.now() / 1000),
|
|
20050
|
+
time_spent: 0,
|
|
20051
|
+
attempts: attempts || 0,
|
|
20052
|
+
authentication: authentication,
|
|
20053
|
+
errors: errors || 0,
|
|
20054
|
+
success: false,
|
|
20055
|
+
mobile: isMobile_1(),
|
|
20056
|
+
input: [],
|
|
20057
|
+
history: history || []
|
|
20058
|
+
};
|
|
20059
|
+
},
|
|
20060
|
+
getTimeSpent: function getTimeSpent(startTime) {
|
|
20061
|
+
var currentTimeInSeconds = Math.round(Date.now() / 1000);
|
|
20062
|
+
return currentTimeInSeconds - startTime;
|
|
20063
|
+
}
|
|
20064
|
+
};
|
|
20065
|
+
|
|
19769
20066
|
var $ = _export;
|
|
19770
20067
|
var global$1 = global$R;
|
|
19771
20068
|
var getBuiltIn = getBuiltIn$a;
|
|
@@ -19812,9 +20109,10 @@ if ($stringify) {
|
|
|
19812
20109
|
});
|
|
19813
20110
|
}
|
|
19814
20111
|
|
|
19815
|
-
var
|
|
19816
|
-
saveLog: function saveLog(
|
|
19817
|
-
var
|
|
20112
|
+
var AnalyticsAPIUtils = {
|
|
20113
|
+
saveLog: function saveLog(url, _ref) {
|
|
20114
|
+
var merchantKey = _ref.merchantKey,
|
|
20115
|
+
log = _ref.log;
|
|
19818
20116
|
var language = getLanguage();
|
|
19819
20117
|
|
|
19820
20118
|
var headers = _objectSpread2({
|
|
@@ -19845,8 +20143,8 @@ var AnalyticsAPI = {
|
|
|
19845
20143
|
return response.data.data.ip_address;
|
|
19846
20144
|
});
|
|
19847
20145
|
},
|
|
19848
|
-
saveIp: function saveIp(
|
|
19849
|
-
var
|
|
20146
|
+
saveIp: function saveIp(url, _ref2) {
|
|
20147
|
+
var merchantKey = _ref2.merchantKey;
|
|
19850
20148
|
var language = getLanguage();
|
|
19851
20149
|
|
|
19852
20150
|
var headers = _objectSpread2({
|
|
@@ -19861,8 +20159,9 @@ var AnalyticsAPI = {
|
|
|
19861
20159
|
return response.data;
|
|
19862
20160
|
});
|
|
19863
20161
|
},
|
|
19864
|
-
saveReferrer: function saveReferrer(
|
|
19865
|
-
var
|
|
20162
|
+
saveReferrer: function saveReferrer(url, _ref3) {
|
|
20163
|
+
var merchantKey = _ref3.merchantKey,
|
|
20164
|
+
referrer = _ref3.referrer;
|
|
19866
20165
|
var language = getLanguage();
|
|
19867
20166
|
|
|
19868
20167
|
var headers = _objectSpread2({
|
|
@@ -19881,29 +20180,38 @@ var AnalyticsAPI = {
|
|
|
19881
20180
|
}
|
|
19882
20181
|
};
|
|
19883
20182
|
|
|
19884
|
-
var
|
|
19885
|
-
|
|
19886
|
-
var
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
|
|
19890
|
-
|
|
20183
|
+
var AnalyticsAPI = {
|
|
20184
|
+
saveLog: function saveLog(transactionId, merchantKey, log) {
|
|
20185
|
+
var url = new URL("transaction/update_log/".concat(transactionId), configToUse.paystackApiUrl).toString();
|
|
20186
|
+
return AnalyticsAPIUtils.saveLog(url, {
|
|
20187
|
+
merchantKey: merchantKey,
|
|
20188
|
+
log: log
|
|
20189
|
+
});
|
|
20190
|
+
},
|
|
20191
|
+
getIp: function getIp() {
|
|
20192
|
+
return AnalyticsAPIUtils.getIp();
|
|
20193
|
+
},
|
|
20194
|
+
saveIp: function saveIp(transactionId, merchantKey) {
|
|
20195
|
+
var url = new URL("transaction/set_ip/".concat(transactionId), configToUse.paystackApiUrl).toString();
|
|
20196
|
+
return AnalyticsAPIUtils.saveIp(url, {
|
|
20197
|
+
merchantKey: merchantKey
|
|
20198
|
+
});
|
|
20199
|
+
},
|
|
20200
|
+
saveReferrer: function saveReferrer(transactionId, merchantKey, referrer) {
|
|
20201
|
+
var url = new URL("transaction/set_referrer/".concat(transactionId), configToUse.paystackApiUrl).toString();
|
|
20202
|
+
return AnalyticsAPIUtils.saveReferrer(url, {
|
|
20203
|
+
merchantKey: merchantKey,
|
|
20204
|
+
referrer: referrer
|
|
20205
|
+
});
|
|
20206
|
+
}
|
|
20207
|
+
};
|
|
19891
20208
|
|
|
19892
|
-
|
|
19893
|
-
|
|
19894
|
-
|
|
19895
|
-
attempts: attempts || 0,
|
|
19896
|
-
authentication: authentication,
|
|
19897
|
-
errors: errors || 0,
|
|
19898
|
-
success: false,
|
|
19899
|
-
mobile: isMobile_1(),
|
|
19900
|
-
input: [],
|
|
19901
|
-
history: history || []
|
|
19902
|
-
};
|
|
20209
|
+
var AnalyticsFunctions$1 = {
|
|
20210
|
+
initializeLog: function initializeLog(log) {
|
|
20211
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
19903
20212
|
},
|
|
19904
20213
|
getTimeSpent: function getTimeSpent() {
|
|
19905
|
-
|
|
19906
|
-
this.log.time_spent = currentTimeInSeconds - this.log.start_time;
|
|
20214
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
19907
20215
|
return this.log.time_spent;
|
|
19908
20216
|
},
|
|
19909
20217
|
logPageOpen: function logPageOpen() {
|
|
@@ -19987,9 +20295,9 @@ var AnalyticsFunctions = {
|
|
|
19987
20295
|
return false;
|
|
19988
20296
|
}
|
|
19989
20297
|
},
|
|
19990
|
-
logMobileMoneyActions: function logMobileMoneyActions(
|
|
19991
|
-
var numberOfTokenRequests =
|
|
19992
|
-
registrationToken =
|
|
20298
|
+
logMobileMoneyActions: function logMobileMoneyActions(_ref) {
|
|
20299
|
+
var numberOfTokenRequests = _ref.numberOfTokenRequests,
|
|
20300
|
+
registrationToken = _ref.registrationToken;
|
|
19993
20301
|
|
|
19994
20302
|
if (numberOfTokenRequests) {
|
|
19995
20303
|
this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
@@ -20115,10 +20423,10 @@ var AnalyticsFunctions = {
|
|
|
20115
20423
|
});
|
|
20116
20424
|
return this.saveLog();
|
|
20117
20425
|
},
|
|
20118
|
-
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(
|
|
20119
|
-
var currency =
|
|
20120
|
-
|
|
20121
|
-
isUserAction =
|
|
20426
|
+
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(_ref2) {
|
|
20427
|
+
var currency = _ref2.currency,
|
|
20428
|
+
_ref2$isUserAction = _ref2.isUserAction,
|
|
20429
|
+
isUserAction = _ref2$isUserAction === void 0 ? true : _ref2$isUserAction;
|
|
20122
20430
|
var prefix = isUserAction ? 'User switched' : 'Switched';
|
|
20123
20431
|
this.log.history.push({
|
|
20124
20432
|
type: 'action',
|
|
@@ -20184,6 +20492,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20184
20492
|
this.subscription = data.subscription || null;
|
|
20185
20493
|
this.planDetails = data.plan_details || null;
|
|
20186
20494
|
this.exchangeRate = data.exchange_rate || null;
|
|
20495
|
+
this.savedCardsConfig = data.saved_cards || {};
|
|
20496
|
+
this.savedCardsToken = null;
|
|
20187
20497
|
/**
|
|
20188
20498
|
* We initialize parameters we send to the API as empty strings
|
|
20189
20499
|
* when we don't have them instead of null because the API expects
|
|
@@ -20194,7 +20504,7 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20194
20504
|
loadPusher(); // Analytics
|
|
20195
20505
|
|
|
20196
20506
|
this.log = null;
|
|
20197
|
-
Object.assign(this, AnalyticsFunctions);
|
|
20507
|
+
Object.assign(this, AnalyticsFunctions$1);
|
|
20198
20508
|
this.initializeLog(data.log);
|
|
20199
20509
|
this.saveIpAddress(); // Bind charge functions for the available channels
|
|
20200
20510
|
|
|
@@ -20454,6 +20764,21 @@ var ToolkitAPI = {
|
|
|
20454
20764
|
resolvedCardBins[bin] = data;
|
|
20455
20765
|
return data;
|
|
20456
20766
|
});
|
|
20767
|
+
},
|
|
20768
|
+
resolveIPAddress: function resolveIPAddress(ipAddress) {
|
|
20769
|
+
var url = new URL("decision/resolve_ip/".concat(ipAddress), configToUse.paystackApiUrl).toString();
|
|
20770
|
+
var language = getLanguage();
|
|
20771
|
+
|
|
20772
|
+
var headers = _objectSpread2({}, language && {
|
|
20773
|
+
'Accept-Language': language
|
|
20774
|
+
});
|
|
20775
|
+
|
|
20776
|
+
return axiosInstance.get(url, {
|
|
20777
|
+
headers: headers
|
|
20778
|
+
}).then(function (_ref2) {
|
|
20779
|
+
var data = _ref2.data;
|
|
20780
|
+
return data;
|
|
20781
|
+
});
|
|
20457
20782
|
}
|
|
20458
20783
|
};
|
|
20459
20784
|
|
|
@@ -20519,6 +20844,11 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20519
20844
|
value: function resolveCardBin(bin) {
|
|
20520
20845
|
return ToolkitAPI.resolveCardBin(bin);
|
|
20521
20846
|
}
|
|
20847
|
+
}, {
|
|
20848
|
+
key: "resolveIPAddress",
|
|
20849
|
+
value: function resolveIPAddress(ipAddress) {
|
|
20850
|
+
return ToolkitAPI.resolveIPAddress(ipAddress);
|
|
20851
|
+
}
|
|
20522
20852
|
}]);
|
|
20523
20853
|
|
|
20524
20854
|
return Toolkit;
|
|
@@ -20681,9 +21011,9 @@ var CardPreauthorization = {
|
|
|
20681
21011
|
publicKey = _ref.publicKey,
|
|
20682
21012
|
_ref$customFields = _ref.customFields,
|
|
20683
21013
|
customFields = _ref$customFields === void 0 ? {} : _ref$customFields;
|
|
20684
|
-
// TODO: Log payment method
|
|
20685
|
-
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20686
21014
|
return validate(this.card).then(function () {
|
|
21015
|
+
_this2.logAttempt(paymentMethod);
|
|
21016
|
+
|
|
20687
21017
|
var chargeParams = {
|
|
20688
21018
|
clientdata: _this2.card.tokenize(),
|
|
20689
21019
|
last4: _this2.card.getLast4(),
|
|
@@ -20692,8 +21022,8 @@ var CardPreauthorization = {
|
|
|
20692
21022
|
customFields: customFields
|
|
20693
21023
|
};
|
|
20694
21024
|
return CardAPI.reserveFunds(chargeParams).then(function (response) {
|
|
20695
|
-
|
|
20696
|
-
|
|
21025
|
+
_this2.logAPIResponse(response, paymentMethod);
|
|
21026
|
+
|
|
20697
21027
|
return response;
|
|
20698
21028
|
});
|
|
20699
21029
|
});
|
|
@@ -20742,6 +21072,191 @@ var PreauthorisationAPI = {
|
|
|
20742
21072
|
}
|
|
20743
21073
|
};
|
|
20744
21074
|
|
|
21075
|
+
var PreauthorizationAnalyticsAPI = {
|
|
21076
|
+
saveLog: function saveLog(preauthorizationId, merchantKey, log) {
|
|
21077
|
+
var url = new URL("preauthorization/update_log/".concat(preauthorizationId), configToUse.paystackApiUrl).toString();
|
|
21078
|
+
return AnalyticsAPIUtils.saveLog(url, {
|
|
21079
|
+
merchantKey: merchantKey,
|
|
21080
|
+
log: log
|
|
21081
|
+
});
|
|
21082
|
+
},
|
|
21083
|
+
getIp: function getIp() {
|
|
21084
|
+
return AnalyticsAPIUtils.getIp();
|
|
21085
|
+
},
|
|
21086
|
+
saveIp: function saveIp(preauthorizationId, merchantKey) {
|
|
21087
|
+
var url = new URL("preauthorization/set_ip/".concat(preauthorizationId), configToUse.paystackApiUrl).toString();
|
|
21088
|
+
return AnalyticsAPIUtils.saveIp(url, {
|
|
21089
|
+
merchantKey: merchantKey
|
|
21090
|
+
});
|
|
21091
|
+
},
|
|
21092
|
+
saveReferrer: function saveReferrer(preauthorizationId, merchantKey, referrer) {
|
|
21093
|
+
var url = new URL("preauthorization/set_referrer/".concat(preauthorizationId), configToUse.paystackApiUrl).toString();
|
|
21094
|
+
return AnalyticsAPIUtils.saveReferrer(url, {
|
|
21095
|
+
merchantKey: merchantKey,
|
|
21096
|
+
referrer: referrer
|
|
21097
|
+
});
|
|
21098
|
+
}
|
|
21099
|
+
};
|
|
21100
|
+
|
|
21101
|
+
var AnalyticsFunctions = {
|
|
21102
|
+
initializeLog: function initializeLog(log) {
|
|
21103
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
21104
|
+
},
|
|
21105
|
+
getTimeSpent: function getTimeSpent() {
|
|
21106
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
21107
|
+
return this.log.time_spent;
|
|
21108
|
+
},
|
|
21109
|
+
logPageOpen: function logPageOpen() {
|
|
21110
|
+
this.log.history.push({
|
|
21111
|
+
type: 'open',
|
|
21112
|
+
message: 'Opened checkout',
|
|
21113
|
+
time: this.getTimeSpent()
|
|
21114
|
+
});
|
|
21115
|
+
return this.saveLog();
|
|
21116
|
+
},
|
|
21117
|
+
logChannelSwitch: function logChannelSwitch(value) {
|
|
21118
|
+
this.log.history.push({
|
|
21119
|
+
type: 'action',
|
|
21120
|
+
message: "Set payment method to: ".concat(value),
|
|
21121
|
+
time: this.getTimeSpent()
|
|
21122
|
+
});
|
|
21123
|
+
return this.saveLog();
|
|
21124
|
+
},
|
|
21125
|
+
logValidationErrors: function logValidationErrors(inputs) {
|
|
21126
|
+
var _this = this;
|
|
21127
|
+
|
|
21128
|
+
inputs.forEach(function (input) {
|
|
21129
|
+
_this.log.history.push({
|
|
21130
|
+
type: 'error',
|
|
21131
|
+
message: "Invalid ".concat(input),
|
|
21132
|
+
time: _this.getTimeSpent()
|
|
21133
|
+
});
|
|
21134
|
+
});
|
|
21135
|
+
return this.saveLog();
|
|
21136
|
+
},
|
|
21137
|
+
logInput: function logInput(value) {
|
|
21138
|
+
var isUpdate = this.log.history.find(function (item) {
|
|
21139
|
+
return item.message === "Filled this field: ".concat(value);
|
|
21140
|
+
});
|
|
21141
|
+
this.log.history.push({
|
|
21142
|
+
type: 'input',
|
|
21143
|
+
message: "".concat(isUpdate ? 'Changed' : 'Filled', " this field: ").concat(value),
|
|
21144
|
+
time: this.getTimeSpent()
|
|
21145
|
+
});
|
|
21146
|
+
return this.saveLog();
|
|
21147
|
+
},
|
|
21148
|
+
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
21149
|
+
this.log.history.push({
|
|
21150
|
+
type: 'action',
|
|
21151
|
+
message: 'Third-party authentication window opened',
|
|
21152
|
+
time: this.getTimeSpent()
|
|
21153
|
+
});
|
|
21154
|
+
return this.saveLog();
|
|
21155
|
+
},
|
|
21156
|
+
logAuthWindowClose: function logAuthWindowClose() {
|
|
21157
|
+
this.log.history.push({
|
|
21158
|
+
type: 'action',
|
|
21159
|
+
message: 'Third-party authentication window closed',
|
|
21160
|
+
time: this.getTimeSpent()
|
|
21161
|
+
});
|
|
21162
|
+
return this.saveLog();
|
|
21163
|
+
},
|
|
21164
|
+
logAPIResponse: function logAPIResponse(response, channel) {
|
|
21165
|
+
switch (response.status) {
|
|
21166
|
+
case 'success':
|
|
21167
|
+
return this.logSuccess(channel);
|
|
21168
|
+
|
|
21169
|
+
case 'failed':
|
|
21170
|
+
return this.logError(response.message);
|
|
21171
|
+
|
|
21172
|
+
case 'auth':
|
|
21173
|
+
return this.logAuth(response.data.auth);
|
|
21174
|
+
|
|
21175
|
+
default:
|
|
21176
|
+
return false;
|
|
21177
|
+
}
|
|
21178
|
+
},
|
|
21179
|
+
logAPIResponseMessage: function logAPIResponseMessage(message) {
|
|
21180
|
+
this.log.history.push({
|
|
21181
|
+
type: 'action',
|
|
21182
|
+
message: message,
|
|
21183
|
+
time: this.getTimeSpent()
|
|
21184
|
+
});
|
|
21185
|
+
return this.saveLog();
|
|
21186
|
+
},
|
|
21187
|
+
logAttempt: function logAttempt(channel) {
|
|
21188
|
+
var message = 'Attempted to pay';
|
|
21189
|
+
|
|
21190
|
+
if (channel) {
|
|
21191
|
+
message += " with ".concat(channel);
|
|
21192
|
+
}
|
|
21193
|
+
|
|
21194
|
+
this.log.attempts += 1;
|
|
21195
|
+
this.log.history.push({
|
|
21196
|
+
type: 'action',
|
|
21197
|
+
message: message,
|
|
21198
|
+
time: this.getTimeSpent()
|
|
21199
|
+
});
|
|
21200
|
+
return this.saveLog();
|
|
21201
|
+
},
|
|
21202
|
+
logAuth: function logAuth(value) {
|
|
21203
|
+
this.log.authentication = value;
|
|
21204
|
+
this.log.history.push({
|
|
21205
|
+
type: 'auth',
|
|
21206
|
+
message: "Authentication Required: ".concat(value),
|
|
21207
|
+
time: this.getTimeSpent()
|
|
21208
|
+
});
|
|
21209
|
+
return this.saveLog();
|
|
21210
|
+
},
|
|
21211
|
+
logSuccess: function logSuccess(channel) {
|
|
21212
|
+
var message = 'Successfully reserved funds';
|
|
21213
|
+
|
|
21214
|
+
if (channel) {
|
|
21215
|
+
message += " with ".concat(channel);
|
|
21216
|
+
}
|
|
21217
|
+
|
|
21218
|
+
this.log.success = true;
|
|
21219
|
+
this.log.history.push({
|
|
21220
|
+
type: 'success',
|
|
21221
|
+
message: message,
|
|
21222
|
+
time: this.getTimeSpent()
|
|
21223
|
+
});
|
|
21224
|
+
return this.saveLog();
|
|
21225
|
+
},
|
|
21226
|
+
logPageClose: function logPageClose() {
|
|
21227
|
+
this.log.history.push({
|
|
21228
|
+
type: 'close',
|
|
21229
|
+
message: 'Closed checkout',
|
|
21230
|
+
time: this.getTimeSpent()
|
|
21231
|
+
});
|
|
21232
|
+
return this.saveLog();
|
|
21233
|
+
},
|
|
21234
|
+
logError: function logError(error) {
|
|
21235
|
+
var message = 'Error';
|
|
21236
|
+
|
|
21237
|
+
if (error) {
|
|
21238
|
+
message += ": ".concat(error);
|
|
21239
|
+
}
|
|
21240
|
+
|
|
21241
|
+
this.log.errors += 1;
|
|
21242
|
+
this.log.history.push({
|
|
21243
|
+
type: 'error',
|
|
21244
|
+
message: message,
|
|
21245
|
+
time: this.getTimeSpent()
|
|
21246
|
+
});
|
|
21247
|
+
return this.saveLog();
|
|
21248
|
+
},
|
|
21249
|
+
saveLog: function saveLog() {
|
|
21250
|
+
return PreauthorizationAnalyticsAPI.saveLog(this.id, this.merchant.key, this.log);
|
|
21251
|
+
},
|
|
21252
|
+
saveIpAddress: function saveIpAddress() {
|
|
21253
|
+
return PreauthorizationAnalyticsAPI.saveIp(this.id, this.merchant.key);
|
|
21254
|
+
},
|
|
21255
|
+
saveReferrer: function saveReferrer(referrer) {
|
|
21256
|
+
return PreauthorizationAnalyticsAPI.saveReferrer(this.id, this.merchant.key, referrer);
|
|
21257
|
+
}
|
|
21258
|
+
};
|
|
21259
|
+
|
|
20745
21260
|
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
20746
21261
|
function PreauthorizationInstance(data) {
|
|
20747
21262
|
_classCallCheck(this, PreauthorizationInstance);
|
|
@@ -20756,6 +21271,7 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20756
21271
|
this.customer = data.customer;
|
|
20757
21272
|
this.channels = data.channels || ['card'];
|
|
20758
21273
|
this.isListening = false;
|
|
21274
|
+
this.isTest = data.domain === 'test';
|
|
20759
21275
|
this.merchant = {
|
|
20760
21276
|
id: data.merchant_id,
|
|
20761
21277
|
logo: data.merchant_logo,
|
|
@@ -20763,9 +21279,11 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20763
21279
|
key: data.merchant_key
|
|
20764
21280
|
};
|
|
20765
21281
|
this.card = {};
|
|
20766
|
-
loadPusher();
|
|
20767
|
-
|
|
20768
|
-
|
|
21282
|
+
loadPusher();
|
|
21283
|
+
this.log = null;
|
|
21284
|
+
Object.assign(this, AnalyticsFunctions);
|
|
21285
|
+
this.initializeLog(data.log);
|
|
21286
|
+
this.saveIpAddress();
|
|
20769
21287
|
Object.assign(this, CardPreauthorization);
|
|
20770
21288
|
}
|
|
20771
21289
|
|
|
@@ -20817,20 +21335,6 @@ var Preauthorization = {
|
|
|
20817
21335
|
}
|
|
20818
21336
|
}, _callee);
|
|
20819
21337
|
}))();
|
|
20820
|
-
},
|
|
20821
|
-
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20822
|
-
|
|
20823
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
20824
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
20825
|
-
while (1) {
|
|
20826
|
-
switch (_context2.prev = _context2.next) {
|
|
20827
|
-
case 0:
|
|
20828
|
-
case "end":
|
|
20829
|
-
return _context2.stop();
|
|
20830
|
-
}
|
|
20831
|
-
}
|
|
20832
|
-
}, _callee2);
|
|
20833
|
-
}))();
|
|
20834
21338
|
}
|
|
20835
21339
|
};
|
|
20836
21340
|
|