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