@paystack/checkout-js 1.21.1 → 1.22.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkout.js +21144 -29
- package/es/checkout.js +297 -2
- package/lib/checkout.js +297 -2
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -6403,14 +6403,16 @@ var devConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
|
6403
6403
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6404
6404
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6405
6405
|
pusherKey: '1c7b262ee18455815893',
|
|
6406
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6406
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js',
|
|
6407
|
+
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6407
6408
|
});
|
|
6408
6409
|
var stagingConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6409
6410
|
checkoutUrl: 'https://checkout-studio.paystack.com/',
|
|
6410
6411
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6411
6412
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6412
6413
|
pusherKey: '1c7b262ee18455815893',
|
|
6413
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6414
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js',
|
|
6415
|
+
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6414
6416
|
});
|
|
6415
6417
|
var productionConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6416
6418
|
checkoutUrl: 'https://checkout.paystack.com/',
|
|
@@ -18664,6 +18666,208 @@ var CardAPI$1 = {
|
|
|
18664
18666
|
}).then(function (response) {
|
|
18665
18667
|
return ChargeResponses.parse(response.data);
|
|
18666
18668
|
});
|
|
18669
|
+
},
|
|
18670
|
+
sendSavedCardsOTP: function sendSavedCardsOTP(email) {
|
|
18671
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18672
|
+
var url, language, headers, _yield$axiosInstance$, data;
|
|
18673
|
+
|
|
18674
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18675
|
+
while (1) {
|
|
18676
|
+
switch (_context.prev = _context.next) {
|
|
18677
|
+
case 0:
|
|
18678
|
+
url = new URL("/authorize", configToUse.savedCardsApiUrl).toString();
|
|
18679
|
+
language = getLanguage();
|
|
18680
|
+
headers = _objectSpread2({}, language && {
|
|
18681
|
+
'Accept-Language': language
|
|
18682
|
+
});
|
|
18683
|
+
_context.next = 5;
|
|
18684
|
+
return axiosInstance.post(url, {
|
|
18685
|
+
email: email
|
|
18686
|
+
}, {
|
|
18687
|
+
headers: headers
|
|
18688
|
+
});
|
|
18689
|
+
|
|
18690
|
+
case 5:
|
|
18691
|
+
_yield$axiosInstance$ = _context.sent;
|
|
18692
|
+
data = _yield$axiosInstance$.data;
|
|
18693
|
+
return _context.abrupt("return", data);
|
|
18694
|
+
|
|
18695
|
+
case 8:
|
|
18696
|
+
case "end":
|
|
18697
|
+
return _context.stop();
|
|
18698
|
+
}
|
|
18699
|
+
}
|
|
18700
|
+
}, _callee);
|
|
18701
|
+
}))();
|
|
18702
|
+
},
|
|
18703
|
+
addUserToSavedCards: function addUserToSavedCards(_ref6) {
|
|
18704
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18705
|
+
var phone, email, url, language, headers, data, response;
|
|
18706
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18707
|
+
while (1) {
|
|
18708
|
+
switch (_context2.prev = _context2.next) {
|
|
18709
|
+
case 0:
|
|
18710
|
+
phone = _ref6.phone, email = _ref6.email;
|
|
18711
|
+
url = new URL('/user', configToUse.savedCardsApiUrl).toString();
|
|
18712
|
+
language = getLanguage();
|
|
18713
|
+
headers = _objectSpread2({}, language && {
|
|
18714
|
+
'Accept-Language': language
|
|
18715
|
+
});
|
|
18716
|
+
data = {
|
|
18717
|
+
phone: phone,
|
|
18718
|
+
email: email
|
|
18719
|
+
};
|
|
18720
|
+
_context2.next = 7;
|
|
18721
|
+
return axiosInstance.post(url, data, {
|
|
18722
|
+
headers: headers
|
|
18723
|
+
});
|
|
18724
|
+
|
|
18725
|
+
case 7:
|
|
18726
|
+
response = _context2.sent;
|
|
18727
|
+
return _context2.abrupt("return", response.data);
|
|
18728
|
+
|
|
18729
|
+
case 9:
|
|
18730
|
+
case "end":
|
|
18731
|
+
return _context2.stop();
|
|
18732
|
+
}
|
|
18733
|
+
}
|
|
18734
|
+
}, _callee2);
|
|
18735
|
+
}))();
|
|
18736
|
+
},
|
|
18737
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref7) {
|
|
18738
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18739
|
+
var code, transaction, url, language, headers, data, response;
|
|
18740
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18741
|
+
while (1) {
|
|
18742
|
+
switch (_context3.prev = _context3.next) {
|
|
18743
|
+
case 0:
|
|
18744
|
+
code = _ref7.code, transaction = _ref7.transaction;
|
|
18745
|
+
url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
|
|
18746
|
+
language = getLanguage();
|
|
18747
|
+
headers = _objectSpread2({}, language && {
|
|
18748
|
+
'Accept-Language': language
|
|
18749
|
+
});
|
|
18750
|
+
data = {
|
|
18751
|
+
code: code,
|
|
18752
|
+
transaction: transaction
|
|
18753
|
+
};
|
|
18754
|
+
_context3.next = 7;
|
|
18755
|
+
return axiosInstance.post(url, data, {
|
|
18756
|
+
headers: headers
|
|
18757
|
+
});
|
|
18758
|
+
|
|
18759
|
+
case 7:
|
|
18760
|
+
response = _context3.sent;
|
|
18761
|
+
return _context3.abrupt("return", response.data);
|
|
18762
|
+
|
|
18763
|
+
case 9:
|
|
18764
|
+
case "end":
|
|
18765
|
+
return _context3.stop();
|
|
18766
|
+
}
|
|
18767
|
+
}
|
|
18768
|
+
}, _callee3);
|
|
18769
|
+
}))();
|
|
18770
|
+
},
|
|
18771
|
+
getSavedCards: function getSavedCards(_ref8) {
|
|
18772
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18773
|
+
var token, url, language, headers, response;
|
|
18774
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18775
|
+
while (1) {
|
|
18776
|
+
switch (_context4.prev = _context4.next) {
|
|
18777
|
+
case 0:
|
|
18778
|
+
token = _ref8.token;
|
|
18779
|
+
url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
|
|
18780
|
+
language = getLanguage();
|
|
18781
|
+
headers = _objectSpread2({
|
|
18782
|
+
Authorization: "Bearer ".concat(token),
|
|
18783
|
+
'jwt-auth': true
|
|
18784
|
+
}, language && {
|
|
18785
|
+
'Accept-Language': language
|
|
18786
|
+
});
|
|
18787
|
+
_context4.next = 6;
|
|
18788
|
+
return axiosInstance.get(url, {
|
|
18789
|
+
headers: headers
|
|
18790
|
+
});
|
|
18791
|
+
|
|
18792
|
+
case 6:
|
|
18793
|
+
response = _context4.sent;
|
|
18794
|
+
return _context4.abrupt("return", response.data);
|
|
18795
|
+
|
|
18796
|
+
case 8:
|
|
18797
|
+
case "end":
|
|
18798
|
+
return _context4.stop();
|
|
18799
|
+
}
|
|
18800
|
+
}
|
|
18801
|
+
}, _callee4);
|
|
18802
|
+
}))();
|
|
18803
|
+
},
|
|
18804
|
+
deleteSavedCard: function deleteSavedCard(_ref9) {
|
|
18805
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
18806
|
+
var cardCode, token, url, language, headers, response;
|
|
18807
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
18808
|
+
while (1) {
|
|
18809
|
+
switch (_context5.prev = _context5.next) {
|
|
18810
|
+
case 0:
|
|
18811
|
+
cardCode = _ref9.cardCode, token = _ref9.token;
|
|
18812
|
+
url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
|
|
18813
|
+
language = getLanguage();
|
|
18814
|
+
headers = _objectSpread2({
|
|
18815
|
+
Authorization: "Bearer ".concat(token),
|
|
18816
|
+
'jwt-auth': true
|
|
18817
|
+
}, language && {
|
|
18818
|
+
'Accept-Language': language
|
|
18819
|
+
});
|
|
18820
|
+
_context5.next = 6;
|
|
18821
|
+
return axiosInstance.delete(url, {
|
|
18822
|
+
headers: headers
|
|
18823
|
+
});
|
|
18824
|
+
|
|
18825
|
+
case 6:
|
|
18826
|
+
response = _context5.sent;
|
|
18827
|
+
return _context5.abrupt("return", response.data);
|
|
18828
|
+
|
|
18829
|
+
case 8:
|
|
18830
|
+
case "end":
|
|
18831
|
+
return _context5.stop();
|
|
18832
|
+
}
|
|
18833
|
+
}
|
|
18834
|
+
}, _callee5);
|
|
18835
|
+
}))();
|
|
18836
|
+
},
|
|
18837
|
+
chargeSavedCard: function chargeSavedCard(_ref10) {
|
|
18838
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
18839
|
+
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data;
|
|
18840
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
18841
|
+
while (1) {
|
|
18842
|
+
switch (_context6.prev = _context6.next) {
|
|
18843
|
+
case 0:
|
|
18844
|
+
token = _ref10.token, device = _ref10.device, cardCode = _ref10.cardCode, transaction = _ref10.transaction, selectedCurrency = _ref10.selectedCurrency;
|
|
18845
|
+
url = new URL("/cards/".concat(cardCode, "/charge"), configToUse.savedCardsApiUrl).toString();
|
|
18846
|
+
language = getLanguage();
|
|
18847
|
+
headers = _objectSpread2({
|
|
18848
|
+
Authorization: "Bearer ".concat(token),
|
|
18849
|
+
'jwt-auth': true
|
|
18850
|
+
}, language && {
|
|
18851
|
+
'Accept-Language': language
|
|
18852
|
+
});
|
|
18853
|
+
data = {
|
|
18854
|
+
device: device,
|
|
18855
|
+
transaction: transaction,
|
|
18856
|
+
selected_currency: selectedCurrency
|
|
18857
|
+
};
|
|
18858
|
+
return _context6.abrupt("return", axiosInstance.post(url, data, {
|
|
18859
|
+
headers: headers
|
|
18860
|
+
}).then(function (response) {
|
|
18861
|
+
return ChargeResponses.parse(response.data);
|
|
18862
|
+
}));
|
|
18863
|
+
|
|
18864
|
+
case 6:
|
|
18865
|
+
case "end":
|
|
18866
|
+
return _context6.stop();
|
|
18867
|
+
}
|
|
18868
|
+
}
|
|
18869
|
+
}, _callee6);
|
|
18870
|
+
}))();
|
|
18667
18871
|
}
|
|
18668
18872
|
};
|
|
18669
18873
|
|
|
@@ -18844,6 +19048,74 @@ var CardCharge = {
|
|
|
18844
19048
|
paymentMethod: paymentMethod$4
|
|
18845
19049
|
};
|
|
18846
19050
|
return this.listenForCharge(listenerOptions, callback);
|
|
19051
|
+
},
|
|
19052
|
+
sendSavedCardsOTP: function sendSavedCardsOTP() {
|
|
19053
|
+
return CardAPI$1.sendSavedCardsOTP(this.email);
|
|
19054
|
+
},
|
|
19055
|
+
addUserToSavedCards: function addUserToSavedCards(_ref4) {
|
|
19056
|
+
var phone = _ref4.phone;
|
|
19057
|
+
return CardAPI$1.addUserToSavedCards({
|
|
19058
|
+
phone: phone,
|
|
19059
|
+
email: this.email
|
|
19060
|
+
});
|
|
19061
|
+
},
|
|
19062
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
|
|
19063
|
+
var _this9 = this;
|
|
19064
|
+
|
|
19065
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
19066
|
+
var code, payload, response;
|
|
19067
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19068
|
+
while (1) {
|
|
19069
|
+
switch (_context.prev = _context.next) {
|
|
19070
|
+
case 0:
|
|
19071
|
+
code = _ref5.code;
|
|
19072
|
+
payload = {
|
|
19073
|
+
code: code,
|
|
19074
|
+
transaction: _this9.id
|
|
19075
|
+
};
|
|
19076
|
+
_context.prev = 2;
|
|
19077
|
+
_context.next = 5;
|
|
19078
|
+
return CardAPI$1.verifySavedCardsOtp(payload);
|
|
19079
|
+
|
|
19080
|
+
case 5:
|
|
19081
|
+
response = _context.sent;
|
|
19082
|
+
_this9.savedCardsToken = response.data.token;
|
|
19083
|
+
return _context.abrupt("return", response);
|
|
19084
|
+
|
|
19085
|
+
case 10:
|
|
19086
|
+
_context.prev = 10;
|
|
19087
|
+
_context.t0 = _context["catch"](2);
|
|
19088
|
+
_this9.savedCardsToken = null;
|
|
19089
|
+
throw _context.t0;
|
|
19090
|
+
|
|
19091
|
+
case 14:
|
|
19092
|
+
case "end":
|
|
19093
|
+
return _context.stop();
|
|
19094
|
+
}
|
|
19095
|
+
}
|
|
19096
|
+
}, _callee, null, [[2, 10]]);
|
|
19097
|
+
}))();
|
|
19098
|
+
},
|
|
19099
|
+
getSavedCards: function getSavedCards() {
|
|
19100
|
+
return CardAPI$1.getSavedCards({
|
|
19101
|
+
token: this.savedCardsToken
|
|
19102
|
+
});
|
|
19103
|
+
},
|
|
19104
|
+
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
19105
|
+
return CardAPI$1.deleteSavedCard({
|
|
19106
|
+
cardCode: cardCode,
|
|
19107
|
+
token: this.savedCardsToken
|
|
19108
|
+
});
|
|
19109
|
+
},
|
|
19110
|
+
chargeSavedCard: function chargeSavedCard(_ref6) {
|
|
19111
|
+
var cardCode = _ref6.cardCode;
|
|
19112
|
+
return CardAPI$1.chargeSavedCard({
|
|
19113
|
+
cardCode: cardCode,
|
|
19114
|
+
transaction: this.id,
|
|
19115
|
+
token: this.savedCardsToken,
|
|
19116
|
+
device: this.deviceFingerprint,
|
|
19117
|
+
selectedCurrency: this.currency
|
|
19118
|
+
});
|
|
18847
19119
|
}
|
|
18848
19120
|
};
|
|
18849
19121
|
|
|
@@ -20184,6 +20456,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20184
20456
|
this.subscription = data.subscription || null;
|
|
20185
20457
|
this.planDetails = data.plan_details || null;
|
|
20186
20458
|
this.exchangeRate = data.exchange_rate || null;
|
|
20459
|
+
this.savedCardsConfig = data.saved_cards || {};
|
|
20460
|
+
this.savedCardsToken = null;
|
|
20187
20461
|
/**
|
|
20188
20462
|
* We initialize parameters we send to the API as empty strings
|
|
20189
20463
|
* when we don't have them instead of null because the API expects
|
|
@@ -20454,6 +20728,21 @@ var ToolkitAPI = {
|
|
|
20454
20728
|
resolvedCardBins[bin] = data;
|
|
20455
20729
|
return data;
|
|
20456
20730
|
});
|
|
20731
|
+
},
|
|
20732
|
+
resolveIPAddress: function resolveIPAddress(ipAddress) {
|
|
20733
|
+
var url = new URL("decision/resolve_ip/".concat(ipAddress), configToUse.paystackApiUrl).toString();
|
|
20734
|
+
var language = getLanguage();
|
|
20735
|
+
|
|
20736
|
+
var headers = _objectSpread2({}, language && {
|
|
20737
|
+
'Accept-Language': language
|
|
20738
|
+
});
|
|
20739
|
+
|
|
20740
|
+
return axiosInstance.get(url, {
|
|
20741
|
+
headers: headers
|
|
20742
|
+
}).then(function (_ref2) {
|
|
20743
|
+
var data = _ref2.data;
|
|
20744
|
+
return data;
|
|
20745
|
+
});
|
|
20457
20746
|
}
|
|
20458
20747
|
};
|
|
20459
20748
|
|
|
@@ -20519,6 +20808,11 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20519
20808
|
value: function resolveCardBin(bin) {
|
|
20520
20809
|
return ToolkitAPI.resolveCardBin(bin);
|
|
20521
20810
|
}
|
|
20811
|
+
}, {
|
|
20812
|
+
key: "resolveIPAddress",
|
|
20813
|
+
value: function resolveIPAddress(ipAddress) {
|
|
20814
|
+
return ToolkitAPI.resolveIPAddress(ipAddress);
|
|
20815
|
+
}
|
|
20522
20816
|
}]);
|
|
20523
20817
|
|
|
20524
20818
|
return Toolkit;
|
|
@@ -20756,6 +21050,7 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20756
21050
|
this.customer = data.customer;
|
|
20757
21051
|
this.channels = data.channels || ['card'];
|
|
20758
21052
|
this.isListening = false;
|
|
21053
|
+
this.isTest = data.domain === 'test';
|
|
20759
21054
|
this.merchant = {
|
|
20760
21055
|
id: data.merchant_id,
|
|
20761
21056
|
logo: data.merchant_logo,
|
package/lib/checkout.js
CHANGED
|
@@ -6407,14 +6407,16 @@ var devConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
|
6407
6407
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6408
6408
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6409
6409
|
pusherKey: '1c7b262ee18455815893',
|
|
6410
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6410
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js',
|
|
6411
|
+
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6411
6412
|
});
|
|
6412
6413
|
var stagingConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6413
6414
|
checkoutUrl: 'https://checkout-studio.paystack.com/',
|
|
6414
6415
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6415
6416
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6416
6417
|
pusherKey: '1c7b262ee18455815893',
|
|
6417
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6418
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js',
|
|
6419
|
+
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6418
6420
|
});
|
|
6419
6421
|
var productionConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6420
6422
|
checkoutUrl: 'https://checkout.paystack.com/',
|
|
@@ -18668,6 +18670,208 @@ var CardAPI$1 = {
|
|
|
18668
18670
|
}).then(function (response) {
|
|
18669
18671
|
return ChargeResponses.parse(response.data);
|
|
18670
18672
|
});
|
|
18673
|
+
},
|
|
18674
|
+
sendSavedCardsOTP: function sendSavedCardsOTP(email) {
|
|
18675
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18676
|
+
var url, language, headers, _yield$axiosInstance$, data;
|
|
18677
|
+
|
|
18678
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18679
|
+
while (1) {
|
|
18680
|
+
switch (_context.prev = _context.next) {
|
|
18681
|
+
case 0:
|
|
18682
|
+
url = new URL("/authorize", configToUse.savedCardsApiUrl).toString();
|
|
18683
|
+
language = getLanguage();
|
|
18684
|
+
headers = _objectSpread2({}, language && {
|
|
18685
|
+
'Accept-Language': language
|
|
18686
|
+
});
|
|
18687
|
+
_context.next = 5;
|
|
18688
|
+
return axiosInstance.post(url, {
|
|
18689
|
+
email: email
|
|
18690
|
+
}, {
|
|
18691
|
+
headers: headers
|
|
18692
|
+
});
|
|
18693
|
+
|
|
18694
|
+
case 5:
|
|
18695
|
+
_yield$axiosInstance$ = _context.sent;
|
|
18696
|
+
data = _yield$axiosInstance$.data;
|
|
18697
|
+
return _context.abrupt("return", data);
|
|
18698
|
+
|
|
18699
|
+
case 8:
|
|
18700
|
+
case "end":
|
|
18701
|
+
return _context.stop();
|
|
18702
|
+
}
|
|
18703
|
+
}
|
|
18704
|
+
}, _callee);
|
|
18705
|
+
}))();
|
|
18706
|
+
},
|
|
18707
|
+
addUserToSavedCards: function addUserToSavedCards(_ref6) {
|
|
18708
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18709
|
+
var phone, email, url, language, headers, data, response;
|
|
18710
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18711
|
+
while (1) {
|
|
18712
|
+
switch (_context2.prev = _context2.next) {
|
|
18713
|
+
case 0:
|
|
18714
|
+
phone = _ref6.phone, email = _ref6.email;
|
|
18715
|
+
url = new URL('/user', configToUse.savedCardsApiUrl).toString();
|
|
18716
|
+
language = getLanguage();
|
|
18717
|
+
headers = _objectSpread2({}, language && {
|
|
18718
|
+
'Accept-Language': language
|
|
18719
|
+
});
|
|
18720
|
+
data = {
|
|
18721
|
+
phone: phone,
|
|
18722
|
+
email: email
|
|
18723
|
+
};
|
|
18724
|
+
_context2.next = 7;
|
|
18725
|
+
return axiosInstance.post(url, data, {
|
|
18726
|
+
headers: headers
|
|
18727
|
+
});
|
|
18728
|
+
|
|
18729
|
+
case 7:
|
|
18730
|
+
response = _context2.sent;
|
|
18731
|
+
return _context2.abrupt("return", response.data);
|
|
18732
|
+
|
|
18733
|
+
case 9:
|
|
18734
|
+
case "end":
|
|
18735
|
+
return _context2.stop();
|
|
18736
|
+
}
|
|
18737
|
+
}
|
|
18738
|
+
}, _callee2);
|
|
18739
|
+
}))();
|
|
18740
|
+
},
|
|
18741
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref7) {
|
|
18742
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18743
|
+
var code, transaction, url, language, headers, data, response;
|
|
18744
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18745
|
+
while (1) {
|
|
18746
|
+
switch (_context3.prev = _context3.next) {
|
|
18747
|
+
case 0:
|
|
18748
|
+
code = _ref7.code, transaction = _ref7.transaction;
|
|
18749
|
+
url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
|
|
18750
|
+
language = getLanguage();
|
|
18751
|
+
headers = _objectSpread2({}, language && {
|
|
18752
|
+
'Accept-Language': language
|
|
18753
|
+
});
|
|
18754
|
+
data = {
|
|
18755
|
+
code: code,
|
|
18756
|
+
transaction: transaction
|
|
18757
|
+
};
|
|
18758
|
+
_context3.next = 7;
|
|
18759
|
+
return axiosInstance.post(url, data, {
|
|
18760
|
+
headers: headers
|
|
18761
|
+
});
|
|
18762
|
+
|
|
18763
|
+
case 7:
|
|
18764
|
+
response = _context3.sent;
|
|
18765
|
+
return _context3.abrupt("return", response.data);
|
|
18766
|
+
|
|
18767
|
+
case 9:
|
|
18768
|
+
case "end":
|
|
18769
|
+
return _context3.stop();
|
|
18770
|
+
}
|
|
18771
|
+
}
|
|
18772
|
+
}, _callee3);
|
|
18773
|
+
}))();
|
|
18774
|
+
},
|
|
18775
|
+
getSavedCards: function getSavedCards(_ref8) {
|
|
18776
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18777
|
+
var token, url, language, headers, response;
|
|
18778
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18779
|
+
while (1) {
|
|
18780
|
+
switch (_context4.prev = _context4.next) {
|
|
18781
|
+
case 0:
|
|
18782
|
+
token = _ref8.token;
|
|
18783
|
+
url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
|
|
18784
|
+
language = getLanguage();
|
|
18785
|
+
headers = _objectSpread2({
|
|
18786
|
+
Authorization: "Bearer ".concat(token),
|
|
18787
|
+
'jwt-auth': true
|
|
18788
|
+
}, language && {
|
|
18789
|
+
'Accept-Language': language
|
|
18790
|
+
});
|
|
18791
|
+
_context4.next = 6;
|
|
18792
|
+
return axiosInstance.get(url, {
|
|
18793
|
+
headers: headers
|
|
18794
|
+
});
|
|
18795
|
+
|
|
18796
|
+
case 6:
|
|
18797
|
+
response = _context4.sent;
|
|
18798
|
+
return _context4.abrupt("return", response.data);
|
|
18799
|
+
|
|
18800
|
+
case 8:
|
|
18801
|
+
case "end":
|
|
18802
|
+
return _context4.stop();
|
|
18803
|
+
}
|
|
18804
|
+
}
|
|
18805
|
+
}, _callee4);
|
|
18806
|
+
}))();
|
|
18807
|
+
},
|
|
18808
|
+
deleteSavedCard: function deleteSavedCard(_ref9) {
|
|
18809
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
18810
|
+
var cardCode, token, url, language, headers, response;
|
|
18811
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
18812
|
+
while (1) {
|
|
18813
|
+
switch (_context5.prev = _context5.next) {
|
|
18814
|
+
case 0:
|
|
18815
|
+
cardCode = _ref9.cardCode, token = _ref9.token;
|
|
18816
|
+
url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
|
|
18817
|
+
language = getLanguage();
|
|
18818
|
+
headers = _objectSpread2({
|
|
18819
|
+
Authorization: "Bearer ".concat(token),
|
|
18820
|
+
'jwt-auth': true
|
|
18821
|
+
}, language && {
|
|
18822
|
+
'Accept-Language': language
|
|
18823
|
+
});
|
|
18824
|
+
_context5.next = 6;
|
|
18825
|
+
return axiosInstance.delete(url, {
|
|
18826
|
+
headers: headers
|
|
18827
|
+
});
|
|
18828
|
+
|
|
18829
|
+
case 6:
|
|
18830
|
+
response = _context5.sent;
|
|
18831
|
+
return _context5.abrupt("return", response.data);
|
|
18832
|
+
|
|
18833
|
+
case 8:
|
|
18834
|
+
case "end":
|
|
18835
|
+
return _context5.stop();
|
|
18836
|
+
}
|
|
18837
|
+
}
|
|
18838
|
+
}, _callee5);
|
|
18839
|
+
}))();
|
|
18840
|
+
},
|
|
18841
|
+
chargeSavedCard: function chargeSavedCard(_ref10) {
|
|
18842
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
18843
|
+
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data;
|
|
18844
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
18845
|
+
while (1) {
|
|
18846
|
+
switch (_context6.prev = _context6.next) {
|
|
18847
|
+
case 0:
|
|
18848
|
+
token = _ref10.token, device = _ref10.device, cardCode = _ref10.cardCode, transaction = _ref10.transaction, selectedCurrency = _ref10.selectedCurrency;
|
|
18849
|
+
url = new URL("/cards/".concat(cardCode, "/charge"), configToUse.savedCardsApiUrl).toString();
|
|
18850
|
+
language = getLanguage();
|
|
18851
|
+
headers = _objectSpread2({
|
|
18852
|
+
Authorization: "Bearer ".concat(token),
|
|
18853
|
+
'jwt-auth': true
|
|
18854
|
+
}, language && {
|
|
18855
|
+
'Accept-Language': language
|
|
18856
|
+
});
|
|
18857
|
+
data = {
|
|
18858
|
+
device: device,
|
|
18859
|
+
transaction: transaction,
|
|
18860
|
+
selected_currency: selectedCurrency
|
|
18861
|
+
};
|
|
18862
|
+
return _context6.abrupt("return", axiosInstance.post(url, data, {
|
|
18863
|
+
headers: headers
|
|
18864
|
+
}).then(function (response) {
|
|
18865
|
+
return ChargeResponses.parse(response.data);
|
|
18866
|
+
}));
|
|
18867
|
+
|
|
18868
|
+
case 6:
|
|
18869
|
+
case "end":
|
|
18870
|
+
return _context6.stop();
|
|
18871
|
+
}
|
|
18872
|
+
}
|
|
18873
|
+
}, _callee6);
|
|
18874
|
+
}))();
|
|
18671
18875
|
}
|
|
18672
18876
|
};
|
|
18673
18877
|
|
|
@@ -18848,6 +19052,74 @@ var CardCharge = {
|
|
|
18848
19052
|
paymentMethod: paymentMethod$4
|
|
18849
19053
|
};
|
|
18850
19054
|
return this.listenForCharge(listenerOptions, callback);
|
|
19055
|
+
},
|
|
19056
|
+
sendSavedCardsOTP: function sendSavedCardsOTP() {
|
|
19057
|
+
return CardAPI$1.sendSavedCardsOTP(this.email);
|
|
19058
|
+
},
|
|
19059
|
+
addUserToSavedCards: function addUserToSavedCards(_ref4) {
|
|
19060
|
+
var phone = _ref4.phone;
|
|
19061
|
+
return CardAPI$1.addUserToSavedCards({
|
|
19062
|
+
phone: phone,
|
|
19063
|
+
email: this.email
|
|
19064
|
+
});
|
|
19065
|
+
},
|
|
19066
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
|
|
19067
|
+
var _this9 = this;
|
|
19068
|
+
|
|
19069
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
19070
|
+
var code, payload, response;
|
|
19071
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19072
|
+
while (1) {
|
|
19073
|
+
switch (_context.prev = _context.next) {
|
|
19074
|
+
case 0:
|
|
19075
|
+
code = _ref5.code;
|
|
19076
|
+
payload = {
|
|
19077
|
+
code: code,
|
|
19078
|
+
transaction: _this9.id
|
|
19079
|
+
};
|
|
19080
|
+
_context.prev = 2;
|
|
19081
|
+
_context.next = 5;
|
|
19082
|
+
return CardAPI$1.verifySavedCardsOtp(payload);
|
|
19083
|
+
|
|
19084
|
+
case 5:
|
|
19085
|
+
response = _context.sent;
|
|
19086
|
+
_this9.savedCardsToken = response.data.token;
|
|
19087
|
+
return _context.abrupt("return", response);
|
|
19088
|
+
|
|
19089
|
+
case 10:
|
|
19090
|
+
_context.prev = 10;
|
|
19091
|
+
_context.t0 = _context["catch"](2);
|
|
19092
|
+
_this9.savedCardsToken = null;
|
|
19093
|
+
throw _context.t0;
|
|
19094
|
+
|
|
19095
|
+
case 14:
|
|
19096
|
+
case "end":
|
|
19097
|
+
return _context.stop();
|
|
19098
|
+
}
|
|
19099
|
+
}
|
|
19100
|
+
}, _callee, null, [[2, 10]]);
|
|
19101
|
+
}))();
|
|
19102
|
+
},
|
|
19103
|
+
getSavedCards: function getSavedCards() {
|
|
19104
|
+
return CardAPI$1.getSavedCards({
|
|
19105
|
+
token: this.savedCardsToken
|
|
19106
|
+
});
|
|
19107
|
+
},
|
|
19108
|
+
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
19109
|
+
return CardAPI$1.deleteSavedCard({
|
|
19110
|
+
cardCode: cardCode,
|
|
19111
|
+
token: this.savedCardsToken
|
|
19112
|
+
});
|
|
19113
|
+
},
|
|
19114
|
+
chargeSavedCard: function chargeSavedCard(_ref6) {
|
|
19115
|
+
var cardCode = _ref6.cardCode;
|
|
19116
|
+
return CardAPI$1.chargeSavedCard({
|
|
19117
|
+
cardCode: cardCode,
|
|
19118
|
+
transaction: this.id,
|
|
19119
|
+
token: this.savedCardsToken,
|
|
19120
|
+
device: this.deviceFingerprint,
|
|
19121
|
+
selectedCurrency: this.currency
|
|
19122
|
+
});
|
|
18851
19123
|
}
|
|
18852
19124
|
};
|
|
18853
19125
|
|
|
@@ -20188,6 +20460,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20188
20460
|
this.subscription = data.subscription || null;
|
|
20189
20461
|
this.planDetails = data.plan_details || null;
|
|
20190
20462
|
this.exchangeRate = data.exchange_rate || null;
|
|
20463
|
+
this.savedCardsConfig = data.saved_cards || {};
|
|
20464
|
+
this.savedCardsToken = null;
|
|
20191
20465
|
/**
|
|
20192
20466
|
* We initialize parameters we send to the API as empty strings
|
|
20193
20467
|
* when we don't have them instead of null because the API expects
|
|
@@ -20458,6 +20732,21 @@ var ToolkitAPI = {
|
|
|
20458
20732
|
resolvedCardBins[bin] = data;
|
|
20459
20733
|
return data;
|
|
20460
20734
|
});
|
|
20735
|
+
},
|
|
20736
|
+
resolveIPAddress: function resolveIPAddress(ipAddress) {
|
|
20737
|
+
var url = new URL("decision/resolve_ip/".concat(ipAddress), configToUse.paystackApiUrl).toString();
|
|
20738
|
+
var language = getLanguage();
|
|
20739
|
+
|
|
20740
|
+
var headers = _objectSpread2({}, language && {
|
|
20741
|
+
'Accept-Language': language
|
|
20742
|
+
});
|
|
20743
|
+
|
|
20744
|
+
return axiosInstance.get(url, {
|
|
20745
|
+
headers: headers
|
|
20746
|
+
}).then(function (_ref2) {
|
|
20747
|
+
var data = _ref2.data;
|
|
20748
|
+
return data;
|
|
20749
|
+
});
|
|
20461
20750
|
}
|
|
20462
20751
|
};
|
|
20463
20752
|
|
|
@@ -20523,6 +20812,11 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20523
20812
|
value: function resolveCardBin(bin) {
|
|
20524
20813
|
return ToolkitAPI.resolveCardBin(bin);
|
|
20525
20814
|
}
|
|
20815
|
+
}, {
|
|
20816
|
+
key: "resolveIPAddress",
|
|
20817
|
+
value: function resolveIPAddress(ipAddress) {
|
|
20818
|
+
return ToolkitAPI.resolveIPAddress(ipAddress);
|
|
20819
|
+
}
|
|
20526
20820
|
}]);
|
|
20527
20821
|
|
|
20528
20822
|
return Toolkit;
|
|
@@ -20760,6 +21054,7 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20760
21054
|
this.customer = data.customer;
|
|
20761
21055
|
this.channels = data.channels || ['card'];
|
|
20762
21056
|
this.isListening = false;
|
|
21057
|
+
this.isTest = data.domain === 'test';
|
|
20763
21058
|
this.merchant = {
|
|
20764
21059
|
id: data.merchant_id,
|
|
20765
21060
|
logo: data.merchant_logo,
|