@paystack/checkout-js 1.13.0 → 1.14.0-dev.1
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 +3 -3
- package/es/checkout.js +65 -2
- package/lib/checkout.js +65 -2
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -19248,6 +19248,17 @@ var MobileMoneyAPI = {
|
|
|
19248
19248
|
headers: headers
|
|
19249
19249
|
}).then(function (response) {
|
|
19250
19250
|
return ChargeResponses.parse(response.data);
|
|
19251
|
+
}).catch(function (error) {
|
|
19252
|
+
var errorData = error.response && error.response.data;
|
|
19253
|
+
var errorResponse = {};
|
|
19254
|
+
|
|
19255
|
+
if (errorData) {
|
|
19256
|
+
errorResponse = _objectSpread2(_objectSpread2({}, errorData), {}, {
|
|
19257
|
+
errors: errorData
|
|
19258
|
+
});
|
|
19259
|
+
}
|
|
19260
|
+
|
|
19261
|
+
return ChargeResponses.parse(errorResponse || error);
|
|
19251
19262
|
});
|
|
19252
19263
|
}
|
|
19253
19264
|
};
|
|
@@ -19272,9 +19283,16 @@ var MobileMoneyCharge = {
|
|
|
19272
19283
|
var phoneNumber = _ref.phoneNumber,
|
|
19273
19284
|
provider = _ref.provider,
|
|
19274
19285
|
voucher = _ref.voucher,
|
|
19275
|
-
registrationToken = _ref.registrationToken
|
|
19286
|
+
registrationToken = _ref.registrationToken,
|
|
19287
|
+
numberOfTokenRequests = _ref.numberOfTokenRequests;
|
|
19276
19288
|
return validate$1(phoneNumber).then(function () {
|
|
19277
|
-
|
|
19289
|
+
if (numberOfTokenRequests) {
|
|
19290
|
+
_this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
19291
|
+
} else if (registrationToken) {
|
|
19292
|
+
_this.logTokenSubmitted('mobile money');
|
|
19293
|
+
} else {
|
|
19294
|
+
_this.logAttempt('mobile money');
|
|
19295
|
+
}
|
|
19278
19296
|
|
|
19279
19297
|
var params = {
|
|
19280
19298
|
provider: provider,
|
|
@@ -19288,6 +19306,14 @@ var MobileMoneyCharge = {
|
|
|
19288
19306
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
19289
19307
|
if (response.status === 'success') {
|
|
19290
19308
|
_this.mobileMoney = response;
|
|
19309
|
+
|
|
19310
|
+
if (response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
19311
|
+
_this.logTokenRequest('mobile money');
|
|
19312
|
+
}
|
|
19313
|
+
} else if (response.errors && response.errors.data && response.errors.data.status === 'awaiting_registration_token') {
|
|
19314
|
+
_this.logTokenAuthenticationFailure(response.message);
|
|
19315
|
+
} else {
|
|
19316
|
+
_this.logError(response.message);
|
|
19291
19317
|
}
|
|
19292
19318
|
|
|
19293
19319
|
return response;
|
|
@@ -19995,6 +20021,43 @@ var AnalyticsFunctions = {
|
|
|
19995
20021
|
});
|
|
19996
20022
|
return this.saveLog();
|
|
19997
20023
|
},
|
|
20024
|
+
logTokenRequest: function logTokenRequest(channel) {
|
|
20025
|
+
var numberOfTokenRequests = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
20026
|
+
var message = numberOfTokenRequests === 0 ? 'Waiting for customer to submit OTP' : 'Customer requested to resend OTP';
|
|
20027
|
+
this.log.history.push({
|
|
20028
|
+
type: 'action',
|
|
20029
|
+
message: message,
|
|
20030
|
+
channel: channel,
|
|
20031
|
+
time: this.getTimeSpent()
|
|
20032
|
+
});
|
|
20033
|
+
return this.saveLog();
|
|
20034
|
+
},
|
|
20035
|
+
logTokenSubmitted: function logTokenSubmitted(channel) {
|
|
20036
|
+
var message = "Customer submitted OTP";
|
|
20037
|
+
this.log.history.push({
|
|
20038
|
+
type: 'action',
|
|
20039
|
+
message: message,
|
|
20040
|
+
channel: channel,
|
|
20041
|
+
time: this.getTimeSpent()
|
|
20042
|
+
});
|
|
20043
|
+
return this.saveLog();
|
|
20044
|
+
},
|
|
20045
|
+
logTokenAuthenticationFailure: function logTokenAuthenticationFailure(error) {
|
|
20046
|
+
var message = 'Error';
|
|
20047
|
+
|
|
20048
|
+
if (error) {
|
|
20049
|
+
message += ": ".concat(error);
|
|
20050
|
+
}
|
|
20051
|
+
|
|
20052
|
+
this.log.errors += 1;
|
|
20053
|
+
this.log.history.push({
|
|
20054
|
+
type: 'error',
|
|
20055
|
+
message: message,
|
|
20056
|
+
authentication: 'failed',
|
|
20057
|
+
time: this.getTimeSpent()
|
|
20058
|
+
});
|
|
20059
|
+
return this.saveLog();
|
|
20060
|
+
},
|
|
19998
20061
|
logError: function logError(error) {
|
|
19999
20062
|
var message = 'Error';
|
|
20000
20063
|
|
package/lib/checkout.js
CHANGED
|
@@ -19252,6 +19252,17 @@ var MobileMoneyAPI = {
|
|
|
19252
19252
|
headers: headers
|
|
19253
19253
|
}).then(function (response) {
|
|
19254
19254
|
return ChargeResponses.parse(response.data);
|
|
19255
|
+
}).catch(function (error) {
|
|
19256
|
+
var errorData = error.response && error.response.data;
|
|
19257
|
+
var errorResponse = {};
|
|
19258
|
+
|
|
19259
|
+
if (errorData) {
|
|
19260
|
+
errorResponse = _objectSpread2(_objectSpread2({}, errorData), {}, {
|
|
19261
|
+
errors: errorData
|
|
19262
|
+
});
|
|
19263
|
+
}
|
|
19264
|
+
|
|
19265
|
+
return ChargeResponses.parse(errorResponse || error);
|
|
19255
19266
|
});
|
|
19256
19267
|
}
|
|
19257
19268
|
};
|
|
@@ -19276,9 +19287,16 @@ var MobileMoneyCharge = {
|
|
|
19276
19287
|
var phoneNumber = _ref.phoneNumber,
|
|
19277
19288
|
provider = _ref.provider,
|
|
19278
19289
|
voucher = _ref.voucher,
|
|
19279
|
-
registrationToken = _ref.registrationToken
|
|
19290
|
+
registrationToken = _ref.registrationToken,
|
|
19291
|
+
numberOfTokenRequests = _ref.numberOfTokenRequests;
|
|
19280
19292
|
return validate$1(phoneNumber).then(function () {
|
|
19281
|
-
|
|
19293
|
+
if (numberOfTokenRequests) {
|
|
19294
|
+
_this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
19295
|
+
} else if (registrationToken) {
|
|
19296
|
+
_this.logTokenSubmitted('mobile money');
|
|
19297
|
+
} else {
|
|
19298
|
+
_this.logAttempt('mobile money');
|
|
19299
|
+
}
|
|
19282
19300
|
|
|
19283
19301
|
var params = {
|
|
19284
19302
|
provider: provider,
|
|
@@ -19292,6 +19310,14 @@ var MobileMoneyCharge = {
|
|
|
19292
19310
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
19293
19311
|
if (response.status === 'success') {
|
|
19294
19312
|
_this.mobileMoney = response;
|
|
19313
|
+
|
|
19314
|
+
if (response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
19315
|
+
_this.logTokenRequest('mobile money');
|
|
19316
|
+
}
|
|
19317
|
+
} else if (response.errors && response.errors.data && response.errors.data.status === 'awaiting_registration_token') {
|
|
19318
|
+
_this.logTokenAuthenticationFailure(response.message);
|
|
19319
|
+
} else {
|
|
19320
|
+
_this.logError(response.message);
|
|
19295
19321
|
}
|
|
19296
19322
|
|
|
19297
19323
|
return response;
|
|
@@ -19999,6 +20025,43 @@ var AnalyticsFunctions = {
|
|
|
19999
20025
|
});
|
|
20000
20026
|
return this.saveLog();
|
|
20001
20027
|
},
|
|
20028
|
+
logTokenRequest: function logTokenRequest(channel) {
|
|
20029
|
+
var numberOfTokenRequests = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
20030
|
+
var message = numberOfTokenRequests === 0 ? 'Waiting for customer to submit OTP' : 'Customer requested to resend OTP';
|
|
20031
|
+
this.log.history.push({
|
|
20032
|
+
type: 'action',
|
|
20033
|
+
message: message,
|
|
20034
|
+
channel: channel,
|
|
20035
|
+
time: this.getTimeSpent()
|
|
20036
|
+
});
|
|
20037
|
+
return this.saveLog();
|
|
20038
|
+
},
|
|
20039
|
+
logTokenSubmitted: function logTokenSubmitted(channel) {
|
|
20040
|
+
var message = "Customer submitted OTP";
|
|
20041
|
+
this.log.history.push({
|
|
20042
|
+
type: 'action',
|
|
20043
|
+
message: message,
|
|
20044
|
+
channel: channel,
|
|
20045
|
+
time: this.getTimeSpent()
|
|
20046
|
+
});
|
|
20047
|
+
return this.saveLog();
|
|
20048
|
+
},
|
|
20049
|
+
logTokenAuthenticationFailure: function logTokenAuthenticationFailure(error) {
|
|
20050
|
+
var message = 'Error';
|
|
20051
|
+
|
|
20052
|
+
if (error) {
|
|
20053
|
+
message += ": ".concat(error);
|
|
20054
|
+
}
|
|
20055
|
+
|
|
20056
|
+
this.log.errors += 1;
|
|
20057
|
+
this.log.history.push({
|
|
20058
|
+
type: 'error',
|
|
20059
|
+
message: message,
|
|
20060
|
+
authentication: 'failed',
|
|
20061
|
+
time: this.getTimeSpent()
|
|
20062
|
+
});
|
|
20063
|
+
return this.saveLog();
|
|
20064
|
+
},
|
|
20002
20065
|
logError: function logError(error) {
|
|
20003
20066
|
var message = 'Error';
|
|
20004
20067
|
|