@paystack/checkout-js 1.19.0-dev.1 → 1.19.0-dev.3
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 +169 -40
- package/lib/checkout.js +169 -40
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -18568,43 +18568,138 @@ var CardAPI = {
|
|
|
18568
18568
|
});
|
|
18569
18569
|
},
|
|
18570
18570
|
requestOtpForSavedCards: function requestOtpForSavedCards(phoneNumber) {
|
|
18571
|
-
|
|
18572
|
-
|
|
18571
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18572
|
+
var url, language, headers, _yield$axiosInstance$, data;
|
|
18573
18573
|
|
|
18574
|
-
|
|
18575
|
-
|
|
18576
|
-
|
|
18574
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18575
|
+
while (1) {
|
|
18576
|
+
switch (_context.prev = _context.next) {
|
|
18577
|
+
case 0:
|
|
18578
|
+
url = new URL("/authorize/".concat(phoneNumber), configToUse.savedCardsApiUrl).toString();
|
|
18579
|
+
language = getLanguage();
|
|
18580
|
+
headers = _objectSpread2({}, language && {
|
|
18581
|
+
'Accept-Language': language
|
|
18582
|
+
});
|
|
18583
|
+
_context.next = 5;
|
|
18584
|
+
return axiosInstance.post(url, {
|
|
18585
|
+
headers: headers
|
|
18586
|
+
});
|
|
18577
18587
|
|
|
18578
|
-
|
|
18579
|
-
|
|
18580
|
-
|
|
18581
|
-
|
|
18582
|
-
|
|
18583
|
-
|
|
18588
|
+
case 5:
|
|
18589
|
+
_yield$axiosInstance$ = _context.sent;
|
|
18590
|
+
data = _yield$axiosInstance$.data;
|
|
18591
|
+
return _context.abrupt("return", data);
|
|
18592
|
+
|
|
18593
|
+
case 8:
|
|
18594
|
+
case "end":
|
|
18595
|
+
return _context.stop();
|
|
18596
|
+
}
|
|
18597
|
+
}
|
|
18598
|
+
}, _callee);
|
|
18599
|
+
}))();
|
|
18584
18600
|
},
|
|
18585
|
-
verifySavedCardsOtp: function verifySavedCardsOtp(
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18601
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref6) {
|
|
18602
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18603
|
+
var code, phone, transaction, url, language, headers, urlEncodedData, response;
|
|
18604
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18605
|
+
while (1) {
|
|
18606
|
+
switch (_context2.prev = _context2.next) {
|
|
18607
|
+
case 0:
|
|
18608
|
+
code = _ref6.code, phone = _ref6.phone, transaction = _ref6.transaction;
|
|
18609
|
+
url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
|
|
18610
|
+
language = getLanguage();
|
|
18611
|
+
headers = _objectSpread2({
|
|
18612
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
18613
|
+
}, language && {
|
|
18614
|
+
'Accept-Language': language
|
|
18615
|
+
});
|
|
18616
|
+
urlEncodedData = formUrlencoded({
|
|
18617
|
+
code: code,
|
|
18618
|
+
phone: phone,
|
|
18619
|
+
transaction: transaction
|
|
18620
|
+
});
|
|
18621
|
+
_context2.next = 7;
|
|
18622
|
+
return axiosInstance.post(url, urlEncodedData, {
|
|
18623
|
+
headers: headers
|
|
18624
|
+
});
|
|
18591
18625
|
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
'Accept-Language': language
|
|
18596
|
-
});
|
|
18626
|
+
case 7:
|
|
18627
|
+
response = _context2.sent;
|
|
18628
|
+
return _context2.abrupt("return", response.data);
|
|
18597
18629
|
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18630
|
+
case 9:
|
|
18631
|
+
case "end":
|
|
18632
|
+
return _context2.stop();
|
|
18633
|
+
}
|
|
18634
|
+
}
|
|
18635
|
+
}, _callee2);
|
|
18636
|
+
}))();
|
|
18637
|
+
},
|
|
18638
|
+
getSavedCards: function getSavedCards(_ref7) {
|
|
18639
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18640
|
+
var token, url, language, headers, response;
|
|
18641
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18642
|
+
while (1) {
|
|
18643
|
+
switch (_context3.prev = _context3.next) {
|
|
18644
|
+
case 0:
|
|
18645
|
+
token = _ref7.token;
|
|
18646
|
+
url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
|
|
18647
|
+
language = getLanguage();
|
|
18648
|
+
headers = _objectSpread2({
|
|
18649
|
+
Authorization: "Bearer ".concat(token),
|
|
18650
|
+
'jwt-auth': true
|
|
18651
|
+
}, language && {
|
|
18652
|
+
'Accept-Language': language
|
|
18653
|
+
});
|
|
18654
|
+
_context3.next = 6;
|
|
18655
|
+
return axiosInstance.get(url, {
|
|
18656
|
+
headers: headers
|
|
18657
|
+
});
|
|
18658
|
+
|
|
18659
|
+
case 6:
|
|
18660
|
+
response = _context3.sent;
|
|
18661
|
+
return _context3.abrupt("return", response.data);
|
|
18662
|
+
|
|
18663
|
+
case 8:
|
|
18664
|
+
case "end":
|
|
18665
|
+
return _context3.stop();
|
|
18666
|
+
}
|
|
18667
|
+
}
|
|
18668
|
+
}, _callee3);
|
|
18669
|
+
}))();
|
|
18670
|
+
},
|
|
18671
|
+
deleteSavedCard: function deleteSavedCard(_ref8) {
|
|
18672
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18673
|
+
var cardCode, token, url, language, headers, response;
|
|
18674
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18675
|
+
while (1) {
|
|
18676
|
+
switch (_context4.prev = _context4.next) {
|
|
18677
|
+
case 0:
|
|
18678
|
+
cardCode = _ref8.cardCode, token = _ref8.token;
|
|
18679
|
+
url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
|
|
18680
|
+
language = getLanguage();
|
|
18681
|
+
headers = _objectSpread2({
|
|
18682
|
+
Authorization: "Bearer ".concat(token),
|
|
18683
|
+
'jwt-auth': true
|
|
18684
|
+
}, language && {
|
|
18685
|
+
'Accept-Language': language
|
|
18686
|
+
});
|
|
18687
|
+
_context4.next = 6;
|
|
18688
|
+
return axiosInstance.delete(url, {
|
|
18689
|
+
headers: headers
|
|
18690
|
+
});
|
|
18691
|
+
|
|
18692
|
+
case 6:
|
|
18693
|
+
response = _context4.sent;
|
|
18694
|
+
return _context4.abrupt("return", response.data);
|
|
18695
|
+
|
|
18696
|
+
case 8:
|
|
18697
|
+
case "end":
|
|
18698
|
+
return _context4.stop();
|
|
18699
|
+
}
|
|
18700
|
+
}
|
|
18701
|
+
}, _callee4);
|
|
18702
|
+
}))();
|
|
18608
18703
|
}
|
|
18609
18704
|
};
|
|
18610
18705
|
|
|
@@ -18790,14 +18885,46 @@ var CardCharge = {
|
|
|
18790
18885
|
return CardAPI.requestOtpForSavedCards(phoneNumber);
|
|
18791
18886
|
},
|
|
18792
18887
|
verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
|
|
18793
|
-
var
|
|
18794
|
-
|
|
18795
|
-
|
|
18796
|
-
|
|
18797
|
-
|
|
18798
|
-
|
|
18799
|
-
|
|
18800
|
-
|
|
18888
|
+
var _this9 = this;
|
|
18889
|
+
|
|
18890
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18891
|
+
var code, phone, payload, response;
|
|
18892
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18893
|
+
while (1) {
|
|
18894
|
+
switch (_context.prev = _context.next) {
|
|
18895
|
+
case 0:
|
|
18896
|
+
code = _ref4.code, phone = _ref4.phone;
|
|
18897
|
+
payload = {
|
|
18898
|
+
code: code,
|
|
18899
|
+
phone: phone,
|
|
18900
|
+
transaction: _this9.id
|
|
18901
|
+
};
|
|
18902
|
+
_context.next = 4;
|
|
18903
|
+
return CardAPI.verifySavedCardsOtp(payload);
|
|
18904
|
+
|
|
18905
|
+
case 4:
|
|
18906
|
+
response = _context.sent;
|
|
18907
|
+
_this9.savedCardsToken = response.data.token;
|
|
18908
|
+
return _context.abrupt("return", response);
|
|
18909
|
+
|
|
18910
|
+
case 7:
|
|
18911
|
+
case "end":
|
|
18912
|
+
return _context.stop();
|
|
18913
|
+
}
|
|
18914
|
+
}
|
|
18915
|
+
}, _callee);
|
|
18916
|
+
}))();
|
|
18917
|
+
},
|
|
18918
|
+
getSavedCards: function getSavedCards() {
|
|
18919
|
+
return CardAPI.getSavedCards({
|
|
18920
|
+
token: this.savedCardsToken
|
|
18921
|
+
});
|
|
18922
|
+
},
|
|
18923
|
+
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
18924
|
+
return CardAPI.deleteSavedCard({
|
|
18925
|
+
cardCode: cardCode,
|
|
18926
|
+
token: this.savedCardsToken
|
|
18927
|
+
});
|
|
18801
18928
|
}
|
|
18802
18929
|
};
|
|
18803
18930
|
|
|
@@ -20354,6 +20481,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20354
20481
|
this.subscription = data.subscription || null;
|
|
20355
20482
|
this.planDetails = data.plan_details || null;
|
|
20356
20483
|
this.exchangeRate = data.exchange_rate || null;
|
|
20484
|
+
this.savedCardsToken = null;
|
|
20485
|
+
this.isSavedCardsEnabled = data.saved_cards && data.saved_cards.enabled || null;
|
|
20357
20486
|
/**
|
|
20358
20487
|
* We initialize parameters we send to the API as empty strings
|
|
20359
20488
|
* when we don't have them instead of null because the API expects
|
package/lib/checkout.js
CHANGED
|
@@ -18572,43 +18572,138 @@ var CardAPI = {
|
|
|
18572
18572
|
});
|
|
18573
18573
|
},
|
|
18574
18574
|
requestOtpForSavedCards: function requestOtpForSavedCards(phoneNumber) {
|
|
18575
|
-
|
|
18576
|
-
|
|
18575
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18576
|
+
var url, language, headers, _yield$axiosInstance$, data;
|
|
18577
18577
|
|
|
18578
|
-
|
|
18579
|
-
|
|
18580
|
-
|
|
18578
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18579
|
+
while (1) {
|
|
18580
|
+
switch (_context.prev = _context.next) {
|
|
18581
|
+
case 0:
|
|
18582
|
+
url = new URL("/authorize/".concat(phoneNumber), configToUse.savedCardsApiUrl).toString();
|
|
18583
|
+
language = getLanguage();
|
|
18584
|
+
headers = _objectSpread2({}, language && {
|
|
18585
|
+
'Accept-Language': language
|
|
18586
|
+
});
|
|
18587
|
+
_context.next = 5;
|
|
18588
|
+
return axiosInstance.post(url, {
|
|
18589
|
+
headers: headers
|
|
18590
|
+
});
|
|
18581
18591
|
|
|
18582
|
-
|
|
18583
|
-
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
|
|
18587
|
-
|
|
18592
|
+
case 5:
|
|
18593
|
+
_yield$axiosInstance$ = _context.sent;
|
|
18594
|
+
data = _yield$axiosInstance$.data;
|
|
18595
|
+
return _context.abrupt("return", data);
|
|
18596
|
+
|
|
18597
|
+
case 8:
|
|
18598
|
+
case "end":
|
|
18599
|
+
return _context.stop();
|
|
18600
|
+
}
|
|
18601
|
+
}
|
|
18602
|
+
}, _callee);
|
|
18603
|
+
}))();
|
|
18588
18604
|
},
|
|
18589
|
-
verifySavedCardsOtp: function verifySavedCardsOtp(
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18605
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref6) {
|
|
18606
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18607
|
+
var code, phone, transaction, url, language, headers, urlEncodedData, response;
|
|
18608
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18609
|
+
while (1) {
|
|
18610
|
+
switch (_context2.prev = _context2.next) {
|
|
18611
|
+
case 0:
|
|
18612
|
+
code = _ref6.code, phone = _ref6.phone, transaction = _ref6.transaction;
|
|
18613
|
+
url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
|
|
18614
|
+
language = getLanguage();
|
|
18615
|
+
headers = _objectSpread2({
|
|
18616
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
18617
|
+
}, language && {
|
|
18618
|
+
'Accept-Language': language
|
|
18619
|
+
});
|
|
18620
|
+
urlEncodedData = formUrlencoded({
|
|
18621
|
+
code: code,
|
|
18622
|
+
phone: phone,
|
|
18623
|
+
transaction: transaction
|
|
18624
|
+
});
|
|
18625
|
+
_context2.next = 7;
|
|
18626
|
+
return axiosInstance.post(url, urlEncodedData, {
|
|
18627
|
+
headers: headers
|
|
18628
|
+
});
|
|
18595
18629
|
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
'Accept-Language': language
|
|
18600
|
-
});
|
|
18630
|
+
case 7:
|
|
18631
|
+
response = _context2.sent;
|
|
18632
|
+
return _context2.abrupt("return", response.data);
|
|
18601
18633
|
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
|
|
18609
|
-
|
|
18610
|
-
|
|
18611
|
-
|
|
18634
|
+
case 9:
|
|
18635
|
+
case "end":
|
|
18636
|
+
return _context2.stop();
|
|
18637
|
+
}
|
|
18638
|
+
}
|
|
18639
|
+
}, _callee2);
|
|
18640
|
+
}))();
|
|
18641
|
+
},
|
|
18642
|
+
getSavedCards: function getSavedCards(_ref7) {
|
|
18643
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18644
|
+
var token, url, language, headers, response;
|
|
18645
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18646
|
+
while (1) {
|
|
18647
|
+
switch (_context3.prev = _context3.next) {
|
|
18648
|
+
case 0:
|
|
18649
|
+
token = _ref7.token;
|
|
18650
|
+
url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
|
|
18651
|
+
language = getLanguage();
|
|
18652
|
+
headers = _objectSpread2({
|
|
18653
|
+
Authorization: "Bearer ".concat(token),
|
|
18654
|
+
'jwt-auth': true
|
|
18655
|
+
}, language && {
|
|
18656
|
+
'Accept-Language': language
|
|
18657
|
+
});
|
|
18658
|
+
_context3.next = 6;
|
|
18659
|
+
return axiosInstance.get(url, {
|
|
18660
|
+
headers: headers
|
|
18661
|
+
});
|
|
18662
|
+
|
|
18663
|
+
case 6:
|
|
18664
|
+
response = _context3.sent;
|
|
18665
|
+
return _context3.abrupt("return", response.data);
|
|
18666
|
+
|
|
18667
|
+
case 8:
|
|
18668
|
+
case "end":
|
|
18669
|
+
return _context3.stop();
|
|
18670
|
+
}
|
|
18671
|
+
}
|
|
18672
|
+
}, _callee3);
|
|
18673
|
+
}))();
|
|
18674
|
+
},
|
|
18675
|
+
deleteSavedCard: function deleteSavedCard(_ref8) {
|
|
18676
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18677
|
+
var cardCode, token, url, language, headers, response;
|
|
18678
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18679
|
+
while (1) {
|
|
18680
|
+
switch (_context4.prev = _context4.next) {
|
|
18681
|
+
case 0:
|
|
18682
|
+
cardCode = _ref8.cardCode, token = _ref8.token;
|
|
18683
|
+
url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
|
|
18684
|
+
language = getLanguage();
|
|
18685
|
+
headers = _objectSpread2({
|
|
18686
|
+
Authorization: "Bearer ".concat(token),
|
|
18687
|
+
'jwt-auth': true
|
|
18688
|
+
}, language && {
|
|
18689
|
+
'Accept-Language': language
|
|
18690
|
+
});
|
|
18691
|
+
_context4.next = 6;
|
|
18692
|
+
return axiosInstance.delete(url, {
|
|
18693
|
+
headers: headers
|
|
18694
|
+
});
|
|
18695
|
+
|
|
18696
|
+
case 6:
|
|
18697
|
+
response = _context4.sent;
|
|
18698
|
+
return _context4.abrupt("return", response.data);
|
|
18699
|
+
|
|
18700
|
+
case 8:
|
|
18701
|
+
case "end":
|
|
18702
|
+
return _context4.stop();
|
|
18703
|
+
}
|
|
18704
|
+
}
|
|
18705
|
+
}, _callee4);
|
|
18706
|
+
}))();
|
|
18612
18707
|
}
|
|
18613
18708
|
};
|
|
18614
18709
|
|
|
@@ -18794,14 +18889,46 @@ var CardCharge = {
|
|
|
18794
18889
|
return CardAPI.requestOtpForSavedCards(phoneNumber);
|
|
18795
18890
|
},
|
|
18796
18891
|
verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
|
|
18797
|
-
var
|
|
18798
|
-
|
|
18799
|
-
|
|
18800
|
-
|
|
18801
|
-
|
|
18802
|
-
|
|
18803
|
-
|
|
18804
|
-
|
|
18892
|
+
var _this9 = this;
|
|
18893
|
+
|
|
18894
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18895
|
+
var code, phone, payload, response;
|
|
18896
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18897
|
+
while (1) {
|
|
18898
|
+
switch (_context.prev = _context.next) {
|
|
18899
|
+
case 0:
|
|
18900
|
+
code = _ref4.code, phone = _ref4.phone;
|
|
18901
|
+
payload = {
|
|
18902
|
+
code: code,
|
|
18903
|
+
phone: phone,
|
|
18904
|
+
transaction: _this9.id
|
|
18905
|
+
};
|
|
18906
|
+
_context.next = 4;
|
|
18907
|
+
return CardAPI.verifySavedCardsOtp(payload);
|
|
18908
|
+
|
|
18909
|
+
case 4:
|
|
18910
|
+
response = _context.sent;
|
|
18911
|
+
_this9.savedCardsToken = response.data.token;
|
|
18912
|
+
return _context.abrupt("return", response);
|
|
18913
|
+
|
|
18914
|
+
case 7:
|
|
18915
|
+
case "end":
|
|
18916
|
+
return _context.stop();
|
|
18917
|
+
}
|
|
18918
|
+
}
|
|
18919
|
+
}, _callee);
|
|
18920
|
+
}))();
|
|
18921
|
+
},
|
|
18922
|
+
getSavedCards: function getSavedCards() {
|
|
18923
|
+
return CardAPI.getSavedCards({
|
|
18924
|
+
token: this.savedCardsToken
|
|
18925
|
+
});
|
|
18926
|
+
},
|
|
18927
|
+
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
18928
|
+
return CardAPI.deleteSavedCard({
|
|
18929
|
+
cardCode: cardCode,
|
|
18930
|
+
token: this.savedCardsToken
|
|
18931
|
+
});
|
|
18805
18932
|
}
|
|
18806
18933
|
};
|
|
18807
18934
|
|
|
@@ -20358,6 +20485,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20358
20485
|
this.subscription = data.subscription || null;
|
|
20359
20486
|
this.planDetails = data.plan_details || null;
|
|
20360
20487
|
this.exchangeRate = data.exchange_rate || null;
|
|
20488
|
+
this.savedCardsToken = null;
|
|
20489
|
+
this.isSavedCardsEnabled = data.saved_cards && data.saved_cards.enabled || null;
|
|
20361
20490
|
/**
|
|
20362
20491
|
* We initialize parameters we send to the API as empty strings
|
|
20363
20492
|
* when we don't have them instead of null because the API expects
|