@paystack/checkout-js 1.26.0-dev.13 → 1.26.0-dev.15
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 +600 -625
- package/es/checkout.js +600 -625
- package/lib/checkout.js +600 -625
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -19817,154 +19817,211 @@ var MobileMoneyAPI = {
|
|
|
19817
19817
|
}
|
|
19818
19818
|
};
|
|
19819
19819
|
|
|
19820
|
-
|
|
19820
|
+
function validate$1(phoneNumber) {
|
|
19821
|
+
return new Promise(function (resolve, reject) {
|
|
19822
|
+
var validation = PhoneNumber.validate(phoneNumber);
|
|
19821
19823
|
|
|
19822
|
-
|
|
19823
|
-
|
|
19824
|
-
|
|
19825
|
-
|
|
19826
|
-
}
|
|
19827
|
-
if (typeof ua != 'string') return false;
|
|
19824
|
+
if (!validation.isValid) {
|
|
19825
|
+
var errorMessage = phoneNumber ? validation.errors[0] : 'Please start a mobile money transaction with Transaction.chargeMobileMoney()';
|
|
19826
|
+
reject(Error(errorMessage));
|
|
19827
|
+
}
|
|
19828
19828
|
|
|
19829
|
-
|
|
19829
|
+
resolve(validation);
|
|
19830
|
+
});
|
|
19830
19831
|
}
|
|
19831
19832
|
|
|
19832
|
-
var
|
|
19833
|
-
|
|
19834
|
-
var
|
|
19835
|
-
attempts = _ref.attempts,
|
|
19836
|
-
authentication = _ref.authentication,
|
|
19837
|
-
errors = _ref.errors,
|
|
19838
|
-
history = _ref.history;
|
|
19833
|
+
var MobileMoneyCharge = {
|
|
19834
|
+
mobileMoneyChargeAPI: function mobileMoneyChargeAPI(params) {
|
|
19835
|
+
var _this = this;
|
|
19839
19836
|
|
|
19840
|
-
return {
|
|
19841
|
-
|
|
19842
|
-
|
|
19843
|
-
|
|
19844
|
-
|
|
19845
|
-
|
|
19846
|
-
|
|
19847
|
-
|
|
19848
|
-
|
|
19849
|
-
|
|
19837
|
+
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
19838
|
+
if (response.status === 'success') {
|
|
19839
|
+
_this.mobileMoney = response;
|
|
19840
|
+
|
|
19841
|
+
if (response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
19842
|
+
_this.logTokenRequest('mobile money');
|
|
19843
|
+
}
|
|
19844
|
+
}
|
|
19845
|
+
|
|
19846
|
+
return response;
|
|
19847
|
+
});
|
|
19848
|
+
},
|
|
19849
|
+
chargeMobileMoney: function chargeMobileMoney(_ref) {
|
|
19850
|
+
var _this2 = this;
|
|
19851
|
+
|
|
19852
|
+
var phoneNumber = _ref.phoneNumber,
|
|
19853
|
+
provider = _ref.provider,
|
|
19854
|
+
voucher = _ref.voucher,
|
|
19855
|
+
registrationToken = _ref.registrationToken;
|
|
19856
|
+
return validate$1(phoneNumber).then(function () {
|
|
19857
|
+
_this2.logAttempt('mobile money');
|
|
19858
|
+
|
|
19859
|
+
var params = {
|
|
19860
|
+
provider: provider,
|
|
19861
|
+
voucher: voucher,
|
|
19862
|
+
registrationToken: registrationToken,
|
|
19863
|
+
transaction: _this2.id,
|
|
19864
|
+
phone: phoneNumber,
|
|
19865
|
+
device: _this2.deviceFingerprint,
|
|
19866
|
+
channel_name: "MOBILE_MONEY_".concat(_this2.id)
|
|
19867
|
+
};
|
|
19868
|
+
return _this2.mobileMoneyChargeAPI(params);
|
|
19869
|
+
});
|
|
19870
|
+
},
|
|
19871
|
+
chargeMpesaOffline: function chargeMpesaOffline(_ref2) {
|
|
19872
|
+
var provider = _ref2.provider,
|
|
19873
|
+
voucher = _ref2.voucher,
|
|
19874
|
+
registrationToken = _ref2.registrationToken;
|
|
19875
|
+
this.logAttempt('mobile money');
|
|
19876
|
+
var params = {
|
|
19877
|
+
provider: provider,
|
|
19878
|
+
voucher: voucher,
|
|
19879
|
+
registrationToken: registrationToken,
|
|
19880
|
+
transaction: this.id,
|
|
19881
|
+
device: this.deviceFingerprint,
|
|
19882
|
+
channel_name: "MOBILE_MONEY_".concat(this.id)
|
|
19850
19883
|
};
|
|
19884
|
+
return this.mobileMoneyChargeAPI(params);
|
|
19851
19885
|
},
|
|
19852
|
-
|
|
19853
|
-
var
|
|
19854
|
-
return currentTimeInSeconds - startTime;
|
|
19855
|
-
}
|
|
19856
|
-
};
|
|
19886
|
+
authenticateMobileMoney: function authenticateMobileMoney(payload) {
|
|
19887
|
+
var _this3 = this;
|
|
19857
19888
|
|
|
19858
|
-
var
|
|
19859
|
-
|
|
19860
|
-
|
|
19861
|
-
|
|
19862
|
-
|
|
19863
|
-
var fails = fails$t;
|
|
19889
|
+
var phoneNumber = payload.phoneNumber,
|
|
19890
|
+
provider = payload.provider,
|
|
19891
|
+
registrationToken = payload.registrationToken;
|
|
19892
|
+
return validate$1(phoneNumber).then(function () {
|
|
19893
|
+
_this3.logMobileMoneyActions(payload);
|
|
19864
19894
|
|
|
19865
|
-
var
|
|
19866
|
-
|
|
19867
|
-
|
|
19868
|
-
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
|
|
19895
|
+
var params = {
|
|
19896
|
+
provider: provider,
|
|
19897
|
+
registrationToken: registrationToken,
|
|
19898
|
+
transaction: _this3.id,
|
|
19899
|
+
phone: phoneNumber,
|
|
19900
|
+
device: _this3.deviceFingerprint,
|
|
19901
|
+
channel_name: "MOBILE_MONEY_".concat(_this3.id)
|
|
19902
|
+
};
|
|
19903
|
+
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
19904
|
+
if (response.status === 'success') {
|
|
19905
|
+
_this3.mobileMoney = response;
|
|
19872
19906
|
|
|
19873
|
-
|
|
19874
|
-
|
|
19875
|
-
|
|
19907
|
+
if (response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
19908
|
+
_this3.logTokenRequest('mobile money');
|
|
19909
|
+
}
|
|
19910
|
+
} else if (response.errors && response.errors.data && response.errors.data.status === 'awaiting_registration_token') {
|
|
19911
|
+
_this3.logTokenAuthenticationFailure(response.message);
|
|
19912
|
+
} else {
|
|
19913
|
+
_this3.logError(response.message);
|
|
19914
|
+
}
|
|
19876
19915
|
|
|
19877
|
-
|
|
19878
|
-
|
|
19879
|
-
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
};
|
|
19916
|
+
return response;
|
|
19917
|
+
});
|
|
19918
|
+
});
|
|
19919
|
+
},
|
|
19920
|
+
submitMobileMoneyCode: function submitMobileMoneyCode(payload) {
|
|
19921
|
+
var _this4 = this;
|
|
19884
19922
|
|
|
19885
|
-
|
|
19886
|
-
|
|
19887
|
-
|
|
19888
|
-
})
|
|
19923
|
+
return MobileMoneyAPI.submitCode({
|
|
19924
|
+
code: payload.code,
|
|
19925
|
+
transaction: this.id
|
|
19926
|
+
}).then(function (response) {
|
|
19927
|
+
_this4.logAPIResponse(response, 'mobile_money');
|
|
19889
19928
|
|
|
19890
|
-
|
|
19891
|
-
|
|
19892
|
-
|
|
19893
|
-
|
|
19894
|
-
|
|
19895
|
-
|
|
19896
|
-
stringify: function stringify(it, replacer, space) {
|
|
19897
|
-
for (var i = 0, l = arguments.length, args = Array$1(l); i < l; i++) args[i] = arguments[i];
|
|
19898
|
-
var result = apply($stringify, null, args);
|
|
19899
|
-
return typeof result == 'string' ? replace(result, tester, fix) : result;
|
|
19929
|
+
return response;
|
|
19930
|
+
});
|
|
19931
|
+
},
|
|
19932
|
+
listenForMobileMoneyCharge: function listenForMobileMoneyCharge(callback) {
|
|
19933
|
+
if (this.mobileMoney.status !== 'success') {
|
|
19934
|
+
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
19900
19935
|
}
|
|
19901
|
-
});
|
|
19902
|
-
}
|
|
19903
19936
|
|
|
19904
|
-
var
|
|
19905
|
-
|
|
19906
|
-
|
|
19907
|
-
|
|
19937
|
+
var _this$mobileMoney$dat = this.mobileMoney.data,
|
|
19938
|
+
channel = _this$mobileMoney$dat.channel,
|
|
19939
|
+
channelName = _this$mobileMoney$dat.channel_name;
|
|
19940
|
+
var listenerOptions = {
|
|
19941
|
+
channel: channel || channelName,
|
|
19942
|
+
paymentMethod: 'mobile_money'
|
|
19943
|
+
};
|
|
19944
|
+
return this.listenForCharge(listenerOptions, callback);
|
|
19945
|
+
}
|
|
19946
|
+
};
|
|
19947
|
+
|
|
19948
|
+
var DirectDebitAPI = {
|
|
19949
|
+
loginToDirectDebitAccount: function loginToDirectDebitAccount(_ref) {
|
|
19950
|
+
var email = _ref.email,
|
|
19951
|
+
password = _ref.password;
|
|
19952
|
+
var params = {
|
|
19953
|
+
email: email,
|
|
19954
|
+
password: password
|
|
19955
|
+
};
|
|
19908
19956
|
var language = getLanguage();
|
|
19909
19957
|
|
|
19910
|
-
var headers = _objectSpread2({
|
|
19911
|
-
Authorization: "Bearer ".concat(merchantKey)
|
|
19912
|
-
}, language && {
|
|
19958
|
+
var headers = _objectSpread2({}, language && {
|
|
19913
19959
|
'Accept-Language': language
|
|
19914
19960
|
});
|
|
19915
19961
|
|
|
19916
|
-
return axiosInstance.post(
|
|
19917
|
-
payload: JSON.stringify(log)
|
|
19918
|
-
}, {
|
|
19962
|
+
return axiosInstance.post("".concat(configToUse.paystackApiUrl, "login"), params, {
|
|
19919
19963
|
headers: headers
|
|
19920
19964
|
}).then(function (response) {
|
|
19921
|
-
return response.data;
|
|
19965
|
+
return ChargeResponses.parse(response.data);
|
|
19922
19966
|
});
|
|
19923
19967
|
},
|
|
19924
|
-
|
|
19925
|
-
var
|
|
19968
|
+
charge: function charge(_ref2) {
|
|
19969
|
+
var accountCode = _ref2.account_code,
|
|
19970
|
+
transaction = _ref2.transaction,
|
|
19971
|
+
token = _ref2.token;
|
|
19926
19972
|
var language = getLanguage();
|
|
19927
19973
|
|
|
19928
|
-
var headers = _objectSpread2({
|
|
19974
|
+
var headers = _objectSpread2({
|
|
19975
|
+
Authorization: "Bearer ".concat(token),
|
|
19976
|
+
'jwt-auth': true
|
|
19977
|
+
}, language && {
|
|
19929
19978
|
'Accept-Language': language
|
|
19930
19979
|
});
|
|
19931
19980
|
|
|
19932
|
-
|
|
19981
|
+
var params = {
|
|
19982
|
+
account_code: accountCode,
|
|
19983
|
+
transaction: transaction
|
|
19984
|
+
};
|
|
19985
|
+
return axiosInstance.post("".concat(configToUse.paystackApiUrl, "directdebit/initiate"), params, {
|
|
19933
19986
|
headers: headers
|
|
19934
19987
|
}).then(function (response) {
|
|
19935
|
-
return response.data
|
|
19988
|
+
return ChargeResponses.parse(response.data);
|
|
19936
19989
|
});
|
|
19937
19990
|
},
|
|
19938
|
-
|
|
19939
|
-
var
|
|
19991
|
+
authenticate: function authenticate(_ref3) {
|
|
19992
|
+
var otp = _ref3.otp,
|
|
19993
|
+
transaction = _ref3.transaction,
|
|
19994
|
+
token = _ref3.token;
|
|
19940
19995
|
var language = getLanguage();
|
|
19941
19996
|
|
|
19942
19997
|
var headers = _objectSpread2({
|
|
19943
|
-
Authorization: "Bearer ".concat(
|
|
19998
|
+
Authorization: "Bearer ".concat(token),
|
|
19999
|
+
'jwt-auth': true
|
|
19944
20000
|
}, language && {
|
|
19945
20001
|
'Accept-Language': language
|
|
19946
20002
|
});
|
|
19947
20003
|
|
|
19948
|
-
|
|
20004
|
+
var params = {
|
|
20005
|
+
otp: otp,
|
|
20006
|
+
transaction: transaction
|
|
20007
|
+
};
|
|
20008
|
+
return axiosInstance.post("".concat(configToUse.paystackApiUrl, "directdebit/validate"), params, {
|
|
19949
20009
|
headers: headers
|
|
19950
20010
|
}).then(function (response) {
|
|
19951
|
-
return response.data;
|
|
20011
|
+
return ChargeResponses.parse(response.data);
|
|
19952
20012
|
});
|
|
19953
20013
|
},
|
|
19954
|
-
|
|
19955
|
-
var merchantKey = _ref3.merchantKey,
|
|
19956
|
-
referrer = _ref3.referrer;
|
|
20014
|
+
getProvisionedAccounts: function getProvisionedAccounts(token) {
|
|
19957
20015
|
var language = getLanguage();
|
|
19958
20016
|
|
|
19959
20017
|
var headers = _objectSpread2({
|
|
19960
|
-
Authorization: "Bearer ".concat(
|
|
20018
|
+
Authorization: "Bearer ".concat(token),
|
|
20019
|
+
'jwt-auth': true
|
|
19961
20020
|
}, language && {
|
|
19962
20021
|
'Accept-Language': language
|
|
19963
20022
|
});
|
|
19964
20023
|
|
|
19965
|
-
return axiosInstance.
|
|
19966
|
-
referrer: referrer
|
|
19967
|
-
}, {
|
|
20024
|
+
return axiosInstance.get("".concat(configToUse.paystackApiUrl, "directdebit/account"), {
|
|
19968
20025
|
headers: headers
|
|
19969
20026
|
}).then(function (response) {
|
|
19970
20027
|
return response.data;
|
|
@@ -19972,632 +20029,549 @@ var AnalyticsAPIUtils = {
|
|
|
19972
20029
|
}
|
|
19973
20030
|
};
|
|
19974
20031
|
|
|
19975
|
-
var
|
|
19976
|
-
|
|
19977
|
-
|
|
19978
|
-
|
|
19979
|
-
merchantKey: merchantKey,
|
|
19980
|
-
log: log
|
|
19981
|
-
});
|
|
19982
|
-
},
|
|
19983
|
-
getIp: function getIp() {
|
|
19984
|
-
return AnalyticsAPIUtils.getIp();
|
|
19985
|
-
},
|
|
19986
|
-
saveIp: function saveIp(transactionId, merchantKey) {
|
|
19987
|
-
var url = new URL("transaction/set_ip/".concat(transactionId), configToUse.paystackApiUrl).toString();
|
|
19988
|
-
return AnalyticsAPIUtils.saveIp(url, {
|
|
19989
|
-
merchantKey: merchantKey
|
|
19990
|
-
});
|
|
19991
|
-
},
|
|
19992
|
-
saveReferrer: function saveReferrer(transactionId, merchantKey, referrer) {
|
|
19993
|
-
var url = new URL("transaction/set_referrer/".concat(transactionId), configToUse.paystackApiUrl).toString();
|
|
19994
|
-
return AnalyticsAPIUtils.saveReferrer(url, {
|
|
19995
|
-
merchantKey: merchantKey,
|
|
19996
|
-
referrer: referrer
|
|
19997
|
-
});
|
|
19998
|
-
}
|
|
19999
|
-
};
|
|
20032
|
+
var paymentMethod$1 = 'direct debit';
|
|
20033
|
+
var DirectDebitCharge = {
|
|
20034
|
+
loginToDirectDebitAccount: function loginToDirectDebitAccount(_ref) {
|
|
20035
|
+
var _this = this;
|
|
20000
20036
|
|
|
20001
|
-
var
|
|
20002
|
-
|
|
20003
|
-
|
|
20004
|
-
|
|
20005
|
-
|
|
20006
|
-
|
|
20007
|
-
return this.log.time_spent;
|
|
20008
|
-
},
|
|
20009
|
-
logPageOpen: function logPageOpen() {
|
|
20010
|
-
this.log.history.push({
|
|
20011
|
-
type: 'open',
|
|
20012
|
-
message: 'Opened checkout',
|
|
20013
|
-
time: this.getTimeSpent()
|
|
20014
|
-
});
|
|
20015
|
-
return this.saveLog();
|
|
20016
|
-
},
|
|
20017
|
-
logChannelSwitch: function logChannelSwitch(value) {
|
|
20018
|
-
this.log.history.push({
|
|
20019
|
-
type: 'action',
|
|
20020
|
-
message: "Set payment method to: ".concat(value),
|
|
20021
|
-
time: this.getTimeSpent()
|
|
20022
|
-
});
|
|
20023
|
-
return this.saveLog();
|
|
20024
|
-
},
|
|
20025
|
-
logValidationErrors: function logValidationErrors(inputs) {
|
|
20026
|
-
var _this = this;
|
|
20037
|
+
var email = _ref.email,
|
|
20038
|
+
password = _ref.password;
|
|
20039
|
+
var params = {
|
|
20040
|
+
email: email,
|
|
20041
|
+
password: password
|
|
20042
|
+
};
|
|
20027
20043
|
|
|
20028
|
-
|
|
20029
|
-
|
|
20030
|
-
|
|
20031
|
-
message: "Invalid ".concat(input),
|
|
20032
|
-
time: _this.getTimeSpent()
|
|
20033
|
-
});
|
|
20034
|
-
});
|
|
20035
|
-
return this.saveLog();
|
|
20036
|
-
},
|
|
20037
|
-
logInput: function logInput(value) {
|
|
20038
|
-
var isUpdate = this.log.history.find(function (item) {
|
|
20039
|
-
return item.message === "Filled this field: ".concat(value);
|
|
20040
|
-
});
|
|
20041
|
-
this.log.history.push({
|
|
20042
|
-
type: 'input',
|
|
20043
|
-
message: "".concat(isUpdate ? 'Changed' : 'Filled', " this field: ").concat(value),
|
|
20044
|
-
time: this.getTimeSpent()
|
|
20045
|
-
});
|
|
20046
|
-
return this.saveLog();
|
|
20047
|
-
},
|
|
20048
|
-
logBankSelect: function logBankSelect(value) {
|
|
20049
|
-
this.log.history.push({
|
|
20050
|
-
type: 'action',
|
|
20051
|
-
message: "Selected bank: ".concat(value),
|
|
20052
|
-
time: this.getTimeSpent()
|
|
20053
|
-
});
|
|
20054
|
-
return this.saveLog();
|
|
20055
|
-
},
|
|
20056
|
-
logSavedCardSelect: function logSavedCardSelect() {
|
|
20057
|
-
this.log.history.push({
|
|
20058
|
-
type: 'action',
|
|
20059
|
-
message: 'Selected saved card',
|
|
20060
|
-
time: this.getTimeSpent()
|
|
20061
|
-
});
|
|
20062
|
-
return this.saveLog();
|
|
20063
|
-
},
|
|
20064
|
-
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
20065
|
-
this.log.history.push({
|
|
20066
|
-
type: 'action',
|
|
20067
|
-
message: 'Third-party authentication window opened',
|
|
20068
|
-
time: this.getTimeSpent()
|
|
20069
|
-
});
|
|
20070
|
-
return this.saveLog();
|
|
20071
|
-
},
|
|
20072
|
-
logAuthWindowClose: function logAuthWindowClose() {
|
|
20073
|
-
this.log.history.push({
|
|
20074
|
-
type: 'action',
|
|
20075
|
-
message: 'Third-party authentication window closed',
|
|
20076
|
-
time: this.getTimeSpent()
|
|
20077
|
-
});
|
|
20078
|
-
return this.saveLog();
|
|
20079
|
-
},
|
|
20080
|
-
logAPIResponse: function logAPIResponse(response, channel) {
|
|
20081
|
-
switch (response.status) {
|
|
20082
|
-
case 'success':
|
|
20083
|
-
return this.logSuccess(channel);
|
|
20044
|
+
if (!isValidEmail(email)) {
|
|
20045
|
+
return Promise.reject(Error('Invalid email'));
|
|
20046
|
+
}
|
|
20084
20047
|
|
|
20085
|
-
|
|
20086
|
-
|
|
20048
|
+
return DirectDebitAPI.loginToDirectDebitAccount(params).then(function (response) {
|
|
20049
|
+
if (response.status === 'success') {
|
|
20050
|
+
var _response$data = response.data,
|
|
20051
|
+
token = _response$data.token,
|
|
20052
|
+
permissions = _response$data.user.permissions;
|
|
20087
20053
|
|
|
20088
|
-
|
|
20089
|
-
|
|
20054
|
+
if (!permissions || permissions.length < 1) {
|
|
20055
|
+
throw Error('You do not have the privileges to perform this action');
|
|
20056
|
+
}
|
|
20090
20057
|
|
|
20091
|
-
|
|
20092
|
-
|
|
20058
|
+
if (permissions.find(function (permission) {
|
|
20059
|
+
return permission === 'directdebit-*';
|
|
20060
|
+
})) {
|
|
20061
|
+
_this.directDebit.token = token;
|
|
20062
|
+
return response;
|
|
20063
|
+
}
|
|
20093
20064
|
|
|
20094
|
-
|
|
20095
|
-
|
|
20096
|
-
}
|
|
20097
|
-
},
|
|
20098
|
-
logMobileMoneyActions: function logMobileMoneyActions(_ref) {
|
|
20099
|
-
var numberOfTokenRequests = _ref.numberOfTokenRequests,
|
|
20100
|
-
registrationToken = _ref.registrationToken;
|
|
20065
|
+
throw Error('You do not have the privileges to perform this action');
|
|
20066
|
+
}
|
|
20101
20067
|
|
|
20102
|
-
|
|
20103
|
-
this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
20104
|
-
} else if (registrationToken) {
|
|
20105
|
-
this.logTokenSubmitted('mobile money');
|
|
20106
|
-
} else {
|
|
20107
|
-
this.logAttempt('mobile money');
|
|
20108
|
-
}
|
|
20109
|
-
},
|
|
20110
|
-
logAPIResponseMessage: function logAPIResponseMessage(message) {
|
|
20111
|
-
this.log.history.push({
|
|
20112
|
-
type: 'action',
|
|
20113
|
-
message: message,
|
|
20114
|
-
time: this.getTimeSpent()
|
|
20068
|
+
return response;
|
|
20115
20069
|
});
|
|
20116
|
-
return this.saveLog();
|
|
20117
20070
|
},
|
|
20118
|
-
|
|
20119
|
-
var
|
|
20071
|
+
chargeDirectDebit: function chargeDirectDebit(accountCode) {
|
|
20072
|
+
var _this2 = this;
|
|
20120
20073
|
|
|
20121
|
-
if (
|
|
20122
|
-
|
|
20074
|
+
if (!this.directDebit.token) {
|
|
20075
|
+
return Promise.reject(Error('Please login with Transaction.loginToDirectDebitAccount() to start a Direct debit charge'));
|
|
20123
20076
|
}
|
|
20124
20077
|
|
|
20125
|
-
this.
|
|
20126
|
-
|
|
20127
|
-
|
|
20128
|
-
|
|
20129
|
-
|
|
20130
|
-
}
|
|
20131
|
-
return
|
|
20132
|
-
|
|
20133
|
-
logTokenRequest: function logTokenRequest(channel) {
|
|
20134
|
-
var numberOfTokenRequests = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
20135
|
-
var message = numberOfTokenRequests === 0 ? 'Waiting for customer to submit OTP' : 'Customer requested to resend OTP';
|
|
20136
|
-
this.log.history.push({
|
|
20137
|
-
type: 'action',
|
|
20138
|
-
message: message,
|
|
20139
|
-
channel: channel,
|
|
20140
|
-
time: this.getTimeSpent()
|
|
20141
|
-
});
|
|
20142
|
-
return this.saveLog();
|
|
20143
|
-
},
|
|
20144
|
-
logTokenSubmitted: function logTokenSubmitted(channel) {
|
|
20145
|
-
var message = 'Customer submitted OTP';
|
|
20146
|
-
this.log.history.push({
|
|
20147
|
-
type: 'action',
|
|
20148
|
-
message: message,
|
|
20149
|
-
channel: channel,
|
|
20150
|
-
time: this.getTimeSpent()
|
|
20151
|
-
});
|
|
20152
|
-
return this.saveLog();
|
|
20153
|
-
},
|
|
20154
|
-
logTokenAuthenticationFailure: function logTokenAuthenticationFailure(error) {
|
|
20155
|
-
var message = error ? "Error: ".concat(error) : 'Error';
|
|
20156
|
-
this.log.errors += 1;
|
|
20157
|
-
this.log.history.push({
|
|
20158
|
-
type: 'error',
|
|
20159
|
-
message: message,
|
|
20160
|
-
authentication: 'failed',
|
|
20161
|
-
time: this.getTimeSpent()
|
|
20162
|
-
});
|
|
20163
|
-
return this.saveLog();
|
|
20164
|
-
},
|
|
20165
|
-
logError: function logError(error) {
|
|
20166
|
-
var message = 'Error';
|
|
20078
|
+
this.logAttempt(paymentMethod$1);
|
|
20079
|
+
var params = {
|
|
20080
|
+
account_code: accountCode,
|
|
20081
|
+
transaction: this.id,
|
|
20082
|
+
token: this.directDebit.token
|
|
20083
|
+
};
|
|
20084
|
+
return DirectDebitAPI.charge(params).then(function (response) {
|
|
20085
|
+
_this2.logAPIResponse(response, paymentMethod$1);
|
|
20167
20086
|
|
|
20168
|
-
|
|
20169
|
-
|
|
20170
|
-
|
|
20087
|
+
if (response.status) {
|
|
20088
|
+
_this2.directDebit.chargeResponse = response;
|
|
20089
|
+
}
|
|
20171
20090
|
|
|
20172
|
-
|
|
20173
|
-
this.log.history.push({
|
|
20174
|
-
type: 'error',
|
|
20175
|
-
message: message,
|
|
20176
|
-
time: this.getTimeSpent()
|
|
20177
|
-
});
|
|
20178
|
-
return this.saveLog();
|
|
20179
|
-
},
|
|
20180
|
-
logAuth: function logAuth(value) {
|
|
20181
|
-
this.log.authentication = value;
|
|
20182
|
-
this.log.history.push({
|
|
20183
|
-
type: 'auth',
|
|
20184
|
-
message: "Authentication Required: ".concat(value),
|
|
20185
|
-
time: this.getTimeSpent()
|
|
20091
|
+
return response;
|
|
20186
20092
|
});
|
|
20187
|
-
return this.saveLog();
|
|
20188
20093
|
},
|
|
20189
|
-
|
|
20190
|
-
var
|
|
20094
|
+
getProvisionedAccounts: function getProvisionedAccounts() {
|
|
20095
|
+
var _this3 = this;
|
|
20191
20096
|
|
|
20192
|
-
|
|
20193
|
-
|
|
20194
|
-
}
|
|
20097
|
+
return DirectDebitAPI.getProvisionedAccounts(this.directDebit.token).then(function (response) {
|
|
20098
|
+
_this3.logAPIResponse(response, paymentMethod$1);
|
|
20195
20099
|
|
|
20196
|
-
|
|
20197
|
-
|
|
20198
|
-
type: 'success',
|
|
20199
|
-
message: message,
|
|
20200
|
-
time: this.getTimeSpent()
|
|
20201
|
-
});
|
|
20202
|
-
return this.saveLog();
|
|
20203
|
-
},
|
|
20204
|
-
logPending: function logPending(channel) {
|
|
20205
|
-
var message = 'Payment in progress';
|
|
20100
|
+
var status = response.status,
|
|
20101
|
+
data = response.data;
|
|
20206
20102
|
|
|
20207
|
-
|
|
20208
|
-
|
|
20209
|
-
|
|
20103
|
+
if (status) {
|
|
20104
|
+
if (data && data.length < 1) {
|
|
20105
|
+
return Promise.reject(Error('You have not provisioned any bank account for Direct Debit yet'));
|
|
20106
|
+
}
|
|
20210
20107
|
|
|
20211
|
-
|
|
20212
|
-
|
|
20213
|
-
|
|
20214
|
-
|
|
20215
|
-
});
|
|
20216
|
-
return this.saveLog();
|
|
20217
|
-
},
|
|
20218
|
-
logPageClose: function logPageClose() {
|
|
20219
|
-
this.log.history.push({
|
|
20220
|
-
type: 'close',
|
|
20221
|
-
message: 'Closed checkout',
|
|
20222
|
-
time: this.getTimeSpent()
|
|
20108
|
+
_this3.directDebit.accounts = response.data;
|
|
20109
|
+
}
|
|
20110
|
+
|
|
20111
|
+
return response;
|
|
20223
20112
|
});
|
|
20224
|
-
return this.saveLog();
|
|
20225
20113
|
},
|
|
20226
|
-
|
|
20227
|
-
var
|
|
20228
|
-
|
|
20229
|
-
|
|
20230
|
-
|
|
20231
|
-
|
|
20232
|
-
|
|
20233
|
-
|
|
20234
|
-
|
|
20114
|
+
authenticateAccount: function authenticateAccount(otp) {
|
|
20115
|
+
var _this4 = this;
|
|
20116
|
+
|
|
20117
|
+
var params = {
|
|
20118
|
+
otp: otp,
|
|
20119
|
+
transaction: this.id,
|
|
20120
|
+
token: this.directDebit.token
|
|
20121
|
+
};
|
|
20122
|
+
return DirectDebitAPI.authenticate(params).then(function (response) {
|
|
20123
|
+
_this4.logAPIResponse(response, paymentMethod$1);
|
|
20124
|
+
|
|
20125
|
+
return response;
|
|
20235
20126
|
});
|
|
20236
|
-
return this.saveLog();
|
|
20237
|
-
},
|
|
20238
|
-
saveLog: function saveLog() {
|
|
20239
|
-
return AnalyticsAPI.saveLog(this.id, this.merchant.key, this.log);
|
|
20240
|
-
},
|
|
20241
|
-
saveIpAddress: function saveIpAddress() {
|
|
20242
|
-
return AnalyticsAPI.saveIp(this.id, this.merchant.key);
|
|
20243
|
-
},
|
|
20244
|
-
saveReferrer: function saveReferrer(referrer) {
|
|
20245
|
-
return AnalyticsAPI.saveReferrer(this.id, this.merchant.key, referrer);
|
|
20246
20127
|
}
|
|
20247
20128
|
};
|
|
20248
20129
|
|
|
20249
|
-
|
|
20250
|
-
|
|
20251
|
-
var
|
|
20252
|
-
|
|
20253
|
-
|
|
20254
|
-
|
|
20255
|
-
|
|
20256
|
-
|
|
20257
|
-
|
|
20258
|
-
|
|
20259
|
-
|
|
20260
|
-
|
|
20261
|
-
|
|
20262
|
-
|
|
20263
|
-
|
|
20264
|
-
|
|
20265
|
-
|
|
20266
|
-
|
|
20267
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20268
|
-
while (1) {
|
|
20269
|
-
switch (_context.prev = _context.next) {
|
|
20270
|
-
case 0:
|
|
20271
|
-
if (!(response.status === 'success')) {
|
|
20272
|
-
_context.next = 5;
|
|
20273
|
-
break;
|
|
20274
|
-
}
|
|
20275
|
-
|
|
20276
|
-
mobileMoney = response;
|
|
20130
|
+
var ChargeFunctions = {
|
|
20131
|
+
get: function get(channel) {
|
|
20132
|
+
var chargeFunctions = {
|
|
20133
|
+
card: CardCharge,
|
|
20134
|
+
bank: BankAccountCharge,
|
|
20135
|
+
ussd: USSDCharge,
|
|
20136
|
+
qr: QRCharge,
|
|
20137
|
+
mobile_money: MobileMoneyCharge,
|
|
20138
|
+
direct_debit: DirectDebitCharge,
|
|
20139
|
+
bank_transfer: PayWithTransferCharge,
|
|
20140
|
+
eft: EFT,
|
|
20141
|
+
payattitude: PayattitudeCharge,
|
|
20142
|
+
apple_pay: ApplePayCharge,
|
|
20143
|
+
paypal: PayPalCharge
|
|
20144
|
+
};
|
|
20145
|
+
return chargeFunctions[channel];
|
|
20146
|
+
}
|
|
20147
|
+
};
|
|
20277
20148
|
|
|
20278
|
-
|
|
20279
|
-
_context.next = 5;
|
|
20280
|
-
break;
|
|
20281
|
-
}
|
|
20149
|
+
var isMobile_1 = isMobile;
|
|
20282
20150
|
|
|
20283
|
-
|
|
20284
|
-
|
|
20151
|
+
function isMobile (ua) {
|
|
20152
|
+
if (!ua && typeof navigator != 'undefined') ua = navigator.userAgent;
|
|
20153
|
+
if (ua && ua.headers && typeof ua.headers['user-agent'] == 'string') {
|
|
20154
|
+
ua = ua.headers['user-agent'];
|
|
20155
|
+
}
|
|
20156
|
+
if (typeof ua != 'string') return false;
|
|
20285
20157
|
|
|
20286
|
-
|
|
20287
|
-
|
|
20158
|
+
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));
|
|
20159
|
+
}
|
|
20288
20160
|
|
|
20289
|
-
|
|
20290
|
-
|
|
20291
|
-
|
|
20292
|
-
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
|
|
20161
|
+
var AnalyticsUtils = {
|
|
20162
|
+
initializeLog: function initializeLog(log) {
|
|
20163
|
+
var _ref = log || {},
|
|
20164
|
+
attempts = _ref.attempts,
|
|
20165
|
+
authentication = _ref.authentication,
|
|
20166
|
+
errors = _ref.errors,
|
|
20167
|
+
history = _ref.history;
|
|
20296
20168
|
|
|
20297
|
-
return
|
|
20298
|
-
|
|
20169
|
+
return {
|
|
20170
|
+
start_time: Math.round(Date.now() / 1000),
|
|
20171
|
+
time_spent: 0,
|
|
20172
|
+
attempts: attempts || 0,
|
|
20173
|
+
authentication: authentication,
|
|
20174
|
+
errors: errors || 0,
|
|
20175
|
+
success: false,
|
|
20176
|
+
mobile: isMobile_1(),
|
|
20177
|
+
input: [],
|
|
20178
|
+
history: history || []
|
|
20299
20179
|
};
|
|
20300
|
-
}
|
|
20301
|
-
|
|
20180
|
+
},
|
|
20181
|
+
getTimeSpent: function getTimeSpent(startTime) {
|
|
20182
|
+
var currentTimeInSeconds = Math.round(Date.now() / 1000);
|
|
20183
|
+
return currentTimeInSeconds - startTime;
|
|
20184
|
+
}
|
|
20185
|
+
};
|
|
20302
20186
|
|
|
20303
|
-
var
|
|
20304
|
-
|
|
20305
|
-
|
|
20187
|
+
var $ = _export;
|
|
20188
|
+
var global$1 = global$R;
|
|
20189
|
+
var getBuiltIn = getBuiltIn$a;
|
|
20190
|
+
var apply = functionApply;
|
|
20191
|
+
var uncurryThis = functionUncurryThis;
|
|
20192
|
+
var fails = fails$t;
|
|
20306
20193
|
|
|
20307
|
-
|
|
20308
|
-
|
|
20309
|
-
|
|
20310
|
-
|
|
20311
|
-
|
|
20312
|
-
|
|
20194
|
+
var Array$1 = global$1.Array;
|
|
20195
|
+
var $stringify = getBuiltIn('JSON', 'stringify');
|
|
20196
|
+
var exec = uncurryThis(/./.exec);
|
|
20197
|
+
var charAt = uncurryThis(''.charAt);
|
|
20198
|
+
var charCodeAt = uncurryThis(''.charCodeAt);
|
|
20199
|
+
var replace = uncurryThis(''.replace);
|
|
20200
|
+
var numberToString = uncurryThis(1.0.toString);
|
|
20201
|
+
|
|
20202
|
+
var tester = /[\uD800-\uDFFF]/g;
|
|
20203
|
+
var low = /^[\uD800-\uDBFF]$/;
|
|
20204
|
+
var hi = /^[\uDC00-\uDFFF]$/;
|
|
20313
20205
|
|
|
20314
|
-
|
|
20315
|
-
|
|
20316
|
-
|
|
20317
|
-
|
|
20318
|
-
|
|
20319
|
-
|
|
20320
|
-
|
|
20321
|
-
channel_name: "MOBILE_MONEY_".concat(_this.id)
|
|
20322
|
-
};
|
|
20323
|
-
return mobileMoneyChargeAPI(params);
|
|
20324
|
-
});
|
|
20325
|
-
},
|
|
20326
|
-
chargeMpesaOffline: function chargeMpesaOffline(_ref3) {
|
|
20327
|
-
var provider = _ref3.provider,
|
|
20328
|
-
voucher = _ref3.voucher,
|
|
20329
|
-
registrationToken = _ref3.registrationToken;
|
|
20330
|
-
this.logAttempt('mobile money');
|
|
20331
|
-
var params = {
|
|
20332
|
-
provider: provider,
|
|
20333
|
-
voucher: voucher,
|
|
20334
|
-
registrationToken: registrationToken,
|
|
20335
|
-
transaction: this.id,
|
|
20336
|
-
device: this.deviceFingerprint,
|
|
20337
|
-
channel_name: "MOBILE_MONEY_".concat(this.id)
|
|
20338
|
-
};
|
|
20339
|
-
return mobileMoneyChargeAPI(params);
|
|
20340
|
-
},
|
|
20341
|
-
authenticateMobileMoney: function authenticateMobileMoney(payload) {
|
|
20342
|
-
var _this2 = this;
|
|
20206
|
+
var fix = function (match, offset, string) {
|
|
20207
|
+
var prev = charAt(string, offset - 1);
|
|
20208
|
+
var next = charAt(string, offset + 1);
|
|
20209
|
+
if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) {
|
|
20210
|
+
return '\\u' + numberToString(charCodeAt(match, 0), 16);
|
|
20211
|
+
} return match;
|
|
20212
|
+
};
|
|
20343
20213
|
|
|
20344
|
-
|
|
20345
|
-
|
|
20346
|
-
|
|
20347
|
-
|
|
20348
|
-
_this2.logMobileMoneyActions(payload);
|
|
20214
|
+
var FORCED = fails(function () {
|
|
20215
|
+
return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
|
|
20216
|
+
|| $stringify('\uDEAD') !== '"\\udead"';
|
|
20217
|
+
});
|
|
20349
20218
|
|
|
20350
|
-
|
|
20351
|
-
|
|
20352
|
-
|
|
20353
|
-
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
|
|
20357
|
-
|
|
20358
|
-
|
|
20359
|
-
|
|
20360
|
-
|
|
20219
|
+
if ($stringify) {
|
|
20220
|
+
// `JSON.stringify` method
|
|
20221
|
+
// https://tc39.es/ecma262/#sec-json.stringify
|
|
20222
|
+
// https://github.com/tc39/proposal-well-formed-stringify
|
|
20223
|
+
$({ target: 'JSON', stat: true, forced: FORCED }, {
|
|
20224
|
+
// eslint-disable-next-line no-unused-vars -- required for `.length`
|
|
20225
|
+
stringify: function stringify(it, replacer, space) {
|
|
20226
|
+
for (var i = 0, l = arguments.length, args = Array$1(l); i < l; i++) args[i] = arguments[i];
|
|
20227
|
+
var result = apply($stringify, null, args);
|
|
20228
|
+
return typeof result == 'string' ? replace(result, tester, fix) : result;
|
|
20229
|
+
}
|
|
20230
|
+
});
|
|
20231
|
+
}
|
|
20361
20232
|
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
|
|
20365
|
-
|
|
20366
|
-
|
|
20367
|
-
} else {
|
|
20368
|
-
_this2.logError(response.message);
|
|
20369
|
-
}
|
|
20233
|
+
var AnalyticsAPIUtils = {
|
|
20234
|
+
saveLog: function saveLog(url, _ref) {
|
|
20235
|
+
var merchantKey = _ref.merchantKey,
|
|
20236
|
+
log = _ref.log;
|
|
20237
|
+
var language = getLanguage();
|
|
20370
20238
|
|
|
20371
|
-
|
|
20372
|
-
|
|
20239
|
+
var headers = _objectSpread2({
|
|
20240
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
20241
|
+
}, language && {
|
|
20242
|
+
'Accept-Language': language
|
|
20373
20243
|
});
|
|
20374
|
-
},
|
|
20375
|
-
submitMobileMoneyCode: function submitMobileMoneyCode(payload) {
|
|
20376
|
-
var _this3 = this;
|
|
20377
20244
|
|
|
20378
|
-
return
|
|
20379
|
-
|
|
20380
|
-
|
|
20245
|
+
return axiosInstance.post(url, {
|
|
20246
|
+
payload: JSON.stringify(log)
|
|
20247
|
+
}, {
|
|
20248
|
+
headers: headers
|
|
20381
20249
|
}).then(function (response) {
|
|
20382
|
-
|
|
20383
|
-
|
|
20384
|
-
return response;
|
|
20250
|
+
return response.data;
|
|
20385
20251
|
});
|
|
20386
20252
|
},
|
|
20387
|
-
|
|
20388
|
-
|
|
20389
|
-
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20390
|
-
}
|
|
20391
|
-
|
|
20392
|
-
var _mobileMoney$data = mobileMoney.data,
|
|
20393
|
-
channel = _mobileMoney$data.channel,
|
|
20394
|
-
channelName = _mobileMoney$data.channel_name;
|
|
20395
|
-
var listenerOptions = {
|
|
20396
|
-
channel: channel || channelName,
|
|
20397
|
-
paymentMethod: 'mobile_money'
|
|
20398
|
-
};
|
|
20399
|
-
return this.listenForCharge(listenerOptions, callback);
|
|
20400
|
-
}
|
|
20401
|
-
};
|
|
20402
|
-
|
|
20403
|
-
var DirectDebitAPI = {
|
|
20404
|
-
loginToDirectDebitAccount: function loginToDirectDebitAccount(_ref) {
|
|
20405
|
-
var email = _ref.email,
|
|
20406
|
-
password = _ref.password;
|
|
20407
|
-
var params = {
|
|
20408
|
-
email: email,
|
|
20409
|
-
password: password
|
|
20410
|
-
};
|
|
20253
|
+
getIp: function getIp() {
|
|
20254
|
+
var url = 'https://api.paystack.co/decision/ip';
|
|
20411
20255
|
var language = getLanguage();
|
|
20412
20256
|
|
|
20413
20257
|
var headers = _objectSpread2({}, language && {
|
|
20414
20258
|
'Accept-Language': language
|
|
20415
20259
|
});
|
|
20416
20260
|
|
|
20417
|
-
return axiosInstance.
|
|
20261
|
+
return axiosInstance.get(url, {
|
|
20418
20262
|
headers: headers
|
|
20419
20263
|
}).then(function (response) {
|
|
20420
|
-
return
|
|
20264
|
+
return response.data.data.ip_address;
|
|
20421
20265
|
});
|
|
20422
20266
|
},
|
|
20423
|
-
|
|
20424
|
-
var
|
|
20425
|
-
transaction = _ref2.transaction,
|
|
20426
|
-
token = _ref2.token;
|
|
20267
|
+
saveIp: function saveIp(url, _ref2) {
|
|
20268
|
+
var merchantKey = _ref2.merchantKey;
|
|
20427
20269
|
var language = getLanguage();
|
|
20428
20270
|
|
|
20429
20271
|
var headers = _objectSpread2({
|
|
20430
|
-
Authorization: "Bearer ".concat(
|
|
20431
|
-
'jwt-auth': true
|
|
20272
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
20432
20273
|
}, language && {
|
|
20433
20274
|
'Accept-Language': language
|
|
20434
20275
|
});
|
|
20435
20276
|
|
|
20436
|
-
|
|
20437
|
-
account_code: accountCode,
|
|
20438
|
-
transaction: transaction
|
|
20439
|
-
};
|
|
20440
|
-
return axiosInstance.post("".concat(configToUse.paystackApiUrl, "directdebit/initiate"), params, {
|
|
20277
|
+
return axiosInstance.post(url, null, {
|
|
20441
20278
|
headers: headers
|
|
20442
20279
|
}).then(function (response) {
|
|
20443
|
-
return
|
|
20280
|
+
return response.data;
|
|
20444
20281
|
});
|
|
20445
20282
|
},
|
|
20446
|
-
|
|
20447
|
-
var
|
|
20448
|
-
|
|
20449
|
-
token = _ref3.token;
|
|
20283
|
+
saveReferrer: function saveReferrer(url, _ref3) {
|
|
20284
|
+
var merchantKey = _ref3.merchantKey,
|
|
20285
|
+
referrer = _ref3.referrer;
|
|
20450
20286
|
var language = getLanguage();
|
|
20451
20287
|
|
|
20452
20288
|
var headers = _objectSpread2({
|
|
20453
|
-
Authorization: "Bearer ".concat(
|
|
20454
|
-
'jwt-auth': true
|
|
20289
|
+
Authorization: "Bearer ".concat(merchantKey)
|
|
20455
20290
|
}, language && {
|
|
20456
20291
|
'Accept-Language': language
|
|
20457
20292
|
});
|
|
20458
20293
|
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
|
|
20462
|
-
};
|
|
20463
|
-
return axiosInstance.post("".concat(configToUse.paystackApiUrl, "directdebit/validate"), params, {
|
|
20294
|
+
return axiosInstance.post(url, {
|
|
20295
|
+
referrer: referrer
|
|
20296
|
+
}, {
|
|
20464
20297
|
headers: headers
|
|
20465
20298
|
}).then(function (response) {
|
|
20466
|
-
return
|
|
20299
|
+
return response.data;
|
|
20300
|
+
});
|
|
20301
|
+
}
|
|
20302
|
+
};
|
|
20303
|
+
|
|
20304
|
+
var AnalyticsAPI = {
|
|
20305
|
+
saveLog: function saveLog(transactionId, merchantKey, log) {
|
|
20306
|
+
var url = new URL("transaction/update_log/".concat(transactionId), configToUse.paystackApiUrl).toString();
|
|
20307
|
+
return AnalyticsAPIUtils.saveLog(url, {
|
|
20308
|
+
merchantKey: merchantKey,
|
|
20309
|
+
log: log
|
|
20310
|
+
});
|
|
20311
|
+
},
|
|
20312
|
+
getIp: function getIp() {
|
|
20313
|
+
return AnalyticsAPIUtils.getIp();
|
|
20314
|
+
},
|
|
20315
|
+
saveIp: function saveIp(transactionId, merchantKey) {
|
|
20316
|
+
var url = new URL("transaction/set_ip/".concat(transactionId), configToUse.paystackApiUrl).toString();
|
|
20317
|
+
return AnalyticsAPIUtils.saveIp(url, {
|
|
20318
|
+
merchantKey: merchantKey
|
|
20319
|
+
});
|
|
20320
|
+
},
|
|
20321
|
+
saveReferrer: function saveReferrer(transactionId, merchantKey, referrer) {
|
|
20322
|
+
var url = new URL("transaction/set_referrer/".concat(transactionId), configToUse.paystackApiUrl).toString();
|
|
20323
|
+
return AnalyticsAPIUtils.saveReferrer(url, {
|
|
20324
|
+
merchantKey: merchantKey,
|
|
20325
|
+
referrer: referrer
|
|
20326
|
+
});
|
|
20327
|
+
}
|
|
20328
|
+
};
|
|
20329
|
+
|
|
20330
|
+
var AnalyticsFunctions$1 = {
|
|
20331
|
+
initializeLog: function initializeLog(log) {
|
|
20332
|
+
this.log = AnalyticsUtils.initializeLog(log);
|
|
20333
|
+
},
|
|
20334
|
+
getTimeSpent: function getTimeSpent() {
|
|
20335
|
+
this.log.time_spent = AnalyticsUtils.getTimeSpent(this.log.start_time);
|
|
20336
|
+
return this.log.time_spent;
|
|
20337
|
+
},
|
|
20338
|
+
logPageOpen: function logPageOpen() {
|
|
20339
|
+
this.log.history.push({
|
|
20340
|
+
type: 'open',
|
|
20341
|
+
message: 'Opened checkout',
|
|
20342
|
+
time: this.getTimeSpent()
|
|
20343
|
+
});
|
|
20344
|
+
return this.saveLog();
|
|
20345
|
+
},
|
|
20346
|
+
logChannelSwitch: function logChannelSwitch(value) {
|
|
20347
|
+
this.log.history.push({
|
|
20348
|
+
type: 'action',
|
|
20349
|
+
message: "Set payment method to: ".concat(value),
|
|
20350
|
+
time: this.getTimeSpent()
|
|
20351
|
+
});
|
|
20352
|
+
return this.saveLog();
|
|
20353
|
+
},
|
|
20354
|
+
logValidationErrors: function logValidationErrors(inputs) {
|
|
20355
|
+
var _this = this;
|
|
20356
|
+
|
|
20357
|
+
inputs.forEach(function (input) {
|
|
20358
|
+
_this.log.history.push({
|
|
20359
|
+
type: 'error',
|
|
20360
|
+
message: "Invalid ".concat(input),
|
|
20361
|
+
time: _this.getTimeSpent()
|
|
20362
|
+
});
|
|
20363
|
+
});
|
|
20364
|
+
return this.saveLog();
|
|
20365
|
+
},
|
|
20366
|
+
logInput: function logInput(value) {
|
|
20367
|
+
var isUpdate = this.log.history.find(function (item) {
|
|
20368
|
+
return item.message === "Filled this field: ".concat(value);
|
|
20369
|
+
});
|
|
20370
|
+
this.log.history.push({
|
|
20371
|
+
type: 'input',
|
|
20372
|
+
message: "".concat(isUpdate ? 'Changed' : 'Filled', " this field: ").concat(value),
|
|
20373
|
+
time: this.getTimeSpent()
|
|
20374
|
+
});
|
|
20375
|
+
return this.saveLog();
|
|
20376
|
+
},
|
|
20377
|
+
logBankSelect: function logBankSelect(value) {
|
|
20378
|
+
this.log.history.push({
|
|
20379
|
+
type: 'action',
|
|
20380
|
+
message: "Selected bank: ".concat(value),
|
|
20381
|
+
time: this.getTimeSpent()
|
|
20382
|
+
});
|
|
20383
|
+
return this.saveLog();
|
|
20384
|
+
},
|
|
20385
|
+
logSavedCardSelect: function logSavedCardSelect() {
|
|
20386
|
+
this.log.history.push({
|
|
20387
|
+
type: 'action',
|
|
20388
|
+
message: 'Selected saved card',
|
|
20389
|
+
time: this.getTimeSpent()
|
|
20390
|
+
});
|
|
20391
|
+
return this.saveLog();
|
|
20392
|
+
},
|
|
20393
|
+
logAuthWindowOpen: function logAuthWindowOpen() {
|
|
20394
|
+
this.log.history.push({
|
|
20395
|
+
type: 'action',
|
|
20396
|
+
message: 'Third-party authentication window opened',
|
|
20397
|
+
time: this.getTimeSpent()
|
|
20398
|
+
});
|
|
20399
|
+
return this.saveLog();
|
|
20400
|
+
},
|
|
20401
|
+
logAuthWindowClose: function logAuthWindowClose() {
|
|
20402
|
+
this.log.history.push({
|
|
20403
|
+
type: 'action',
|
|
20404
|
+
message: 'Third-party authentication window closed',
|
|
20405
|
+
time: this.getTimeSpent()
|
|
20467
20406
|
});
|
|
20407
|
+
return this.saveLog();
|
|
20468
20408
|
},
|
|
20469
|
-
|
|
20470
|
-
|
|
20471
|
-
|
|
20472
|
-
|
|
20473
|
-
Authorization: "Bearer ".concat(token),
|
|
20474
|
-
'jwt-auth': true
|
|
20475
|
-
}, language && {
|
|
20476
|
-
'Accept-Language': language
|
|
20477
|
-
});
|
|
20409
|
+
logAPIResponse: function logAPIResponse(response, channel) {
|
|
20410
|
+
switch (response.status) {
|
|
20411
|
+
case 'success':
|
|
20412
|
+
return this.logSuccess(channel);
|
|
20478
20413
|
|
|
20479
|
-
|
|
20480
|
-
|
|
20481
|
-
}).then(function (response) {
|
|
20482
|
-
return response.data;
|
|
20483
|
-
});
|
|
20484
|
-
}
|
|
20485
|
-
};
|
|
20414
|
+
case 'pending':
|
|
20415
|
+
return this.logPending(channel);
|
|
20486
20416
|
|
|
20487
|
-
|
|
20488
|
-
|
|
20489
|
-
loginToDirectDebitAccount: function loginToDirectDebitAccount(_ref) {
|
|
20490
|
-
var _this = this;
|
|
20417
|
+
case 'failed':
|
|
20418
|
+
return this.logError(response.message);
|
|
20491
20419
|
|
|
20492
|
-
|
|
20493
|
-
|
|
20494
|
-
var params = {
|
|
20495
|
-
email: email,
|
|
20496
|
-
password: password
|
|
20497
|
-
};
|
|
20420
|
+
case 'auth':
|
|
20421
|
+
return this.logAuth(response.data.auth);
|
|
20498
20422
|
|
|
20499
|
-
|
|
20500
|
-
|
|
20423
|
+
default:
|
|
20424
|
+
return false;
|
|
20501
20425
|
}
|
|
20426
|
+
},
|
|
20427
|
+
logMobileMoneyActions: function logMobileMoneyActions(_ref) {
|
|
20428
|
+
var numberOfTokenRequests = _ref.numberOfTokenRequests,
|
|
20429
|
+
registrationToken = _ref.registrationToken;
|
|
20502
20430
|
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
|
|
20512
|
-
|
|
20513
|
-
|
|
20514
|
-
|
|
20515
|
-
|
|
20516
|
-
_this.directDebit.token = token;
|
|
20517
|
-
return response;
|
|
20518
|
-
}
|
|
20519
|
-
|
|
20520
|
-
throw Error('You do not have the privileges to perform this action');
|
|
20521
|
-
}
|
|
20522
|
-
|
|
20523
|
-
return response;
|
|
20431
|
+
if (numberOfTokenRequests) {
|
|
20432
|
+
this.logTokenRequest('mobile money', numberOfTokenRequests);
|
|
20433
|
+
} else if (registrationToken) {
|
|
20434
|
+
this.logTokenSubmitted('mobile money');
|
|
20435
|
+
} else {
|
|
20436
|
+
this.logAttempt('mobile money');
|
|
20437
|
+
}
|
|
20438
|
+
},
|
|
20439
|
+
logAPIResponseMessage: function logAPIResponseMessage(message) {
|
|
20440
|
+
this.log.history.push({
|
|
20441
|
+
type: 'action',
|
|
20442
|
+
message: message,
|
|
20443
|
+
time: this.getTimeSpent()
|
|
20524
20444
|
});
|
|
20445
|
+
return this.saveLog();
|
|
20525
20446
|
},
|
|
20526
|
-
|
|
20527
|
-
var
|
|
20447
|
+
logAttempt: function logAttempt(channel) {
|
|
20448
|
+
var message = 'Attempted to pay';
|
|
20528
20449
|
|
|
20529
|
-
if (
|
|
20530
|
-
|
|
20450
|
+
if (channel) {
|
|
20451
|
+
message += " with ".concat(channel);
|
|
20531
20452
|
}
|
|
20532
20453
|
|
|
20533
|
-
this.
|
|
20534
|
-
|
|
20535
|
-
|
|
20536
|
-
|
|
20537
|
-
|
|
20538
|
-
};
|
|
20539
|
-
return DirectDebitAPI.charge(params).then(function (response) {
|
|
20540
|
-
_this2.logAPIResponse(response, paymentMethod$1);
|
|
20541
|
-
|
|
20542
|
-
if (response.status) {
|
|
20543
|
-
_this2.directDebit.chargeResponse = response;
|
|
20544
|
-
}
|
|
20545
|
-
|
|
20546
|
-
return response;
|
|
20454
|
+
this.log.attempts += 1;
|
|
20455
|
+
this.log.history.push({
|
|
20456
|
+
type: 'action',
|
|
20457
|
+
message: message,
|
|
20458
|
+
time: this.getTimeSpent()
|
|
20547
20459
|
});
|
|
20460
|
+
return this.saveLog();
|
|
20548
20461
|
},
|
|
20549
|
-
|
|
20550
|
-
var
|
|
20551
|
-
|
|
20552
|
-
|
|
20553
|
-
|
|
20462
|
+
logTokenRequest: function logTokenRequest(channel) {
|
|
20463
|
+
var numberOfTokenRequests = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
20464
|
+
var message = numberOfTokenRequests === 0 ? 'Waiting for customer to submit OTP' : 'Customer requested to resend OTP';
|
|
20465
|
+
this.log.history.push({
|
|
20466
|
+
type: 'action',
|
|
20467
|
+
message: message,
|
|
20468
|
+
channel: channel,
|
|
20469
|
+
time: this.getTimeSpent()
|
|
20470
|
+
});
|
|
20471
|
+
return this.saveLog();
|
|
20472
|
+
},
|
|
20473
|
+
logTokenSubmitted: function logTokenSubmitted(channel) {
|
|
20474
|
+
var message = 'Customer submitted OTP';
|
|
20475
|
+
this.log.history.push({
|
|
20476
|
+
type: 'action',
|
|
20477
|
+
message: message,
|
|
20478
|
+
channel: channel,
|
|
20479
|
+
time: this.getTimeSpent()
|
|
20480
|
+
});
|
|
20481
|
+
return this.saveLog();
|
|
20482
|
+
},
|
|
20483
|
+
logTokenAuthenticationFailure: function logTokenAuthenticationFailure(error) {
|
|
20484
|
+
var message = error ? "Error: ".concat(error) : 'Error';
|
|
20485
|
+
this.log.errors += 1;
|
|
20486
|
+
this.log.history.push({
|
|
20487
|
+
type: 'error',
|
|
20488
|
+
message: message,
|
|
20489
|
+
authentication: 'failed',
|
|
20490
|
+
time: this.getTimeSpent()
|
|
20491
|
+
});
|
|
20492
|
+
return this.saveLog();
|
|
20493
|
+
},
|
|
20494
|
+
logError: function logError(error) {
|
|
20495
|
+
var message = 'Error';
|
|
20554
20496
|
|
|
20555
|
-
|
|
20556
|
-
|
|
20497
|
+
if (error) {
|
|
20498
|
+
message += ": ".concat(error);
|
|
20499
|
+
}
|
|
20557
20500
|
|
|
20558
|
-
|
|
20559
|
-
|
|
20560
|
-
|
|
20561
|
-
|
|
20501
|
+
this.log.errors += 1;
|
|
20502
|
+
this.log.history.push({
|
|
20503
|
+
type: 'error',
|
|
20504
|
+
message: message,
|
|
20505
|
+
time: this.getTimeSpent()
|
|
20506
|
+
});
|
|
20507
|
+
return this.saveLog();
|
|
20508
|
+
},
|
|
20509
|
+
logAuth: function logAuth(value) {
|
|
20510
|
+
this.log.authentication = value;
|
|
20511
|
+
this.log.history.push({
|
|
20512
|
+
type: 'auth',
|
|
20513
|
+
message: "Authentication Required: ".concat(value),
|
|
20514
|
+
time: this.getTimeSpent()
|
|
20515
|
+
});
|
|
20516
|
+
return this.saveLog();
|
|
20517
|
+
},
|
|
20518
|
+
logSuccess: function logSuccess(channel) {
|
|
20519
|
+
var message = 'Successfully paid';
|
|
20562
20520
|
|
|
20563
|
-
|
|
20564
|
-
|
|
20521
|
+
if (channel) {
|
|
20522
|
+
message += " with ".concat(channel);
|
|
20523
|
+
}
|
|
20565
20524
|
|
|
20566
|
-
|
|
20525
|
+
this.log.success = true;
|
|
20526
|
+
this.log.history.push({
|
|
20527
|
+
type: 'success',
|
|
20528
|
+
message: message,
|
|
20529
|
+
time: this.getTimeSpent()
|
|
20567
20530
|
});
|
|
20531
|
+
return this.saveLog();
|
|
20568
20532
|
},
|
|
20569
|
-
|
|
20570
|
-
var
|
|
20533
|
+
logPending: function logPending(channel) {
|
|
20534
|
+
var message = 'Payment in progress';
|
|
20571
20535
|
|
|
20572
|
-
|
|
20573
|
-
|
|
20574
|
-
|
|
20575
|
-
token: this.directDebit.token
|
|
20576
|
-
};
|
|
20577
|
-
return DirectDebitAPI.authenticate(params).then(function (response) {
|
|
20578
|
-
_this4.logAPIResponse(response, paymentMethod$1);
|
|
20536
|
+
if (channel) {
|
|
20537
|
+
message += " with ".concat(channel);
|
|
20538
|
+
}
|
|
20579
20539
|
|
|
20580
|
-
|
|
20540
|
+
this.log.history.push({
|
|
20541
|
+
type: 'pending',
|
|
20542
|
+
message: message,
|
|
20543
|
+
time: this.getTimeSpent()
|
|
20581
20544
|
});
|
|
20582
|
-
|
|
20583
|
-
}
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20588
|
-
|
|
20589
|
-
|
|
20590
|
-
|
|
20591
|
-
|
|
20592
|
-
|
|
20593
|
-
|
|
20594
|
-
|
|
20595
|
-
|
|
20596
|
-
|
|
20597
|
-
|
|
20598
|
-
|
|
20599
|
-
|
|
20600
|
-
|
|
20545
|
+
return this.saveLog();
|
|
20546
|
+
},
|
|
20547
|
+
logPageClose: function logPageClose() {
|
|
20548
|
+
this.log.history.push({
|
|
20549
|
+
type: 'close',
|
|
20550
|
+
message: 'Closed checkout',
|
|
20551
|
+
time: this.getTimeSpent()
|
|
20552
|
+
});
|
|
20553
|
+
return this.saveLog();
|
|
20554
|
+
},
|
|
20555
|
+
logTransactionCurrencySwitch: function logTransactionCurrencySwitch(_ref2) {
|
|
20556
|
+
var currency = _ref2.currency,
|
|
20557
|
+
_ref2$isUserAction = _ref2.isUserAction,
|
|
20558
|
+
isUserAction = _ref2$isUserAction === void 0 ? true : _ref2$isUserAction;
|
|
20559
|
+
var prefix = isUserAction ? 'User switched' : 'Switched';
|
|
20560
|
+
this.log.history.push({
|
|
20561
|
+
type: 'action',
|
|
20562
|
+
message: "".concat(prefix, " transaction currency to ").concat(currency),
|
|
20563
|
+
time: this.getTimeSpent()
|
|
20564
|
+
});
|
|
20565
|
+
return this.saveLog();
|
|
20566
|
+
},
|
|
20567
|
+
saveLog: function saveLog() {
|
|
20568
|
+
return AnalyticsAPI.saveLog(this.id, this.merchant.key, this.log);
|
|
20569
|
+
},
|
|
20570
|
+
saveIpAddress: function saveIpAddress() {
|
|
20571
|
+
return AnalyticsAPI.saveIp(this.id, this.merchant.key);
|
|
20572
|
+
},
|
|
20573
|
+
saveReferrer: function saveReferrer(referrer) {
|
|
20574
|
+
return AnalyticsAPI.saveReferrer(this.id, this.merchant.key, referrer);
|
|
20601
20575
|
}
|
|
20602
20576
|
};
|
|
20603
20577
|
|
|
@@ -20633,6 +20607,7 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20633
20607
|
this.rememberMeEnabled = data.is_remember_me_enabled;
|
|
20634
20608
|
this.card = {};
|
|
20635
20609
|
this.bankAccount = {};
|
|
20610
|
+
this.mobileMoney = {};
|
|
20636
20611
|
this.ussd = {};
|
|
20637
20612
|
this.bankTransfer = {};
|
|
20638
20613
|
this.qr = {};
|