@paystack/checkout-js 1.13.0 → 1.14.0-dev.2
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 +69 -6
- package/lib/checkout.js +69 -6
- 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
|
};
|
|
@@ -19266,15 +19277,15 @@ function validate$1(phoneNumber) {
|
|
|
19266
19277
|
}
|
|
19267
19278
|
|
|
19268
19279
|
var MobileMoneyCharge = {
|
|
19269
|
-
chargeMobileMoney: function chargeMobileMoney(
|
|
19280
|
+
chargeMobileMoney: function chargeMobileMoney(payload) {
|
|
19270
19281
|
var _this = this;
|
|
19271
19282
|
|
|
19272
|
-
var phoneNumber =
|
|
19273
|
-
provider =
|
|
19274
|
-
voucher =
|
|
19275
|
-
registrationToken =
|
|
19283
|
+
var phoneNumber = payload.phoneNumber,
|
|
19284
|
+
provider = payload.provider,
|
|
19285
|
+
voucher = payload.voucher,
|
|
19286
|
+
registrationToken = payload.registrationToken;
|
|
19276
19287
|
return validate$1(phoneNumber).then(function () {
|
|
19277
|
-
_this.
|
|
19288
|
+
_this.logMobileMoneyActions(payload);
|
|
19278
19289
|
|
|
19279
19290
|
var params = {
|
|
19280
19291
|
provider: provider,
|
|
@@ -19288,6 +19299,14 @@ var MobileMoneyCharge = {
|
|
|
19288
19299
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
19289
19300
|
if (response.status === 'success') {
|
|
19290
19301
|
_this.mobileMoney = response;
|
|
19302
|
+
|
|
19303
|
+
if (response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
19304
|
+
_this.logTokenRequest('mobile money');
|
|
19305
|
+
}
|
|
19306
|
+
} else if (response.errors && response.errors.data && response.errors.data.status === 'awaiting_registration_token') {
|
|
19307
|
+
_this.logTokenAuthenticationFailure(response.message);
|
|
19308
|
+
} else {
|
|
19309
|
+
_this.logError(response.message);
|
|
19291
19310
|
}
|
|
19292
19311
|
|
|
19293
19312
|
return response;
|
|
@@ -19972,6 +19991,18 @@ var AnalyticsFunctions = {
|
|
|
19972
19991
|
return false;
|
|
19973
19992
|
}
|
|
19974
19993
|
},
|
|
19994
|
+
logMobileMoneyActions: function logMobileMoneyActions(_ref2) {
|
|
19995
|
+
var numberOfTokenRequests = _ref2.numberOfTokenRequests,
|
|
19996
|
+
registrationToken = _ref2.registrationToken;
|
|
19997
|
+
|
|
19998
|
+
if (numberOfTokenRequests) {
|
|
19999
|
+
this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
20000
|
+
} else if (registrationToken) {
|
|
20001
|
+
this.logTokenSubmitted('mobile money');
|
|
20002
|
+
} else {
|
|
20003
|
+
this.logAttempt('mobile money');
|
|
20004
|
+
}
|
|
20005
|
+
},
|
|
19975
20006
|
logAPIResponseMessage: function logAPIResponseMessage(message) {
|
|
19976
20007
|
this.log.history.push({
|
|
19977
20008
|
type: 'action',
|
|
@@ -19995,6 +20026,38 @@ var AnalyticsFunctions = {
|
|
|
19995
20026
|
});
|
|
19996
20027
|
return this.saveLog();
|
|
19997
20028
|
},
|
|
20029
|
+
logTokenRequest: function logTokenRequest(channel) {
|
|
20030
|
+
var numberOfTokenRequests = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
20031
|
+
var message = numberOfTokenRequests === 0 ? 'Waiting for customer to submit OTP' : 'Customer requested to resend OTP';
|
|
20032
|
+
this.log.history.push({
|
|
20033
|
+
type: 'action',
|
|
20034
|
+
message: message,
|
|
20035
|
+
channel: channel,
|
|
20036
|
+
time: this.getTimeSpent()
|
|
20037
|
+
});
|
|
20038
|
+
return this.saveLog();
|
|
20039
|
+
},
|
|
20040
|
+
logTokenSubmitted: function logTokenSubmitted(channel) {
|
|
20041
|
+
var message = 'Customer submitted OTP';
|
|
20042
|
+
this.log.history.push({
|
|
20043
|
+
type: 'action',
|
|
20044
|
+
message: message,
|
|
20045
|
+
channel: channel,
|
|
20046
|
+
time: this.getTimeSpent()
|
|
20047
|
+
});
|
|
20048
|
+
return this.saveLog();
|
|
20049
|
+
},
|
|
20050
|
+
logTokenAuthenticationFailure: function logTokenAuthenticationFailure(error) {
|
|
20051
|
+
var message = error ? "Error: ".concat(error) : 'Error';
|
|
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
|
};
|
|
@@ -19270,15 +19281,15 @@ function validate$1(phoneNumber) {
|
|
|
19270
19281
|
}
|
|
19271
19282
|
|
|
19272
19283
|
var MobileMoneyCharge = {
|
|
19273
|
-
chargeMobileMoney: function chargeMobileMoney(
|
|
19284
|
+
chargeMobileMoney: function chargeMobileMoney(payload) {
|
|
19274
19285
|
var _this = this;
|
|
19275
19286
|
|
|
19276
|
-
var phoneNumber =
|
|
19277
|
-
provider =
|
|
19278
|
-
voucher =
|
|
19279
|
-
registrationToken =
|
|
19287
|
+
var phoneNumber = payload.phoneNumber,
|
|
19288
|
+
provider = payload.provider,
|
|
19289
|
+
voucher = payload.voucher,
|
|
19290
|
+
registrationToken = payload.registrationToken;
|
|
19280
19291
|
return validate$1(phoneNumber).then(function () {
|
|
19281
|
-
_this.
|
|
19292
|
+
_this.logMobileMoneyActions(payload);
|
|
19282
19293
|
|
|
19283
19294
|
var params = {
|
|
19284
19295
|
provider: provider,
|
|
@@ -19292,6 +19303,14 @@ var MobileMoneyCharge = {
|
|
|
19292
19303
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
19293
19304
|
if (response.status === 'success') {
|
|
19294
19305
|
_this.mobileMoney = response;
|
|
19306
|
+
|
|
19307
|
+
if (response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
19308
|
+
_this.logTokenRequest('mobile money');
|
|
19309
|
+
}
|
|
19310
|
+
} else if (response.errors && response.errors.data && response.errors.data.status === 'awaiting_registration_token') {
|
|
19311
|
+
_this.logTokenAuthenticationFailure(response.message);
|
|
19312
|
+
} else {
|
|
19313
|
+
_this.logError(response.message);
|
|
19295
19314
|
}
|
|
19296
19315
|
|
|
19297
19316
|
return response;
|
|
@@ -19976,6 +19995,18 @@ var AnalyticsFunctions = {
|
|
|
19976
19995
|
return false;
|
|
19977
19996
|
}
|
|
19978
19997
|
},
|
|
19998
|
+
logMobileMoneyActions: function logMobileMoneyActions(_ref2) {
|
|
19999
|
+
var numberOfTokenRequests = _ref2.numberOfTokenRequests,
|
|
20000
|
+
registrationToken = _ref2.registrationToken;
|
|
20001
|
+
|
|
20002
|
+
if (numberOfTokenRequests) {
|
|
20003
|
+
this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
20004
|
+
} else if (registrationToken) {
|
|
20005
|
+
this.logTokenSubmitted('mobile money');
|
|
20006
|
+
} else {
|
|
20007
|
+
this.logAttempt('mobile money');
|
|
20008
|
+
}
|
|
20009
|
+
},
|
|
19979
20010
|
logAPIResponseMessage: function logAPIResponseMessage(message) {
|
|
19980
20011
|
this.log.history.push({
|
|
19981
20012
|
type: 'action',
|
|
@@ -19999,6 +20030,38 @@ var AnalyticsFunctions = {
|
|
|
19999
20030
|
});
|
|
20000
20031
|
return this.saveLog();
|
|
20001
20032
|
},
|
|
20033
|
+
logTokenRequest: function logTokenRequest(channel) {
|
|
20034
|
+
var numberOfTokenRequests = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
20035
|
+
var message = numberOfTokenRequests === 0 ? 'Waiting for customer to submit OTP' : 'Customer requested to resend OTP';
|
|
20036
|
+
this.log.history.push({
|
|
20037
|
+
type: 'action',
|
|
20038
|
+
message: message,
|
|
20039
|
+
channel: channel,
|
|
20040
|
+
time: this.getTimeSpent()
|
|
20041
|
+
});
|
|
20042
|
+
return this.saveLog();
|
|
20043
|
+
},
|
|
20044
|
+
logTokenSubmitted: function logTokenSubmitted(channel) {
|
|
20045
|
+
var message = 'Customer submitted OTP';
|
|
20046
|
+
this.log.history.push({
|
|
20047
|
+
type: 'action',
|
|
20048
|
+
message: message,
|
|
20049
|
+
channel: channel,
|
|
20050
|
+
time: this.getTimeSpent()
|
|
20051
|
+
});
|
|
20052
|
+
return this.saveLog();
|
|
20053
|
+
},
|
|
20054
|
+
logTokenAuthenticationFailure: function logTokenAuthenticationFailure(error) {
|
|
20055
|
+
var message = error ? "Error: ".concat(error) : 'Error';
|
|
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
|
|