@paystack/checkout-js 1.23.0 → 1.23.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 +3 -3
- package/es/checkout.js +101 -97
- package/lib/checkout.js +101 -97
- package/package.json +1 -1
package/lib/checkout.js
CHANGED
|
@@ -18669,30 +18669,34 @@ var CardAPI$1 = {
|
|
|
18669
18669
|
return ChargeResponses.parse(response.data);
|
|
18670
18670
|
});
|
|
18671
18671
|
},
|
|
18672
|
-
sendSavedCardsOTP: function sendSavedCardsOTP(
|
|
18672
|
+
sendSavedCardsOTP: function sendSavedCardsOTP(_ref6) {
|
|
18673
18673
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18674
|
-
var url, language, headers, response;
|
|
18674
|
+
var transaction, phone, url, language, headers, data, response;
|
|
18675
18675
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18676
18676
|
while (1) {
|
|
18677
18677
|
switch (_context.prev = _context.next) {
|
|
18678
18678
|
case 0:
|
|
18679
|
+
transaction = _ref6.transaction, phone = _ref6.phone;
|
|
18679
18680
|
url = new URL('/saved_cards/authorize', configToUse.paystackApiUrl).toString();
|
|
18680
18681
|
language = getLanguage();
|
|
18681
18682
|
headers = _objectSpread2({}, language && {
|
|
18682
18683
|
'Accept-Language': language
|
|
18683
18684
|
});
|
|
18684
|
-
|
|
18685
|
-
|
|
18685
|
+
data = _objectSpread2(_objectSpread2({}, phone && {
|
|
18686
|
+
phone: phone
|
|
18687
|
+
}), {}, {
|
|
18686
18688
|
transaction: transaction
|
|
18687
|
-
}
|
|
18689
|
+
});
|
|
18690
|
+
_context.next = 7;
|
|
18691
|
+
return axiosInstance.post(url, data, {
|
|
18688
18692
|
headers: headers
|
|
18689
18693
|
});
|
|
18690
18694
|
|
|
18691
|
-
case
|
|
18695
|
+
case 7:
|
|
18692
18696
|
response = _context.sent;
|
|
18693
18697
|
return _context.abrupt("return", response.data);
|
|
18694
18698
|
|
|
18695
|
-
case
|
|
18699
|
+
case 9:
|
|
18696
18700
|
case "end":
|
|
18697
18701
|
return _context.stop();
|
|
18698
18702
|
}
|
|
@@ -18700,21 +18704,23 @@ var CardAPI$1 = {
|
|
|
18700
18704
|
}, _callee);
|
|
18701
18705
|
}))();
|
|
18702
18706
|
},
|
|
18703
|
-
|
|
18707
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref7) {
|
|
18704
18708
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18705
|
-
var
|
|
18709
|
+
var code, transaction, token, url, language, headers, data, response;
|
|
18706
18710
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18707
18711
|
while (1) {
|
|
18708
18712
|
switch (_context2.prev = _context2.next) {
|
|
18709
18713
|
case 0:
|
|
18710
|
-
|
|
18711
|
-
url = new URL('/saved_cards/
|
|
18714
|
+
code = _ref7.code, transaction = _ref7.transaction, token = _ref7.token;
|
|
18715
|
+
url = new URL('/saved_cards/authorize/verify', configToUse.paystackApiUrl).toString();
|
|
18712
18716
|
language = getLanguage();
|
|
18713
|
-
headers = _objectSpread2({
|
|
18717
|
+
headers = _objectSpread2({
|
|
18718
|
+
Authorization: "Bearer ".concat(token)
|
|
18719
|
+
}, language && {
|
|
18714
18720
|
'Accept-Language': language
|
|
18715
18721
|
});
|
|
18716
18722
|
data = {
|
|
18717
|
-
|
|
18723
|
+
code: code,
|
|
18718
18724
|
transaction: transaction
|
|
18719
18725
|
};
|
|
18720
18726
|
_context2.next = 7;
|
|
@@ -18734,46 +18740,12 @@ var CardAPI$1 = {
|
|
|
18734
18740
|
}, _callee2);
|
|
18735
18741
|
}))();
|
|
18736
18742
|
},
|
|
18737
|
-
|
|
18743
|
+
getSavedCards: function getSavedCards(_ref8) {
|
|
18738
18744
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18739
|
-
var
|
|
18745
|
+
var token, url, language, headers, response;
|
|
18740
18746
|
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18741
18747
|
while (1) {
|
|
18742
18748
|
switch (_context3.prev = _context3.next) {
|
|
18743
|
-
case 0:
|
|
18744
|
-
code = _ref7.code, transaction = _ref7.transaction;
|
|
18745
|
-
url = new URL('/saved_cards/authorize/verify', configToUse.paystackApiUrl).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
18749
|
case 0:
|
|
18778
18750
|
token = _ref8.token;
|
|
18779
18751
|
url = new URL('/saved_cards/cards', configToUse.paystackApiUrl).toString();
|
|
@@ -18784,29 +18756,29 @@ var CardAPI$1 = {
|
|
|
18784
18756
|
}, language && {
|
|
18785
18757
|
'Accept-Language': language
|
|
18786
18758
|
});
|
|
18787
|
-
|
|
18759
|
+
_context3.next = 6;
|
|
18788
18760
|
return axiosInstance.get(url, {
|
|
18789
18761
|
headers: headers
|
|
18790
18762
|
});
|
|
18791
18763
|
|
|
18792
18764
|
case 6:
|
|
18793
|
-
response =
|
|
18794
|
-
return
|
|
18765
|
+
response = _context3.sent;
|
|
18766
|
+
return _context3.abrupt("return", response.data);
|
|
18795
18767
|
|
|
18796
18768
|
case 8:
|
|
18797
18769
|
case "end":
|
|
18798
|
-
return
|
|
18770
|
+
return _context3.stop();
|
|
18799
18771
|
}
|
|
18800
18772
|
}
|
|
18801
|
-
},
|
|
18773
|
+
}, _callee3);
|
|
18802
18774
|
}))();
|
|
18803
18775
|
},
|
|
18804
18776
|
deleteSavedCard: function deleteSavedCard(_ref9) {
|
|
18805
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
18777
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18806
18778
|
var cardCode, token, url, language, headers, response;
|
|
18807
|
-
return regeneratorRuntime.wrap(function
|
|
18779
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18808
18780
|
while (1) {
|
|
18809
|
-
switch (
|
|
18781
|
+
switch (_context4.prev = _context4.next) {
|
|
18810
18782
|
case 0:
|
|
18811
18783
|
cardCode = _ref9.cardCode, token = _ref9.token;
|
|
18812
18784
|
url = new URL("/saved_cards/cards/".concat(cardCode), configToUse.paystackApiUrl).toString();
|
|
@@ -18817,29 +18789,29 @@ var CardAPI$1 = {
|
|
|
18817
18789
|
}, language && {
|
|
18818
18790
|
'Accept-Language': language
|
|
18819
18791
|
});
|
|
18820
|
-
|
|
18792
|
+
_context4.next = 6;
|
|
18821
18793
|
return axiosInstance.delete(url, {
|
|
18822
18794
|
headers: headers
|
|
18823
18795
|
});
|
|
18824
18796
|
|
|
18825
18797
|
case 6:
|
|
18826
|
-
response =
|
|
18827
|
-
return
|
|
18798
|
+
response = _context4.sent;
|
|
18799
|
+
return _context4.abrupt("return", response.data);
|
|
18828
18800
|
|
|
18829
18801
|
case 8:
|
|
18830
18802
|
case "end":
|
|
18831
|
-
return
|
|
18803
|
+
return _context4.stop();
|
|
18832
18804
|
}
|
|
18833
18805
|
}
|
|
18834
|
-
},
|
|
18806
|
+
}, _callee4);
|
|
18835
18807
|
}))();
|
|
18836
18808
|
},
|
|
18837
18809
|
chargeSavedCard: function chargeSavedCard(_ref10) {
|
|
18838
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
18810
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
18839
18811
|
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data, response;
|
|
18840
|
-
return regeneratorRuntime.wrap(function
|
|
18812
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
18841
18813
|
while (1) {
|
|
18842
|
-
switch (
|
|
18814
|
+
switch (_context5.prev = _context5.next) {
|
|
18843
18815
|
case 0:
|
|
18844
18816
|
token = _ref10.token, device = _ref10.device, cardCode = _ref10.cardCode, transaction = _ref10.transaction, selectedCurrency = _ref10.selectedCurrency;
|
|
18845
18817
|
url = new URL("/saved_cards/cards/".concat(cardCode, "/charge"), configToUse.paystackApiUrl).toString();
|
|
@@ -18855,21 +18827,21 @@ var CardAPI$1 = {
|
|
|
18855
18827
|
transaction: transaction,
|
|
18856
18828
|
selected_currency: selectedCurrency
|
|
18857
18829
|
};
|
|
18858
|
-
|
|
18830
|
+
_context5.next = 7;
|
|
18859
18831
|
return axiosInstance.post(url, data, {
|
|
18860
18832
|
headers: headers
|
|
18861
18833
|
});
|
|
18862
18834
|
|
|
18863
18835
|
case 7:
|
|
18864
|
-
response =
|
|
18865
|
-
return
|
|
18836
|
+
response = _context5.sent;
|
|
18837
|
+
return _context5.abrupt("return", ChargeResponses.parse(response.data));
|
|
18866
18838
|
|
|
18867
18839
|
case 9:
|
|
18868
18840
|
case "end":
|
|
18869
|
-
return
|
|
18841
|
+
return _context5.stop();
|
|
18870
18842
|
}
|
|
18871
18843
|
}
|
|
18872
|
-
},
|
|
18844
|
+
}, _callee5);
|
|
18873
18845
|
}))();
|
|
18874
18846
|
}
|
|
18875
18847
|
};
|
|
@@ -19052,51 +19024,77 @@ var CardCharge = {
|
|
|
19052
19024
|
};
|
|
19053
19025
|
return this.listenForCharge(listenerOptions, callback);
|
|
19054
19026
|
},
|
|
19055
|
-
sendSavedCardsOTP: function sendSavedCardsOTP() {
|
|
19056
|
-
return CardAPI$1.sendSavedCardsOTP(this.id);
|
|
19057
|
-
},
|
|
19058
|
-
addUserToSavedCards: function addUserToSavedCards(_ref4) {
|
|
19059
|
-
var phone = _ref4.phone;
|
|
19060
|
-
return CardAPI$1.addUserToSavedCards({
|
|
19061
|
-
phone: phone,
|
|
19062
|
-
transaction: this.id
|
|
19063
|
-
});
|
|
19064
|
-
},
|
|
19065
|
-
verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
|
|
19027
|
+
sendSavedCardsOTP: function sendSavedCardsOTP(phone) {
|
|
19066
19028
|
var _this9 = this;
|
|
19067
19029
|
|
|
19068
19030
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
19069
|
-
var
|
|
19031
|
+
var response;
|
|
19070
19032
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19071
19033
|
while (1) {
|
|
19072
19034
|
switch (_context.prev = _context.next) {
|
|
19073
19035
|
case 0:
|
|
19074
|
-
|
|
19036
|
+
_context.prev = 0;
|
|
19037
|
+
_context.next = 3;
|
|
19038
|
+
return CardAPI$1.sendSavedCardsOTP({
|
|
19039
|
+
phone: phone,
|
|
19040
|
+
transaction: _this9.id
|
|
19041
|
+
});
|
|
19042
|
+
|
|
19043
|
+
case 3:
|
|
19044
|
+
response = _context.sent;
|
|
19045
|
+
_this9.savedCardsTempAuthToken = response.data.token;
|
|
19046
|
+
return _context.abrupt("return", response);
|
|
19047
|
+
|
|
19048
|
+
case 8:
|
|
19049
|
+
_context.prev = 8;
|
|
19050
|
+
_context.t0 = _context["catch"](0);
|
|
19051
|
+
_this9.savedCardsTempAuthToken = null;
|
|
19052
|
+
throw _context.t0;
|
|
19053
|
+
|
|
19054
|
+
case 12:
|
|
19055
|
+
case "end":
|
|
19056
|
+
return _context.stop();
|
|
19057
|
+
}
|
|
19058
|
+
}
|
|
19059
|
+
}, _callee, null, [[0, 8]]);
|
|
19060
|
+
}))();
|
|
19061
|
+
},
|
|
19062
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
|
|
19063
|
+
var _this10 = this;
|
|
19064
|
+
|
|
19065
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
19066
|
+
var code, payload, response;
|
|
19067
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
19068
|
+
while (1) {
|
|
19069
|
+
switch (_context2.prev = _context2.next) {
|
|
19070
|
+
case 0:
|
|
19071
|
+
code = _ref4.code;
|
|
19075
19072
|
payload = {
|
|
19076
19073
|
code: code,
|
|
19077
|
-
transaction:
|
|
19074
|
+
transaction: _this10.id,
|
|
19075
|
+
token: _this10.savedCardsTempAuthToken
|
|
19078
19076
|
};
|
|
19079
|
-
|
|
19080
|
-
|
|
19077
|
+
_context2.prev = 2;
|
|
19078
|
+
_context2.next = 5;
|
|
19081
19079
|
return CardAPI$1.verifySavedCardsOtp(payload);
|
|
19082
19080
|
|
|
19083
19081
|
case 5:
|
|
19084
|
-
response =
|
|
19085
|
-
|
|
19086
|
-
return
|
|
19082
|
+
response = _context2.sent;
|
|
19083
|
+
_this10.savedCardsToken = response.data.token;
|
|
19084
|
+
return _context2.abrupt("return", response);
|
|
19087
19085
|
|
|
19088
19086
|
case 10:
|
|
19089
|
-
|
|
19090
|
-
|
|
19091
|
-
|
|
19092
|
-
throw
|
|
19087
|
+
_context2.prev = 10;
|
|
19088
|
+
_context2.t0 = _context2["catch"](2);
|
|
19089
|
+
_this10.savedCardsToken = null;
|
|
19090
|
+
throw _context2.t0;
|
|
19093
19091
|
|
|
19094
19092
|
case 14:
|
|
19095
19093
|
case "end":
|
|
19096
|
-
return
|
|
19094
|
+
return _context2.stop();
|
|
19097
19095
|
}
|
|
19098
19096
|
}
|
|
19099
|
-
},
|
|
19097
|
+
}, _callee2, null, [[2, 10]]);
|
|
19100
19098
|
}))();
|
|
19101
19099
|
},
|
|
19102
19100
|
getSavedCards: function getSavedCards() {
|
|
@@ -19110,8 +19108,8 @@ var CardCharge = {
|
|
|
19110
19108
|
token: this.savedCardsToken
|
|
19111
19109
|
});
|
|
19112
19110
|
},
|
|
19113
|
-
chargeSavedCard: function chargeSavedCard(
|
|
19114
|
-
var cardCode =
|
|
19111
|
+
chargeSavedCard: function chargeSavedCard(_ref5) {
|
|
19112
|
+
var cardCode = _ref5.cardCode;
|
|
19115
19113
|
return CardAPI$1.chargeSavedCard({
|
|
19116
19114
|
cardCode: cardCode,
|
|
19117
19115
|
transaction: this.id,
|
|
@@ -20497,6 +20495,12 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20497
20495
|
this.planDetails = data.plan_details || null;
|
|
20498
20496
|
this.exchangeRate = data.exchange_rate || null;
|
|
20499
20497
|
this.savedCardsConfig = data.saved_cards || {};
|
|
20498
|
+
/**
|
|
20499
|
+
* savedCardsTempAuthToken: This token is issued on calling `authorize` and we pass it down to `authorize/verify` to ensure we only add users to saved cards only after a successful verification.
|
|
20500
|
+
* savedCardsToken: This token is issued after verification and is used for all saved card auth requests.
|
|
20501
|
+
*/
|
|
20502
|
+
|
|
20503
|
+
this.savedCardsTempAuthToken = null;
|
|
20500
20504
|
this.savedCardsToken = null;
|
|
20501
20505
|
/**
|
|
20502
20506
|
* We initialize parameters we send to the API as empty strings
|