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