@paystack/checkout-js 1.22.0-dev.4 → 1.22.0-dev.6
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 +296 -62
- package/es/checkout.js +296 -62
- package/lib/checkout.js +296 -62
- package/package.json +1 -1
package/dist/checkout.js
CHANGED
|
@@ -18491,7 +18491,7 @@ var Paystack = (function (exports) {
|
|
|
18491
18491
|
return Card;
|
|
18492
18492
|
}();
|
|
18493
18493
|
|
|
18494
|
-
var savedCardsApiUrl = new URL('/saved_cards', configToUse.paystackApiUrl).toString();
|
|
18494
|
+
var savedCardsApiUrl = new URL('/saved_cards/', configToUse.paystackApiUrl).toString();
|
|
18495
18495
|
var CardAPI$1 = {
|
|
18496
18496
|
charge: function charge(_ref) {
|
|
18497
18497
|
var clientdata = _ref.clientdata,
|
|
@@ -20041,6 +20041,46 @@ var Paystack = (function (exports) {
|
|
|
20041
20041
|
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));
|
|
20042
20042
|
}
|
|
20043
20043
|
|
|
20044
|
+
var AnalyticsUtils = {
|
|
20045
|
+
getIp: function getIp() {
|
|
20046
|
+
var url = 'https://api.paystack.co/decision/ip';
|
|
20047
|
+
var language = getLanguage();
|
|
20048
|
+
|
|
20049
|
+
var headers = _objectSpread2({}, language && {
|
|
20050
|
+
'Accept-Language': language
|
|
20051
|
+
});
|
|
20052
|
+
|
|
20053
|
+
return axiosInstance.get(url, {
|
|
20054
|
+
headers: headers
|
|
20055
|
+
}).then(function (response) {
|
|
20056
|
+
return response.data.data.ip_address;
|
|
20057
|
+
});
|
|
20058
|
+
},
|
|
20059
|
+
initializeLog: function initializeLog(log) {
|
|
20060
|
+
var _ref = log || {},
|
|
20061
|
+
attempts = _ref.attempts,
|
|
20062
|
+
authentication = _ref.authentication,
|
|
20063
|
+
errors = _ref.errors,
|
|
20064
|
+
history = _ref.history;
|
|
20065
|
+
|
|
20066
|
+
return {
|
|
20067
|
+
start_time: Math.round(Date.now() / 1000),
|
|
20068
|
+
time_spent: 0,
|
|
20069
|
+
attempts: attempts || 0,
|
|
20070
|
+
authentication: authentication,
|
|
20071
|
+
errors: errors || 0,
|
|
20072
|
+
success: false,
|
|
20073
|
+
mobile: isMobile_1(),
|
|
20074
|
+
input: [],
|
|
20075
|
+
history: history || []
|
|
20076
|
+
};
|
|
20077
|
+
},
|
|
20078
|
+
getTimeSpent: function getTimeSpent(startTime) {
|
|
20079
|
+
var currentTimeInSeconds = Math.round(Date.now() / 1000);
|
|
20080
|
+
return currentTimeInSeconds - startTime;
|
|
20081
|
+
}
|
|
20082
|
+
};
|
|
20083
|
+
|
|
20044
20084
|
var $ = _export;
|
|
20045
20085
|
var global$1 = global$R;
|
|
20046
20086
|
var getBuiltIn = getBuiltIn$a;
|
|
@@ -20107,18 +20147,7 @@ var Paystack = (function (exports) {
|
|
|
20107
20147
|
});
|
|
20108
20148
|
},
|
|
20109
20149
|
getIp: function getIp() {
|
|
20110
|
-
|
|
20111
|
-
var language = getLanguage();
|
|
20112
|
-
|
|
20113
|
-
var headers = _objectSpread2({}, language && {
|
|
20114
|
-
'Accept-Language': language
|
|
20115
|
-
});
|
|
20116
|
-
|
|
20117
|
-
return axiosInstance.get(url, {
|
|
20118
|
-
headers: headers
|
|
20119
|
-
}).then(function (response) {
|
|
20120
|
-
return response.data.data.ip_address;
|
|
20121
|
-
});
|
|
20150
|
+
return AnalyticsUtils.getIp();
|
|
20122
20151
|
},
|
|
20123
20152
|
saveIp: function saveIp(transactionId, merchantKey) {
|
|
20124
20153
|
var url = "".concat(configToUse.paystackApiUrl, "transaction/set_ip/").concat(transactionId);
|
|
@@ -20156,29 +20185,12 @@ var Paystack = (function (exports) {
|
|
|
20156
20185
|
}
|
|
20157
20186
|
};
|
|
20158
20187
|
|
|
20159
|
-
var AnalyticsFunctions = {
|
|
20188
|
+
var AnalyticsFunctions$1 = {
|
|
20160
20189
|
initializeLog: function initializeLog(log) {
|
|
20161
|
-
|
|
20162
|
-
attempts = _ref.attempts,
|
|
20163
|
-
authentication = _ref.authentication,
|
|
20164
|
-
errors = _ref.errors,
|
|
20165
|
-
history = _ref.history;
|
|
20166
|
-
|
|
20167
|
-
this.log = {
|
|
20168
|
-
start_time: Math.round(Date.now() / 1000),
|
|
20169
|
-
time_spent: 0,
|
|
20170
|
-
attempts: attempts || 0,
|
|
20171
|
-
authentication: authentication,
|
|
20172
|
-
errors: errors || 0,
|
|
20173
|
-
success: false,
|
|
20174
|
-
mobile: isMobile_1(),
|
|
20175
|
-
input: [],
|
|
20176
|
-
history: history || []
|
|
20177
|
-
};
|
|
20190
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
20178
20191
|
},
|
|
20179
20192
|
getTimeSpent: function getTimeSpent() {
|
|
20180
|
-
|
|
20181
|
-
this.log.time_spent = currentTimeInSeconds - this.log.start_time;
|
|
20193
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
20182
20194
|
return this.log.time_spent;
|
|
20183
20195
|
},
|
|
20184
20196
|
logPageOpen: function logPageOpen() {
|
|
@@ -20262,9 +20274,9 @@ var Paystack = (function (exports) {
|
|
|
20262
20274
|
return false;
|
|
20263
20275
|
}
|
|
20264
20276
|
},
|
|
20265
|
-
logMobileMoneyActions: function logMobileMoneyActions(
|
|
20266
|
-
var numberOfTokenRequests =
|
|
20267
|
-
registrationToken =
|
|
20277
|
+
logMobileMoneyActions: function logMobileMoneyActions(_ref) {
|
|
20278
|
+
var numberOfTokenRequests = _ref.numberOfTokenRequests,
|
|
20279
|
+
registrationToken = _ref.registrationToken;
|
|
20268
20280
|
|
|
20269
20281
|
if (numberOfTokenRequests) {
|
|
20270
20282
|
this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
@@ -20390,10 +20402,10 @@ var Paystack = (function (exports) {
|
|
|
20390
20402
|
});
|
|
20391
20403
|
return this.saveLog();
|
|
20392
20404
|
},
|
|
20393
|
-
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(
|
|
20394
|
-
var currency =
|
|
20395
|
-
|
|
20396
|
-
isUserAction =
|
|
20405
|
+
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(_ref2) {
|
|
20406
|
+
var currency = _ref2.currency,
|
|
20407
|
+
_ref2$isUserAction = _ref2.isUserAction,
|
|
20408
|
+
isUserAction = _ref2$isUserAction === void 0 ? true : _ref2$isUserAction;
|
|
20397
20409
|
var prefix = isUserAction ? 'User switched' : 'Switched';
|
|
20398
20410
|
this.log.history.push({
|
|
20399
20411
|
type: 'action',
|
|
@@ -20471,7 +20483,7 @@ var Paystack = (function (exports) {
|
|
|
20471
20483
|
loadPusher(); // Analytics
|
|
20472
20484
|
|
|
20473
20485
|
this.log = null;
|
|
20474
|
-
Object.assign(this, AnalyticsFunctions);
|
|
20486
|
+
Object.assign(this, AnalyticsFunctions$1);
|
|
20475
20487
|
this.initializeLog(data.log);
|
|
20476
20488
|
this.saveIpAddress(); // Bind charge functions for the available channels
|
|
20477
20489
|
|
|
@@ -20978,9 +20990,9 @@ var Paystack = (function (exports) {
|
|
|
20978
20990
|
publicKey = _ref.publicKey,
|
|
20979
20991
|
_ref$customFields = _ref.customFields,
|
|
20980
20992
|
customFields = _ref$customFields === void 0 ? {} : _ref$customFields;
|
|
20981
|
-
// TODO: Log payment method
|
|
20982
|
-
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20983
20993
|
return validate(this.card).then(function () {
|
|
20994
|
+
_this2.logAttempt(paymentMethod);
|
|
20995
|
+
|
|
20984
20996
|
var chargeParams = {
|
|
20985
20997
|
clientdata: _this2.card.tokenize(),
|
|
20986
20998
|
last4: _this2.card.getLast4(),
|
|
@@ -20989,8 +21001,8 @@ var Paystack = (function (exports) {
|
|
|
20989
21001
|
customFields: customFields
|
|
20990
21002
|
};
|
|
20991
21003
|
return CardAPI.reserveFunds(chargeParams).then(function (response) {
|
|
20992
|
-
|
|
20993
|
-
|
|
21004
|
+
_this2.logAPIResponse(response, paymentMethod);
|
|
21005
|
+
|
|
20994
21006
|
return response;
|
|
20995
21007
|
});
|
|
20996
21008
|
});
|
|
@@ -21039,6 +21051,240 @@ var Paystack = (function (exports) {
|
|
|
21039
21051
|
}
|
|
21040
21052
|
};
|
|
21041
21053
|
|
|
21054
|
+
var PreauthorizationAnalyticsAPI = {
|
|
21055
|
+
saveLog: function saveLog(transactionId, merchantKey, log) {
|
|
21056
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/update_log/").concat(transactionId);
|
|
21057
|
+
var language = getLanguage();
|
|
21058
|
+
|
|
21059
|
+
var headers = _objectSpread2({
|
|
21060
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
21061
|
+
}, language && {
|
|
21062
|
+
'Accept-Language': language
|
|
21063
|
+
});
|
|
21064
|
+
|
|
21065
|
+
return axiosInstance.post(url, {
|
|
21066
|
+
payload: JSON.stringify(log)
|
|
21067
|
+
}, {
|
|
21068
|
+
headers: headers
|
|
21069
|
+
}).then(function (response) {
|
|
21070
|
+
return response.data;
|
|
21071
|
+
});
|
|
21072
|
+
},
|
|
21073
|
+
getIp: function getIp() {
|
|
21074
|
+
return AnalyticsUtils.getIp();
|
|
21075
|
+
},
|
|
21076
|
+
saveIp: function saveIp(transactionId, merchantKey) {
|
|
21077
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/set_ip/").concat(transactionId);
|
|
21078
|
+
var language = getLanguage();
|
|
21079
|
+
|
|
21080
|
+
var headers = _objectSpread2({
|
|
21081
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
21082
|
+
}, language && {
|
|
21083
|
+
'Accept-Language': language
|
|
21084
|
+
});
|
|
21085
|
+
|
|
21086
|
+
return axiosInstance.post(url, null, {
|
|
21087
|
+
headers: headers
|
|
21088
|
+
}).then(function (response) {
|
|
21089
|
+
return response.data;
|
|
21090
|
+
});
|
|
21091
|
+
},
|
|
21092
|
+
saveReferrer: function saveReferrer(transactionId, merchantKey, referrer) {
|
|
21093
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/set_referrer/").concat(transactionId);
|
|
21094
|
+
var language = getLanguage();
|
|
21095
|
+
|
|
21096
|
+
var headers = _objectSpread2({
|
|
21097
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
21098
|
+
}, language && {
|
|
21099
|
+
'Accept-Language': language
|
|
21100
|
+
});
|
|
21101
|
+
|
|
21102
|
+
return axiosInstance.post(url, {
|
|
21103
|
+
referrer: referrer
|
|
21104
|
+
}, {
|
|
21105
|
+
headers: headers
|
|
21106
|
+
}).then(function (response) {
|
|
21107
|
+
return response.data;
|
|
21108
|
+
});
|
|
21109
|
+
}
|
|
21110
|
+
};
|
|
21111
|
+
|
|
21112
|
+
var AnalyticsFunctions = {
|
|
21113
|
+
initializeLog: function initializeLog(log) {
|
|
21114
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
21115
|
+
},
|
|
21116
|
+
getTimeSpent: function getTimeSpent() {
|
|
21117
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
21118
|
+
return this.log.time_spent;
|
|
21119
|
+
},
|
|
21120
|
+
logPageOpen: function logPageOpen() {
|
|
21121
|
+
this.log.history.push({
|
|
21122
|
+
type: 'open',
|
|
21123
|
+
message: 'Opened checkout',
|
|
21124
|
+
time: this.getTimeSpent()
|
|
21125
|
+
});
|
|
21126
|
+
return this.saveLog();
|
|
21127
|
+
},
|
|
21128
|
+
logChannelSwitch: function logChannelSwitch(value) {
|
|
21129
|
+
this.log.history.push({
|
|
21130
|
+
type: 'action',
|
|
21131
|
+
message: "Set payment method to: ".concat(value),
|
|
21132
|
+
time: this.getTimeSpent()
|
|
21133
|
+
});
|
|
21134
|
+
return this.saveLog();
|
|
21135
|
+
},
|
|
21136
|
+
logValidationErrors: function logValidationErrors(inputs) {
|
|
21137
|
+
var _this = this;
|
|
21138
|
+
|
|
21139
|
+
inputs.forEach(function (input) {
|
|
21140
|
+
_this.log.history.push({
|
|
21141
|
+
type: 'error',
|
|
21142
|
+
message: "Invalid ".concat(input),
|
|
21143
|
+
time: _this.getTimeSpent()
|
|
21144
|
+
});
|
|
21145
|
+
});
|
|
21146
|
+
return this.saveLog();
|
|
21147
|
+
},
|
|
21148
|
+
logInput: function logInput(value) {
|
|
21149
|
+
var isUpdate = this.log.history.find(function (item) {
|
|
21150
|
+
return item.message === "Filled this field: ".concat(value);
|
|
21151
|
+
});
|
|
21152
|
+
this.log.history.push({
|
|
21153
|
+
type: 'input',
|
|
21154
|
+
message: "".concat(isUpdate ? 'Changed' : 'Filled', " this field: ").concat(value),
|
|
21155
|
+
time: this.getTimeSpent()
|
|
21156
|
+
});
|
|
21157
|
+
return this.saveLog();
|
|
21158
|
+
},
|
|
21159
|
+
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
21160
|
+
this.log.history.push({
|
|
21161
|
+
type: 'action',
|
|
21162
|
+
message: 'Third-party authentication window opened',
|
|
21163
|
+
time: this.getTimeSpent()
|
|
21164
|
+
});
|
|
21165
|
+
return this.saveLog();
|
|
21166
|
+
},
|
|
21167
|
+
logAuthWindowClose: function logAuthWindowClose() {
|
|
21168
|
+
this.log.history.push({
|
|
21169
|
+
type: 'action',
|
|
21170
|
+
message: 'Third-party authentication window closed',
|
|
21171
|
+
time: this.getTimeSpent()
|
|
21172
|
+
});
|
|
21173
|
+
return this.saveLog();
|
|
21174
|
+
},
|
|
21175
|
+
logAPIResponse: function logAPIResponse(response, channel) {
|
|
21176
|
+
switch (response.status) {
|
|
21177
|
+
case 'success':
|
|
21178
|
+
return this.logSuccess(channel);
|
|
21179
|
+
|
|
21180
|
+
case 'pending':
|
|
21181
|
+
return this.logPending(channel);
|
|
21182
|
+
|
|
21183
|
+
case 'failed':
|
|
21184
|
+
return this.logError(response.message);
|
|
21185
|
+
|
|
21186
|
+
case 'auth':
|
|
21187
|
+
return this.logAuth(response.data.auth);
|
|
21188
|
+
|
|
21189
|
+
default:
|
|
21190
|
+
return false;
|
|
21191
|
+
}
|
|
21192
|
+
},
|
|
21193
|
+
logAPIResponseMessage: function logAPIResponseMessage(message) {
|
|
21194
|
+
this.log.history.push({
|
|
21195
|
+
type: 'action',
|
|
21196
|
+
message: message,
|
|
21197
|
+
time: this.getTimeSpent()
|
|
21198
|
+
});
|
|
21199
|
+
return this.saveLog();
|
|
21200
|
+
},
|
|
21201
|
+
logAttempt: function logAttempt(channel) {
|
|
21202
|
+
var message = 'Attempted to pay';
|
|
21203
|
+
|
|
21204
|
+
if (channel) {
|
|
21205
|
+
message += " with ".concat(channel);
|
|
21206
|
+
}
|
|
21207
|
+
|
|
21208
|
+
this.log.attempts += 1;
|
|
21209
|
+
this.log.history.push({
|
|
21210
|
+
type: 'action',
|
|
21211
|
+
message: message,
|
|
21212
|
+
time: this.getTimeSpent()
|
|
21213
|
+
});
|
|
21214
|
+
return this.saveLog();
|
|
21215
|
+
},
|
|
21216
|
+
logAuth: function logAuth(value) {
|
|
21217
|
+
this.log.authentication = value;
|
|
21218
|
+
this.log.history.push({
|
|
21219
|
+
type: 'auth',
|
|
21220
|
+
message: "Authentication Required: ".concat(value),
|
|
21221
|
+
time: this.getTimeSpent()
|
|
21222
|
+
});
|
|
21223
|
+
return this.saveLog();
|
|
21224
|
+
},
|
|
21225
|
+
logSuccess: function logSuccess(channel) {
|
|
21226
|
+
var message = 'Successfully paid';
|
|
21227
|
+
|
|
21228
|
+
if (channel) {
|
|
21229
|
+
message += " with ".concat(channel);
|
|
21230
|
+
}
|
|
21231
|
+
|
|
21232
|
+
this.log.success = true;
|
|
21233
|
+
this.log.history.push({
|
|
21234
|
+
type: 'success',
|
|
21235
|
+
message: message,
|
|
21236
|
+
time: this.getTimeSpent()
|
|
21237
|
+
});
|
|
21238
|
+
return this.saveLog();
|
|
21239
|
+
},
|
|
21240
|
+
logPending: function logPending(channel) {
|
|
21241
|
+
var message = 'Payment in progress';
|
|
21242
|
+
|
|
21243
|
+
if (channel) {
|
|
21244
|
+
message += " with ".concat(channel);
|
|
21245
|
+
}
|
|
21246
|
+
|
|
21247
|
+
this.log.history.push({
|
|
21248
|
+
type: 'pending',
|
|
21249
|
+
message: message,
|
|
21250
|
+
time: this.getTimeSpent()
|
|
21251
|
+
});
|
|
21252
|
+
return this.saveLog();
|
|
21253
|
+
},
|
|
21254
|
+
logPageClose: function logPageClose() {
|
|
21255
|
+
this.log.history.push({
|
|
21256
|
+
type: 'close',
|
|
21257
|
+
message: 'Closed checkout',
|
|
21258
|
+
time: this.getTimeSpent()
|
|
21259
|
+
});
|
|
21260
|
+
return this.saveLog();
|
|
21261
|
+
},
|
|
21262
|
+
logError: function logError(error) {
|
|
21263
|
+
var message = 'Error';
|
|
21264
|
+
|
|
21265
|
+
if (error) {
|
|
21266
|
+
message += ": ".concat(error);
|
|
21267
|
+
}
|
|
21268
|
+
|
|
21269
|
+
this.log.errors += 1;
|
|
21270
|
+
this.log.history.push({
|
|
21271
|
+
type: 'error',
|
|
21272
|
+
message: message,
|
|
21273
|
+
time: this.getTimeSpent()
|
|
21274
|
+
});
|
|
21275
|
+
return this.saveLog();
|
|
21276
|
+
},
|
|
21277
|
+
saveLog: function saveLog() {
|
|
21278
|
+
return PreauthorizationAnalyticsAPI.saveLog(this.id, this.merchant.key, this.log);
|
|
21279
|
+
},
|
|
21280
|
+
saveIpAddress: function saveIpAddress() {
|
|
21281
|
+
return PreauthorizationAnalyticsAPI.saveIp(this.id, this.merchant.key);
|
|
21282
|
+
},
|
|
21283
|
+
saveReferrer: function saveReferrer(referrer) {
|
|
21284
|
+
return PreauthorizationAnalyticsAPI.saveReferrer(this.id, this.merchant.key, referrer);
|
|
21285
|
+
}
|
|
21286
|
+
};
|
|
21287
|
+
|
|
21042
21288
|
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
21043
21289
|
function PreauthorizationInstance(data) {
|
|
21044
21290
|
_classCallCheck(this, PreauthorizationInstance);
|
|
@@ -21061,9 +21307,11 @@ var Paystack = (function (exports) {
|
|
|
21061
21307
|
key: data.merchant_key
|
|
21062
21308
|
};
|
|
21063
21309
|
this.card = {};
|
|
21064
|
-
loadPusher();
|
|
21065
|
-
|
|
21066
|
-
|
|
21310
|
+
loadPusher();
|
|
21311
|
+
this.log = null;
|
|
21312
|
+
Object.assign(this, AnalyticsFunctions);
|
|
21313
|
+
this.initializeLog(data.log);
|
|
21314
|
+
this.saveIpAddress();
|
|
21067
21315
|
Object.assign(this, CardPreauthorization);
|
|
21068
21316
|
}
|
|
21069
21317
|
|
|
@@ -21115,20 +21363,6 @@ var Paystack = (function (exports) {
|
|
|
21115
21363
|
}
|
|
21116
21364
|
}, _callee);
|
|
21117
21365
|
}))();
|
|
21118
|
-
},
|
|
21119
|
-
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
21120
|
-
|
|
21121
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
21122
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
21123
|
-
while (1) {
|
|
21124
|
-
switch (_context2.prev = _context2.next) {
|
|
21125
|
-
case 0:
|
|
21126
|
-
case "end":
|
|
21127
|
-
return _context2.stop();
|
|
21128
|
-
}
|
|
21129
|
-
}
|
|
21130
|
-
}, _callee2);
|
|
21131
|
-
}))();
|
|
21132
21366
|
}
|
|
21133
21367
|
};
|
|
21134
21368
|
|
package/es/checkout.js
CHANGED
|
@@ -18488,7 +18488,7 @@ var Card$1 = /*#__PURE__*/function () {
|
|
|
18488
18488
|
return Card;
|
|
18489
18489
|
}();
|
|
18490
18490
|
|
|
18491
|
-
var savedCardsApiUrl = new URL('/saved_cards', configToUse.paystackApiUrl).toString();
|
|
18491
|
+
var savedCardsApiUrl = new URL('/saved_cards/', configToUse.paystackApiUrl).toString();
|
|
18492
18492
|
var CardAPI$1 = {
|
|
18493
18493
|
charge: function charge(_ref) {
|
|
18494
18494
|
var clientdata = _ref.clientdata,
|
|
@@ -20038,6 +20038,46 @@ function isMobile (ua) {
|
|
|
20038
20038
|
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
20039
|
}
|
|
20040
20040
|
|
|
20041
|
+
var AnalyticsUtils = {
|
|
20042
|
+
getIp: function getIp() {
|
|
20043
|
+
var url = 'https://api.paystack.co/decision/ip';
|
|
20044
|
+
var language = getLanguage();
|
|
20045
|
+
|
|
20046
|
+
var headers = _objectSpread2({}, language && {
|
|
20047
|
+
'Accept-Language': language
|
|
20048
|
+
});
|
|
20049
|
+
|
|
20050
|
+
return axiosInstance.get(url, {
|
|
20051
|
+
headers: headers
|
|
20052
|
+
}).then(function (response) {
|
|
20053
|
+
return response.data.data.ip_address;
|
|
20054
|
+
});
|
|
20055
|
+
},
|
|
20056
|
+
initializeLog: function initializeLog(log) {
|
|
20057
|
+
var _ref = log || {},
|
|
20058
|
+
attempts = _ref.attempts,
|
|
20059
|
+
authentication = _ref.authentication,
|
|
20060
|
+
errors = _ref.errors,
|
|
20061
|
+
history = _ref.history;
|
|
20062
|
+
|
|
20063
|
+
return {
|
|
20064
|
+
start_time: Math.round(Date.now() / 1000),
|
|
20065
|
+
time_spent: 0,
|
|
20066
|
+
attempts: attempts || 0,
|
|
20067
|
+
authentication: authentication,
|
|
20068
|
+
errors: errors || 0,
|
|
20069
|
+
success: false,
|
|
20070
|
+
mobile: isMobile_1(),
|
|
20071
|
+
input: [],
|
|
20072
|
+
history: history || []
|
|
20073
|
+
};
|
|
20074
|
+
},
|
|
20075
|
+
getTimeSpent: function getTimeSpent(startTime) {
|
|
20076
|
+
var currentTimeInSeconds = Math.round(Date.now() / 1000);
|
|
20077
|
+
return currentTimeInSeconds - startTime;
|
|
20078
|
+
}
|
|
20079
|
+
};
|
|
20080
|
+
|
|
20041
20081
|
var $ = _export;
|
|
20042
20082
|
var global$1 = global$R;
|
|
20043
20083
|
var getBuiltIn = getBuiltIn$a;
|
|
@@ -20104,18 +20144,7 @@ var AnalyticsAPI = {
|
|
|
20104
20144
|
});
|
|
20105
20145
|
},
|
|
20106
20146
|
getIp: function getIp() {
|
|
20107
|
-
|
|
20108
|
-
var language = getLanguage();
|
|
20109
|
-
|
|
20110
|
-
var headers = _objectSpread2({}, language && {
|
|
20111
|
-
'Accept-Language': language
|
|
20112
|
-
});
|
|
20113
|
-
|
|
20114
|
-
return axiosInstance.get(url, {
|
|
20115
|
-
headers: headers
|
|
20116
|
-
}).then(function (response) {
|
|
20117
|
-
return response.data.data.ip_address;
|
|
20118
|
-
});
|
|
20147
|
+
return AnalyticsUtils.getIp();
|
|
20119
20148
|
},
|
|
20120
20149
|
saveIp: function saveIp(transactionId, merchantKey) {
|
|
20121
20150
|
var url = "".concat(configToUse.paystackApiUrl, "transaction/set_ip/").concat(transactionId);
|
|
@@ -20153,29 +20182,12 @@ var AnalyticsAPI = {
|
|
|
20153
20182
|
}
|
|
20154
20183
|
};
|
|
20155
20184
|
|
|
20156
|
-
var AnalyticsFunctions = {
|
|
20185
|
+
var AnalyticsFunctions$1 = {
|
|
20157
20186
|
initializeLog: function initializeLog(log) {
|
|
20158
|
-
|
|
20159
|
-
attempts = _ref.attempts,
|
|
20160
|
-
authentication = _ref.authentication,
|
|
20161
|
-
errors = _ref.errors,
|
|
20162
|
-
history = _ref.history;
|
|
20163
|
-
|
|
20164
|
-
this.log = {
|
|
20165
|
-
start_time: Math.round(Date.now() / 1000),
|
|
20166
|
-
time_spent: 0,
|
|
20167
|
-
attempts: attempts || 0,
|
|
20168
|
-
authentication: authentication,
|
|
20169
|
-
errors: errors || 0,
|
|
20170
|
-
success: false,
|
|
20171
|
-
mobile: isMobile_1(),
|
|
20172
|
-
input: [],
|
|
20173
|
-
history: history || []
|
|
20174
|
-
};
|
|
20187
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
20175
20188
|
},
|
|
20176
20189
|
getTimeSpent: function getTimeSpent() {
|
|
20177
|
-
|
|
20178
|
-
this.log.time_spent = currentTimeInSeconds - this.log.start_time;
|
|
20190
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
20179
20191
|
return this.log.time_spent;
|
|
20180
20192
|
},
|
|
20181
20193
|
logPageOpen: function logPageOpen() {
|
|
@@ -20259,9 +20271,9 @@ var AnalyticsFunctions = {
|
|
|
20259
20271
|
return false;
|
|
20260
20272
|
}
|
|
20261
20273
|
},
|
|
20262
|
-
logMobileMoneyActions: function logMobileMoneyActions(
|
|
20263
|
-
var numberOfTokenRequests =
|
|
20264
|
-
registrationToken =
|
|
20274
|
+
logMobileMoneyActions: function logMobileMoneyActions(_ref) {
|
|
20275
|
+
var numberOfTokenRequests = _ref.numberOfTokenRequests,
|
|
20276
|
+
registrationToken = _ref.registrationToken;
|
|
20265
20277
|
|
|
20266
20278
|
if (numberOfTokenRequests) {
|
|
20267
20279
|
this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
@@ -20387,10 +20399,10 @@ var AnalyticsFunctions = {
|
|
|
20387
20399
|
});
|
|
20388
20400
|
return this.saveLog();
|
|
20389
20401
|
},
|
|
20390
|
-
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(
|
|
20391
|
-
var currency =
|
|
20392
|
-
|
|
20393
|
-
isUserAction =
|
|
20402
|
+
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(_ref2) {
|
|
20403
|
+
var currency = _ref2.currency,
|
|
20404
|
+
_ref2$isUserAction = _ref2.isUserAction,
|
|
20405
|
+
isUserAction = _ref2$isUserAction === void 0 ? true : _ref2$isUserAction;
|
|
20394
20406
|
var prefix = isUserAction ? 'User switched' : 'Switched';
|
|
20395
20407
|
this.log.history.push({
|
|
20396
20408
|
type: 'action',
|
|
@@ -20468,7 +20480,7 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20468
20480
|
loadPusher(); // Analytics
|
|
20469
20481
|
|
|
20470
20482
|
this.log = null;
|
|
20471
|
-
Object.assign(this, AnalyticsFunctions);
|
|
20483
|
+
Object.assign(this, AnalyticsFunctions$1);
|
|
20472
20484
|
this.initializeLog(data.log);
|
|
20473
20485
|
this.saveIpAddress(); // Bind charge functions for the available channels
|
|
20474
20486
|
|
|
@@ -20975,9 +20987,9 @@ var CardPreauthorization = {
|
|
|
20975
20987
|
publicKey = _ref.publicKey,
|
|
20976
20988
|
_ref$customFields = _ref.customFields,
|
|
20977
20989
|
customFields = _ref$customFields === void 0 ? {} : _ref$customFields;
|
|
20978
|
-
// TODO: Log payment method
|
|
20979
|
-
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20980
20990
|
return validate(this.card).then(function () {
|
|
20991
|
+
_this2.logAttempt(paymentMethod);
|
|
20992
|
+
|
|
20981
20993
|
var chargeParams = {
|
|
20982
20994
|
clientdata: _this2.card.tokenize(),
|
|
20983
20995
|
last4: _this2.card.getLast4(),
|
|
@@ -20986,8 +20998,8 @@ var CardPreauthorization = {
|
|
|
20986
20998
|
customFields: customFields
|
|
20987
20999
|
};
|
|
20988
21000
|
return CardAPI.reserveFunds(chargeParams).then(function (response) {
|
|
20989
|
-
|
|
20990
|
-
|
|
21001
|
+
_this2.logAPIResponse(response, paymentMethod);
|
|
21002
|
+
|
|
20991
21003
|
return response;
|
|
20992
21004
|
});
|
|
20993
21005
|
});
|
|
@@ -21036,6 +21048,240 @@ var PreauthorisationAPI = {
|
|
|
21036
21048
|
}
|
|
21037
21049
|
};
|
|
21038
21050
|
|
|
21051
|
+
var PreauthorizationAnalyticsAPI = {
|
|
21052
|
+
saveLog: function saveLog(transactionId, merchantKey, log) {
|
|
21053
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/update_log/").concat(transactionId);
|
|
21054
|
+
var language = getLanguage();
|
|
21055
|
+
|
|
21056
|
+
var headers = _objectSpread2({
|
|
21057
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
21058
|
+
}, language && {
|
|
21059
|
+
'Accept-Language': language
|
|
21060
|
+
});
|
|
21061
|
+
|
|
21062
|
+
return axiosInstance.post(url, {
|
|
21063
|
+
payload: JSON.stringify(log)
|
|
21064
|
+
}, {
|
|
21065
|
+
headers: headers
|
|
21066
|
+
}).then(function (response) {
|
|
21067
|
+
return response.data;
|
|
21068
|
+
});
|
|
21069
|
+
},
|
|
21070
|
+
getIp: function getIp() {
|
|
21071
|
+
return AnalyticsUtils.getIp();
|
|
21072
|
+
},
|
|
21073
|
+
saveIp: function saveIp(transactionId, merchantKey) {
|
|
21074
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/set_ip/").concat(transactionId);
|
|
21075
|
+
var language = getLanguage();
|
|
21076
|
+
|
|
21077
|
+
var headers = _objectSpread2({
|
|
21078
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
21079
|
+
}, language && {
|
|
21080
|
+
'Accept-Language': language
|
|
21081
|
+
});
|
|
21082
|
+
|
|
21083
|
+
return axiosInstance.post(url, null, {
|
|
21084
|
+
headers: headers
|
|
21085
|
+
}).then(function (response) {
|
|
21086
|
+
return response.data;
|
|
21087
|
+
});
|
|
21088
|
+
},
|
|
21089
|
+
saveReferrer: function saveReferrer(transactionId, merchantKey, referrer) {
|
|
21090
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/set_referrer/").concat(transactionId);
|
|
21091
|
+
var language = getLanguage();
|
|
21092
|
+
|
|
21093
|
+
var headers = _objectSpread2({
|
|
21094
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
21095
|
+
}, language && {
|
|
21096
|
+
'Accept-Language': language
|
|
21097
|
+
});
|
|
21098
|
+
|
|
21099
|
+
return axiosInstance.post(url, {
|
|
21100
|
+
referrer: referrer
|
|
21101
|
+
}, {
|
|
21102
|
+
headers: headers
|
|
21103
|
+
}).then(function (response) {
|
|
21104
|
+
return response.data;
|
|
21105
|
+
});
|
|
21106
|
+
}
|
|
21107
|
+
};
|
|
21108
|
+
|
|
21109
|
+
var AnalyticsFunctions = {
|
|
21110
|
+
initializeLog: function initializeLog(log) {
|
|
21111
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
21112
|
+
},
|
|
21113
|
+
getTimeSpent: function getTimeSpent() {
|
|
21114
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
21115
|
+
return this.log.time_spent;
|
|
21116
|
+
},
|
|
21117
|
+
logPageOpen: function logPageOpen() {
|
|
21118
|
+
this.log.history.push({
|
|
21119
|
+
type: 'open',
|
|
21120
|
+
message: 'Opened checkout',
|
|
21121
|
+
time: this.getTimeSpent()
|
|
21122
|
+
});
|
|
21123
|
+
return this.saveLog();
|
|
21124
|
+
},
|
|
21125
|
+
logChannelSwitch: function logChannelSwitch(value) {
|
|
21126
|
+
this.log.history.push({
|
|
21127
|
+
type: 'action',
|
|
21128
|
+
message: "Set payment method to: ".concat(value),
|
|
21129
|
+
time: this.getTimeSpent()
|
|
21130
|
+
});
|
|
21131
|
+
return this.saveLog();
|
|
21132
|
+
},
|
|
21133
|
+
logValidationErrors: function logValidationErrors(inputs) {
|
|
21134
|
+
var _this = this;
|
|
21135
|
+
|
|
21136
|
+
inputs.forEach(function (input) {
|
|
21137
|
+
_this.log.history.push({
|
|
21138
|
+
type: 'error',
|
|
21139
|
+
message: "Invalid ".concat(input),
|
|
21140
|
+
time: _this.getTimeSpent()
|
|
21141
|
+
});
|
|
21142
|
+
});
|
|
21143
|
+
return this.saveLog();
|
|
21144
|
+
},
|
|
21145
|
+
logInput: function logInput(value) {
|
|
21146
|
+
var isUpdate = this.log.history.find(function (item) {
|
|
21147
|
+
return item.message === "Filled this field: ".concat(value);
|
|
21148
|
+
});
|
|
21149
|
+
this.log.history.push({
|
|
21150
|
+
type: 'input',
|
|
21151
|
+
message: "".concat(isUpdate ? 'Changed' : 'Filled', " this field: ").concat(value),
|
|
21152
|
+
time: this.getTimeSpent()
|
|
21153
|
+
});
|
|
21154
|
+
return this.saveLog();
|
|
21155
|
+
},
|
|
21156
|
+
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
21157
|
+
this.log.history.push({
|
|
21158
|
+
type: 'action',
|
|
21159
|
+
message: 'Third-party authentication window opened',
|
|
21160
|
+
time: this.getTimeSpent()
|
|
21161
|
+
});
|
|
21162
|
+
return this.saveLog();
|
|
21163
|
+
},
|
|
21164
|
+
logAuthWindowClose: function logAuthWindowClose() {
|
|
21165
|
+
this.log.history.push({
|
|
21166
|
+
type: 'action',
|
|
21167
|
+
message: 'Third-party authentication window closed',
|
|
21168
|
+
time: this.getTimeSpent()
|
|
21169
|
+
});
|
|
21170
|
+
return this.saveLog();
|
|
21171
|
+
},
|
|
21172
|
+
logAPIResponse: function logAPIResponse(response, channel) {
|
|
21173
|
+
switch (response.status) {
|
|
21174
|
+
case 'success':
|
|
21175
|
+
return this.logSuccess(channel);
|
|
21176
|
+
|
|
21177
|
+
case 'pending':
|
|
21178
|
+
return this.logPending(channel);
|
|
21179
|
+
|
|
21180
|
+
case 'failed':
|
|
21181
|
+
return this.logError(response.message);
|
|
21182
|
+
|
|
21183
|
+
case 'auth':
|
|
21184
|
+
return this.logAuth(response.data.auth);
|
|
21185
|
+
|
|
21186
|
+
default:
|
|
21187
|
+
return false;
|
|
21188
|
+
}
|
|
21189
|
+
},
|
|
21190
|
+
logAPIResponseMessage: function logAPIResponseMessage(message) {
|
|
21191
|
+
this.log.history.push({
|
|
21192
|
+
type: 'action',
|
|
21193
|
+
message: message,
|
|
21194
|
+
time: this.getTimeSpent()
|
|
21195
|
+
});
|
|
21196
|
+
return this.saveLog();
|
|
21197
|
+
},
|
|
21198
|
+
logAttempt: function logAttempt(channel) {
|
|
21199
|
+
var message = 'Attempted to pay';
|
|
21200
|
+
|
|
21201
|
+
if (channel) {
|
|
21202
|
+
message += " with ".concat(channel);
|
|
21203
|
+
}
|
|
21204
|
+
|
|
21205
|
+
this.log.attempts += 1;
|
|
21206
|
+
this.log.history.push({
|
|
21207
|
+
type: 'action',
|
|
21208
|
+
message: message,
|
|
21209
|
+
time: this.getTimeSpent()
|
|
21210
|
+
});
|
|
21211
|
+
return this.saveLog();
|
|
21212
|
+
},
|
|
21213
|
+
logAuth: function logAuth(value) {
|
|
21214
|
+
this.log.authentication = value;
|
|
21215
|
+
this.log.history.push({
|
|
21216
|
+
type: 'auth',
|
|
21217
|
+
message: "Authentication Required: ".concat(value),
|
|
21218
|
+
time: this.getTimeSpent()
|
|
21219
|
+
});
|
|
21220
|
+
return this.saveLog();
|
|
21221
|
+
},
|
|
21222
|
+
logSuccess: function logSuccess(channel) {
|
|
21223
|
+
var message = 'Successfully paid';
|
|
21224
|
+
|
|
21225
|
+
if (channel) {
|
|
21226
|
+
message += " with ".concat(channel);
|
|
21227
|
+
}
|
|
21228
|
+
|
|
21229
|
+
this.log.success = true;
|
|
21230
|
+
this.log.history.push({
|
|
21231
|
+
type: 'success',
|
|
21232
|
+
message: message,
|
|
21233
|
+
time: this.getTimeSpent()
|
|
21234
|
+
});
|
|
21235
|
+
return this.saveLog();
|
|
21236
|
+
},
|
|
21237
|
+
logPending: function logPending(channel) {
|
|
21238
|
+
var message = 'Payment in progress';
|
|
21239
|
+
|
|
21240
|
+
if (channel) {
|
|
21241
|
+
message += " with ".concat(channel);
|
|
21242
|
+
}
|
|
21243
|
+
|
|
21244
|
+
this.log.history.push({
|
|
21245
|
+
type: 'pending',
|
|
21246
|
+
message: message,
|
|
21247
|
+
time: this.getTimeSpent()
|
|
21248
|
+
});
|
|
21249
|
+
return this.saveLog();
|
|
21250
|
+
},
|
|
21251
|
+
logPageClose: function logPageClose() {
|
|
21252
|
+
this.log.history.push({
|
|
21253
|
+
type: 'close',
|
|
21254
|
+
message: 'Closed checkout',
|
|
21255
|
+
time: this.getTimeSpent()
|
|
21256
|
+
});
|
|
21257
|
+
return this.saveLog();
|
|
21258
|
+
},
|
|
21259
|
+
logError: function logError(error) {
|
|
21260
|
+
var message = 'Error';
|
|
21261
|
+
|
|
21262
|
+
if (error) {
|
|
21263
|
+
message += ": ".concat(error);
|
|
21264
|
+
}
|
|
21265
|
+
|
|
21266
|
+
this.log.errors += 1;
|
|
21267
|
+
this.log.history.push({
|
|
21268
|
+
type: 'error',
|
|
21269
|
+
message: message,
|
|
21270
|
+
time: this.getTimeSpent()
|
|
21271
|
+
});
|
|
21272
|
+
return this.saveLog();
|
|
21273
|
+
},
|
|
21274
|
+
saveLog: function saveLog() {
|
|
21275
|
+
return PreauthorizationAnalyticsAPI.saveLog(this.id, this.merchant.key, this.log);
|
|
21276
|
+
},
|
|
21277
|
+
saveIpAddress: function saveIpAddress() {
|
|
21278
|
+
return PreauthorizationAnalyticsAPI.saveIp(this.id, this.merchant.key);
|
|
21279
|
+
},
|
|
21280
|
+
saveReferrer: function saveReferrer(referrer) {
|
|
21281
|
+
return PreauthorizationAnalyticsAPI.saveReferrer(this.id, this.merchant.key, referrer);
|
|
21282
|
+
}
|
|
21283
|
+
};
|
|
21284
|
+
|
|
21039
21285
|
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
21040
21286
|
function PreauthorizationInstance(data) {
|
|
21041
21287
|
_classCallCheck(this, PreauthorizationInstance);
|
|
@@ -21058,9 +21304,11 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
21058
21304
|
key: data.merchant_key
|
|
21059
21305
|
};
|
|
21060
21306
|
this.card = {};
|
|
21061
|
-
loadPusher();
|
|
21062
|
-
|
|
21063
|
-
|
|
21307
|
+
loadPusher();
|
|
21308
|
+
this.log = null;
|
|
21309
|
+
Object.assign(this, AnalyticsFunctions);
|
|
21310
|
+
this.initializeLog(data.log);
|
|
21311
|
+
this.saveIpAddress();
|
|
21064
21312
|
Object.assign(this, CardPreauthorization);
|
|
21065
21313
|
}
|
|
21066
21314
|
|
|
@@ -21112,20 +21360,6 @@ var Preauthorization = {
|
|
|
21112
21360
|
}
|
|
21113
21361
|
}, _callee);
|
|
21114
21362
|
}))();
|
|
21115
|
-
},
|
|
21116
|
-
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
21117
|
-
|
|
21118
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
21119
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
21120
|
-
while (1) {
|
|
21121
|
-
switch (_context2.prev = _context2.next) {
|
|
21122
|
-
case 0:
|
|
21123
|
-
case "end":
|
|
21124
|
-
return _context2.stop();
|
|
21125
|
-
}
|
|
21126
|
-
}
|
|
21127
|
-
}, _callee2);
|
|
21128
|
-
}))();
|
|
21129
21363
|
}
|
|
21130
21364
|
};
|
|
21131
21365
|
|
package/lib/checkout.js
CHANGED
|
@@ -18492,7 +18492,7 @@ var Card$1 = /*#__PURE__*/function () {
|
|
|
18492
18492
|
return Card;
|
|
18493
18493
|
}();
|
|
18494
18494
|
|
|
18495
|
-
var savedCardsApiUrl = new URL('/saved_cards', configToUse.paystackApiUrl).toString();
|
|
18495
|
+
var savedCardsApiUrl = new URL('/saved_cards/', configToUse.paystackApiUrl).toString();
|
|
18496
18496
|
var CardAPI$1 = {
|
|
18497
18497
|
charge: function charge(_ref) {
|
|
18498
18498
|
var clientdata = _ref.clientdata,
|
|
@@ -20042,6 +20042,46 @@ function isMobile (ua) {
|
|
|
20042
20042
|
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));
|
|
20043
20043
|
}
|
|
20044
20044
|
|
|
20045
|
+
var AnalyticsUtils = {
|
|
20046
|
+
getIp: function getIp() {
|
|
20047
|
+
var url = 'https://api.paystack.co/decision/ip';
|
|
20048
|
+
var language = getLanguage();
|
|
20049
|
+
|
|
20050
|
+
var headers = _objectSpread2({}, language && {
|
|
20051
|
+
'Accept-Language': language
|
|
20052
|
+
});
|
|
20053
|
+
|
|
20054
|
+
return axiosInstance.get(url, {
|
|
20055
|
+
headers: headers
|
|
20056
|
+
}).then(function (response) {
|
|
20057
|
+
return response.data.data.ip_address;
|
|
20058
|
+
});
|
|
20059
|
+
},
|
|
20060
|
+
initializeLog: function initializeLog(log) {
|
|
20061
|
+
var _ref = log || {},
|
|
20062
|
+
attempts = _ref.attempts,
|
|
20063
|
+
authentication = _ref.authentication,
|
|
20064
|
+
errors = _ref.errors,
|
|
20065
|
+
history = _ref.history;
|
|
20066
|
+
|
|
20067
|
+
return {
|
|
20068
|
+
start_time: Math.round(Date.now() / 1000),
|
|
20069
|
+
time_spent: 0,
|
|
20070
|
+
attempts: attempts || 0,
|
|
20071
|
+
authentication: authentication,
|
|
20072
|
+
errors: errors || 0,
|
|
20073
|
+
success: false,
|
|
20074
|
+
mobile: isMobile_1(),
|
|
20075
|
+
input: [],
|
|
20076
|
+
history: history || []
|
|
20077
|
+
};
|
|
20078
|
+
},
|
|
20079
|
+
getTimeSpent: function getTimeSpent(startTime) {
|
|
20080
|
+
var currentTimeInSeconds = Math.round(Date.now() / 1000);
|
|
20081
|
+
return currentTimeInSeconds - startTime;
|
|
20082
|
+
}
|
|
20083
|
+
};
|
|
20084
|
+
|
|
20045
20085
|
var $ = _export;
|
|
20046
20086
|
var global$1 = global$R;
|
|
20047
20087
|
var getBuiltIn = getBuiltIn$a;
|
|
@@ -20108,18 +20148,7 @@ var AnalyticsAPI = {
|
|
|
20108
20148
|
});
|
|
20109
20149
|
},
|
|
20110
20150
|
getIp: function getIp() {
|
|
20111
|
-
|
|
20112
|
-
var language = getLanguage();
|
|
20113
|
-
|
|
20114
|
-
var headers = _objectSpread2({}, language && {
|
|
20115
|
-
'Accept-Language': language
|
|
20116
|
-
});
|
|
20117
|
-
|
|
20118
|
-
return axiosInstance.get(url, {
|
|
20119
|
-
headers: headers
|
|
20120
|
-
}).then(function (response) {
|
|
20121
|
-
return response.data.data.ip_address;
|
|
20122
|
-
});
|
|
20151
|
+
return AnalyticsUtils.getIp();
|
|
20123
20152
|
},
|
|
20124
20153
|
saveIp: function saveIp(transactionId, merchantKey) {
|
|
20125
20154
|
var url = "".concat(configToUse.paystackApiUrl, "transaction/set_ip/").concat(transactionId);
|
|
@@ -20157,29 +20186,12 @@ var AnalyticsAPI = {
|
|
|
20157
20186
|
}
|
|
20158
20187
|
};
|
|
20159
20188
|
|
|
20160
|
-
var AnalyticsFunctions = {
|
|
20189
|
+
var AnalyticsFunctions$1 = {
|
|
20161
20190
|
initializeLog: function initializeLog(log) {
|
|
20162
|
-
|
|
20163
|
-
attempts = _ref.attempts,
|
|
20164
|
-
authentication = _ref.authentication,
|
|
20165
|
-
errors = _ref.errors,
|
|
20166
|
-
history = _ref.history;
|
|
20167
|
-
|
|
20168
|
-
this.log = {
|
|
20169
|
-
start_time: Math.round(Date.now() / 1000),
|
|
20170
|
-
time_spent: 0,
|
|
20171
|
-
attempts: attempts || 0,
|
|
20172
|
-
authentication: authentication,
|
|
20173
|
-
errors: errors || 0,
|
|
20174
|
-
success: false,
|
|
20175
|
-
mobile: isMobile_1(),
|
|
20176
|
-
input: [],
|
|
20177
|
-
history: history || []
|
|
20178
|
-
};
|
|
20191
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
20179
20192
|
},
|
|
20180
20193
|
getTimeSpent: function getTimeSpent() {
|
|
20181
|
-
|
|
20182
|
-
this.log.time_spent = currentTimeInSeconds - this.log.start_time;
|
|
20194
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
20183
20195
|
return this.log.time_spent;
|
|
20184
20196
|
},
|
|
20185
20197
|
logPageOpen: function logPageOpen() {
|
|
@@ -20263,9 +20275,9 @@ var AnalyticsFunctions = {
|
|
|
20263
20275
|
return false;
|
|
20264
20276
|
}
|
|
20265
20277
|
},
|
|
20266
|
-
logMobileMoneyActions: function logMobileMoneyActions(
|
|
20267
|
-
var numberOfTokenRequests =
|
|
20268
|
-
registrationToken =
|
|
20278
|
+
logMobileMoneyActions: function logMobileMoneyActions(_ref) {
|
|
20279
|
+
var numberOfTokenRequests = _ref.numberOfTokenRequests,
|
|
20280
|
+
registrationToken = _ref.registrationToken;
|
|
20269
20281
|
|
|
20270
20282
|
if (numberOfTokenRequests) {
|
|
20271
20283
|
this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
@@ -20391,10 +20403,10 @@ var AnalyticsFunctions = {
|
|
|
20391
20403
|
});
|
|
20392
20404
|
return this.saveLog();
|
|
20393
20405
|
},
|
|
20394
|
-
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(
|
|
20395
|
-
var currency =
|
|
20396
|
-
|
|
20397
|
-
isUserAction =
|
|
20406
|
+
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(_ref2) {
|
|
20407
|
+
var currency = _ref2.currency,
|
|
20408
|
+
_ref2$isUserAction = _ref2.isUserAction,
|
|
20409
|
+
isUserAction = _ref2$isUserAction === void 0 ? true : _ref2$isUserAction;
|
|
20398
20410
|
var prefix = isUserAction ? 'User switched' : 'Switched';
|
|
20399
20411
|
this.log.history.push({
|
|
20400
20412
|
type: 'action',
|
|
@@ -20472,7 +20484,7 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20472
20484
|
loadPusher(); // Analytics
|
|
20473
20485
|
|
|
20474
20486
|
this.log = null;
|
|
20475
|
-
Object.assign(this, AnalyticsFunctions);
|
|
20487
|
+
Object.assign(this, AnalyticsFunctions$1);
|
|
20476
20488
|
this.initializeLog(data.log);
|
|
20477
20489
|
this.saveIpAddress(); // Bind charge functions for the available channels
|
|
20478
20490
|
|
|
@@ -20979,9 +20991,9 @@ var CardPreauthorization = {
|
|
|
20979
20991
|
publicKey = _ref.publicKey,
|
|
20980
20992
|
_ref$customFields = _ref.customFields,
|
|
20981
20993
|
customFields = _ref$customFields === void 0 ? {} : _ref$customFields;
|
|
20982
|
-
// TODO: Log payment method
|
|
20983
|
-
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20984
20994
|
return validate(this.card).then(function () {
|
|
20995
|
+
_this2.logAttempt(paymentMethod);
|
|
20996
|
+
|
|
20985
20997
|
var chargeParams = {
|
|
20986
20998
|
clientdata: _this2.card.tokenize(),
|
|
20987
20999
|
last4: _this2.card.getLast4(),
|
|
@@ -20990,8 +21002,8 @@ var CardPreauthorization = {
|
|
|
20990
21002
|
customFields: customFields
|
|
20991
21003
|
};
|
|
20992
21004
|
return CardAPI.reserveFunds(chargeParams).then(function (response) {
|
|
20993
|
-
|
|
20994
|
-
|
|
21005
|
+
_this2.logAPIResponse(response, paymentMethod);
|
|
21006
|
+
|
|
20995
21007
|
return response;
|
|
20996
21008
|
});
|
|
20997
21009
|
});
|
|
@@ -21040,6 +21052,240 @@ var PreauthorisationAPI = {
|
|
|
21040
21052
|
}
|
|
21041
21053
|
};
|
|
21042
21054
|
|
|
21055
|
+
var PreauthorizationAnalyticsAPI = {
|
|
21056
|
+
saveLog: function saveLog(transactionId, merchantKey, log) {
|
|
21057
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/update_log/").concat(transactionId);
|
|
21058
|
+
var language = getLanguage();
|
|
21059
|
+
|
|
21060
|
+
var headers = _objectSpread2({
|
|
21061
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
21062
|
+
}, language && {
|
|
21063
|
+
'Accept-Language': language
|
|
21064
|
+
});
|
|
21065
|
+
|
|
21066
|
+
return axiosInstance.post(url, {
|
|
21067
|
+
payload: JSON.stringify(log)
|
|
21068
|
+
}, {
|
|
21069
|
+
headers: headers
|
|
21070
|
+
}).then(function (response) {
|
|
21071
|
+
return response.data;
|
|
21072
|
+
});
|
|
21073
|
+
},
|
|
21074
|
+
getIp: function getIp() {
|
|
21075
|
+
return AnalyticsUtils.getIp();
|
|
21076
|
+
},
|
|
21077
|
+
saveIp: function saveIp(transactionId, merchantKey) {
|
|
21078
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/set_ip/").concat(transactionId);
|
|
21079
|
+
var language = getLanguage();
|
|
21080
|
+
|
|
21081
|
+
var headers = _objectSpread2({
|
|
21082
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
21083
|
+
}, language && {
|
|
21084
|
+
'Accept-Language': language
|
|
21085
|
+
});
|
|
21086
|
+
|
|
21087
|
+
return axiosInstance.post(url, null, {
|
|
21088
|
+
headers: headers
|
|
21089
|
+
}).then(function (response) {
|
|
21090
|
+
return response.data;
|
|
21091
|
+
});
|
|
21092
|
+
},
|
|
21093
|
+
saveReferrer: function saveReferrer(transactionId, merchantKey, referrer) {
|
|
21094
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/set_referrer/").concat(transactionId);
|
|
21095
|
+
var language = getLanguage();
|
|
21096
|
+
|
|
21097
|
+
var headers = _objectSpread2({
|
|
21098
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
21099
|
+
}, language && {
|
|
21100
|
+
'Accept-Language': language
|
|
21101
|
+
});
|
|
21102
|
+
|
|
21103
|
+
return axiosInstance.post(url, {
|
|
21104
|
+
referrer: referrer
|
|
21105
|
+
}, {
|
|
21106
|
+
headers: headers
|
|
21107
|
+
}).then(function (response) {
|
|
21108
|
+
return response.data;
|
|
21109
|
+
});
|
|
21110
|
+
}
|
|
21111
|
+
};
|
|
21112
|
+
|
|
21113
|
+
var AnalyticsFunctions = {
|
|
21114
|
+
initializeLog: function initializeLog(log) {
|
|
21115
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
21116
|
+
},
|
|
21117
|
+
getTimeSpent: function getTimeSpent() {
|
|
21118
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
21119
|
+
return this.log.time_spent;
|
|
21120
|
+
},
|
|
21121
|
+
logPageOpen: function logPageOpen() {
|
|
21122
|
+
this.log.history.push({
|
|
21123
|
+
type: 'open',
|
|
21124
|
+
message: 'Opened checkout',
|
|
21125
|
+
time: this.getTimeSpent()
|
|
21126
|
+
});
|
|
21127
|
+
return this.saveLog();
|
|
21128
|
+
},
|
|
21129
|
+
logChannelSwitch: function logChannelSwitch(value) {
|
|
21130
|
+
this.log.history.push({
|
|
21131
|
+
type: 'action',
|
|
21132
|
+
message: "Set payment method to: ".concat(value),
|
|
21133
|
+
time: this.getTimeSpent()
|
|
21134
|
+
});
|
|
21135
|
+
return this.saveLog();
|
|
21136
|
+
},
|
|
21137
|
+
logValidationErrors: function logValidationErrors(inputs) {
|
|
21138
|
+
var _this = this;
|
|
21139
|
+
|
|
21140
|
+
inputs.forEach(function (input) {
|
|
21141
|
+
_this.log.history.push({
|
|
21142
|
+
type: 'error',
|
|
21143
|
+
message: "Invalid ".concat(input),
|
|
21144
|
+
time: _this.getTimeSpent()
|
|
21145
|
+
});
|
|
21146
|
+
});
|
|
21147
|
+
return this.saveLog();
|
|
21148
|
+
},
|
|
21149
|
+
logInput: function logInput(value) {
|
|
21150
|
+
var isUpdate = this.log.history.find(function (item) {
|
|
21151
|
+
return item.message === "Filled this field: ".concat(value);
|
|
21152
|
+
});
|
|
21153
|
+
this.log.history.push({
|
|
21154
|
+
type: 'input',
|
|
21155
|
+
message: "".concat(isUpdate ? 'Changed' : 'Filled', " this field: ").concat(value),
|
|
21156
|
+
time: this.getTimeSpent()
|
|
21157
|
+
});
|
|
21158
|
+
return this.saveLog();
|
|
21159
|
+
},
|
|
21160
|
+
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
21161
|
+
this.log.history.push({
|
|
21162
|
+
type: 'action',
|
|
21163
|
+
message: 'Third-party authentication window opened',
|
|
21164
|
+
time: this.getTimeSpent()
|
|
21165
|
+
});
|
|
21166
|
+
return this.saveLog();
|
|
21167
|
+
},
|
|
21168
|
+
logAuthWindowClose: function logAuthWindowClose() {
|
|
21169
|
+
this.log.history.push({
|
|
21170
|
+
type: 'action',
|
|
21171
|
+
message: 'Third-party authentication window closed',
|
|
21172
|
+
time: this.getTimeSpent()
|
|
21173
|
+
});
|
|
21174
|
+
return this.saveLog();
|
|
21175
|
+
},
|
|
21176
|
+
logAPIResponse: function logAPIResponse(response, channel) {
|
|
21177
|
+
switch (response.status) {
|
|
21178
|
+
case 'success':
|
|
21179
|
+
return this.logSuccess(channel);
|
|
21180
|
+
|
|
21181
|
+
case 'pending':
|
|
21182
|
+
return this.logPending(channel);
|
|
21183
|
+
|
|
21184
|
+
case 'failed':
|
|
21185
|
+
return this.logError(response.message);
|
|
21186
|
+
|
|
21187
|
+
case 'auth':
|
|
21188
|
+
return this.logAuth(response.data.auth);
|
|
21189
|
+
|
|
21190
|
+
default:
|
|
21191
|
+
return false;
|
|
21192
|
+
}
|
|
21193
|
+
},
|
|
21194
|
+
logAPIResponseMessage: function logAPIResponseMessage(message) {
|
|
21195
|
+
this.log.history.push({
|
|
21196
|
+
type: 'action',
|
|
21197
|
+
message: message,
|
|
21198
|
+
time: this.getTimeSpent()
|
|
21199
|
+
});
|
|
21200
|
+
return this.saveLog();
|
|
21201
|
+
},
|
|
21202
|
+
logAttempt: function logAttempt(channel) {
|
|
21203
|
+
var message = 'Attempted to pay';
|
|
21204
|
+
|
|
21205
|
+
if (channel) {
|
|
21206
|
+
message += " with ".concat(channel);
|
|
21207
|
+
}
|
|
21208
|
+
|
|
21209
|
+
this.log.attempts += 1;
|
|
21210
|
+
this.log.history.push({
|
|
21211
|
+
type: 'action',
|
|
21212
|
+
message: message,
|
|
21213
|
+
time: this.getTimeSpent()
|
|
21214
|
+
});
|
|
21215
|
+
return this.saveLog();
|
|
21216
|
+
},
|
|
21217
|
+
logAuth: function logAuth(value) {
|
|
21218
|
+
this.log.authentication = value;
|
|
21219
|
+
this.log.history.push({
|
|
21220
|
+
type: 'auth',
|
|
21221
|
+
message: "Authentication Required: ".concat(value),
|
|
21222
|
+
time: this.getTimeSpent()
|
|
21223
|
+
});
|
|
21224
|
+
return this.saveLog();
|
|
21225
|
+
},
|
|
21226
|
+
logSuccess: function logSuccess(channel) {
|
|
21227
|
+
var message = 'Successfully paid';
|
|
21228
|
+
|
|
21229
|
+
if (channel) {
|
|
21230
|
+
message += " with ".concat(channel);
|
|
21231
|
+
}
|
|
21232
|
+
|
|
21233
|
+
this.log.success = true;
|
|
21234
|
+
this.log.history.push({
|
|
21235
|
+
type: 'success',
|
|
21236
|
+
message: message,
|
|
21237
|
+
time: this.getTimeSpent()
|
|
21238
|
+
});
|
|
21239
|
+
return this.saveLog();
|
|
21240
|
+
},
|
|
21241
|
+
logPending: function logPending(channel) {
|
|
21242
|
+
var message = 'Payment in progress';
|
|
21243
|
+
|
|
21244
|
+
if (channel) {
|
|
21245
|
+
message += " with ".concat(channel);
|
|
21246
|
+
}
|
|
21247
|
+
|
|
21248
|
+
this.log.history.push({
|
|
21249
|
+
type: 'pending',
|
|
21250
|
+
message: message,
|
|
21251
|
+
time: this.getTimeSpent()
|
|
21252
|
+
});
|
|
21253
|
+
return this.saveLog();
|
|
21254
|
+
},
|
|
21255
|
+
logPageClose: function logPageClose() {
|
|
21256
|
+
this.log.history.push({
|
|
21257
|
+
type: 'close',
|
|
21258
|
+
message: 'Closed checkout',
|
|
21259
|
+
time: this.getTimeSpent()
|
|
21260
|
+
});
|
|
21261
|
+
return this.saveLog();
|
|
21262
|
+
},
|
|
21263
|
+
logError: function logError(error) {
|
|
21264
|
+
var message = 'Error';
|
|
21265
|
+
|
|
21266
|
+
if (error) {
|
|
21267
|
+
message += ": ".concat(error);
|
|
21268
|
+
}
|
|
21269
|
+
|
|
21270
|
+
this.log.errors += 1;
|
|
21271
|
+
this.log.history.push({
|
|
21272
|
+
type: 'error',
|
|
21273
|
+
message: message,
|
|
21274
|
+
time: this.getTimeSpent()
|
|
21275
|
+
});
|
|
21276
|
+
return this.saveLog();
|
|
21277
|
+
},
|
|
21278
|
+
saveLog: function saveLog() {
|
|
21279
|
+
return PreauthorizationAnalyticsAPI.saveLog(this.id, this.merchant.key, this.log);
|
|
21280
|
+
},
|
|
21281
|
+
saveIpAddress: function saveIpAddress() {
|
|
21282
|
+
return PreauthorizationAnalyticsAPI.saveIp(this.id, this.merchant.key);
|
|
21283
|
+
},
|
|
21284
|
+
saveReferrer: function saveReferrer(referrer) {
|
|
21285
|
+
return PreauthorizationAnalyticsAPI.saveReferrer(this.id, this.merchant.key, referrer);
|
|
21286
|
+
}
|
|
21287
|
+
};
|
|
21288
|
+
|
|
21043
21289
|
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
21044
21290
|
function PreauthorizationInstance(data) {
|
|
21045
21291
|
_classCallCheck(this, PreauthorizationInstance);
|
|
@@ -21062,9 +21308,11 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
21062
21308
|
key: data.merchant_key
|
|
21063
21309
|
};
|
|
21064
21310
|
this.card = {};
|
|
21065
|
-
loadPusher();
|
|
21066
|
-
|
|
21067
|
-
|
|
21311
|
+
loadPusher();
|
|
21312
|
+
this.log = null;
|
|
21313
|
+
Object.assign(this, AnalyticsFunctions);
|
|
21314
|
+
this.initializeLog(data.log);
|
|
21315
|
+
this.saveIpAddress();
|
|
21068
21316
|
Object.assign(this, CardPreauthorization);
|
|
21069
21317
|
}
|
|
21070
21318
|
|
|
@@ -21116,20 +21364,6 @@ var Preauthorization = {
|
|
|
21116
21364
|
}
|
|
21117
21365
|
}, _callee);
|
|
21118
21366
|
}))();
|
|
21119
|
-
},
|
|
21120
|
-
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
21121
|
-
|
|
21122
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
21123
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
21124
|
-
while (1) {
|
|
21125
|
-
switch (_context2.prev = _context2.next) {
|
|
21126
|
-
case 0:
|
|
21127
|
-
case "end":
|
|
21128
|
-
return _context2.stop();
|
|
21129
|
-
}
|
|
21130
|
-
}
|
|
21131
|
-
}, _callee2);
|
|
21132
|
-
}))();
|
|
21133
21367
|
}
|
|
21134
21368
|
};
|
|
21135
21369
|
|