@paystack/checkout-js 1.20.1 → 1.21.0-dev.1
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 +21087 -29
- package/es/checkout.js +276 -2
- package/lib/checkout.js +276 -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
|
|
|
@@ -20172,6 +20444,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20172
20444
|
this.subscription = data.subscription || null;
|
|
20173
20445
|
this.planDetails = data.plan_details || null;
|
|
20174
20446
|
this.exchangeRate = data.exchange_rate || null;
|
|
20447
|
+
this.savedCardsConfig = data.saved_cards || {};
|
|
20448
|
+
this.savedCardsToken = null;
|
|
20175
20449
|
/**
|
|
20176
20450
|
* We initialize parameters we send to the API as empty strings
|
|
20177
20451
|
* when we don't have them instead of null because the API expects
|
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
|
|
|
@@ -20176,6 +20448,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20176
20448
|
this.subscription = data.subscription || null;
|
|
20177
20449
|
this.planDetails = data.plan_details || null;
|
|
20178
20450
|
this.exchangeRate = data.exchange_rate || null;
|
|
20451
|
+
this.savedCardsConfig = data.saved_cards || {};
|
|
20452
|
+
this.savedCardsToken = null;
|
|
20179
20453
|
/**
|
|
20180
20454
|
* We initialize parameters we send to the API as empty strings
|
|
20181
20455
|
* when we don't have them instead of null because the API expects
|