@paystack/checkout-js 1.22.0-dev.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 +294 -84
- package/es/checkout.js +294 -84
- package/lib/checkout.js +294 -84
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -6403,16 +6403,14 @@ var devConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
|
6403
6403
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6404
6404
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6405
6405
|
pusherKey: '1c7b262ee18455815893',
|
|
6406
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6407
|
-
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6406
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6408
6407
|
});
|
|
6409
6408
|
var stagingConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6410
6409
|
checkoutUrl: 'https://checkout-studio.paystack.com/',
|
|
6411
6410
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6412
6411
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6413
6412
|
pusherKey: '1c7b262ee18455815893',
|
|
6414
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6415
|
-
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6413
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6416
6414
|
});
|
|
6417
6415
|
var productionConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6418
6416
|
checkoutUrl: 'https://checkout.paystack.com/',
|
|
@@ -18667,32 +18665,30 @@ var CardAPI$1 = {
|
|
|
18667
18665
|
return ChargeResponses.parse(response.data);
|
|
18668
18666
|
});
|
|
18669
18667
|
},
|
|
18670
|
-
sendSavedCardsOTP: function sendSavedCardsOTP(
|
|
18668
|
+
sendSavedCardsOTP: function sendSavedCardsOTP(transaction) {
|
|
18671
18669
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18672
|
-
var url, language, headers,
|
|
18673
|
-
|
|
18670
|
+
var url, language, headers, response;
|
|
18674
18671
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18675
18672
|
while (1) {
|
|
18676
18673
|
switch (_context.prev = _context.next) {
|
|
18677
18674
|
case 0:
|
|
18678
|
-
url = new URL(
|
|
18675
|
+
url = new URL('/saved_cards/authorize', configToUse.paystackApiUrl).toString();
|
|
18679
18676
|
language = getLanguage();
|
|
18680
18677
|
headers = _objectSpread2({}, language && {
|
|
18681
18678
|
'Accept-Language': language
|
|
18682
18679
|
});
|
|
18683
18680
|
_context.next = 5;
|
|
18684
18681
|
return axiosInstance.post(url, {
|
|
18685
|
-
|
|
18682
|
+
transaction: transaction
|
|
18686
18683
|
}, {
|
|
18687
18684
|
headers: headers
|
|
18688
18685
|
});
|
|
18689
18686
|
|
|
18690
18687
|
case 5:
|
|
18691
|
-
|
|
18692
|
-
|
|
18693
|
-
return _context.abrupt("return", data);
|
|
18688
|
+
response = _context.sent;
|
|
18689
|
+
return _context.abrupt("return", response.data);
|
|
18694
18690
|
|
|
18695
|
-
case
|
|
18691
|
+
case 7:
|
|
18696
18692
|
case "end":
|
|
18697
18693
|
return _context.stop();
|
|
18698
18694
|
}
|
|
@@ -18702,20 +18698,20 @@ var CardAPI$1 = {
|
|
|
18702
18698
|
},
|
|
18703
18699
|
addUserToSavedCards: function addUserToSavedCards(_ref6) {
|
|
18704
18700
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18705
|
-
var phone,
|
|
18701
|
+
var phone, transaction, url, language, headers, data, response;
|
|
18706
18702
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18707
18703
|
while (1) {
|
|
18708
18704
|
switch (_context2.prev = _context2.next) {
|
|
18709
18705
|
case 0:
|
|
18710
|
-
phone = _ref6.phone,
|
|
18711
|
-
url = new URL('/user', configToUse.
|
|
18706
|
+
phone = _ref6.phone, transaction = _ref6.transaction;
|
|
18707
|
+
url = new URL('/saved_cards/user', configToUse.paystackApiUrl).toString();
|
|
18712
18708
|
language = getLanguage();
|
|
18713
18709
|
headers = _objectSpread2({}, language && {
|
|
18714
18710
|
'Accept-Language': language
|
|
18715
18711
|
});
|
|
18716
18712
|
data = {
|
|
18717
18713
|
phone: phone,
|
|
18718
|
-
|
|
18714
|
+
transaction: transaction
|
|
18719
18715
|
};
|
|
18720
18716
|
_context2.next = 7;
|
|
18721
18717
|
return axiosInstance.post(url, data, {
|
|
@@ -18742,7 +18738,7 @@ var CardAPI$1 = {
|
|
|
18742
18738
|
switch (_context3.prev = _context3.next) {
|
|
18743
18739
|
case 0:
|
|
18744
18740
|
code = _ref7.code, transaction = _ref7.transaction;
|
|
18745
|
-
url = new URL('/authorize/verify', configToUse.
|
|
18741
|
+
url = new URL('/saved_cards/authorize/verify', configToUse.paystackApiUrl).toString();
|
|
18746
18742
|
language = getLanguage();
|
|
18747
18743
|
headers = _objectSpread2({}, language && {
|
|
18748
18744
|
'Accept-Language': language
|
|
@@ -18776,7 +18772,7 @@ var CardAPI$1 = {
|
|
|
18776
18772
|
switch (_context4.prev = _context4.next) {
|
|
18777
18773
|
case 0:
|
|
18778
18774
|
token = _ref8.token;
|
|
18779
|
-
url = new URL('/cards', configToUse.
|
|
18775
|
+
url = new URL('/saved_cards/cards', configToUse.paystackApiUrl).toString();
|
|
18780
18776
|
language = getLanguage();
|
|
18781
18777
|
headers = _objectSpread2({
|
|
18782
18778
|
Authorization: "Bearer ".concat(token),
|
|
@@ -18809,7 +18805,7 @@ var CardAPI$1 = {
|
|
|
18809
18805
|
switch (_context5.prev = _context5.next) {
|
|
18810
18806
|
case 0:
|
|
18811
18807
|
cardCode = _ref9.cardCode, token = _ref9.token;
|
|
18812
|
-
url = new URL("/cards/".concat(cardCode), configToUse.
|
|
18808
|
+
url = new URL("/saved_cards/cards/".concat(cardCode), configToUse.paystackApiUrl).toString();
|
|
18813
18809
|
language = getLanguage();
|
|
18814
18810
|
headers = _objectSpread2({
|
|
18815
18811
|
Authorization: "Bearer ".concat(token),
|
|
@@ -18836,13 +18832,13 @@ var CardAPI$1 = {
|
|
|
18836
18832
|
},
|
|
18837
18833
|
chargeSavedCard: function chargeSavedCard(_ref10) {
|
|
18838
18834
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
18839
|
-
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data;
|
|
18835
|
+
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data, response;
|
|
18840
18836
|
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
18841
18837
|
while (1) {
|
|
18842
18838
|
switch (_context6.prev = _context6.next) {
|
|
18843
18839
|
case 0:
|
|
18844
18840
|
token = _ref10.token, device = _ref10.device, cardCode = _ref10.cardCode, transaction = _ref10.transaction, selectedCurrency = _ref10.selectedCurrency;
|
|
18845
|
-
url = new URL("/cards/".concat(cardCode, "/charge"), configToUse.
|
|
18841
|
+
url = new URL("/saved_cards/cards/".concat(cardCode, "/charge"), configToUse.paystackApiUrl).toString();
|
|
18846
18842
|
language = getLanguage();
|
|
18847
18843
|
headers = _objectSpread2({
|
|
18848
18844
|
Authorization: "Bearer ".concat(token),
|
|
@@ -18855,13 +18851,16 @@ var CardAPI$1 = {
|
|
|
18855
18851
|
transaction: transaction,
|
|
18856
18852
|
selected_currency: selectedCurrency
|
|
18857
18853
|
};
|
|
18858
|
-
|
|
18854
|
+
_context6.next = 7;
|
|
18855
|
+
return axiosInstance.post(url, data, {
|
|
18859
18856
|
headers: headers
|
|
18860
|
-
})
|
|
18861
|
-
return ChargeResponses.parse(response.data);
|
|
18862
|
-
}));
|
|
18857
|
+
});
|
|
18863
18858
|
|
|
18864
|
-
case
|
|
18859
|
+
case 7:
|
|
18860
|
+
response = _context6.sent;
|
|
18861
|
+
return _context6.abrupt("return", ChargeResponses.parse(response.data));
|
|
18862
|
+
|
|
18863
|
+
case 9:
|
|
18865
18864
|
case "end":
|
|
18866
18865
|
return _context6.stop();
|
|
18867
18866
|
}
|
|
@@ -19050,13 +19049,13 @@ var CardCharge = {
|
|
|
19050
19049
|
return this.listenForCharge(listenerOptions, callback);
|
|
19051
19050
|
},
|
|
19052
19051
|
sendSavedCardsOTP: function sendSavedCardsOTP() {
|
|
19053
|
-
return CardAPI$1.sendSavedCardsOTP(this.
|
|
19052
|
+
return CardAPI$1.sendSavedCardsOTP(this.id);
|
|
19054
19053
|
},
|
|
19055
19054
|
addUserToSavedCards: function addUserToSavedCards(_ref4) {
|
|
19056
19055
|
var phone = _ref4.phone;
|
|
19057
19056
|
return CardAPI$1.addUserToSavedCards({
|
|
19058
19057
|
phone: phone,
|
|
19059
|
-
|
|
19058
|
+
transaction: this.id
|
|
19060
19059
|
});
|
|
19061
19060
|
},
|
|
19062
19061
|
verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
|
|
@@ -20038,6 +20037,32 @@ function isMobile (ua) {
|
|
|
20038
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));
|
|
20039
20038
|
}
|
|
20040
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
|
+
|
|
20041
20066
|
var $ = _export;
|
|
20042
20067
|
var global$1 = global$R;
|
|
20043
20068
|
var getBuiltIn = getBuiltIn$a;
|
|
@@ -20084,9 +20109,10 @@ if ($stringify) {
|
|
|
20084
20109
|
});
|
|
20085
20110
|
}
|
|
20086
20111
|
|
|
20087
|
-
var
|
|
20088
|
-
saveLog: function saveLog(
|
|
20089
|
-
var
|
|
20112
|
+
var AnalyticsAPIUtils = {
|
|
20113
|
+
saveLog: function saveLog(url, _ref) {
|
|
20114
|
+
var merchantKey = _ref.merchantKey,
|
|
20115
|
+
log = _ref.log;
|
|
20090
20116
|
var language = getLanguage();
|
|
20091
20117
|
|
|
20092
20118
|
var headers = _objectSpread2({
|
|
@@ -20117,8 +20143,8 @@ var AnalyticsAPI = {
|
|
|
20117
20143
|
return response.data.data.ip_address;
|
|
20118
20144
|
});
|
|
20119
20145
|
},
|
|
20120
|
-
saveIp: function saveIp(
|
|
20121
|
-
var
|
|
20146
|
+
saveIp: function saveIp(url, _ref2) {
|
|
20147
|
+
var merchantKey = _ref2.merchantKey;
|
|
20122
20148
|
var language = getLanguage();
|
|
20123
20149
|
|
|
20124
20150
|
var headers = _objectSpread2({
|
|
@@ -20133,8 +20159,9 @@ var AnalyticsAPI = {
|
|
|
20133
20159
|
return response.data;
|
|
20134
20160
|
});
|
|
20135
20161
|
},
|
|
20136
|
-
saveReferrer: function saveReferrer(
|
|
20137
|
-
var
|
|
20162
|
+
saveReferrer: function saveReferrer(url, _ref3) {
|
|
20163
|
+
var merchantKey = _ref3.merchantKey,
|
|
20164
|
+
referrer = _ref3.referrer;
|
|
20138
20165
|
var language = getLanguage();
|
|
20139
20166
|
|
|
20140
20167
|
var headers = _objectSpread2({
|
|
@@ -20153,29 +20180,38 @@ var AnalyticsAPI = {
|
|
|
20153
20180
|
}
|
|
20154
20181
|
};
|
|
20155
20182
|
|
|
20156
|
-
var
|
|
20157
|
-
|
|
20158
|
-
var
|
|
20159
|
-
|
|
20160
|
-
|
|
20161
|
-
|
|
20162
|
-
|
|
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
|
+
};
|
|
20163
20208
|
|
|
20164
|
-
|
|
20165
|
-
|
|
20166
|
-
|
|
20167
|
-
attempts: attempts || 0,
|
|
20168
|
-
authentication: authentication,
|
|
20169
|
-
errors: errors || 0,
|
|
20170
|
-
success: false,
|
|
20171
|
-
mobile: isMobile_1(),
|
|
20172
|
-
input: [],
|
|
20173
|
-
history: history || []
|
|
20174
|
-
};
|
|
20209
|
+
var AnalyticsFunctions$1 = {
|
|
20210
|
+
initializeLog: function initializeLog(log) {
|
|
20211
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
20175
20212
|
},
|
|
20176
20213
|
getTimeSpent: function getTimeSpent() {
|
|
20177
|
-
|
|
20178
|
-
this.log.time_spent = currentTimeInSeconds - this.log.start_time;
|
|
20214
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
20179
20215
|
return this.log.time_spent;
|
|
20180
20216
|
},
|
|
20181
20217
|
logPageOpen: function logPageOpen() {
|
|
@@ -20259,9 +20295,9 @@ var AnalyticsFunctions = {
|
|
|
20259
20295
|
return false;
|
|
20260
20296
|
}
|
|
20261
20297
|
},
|
|
20262
|
-
logMobileMoneyActions: function logMobileMoneyActions(
|
|
20263
|
-
var numberOfTokenRequests =
|
|
20264
|
-
registrationToken =
|
|
20298
|
+
logMobileMoneyActions: function logMobileMoneyActions(_ref) {
|
|
20299
|
+
var numberOfTokenRequests = _ref.numberOfTokenRequests,
|
|
20300
|
+
registrationToken = _ref.registrationToken;
|
|
20265
20301
|
|
|
20266
20302
|
if (numberOfTokenRequests) {
|
|
20267
20303
|
this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
@@ -20387,9 +20423,10 @@ var AnalyticsFunctions = {
|
|
|
20387
20423
|
});
|
|
20388
20424
|
return this.saveLog();
|
|
20389
20425
|
},
|
|
20390
|
-
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(
|
|
20391
|
-
var currency =
|
|
20392
|
-
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;
|
|
20393
20430
|
var prefix = isUserAction ? 'User switched' : 'Switched';
|
|
20394
20431
|
this.log.history.push({
|
|
20395
20432
|
type: 'action',
|
|
@@ -20467,7 +20504,7 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20467
20504
|
loadPusher(); // Analytics
|
|
20468
20505
|
|
|
20469
20506
|
this.log = null;
|
|
20470
|
-
Object.assign(this, AnalyticsFunctions);
|
|
20507
|
+
Object.assign(this, AnalyticsFunctions$1);
|
|
20471
20508
|
this.initializeLog(data.log);
|
|
20472
20509
|
this.saveIpAddress(); // Bind charge functions for the available channels
|
|
20473
20510
|
|
|
@@ -20974,9 +21011,9 @@ var CardPreauthorization = {
|
|
|
20974
21011
|
publicKey = _ref.publicKey,
|
|
20975
21012
|
_ref$customFields = _ref.customFields,
|
|
20976
21013
|
customFields = _ref$customFields === void 0 ? {} : _ref$customFields;
|
|
20977
|
-
// TODO: Log payment method
|
|
20978
|
-
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20979
21014
|
return validate(this.card).then(function () {
|
|
21015
|
+
_this2.logAttempt(paymentMethod);
|
|
21016
|
+
|
|
20980
21017
|
var chargeParams = {
|
|
20981
21018
|
clientdata: _this2.card.tokenize(),
|
|
20982
21019
|
last4: _this2.card.getLast4(),
|
|
@@ -20985,8 +21022,8 @@ var CardPreauthorization = {
|
|
|
20985
21022
|
customFields: customFields
|
|
20986
21023
|
};
|
|
20987
21024
|
return CardAPI.reserveFunds(chargeParams).then(function (response) {
|
|
20988
|
-
|
|
20989
|
-
|
|
21025
|
+
_this2.logAPIResponse(response, paymentMethod);
|
|
21026
|
+
|
|
20990
21027
|
return response;
|
|
20991
21028
|
});
|
|
20992
21029
|
});
|
|
@@ -21035,6 +21072,191 @@ var PreauthorisationAPI = {
|
|
|
21035
21072
|
}
|
|
21036
21073
|
};
|
|
21037
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
|
+
|
|
21038
21260
|
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
21039
21261
|
function PreauthorizationInstance(data) {
|
|
21040
21262
|
_classCallCheck(this, PreauthorizationInstance);
|
|
@@ -21057,9 +21279,11 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
21057
21279
|
key: data.merchant_key
|
|
21058
21280
|
};
|
|
21059
21281
|
this.card = {};
|
|
21060
|
-
loadPusher();
|
|
21061
|
-
|
|
21062
|
-
|
|
21282
|
+
loadPusher();
|
|
21283
|
+
this.log = null;
|
|
21284
|
+
Object.assign(this, AnalyticsFunctions);
|
|
21285
|
+
this.initializeLog(data.log);
|
|
21286
|
+
this.saveIpAddress();
|
|
21063
21287
|
Object.assign(this, CardPreauthorization);
|
|
21064
21288
|
}
|
|
21065
21289
|
|
|
@@ -21111,20 +21335,6 @@ var Preauthorization = {
|
|
|
21111
21335
|
}
|
|
21112
21336
|
}, _callee);
|
|
21113
21337
|
}))();
|
|
21114
|
-
},
|
|
21115
|
-
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
21116
|
-
|
|
21117
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
21118
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
21119
|
-
while (1) {
|
|
21120
|
-
switch (_context2.prev = _context2.next) {
|
|
21121
|
-
case 0:
|
|
21122
|
-
case "end":
|
|
21123
|
-
return _context2.stop();
|
|
21124
|
-
}
|
|
21125
|
-
}
|
|
21126
|
-
}, _callee2);
|
|
21127
|
-
}))();
|
|
21128
21338
|
}
|
|
21129
21339
|
};
|
|
21130
21340
|
|