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