@paystack/checkout-js 1.20.0-dev.9 → 1.20.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 +29 -21089
- package/es/checkout.js +8 -284
- package/lib/checkout.js +8 -284
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -6403,16 +6403,14 @@ 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'
|
|
6407
|
-
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6406
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6408
6407
|
});
|
|
6409
6408
|
var stagingConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6410
6409
|
checkoutUrl: 'https://checkout-studio.paystack.com/',
|
|
6411
6410
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6412
6411
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6413
6412
|
pusherKey: '1c7b262ee18455815893',
|
|
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/'
|
|
6413
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6416
6414
|
});
|
|
6417
6415
|
var productionConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6418
6416
|
checkoutUrl: 'https://checkout.paystack.com/',
|
|
@@ -18375,7 +18373,7 @@ var Card$2 = {
|
|
|
18375
18373
|
return Card$2.validateCVV(cvv, cardType).isValid;
|
|
18376
18374
|
},
|
|
18377
18375
|
validateExpiry: function validateExpiry(value) {
|
|
18378
|
-
if (_typeof$1(value) === 'object') {
|
|
18376
|
+
if (value !== null && _typeof$1(value) === 'object') {
|
|
18379
18377
|
var month = value.month,
|
|
18380
18378
|
year = value.year;
|
|
18381
18379
|
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
@@ -18666,209 +18664,6 @@ var CardAPI$1 = {
|
|
|
18666
18664
|
}).then(function (response) {
|
|
18667
18665
|
return ChargeResponses.parse(response.data);
|
|
18668
18666
|
});
|
|
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, email, 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, email = _ref7.email, 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
|
-
email: email,
|
|
18753
|
-
transaction: transaction
|
|
18754
|
-
};
|
|
18755
|
-
_context3.next = 7;
|
|
18756
|
-
return axiosInstance.post(url, data, {
|
|
18757
|
-
headers: headers
|
|
18758
|
-
});
|
|
18759
|
-
|
|
18760
|
-
case 7:
|
|
18761
|
-
response = _context3.sent;
|
|
18762
|
-
return _context3.abrupt("return", response.data);
|
|
18763
|
-
|
|
18764
|
-
case 9:
|
|
18765
|
-
case "end":
|
|
18766
|
-
return _context3.stop();
|
|
18767
|
-
}
|
|
18768
|
-
}
|
|
18769
|
-
}, _callee3);
|
|
18770
|
-
}))();
|
|
18771
|
-
},
|
|
18772
|
-
getSavedCards: function getSavedCards(_ref8) {
|
|
18773
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18774
|
-
var token, url, language, headers, response;
|
|
18775
|
-
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18776
|
-
while (1) {
|
|
18777
|
-
switch (_context4.prev = _context4.next) {
|
|
18778
|
-
case 0:
|
|
18779
|
-
token = _ref8.token;
|
|
18780
|
-
url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
|
|
18781
|
-
language = getLanguage();
|
|
18782
|
-
headers = _objectSpread2({
|
|
18783
|
-
Authorization: "Bearer ".concat(token),
|
|
18784
|
-
'jwt-auth': true
|
|
18785
|
-
}, language && {
|
|
18786
|
-
'Accept-Language': language
|
|
18787
|
-
});
|
|
18788
|
-
_context4.next = 6;
|
|
18789
|
-
return axiosInstance.get(url, {
|
|
18790
|
-
headers: headers
|
|
18791
|
-
});
|
|
18792
|
-
|
|
18793
|
-
case 6:
|
|
18794
|
-
response = _context4.sent;
|
|
18795
|
-
return _context4.abrupt("return", response.data);
|
|
18796
|
-
|
|
18797
|
-
case 8:
|
|
18798
|
-
case "end":
|
|
18799
|
-
return _context4.stop();
|
|
18800
|
-
}
|
|
18801
|
-
}
|
|
18802
|
-
}, _callee4);
|
|
18803
|
-
}))();
|
|
18804
|
-
},
|
|
18805
|
-
deleteSavedCard: function deleteSavedCard(_ref9) {
|
|
18806
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
18807
|
-
var cardCode, token, url, language, headers, response;
|
|
18808
|
-
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
18809
|
-
while (1) {
|
|
18810
|
-
switch (_context5.prev = _context5.next) {
|
|
18811
|
-
case 0:
|
|
18812
|
-
cardCode = _ref9.cardCode, token = _ref9.token;
|
|
18813
|
-
url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
|
|
18814
|
-
language = getLanguage();
|
|
18815
|
-
headers = _objectSpread2({
|
|
18816
|
-
Authorization: "Bearer ".concat(token),
|
|
18817
|
-
'jwt-auth': true
|
|
18818
|
-
}, language && {
|
|
18819
|
-
'Accept-Language': language
|
|
18820
|
-
});
|
|
18821
|
-
_context5.next = 6;
|
|
18822
|
-
return axiosInstance.delete(url, {
|
|
18823
|
-
headers: headers
|
|
18824
|
-
});
|
|
18825
|
-
|
|
18826
|
-
case 6:
|
|
18827
|
-
response = _context5.sent;
|
|
18828
|
-
return _context5.abrupt("return", response.data);
|
|
18829
|
-
|
|
18830
|
-
case 8:
|
|
18831
|
-
case "end":
|
|
18832
|
-
return _context5.stop();
|
|
18833
|
-
}
|
|
18834
|
-
}
|
|
18835
|
-
}, _callee5);
|
|
18836
|
-
}))();
|
|
18837
|
-
},
|
|
18838
|
-
chargeSavedCard: function chargeSavedCard(_ref10) {
|
|
18839
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
18840
|
-
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data;
|
|
18841
|
-
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
18842
|
-
while (1) {
|
|
18843
|
-
switch (_context6.prev = _context6.next) {
|
|
18844
|
-
case 0:
|
|
18845
|
-
token = _ref10.token, device = _ref10.device, cardCode = _ref10.cardCode, transaction = _ref10.transaction, selectedCurrency = _ref10.selectedCurrency;
|
|
18846
|
-
url = new URL("/cards/".concat(cardCode, "/charge"), configToUse.savedCardsApiUrl).toString();
|
|
18847
|
-
language = getLanguage();
|
|
18848
|
-
headers = _objectSpread2({
|
|
18849
|
-
Authorization: "Bearer ".concat(token),
|
|
18850
|
-
'jwt-auth': true
|
|
18851
|
-
}, language && {
|
|
18852
|
-
'Accept-Language': language
|
|
18853
|
-
});
|
|
18854
|
-
data = {
|
|
18855
|
-
device: device,
|
|
18856
|
-
transaction: transaction,
|
|
18857
|
-
selectedCurrency: selectedCurrency
|
|
18858
|
-
};
|
|
18859
|
-
return _context6.abrupt("return", axiosInstance.post(url, data, {
|
|
18860
|
-
headers: headers
|
|
18861
|
-
}).then(function (response) {
|
|
18862
|
-
return ChargeResponses.parse(response.data);
|
|
18863
|
-
}));
|
|
18864
|
-
|
|
18865
|
-
case 6:
|
|
18866
|
-
case "end":
|
|
18867
|
-
return _context6.stop();
|
|
18868
|
-
}
|
|
18869
|
-
}
|
|
18870
|
-
}, _callee6);
|
|
18871
|
-
}))();
|
|
18872
18667
|
}
|
|
18873
18668
|
};
|
|
18874
18669
|
|
|
@@ -19049,75 +18844,6 @@ var CardCharge = {
|
|
|
19049
18844
|
paymentMethod: paymentMethod$4
|
|
19050
18845
|
};
|
|
19051
18846
|
return this.listenForCharge(listenerOptions, callback);
|
|
19052
|
-
},
|
|
19053
|
-
sendSavedCardsOTP: function sendSavedCardsOTP() {
|
|
19054
|
-
return CardAPI$1.sendSavedCardsOTP(this.email);
|
|
19055
|
-
},
|
|
19056
|
-
addUserToSavedCards: function addUserToSavedCards(_ref4) {
|
|
19057
|
-
var phone = _ref4.phone;
|
|
19058
|
-
return CardAPI$1.addUserToSavedCards({
|
|
19059
|
-
phone: phone,
|
|
19060
|
-
email: this.email
|
|
19061
|
-
});
|
|
19062
|
-
},
|
|
19063
|
-
verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
|
|
19064
|
-
var _this9 = this;
|
|
19065
|
-
|
|
19066
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
19067
|
-
var code, payload, response;
|
|
19068
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19069
|
-
while (1) {
|
|
19070
|
-
switch (_context.prev = _context.next) {
|
|
19071
|
-
case 0:
|
|
19072
|
-
code = _ref5.code;
|
|
19073
|
-
payload = {
|
|
19074
|
-
code: code,
|
|
19075
|
-
email: _this9.email,
|
|
19076
|
-
transaction: _this9.id
|
|
19077
|
-
};
|
|
19078
|
-
_context.prev = 2;
|
|
19079
|
-
_context.next = 5;
|
|
19080
|
-
return CardAPI$1.verifySavedCardsOtp(payload);
|
|
19081
|
-
|
|
19082
|
-
case 5:
|
|
19083
|
-
response = _context.sent;
|
|
19084
|
-
_this9.savedCardsToken = response.data.token;
|
|
19085
|
-
return _context.abrupt("return", response);
|
|
19086
|
-
|
|
19087
|
-
case 10:
|
|
19088
|
-
_context.prev = 10;
|
|
19089
|
-
_context.t0 = _context["catch"](2);
|
|
19090
|
-
_this9.savedCardsToken = null;
|
|
19091
|
-
throw _context.t0;
|
|
19092
|
-
|
|
19093
|
-
case 14:
|
|
19094
|
-
case "end":
|
|
19095
|
-
return _context.stop();
|
|
19096
|
-
}
|
|
19097
|
-
}
|
|
19098
|
-
}, _callee, null, [[2, 10]]);
|
|
19099
|
-
}))();
|
|
19100
|
-
},
|
|
19101
|
-
getSavedCards: function getSavedCards() {
|
|
19102
|
-
return CardAPI$1.getSavedCards({
|
|
19103
|
-
token: this.savedCardsToken
|
|
19104
|
-
});
|
|
19105
|
-
},
|
|
19106
|
-
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
19107
|
-
return CardAPI$1.deleteSavedCard({
|
|
19108
|
-
cardCode: cardCode,
|
|
19109
|
-
token: this.savedCardsToken
|
|
19110
|
-
});
|
|
19111
|
-
},
|
|
19112
|
-
chargeSavedCard: function chargeSavedCard(_ref6) {
|
|
19113
|
-
var cardCode = _ref6.cardCode;
|
|
19114
|
-
return CardAPI$1.chargeSavedCard({
|
|
19115
|
-
cardCode: cardCode,
|
|
19116
|
-
transaction: this.id,
|
|
19117
|
-
token: this.savedCardsToken,
|
|
19118
|
-
device: this.deviceFingerprint,
|
|
19119
|
-
selectedCurrency: this.currency
|
|
19120
|
-
});
|
|
19121
18847
|
}
|
|
19122
18848
|
};
|
|
19123
18849
|
|
|
@@ -20446,8 +20172,6 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20446
20172
|
this.subscription = data.subscription || null;
|
|
20447
20173
|
this.planDetails = data.plan_details || null;
|
|
20448
20174
|
this.exchangeRate = data.exchange_rate || null;
|
|
20449
|
-
this.savedCardsConfig = data.saved_cards || {};
|
|
20450
|
-
this.savedCardsToken = null;
|
|
20451
20175
|
/**
|
|
20452
20176
|
* We initialize parameters we send to the API as empty strings
|
|
20453
20177
|
* when we don't have them instead of null because the API expects
|
|
@@ -20885,7 +20609,7 @@ var Card = /*#__PURE__*/function () {
|
|
|
20885
20609
|
}();
|
|
20886
20610
|
|
|
20887
20611
|
var CardAPI = {
|
|
20888
|
-
|
|
20612
|
+
reserveFunds: function reserveFunds(_ref) {
|
|
20889
20613
|
var clientdata = _ref.clientdata,
|
|
20890
20614
|
last4 = _ref.last4,
|
|
20891
20615
|
preauthorizationId = _ref.preauthorizationId,
|
|
@@ -20930,7 +20654,7 @@ function validate(card, isSetter) {
|
|
|
20930
20654
|
});
|
|
20931
20655
|
}
|
|
20932
20656
|
|
|
20933
|
-
var
|
|
20657
|
+
var CardPreauthorization = {
|
|
20934
20658
|
setCard: function setCard(params) {
|
|
20935
20659
|
var _this = this;
|
|
20936
20660
|
|
|
@@ -20938,7 +20662,7 @@ var ReserveCardFunds = {
|
|
|
20938
20662
|
_this.card = new Card(params);
|
|
20939
20663
|
});
|
|
20940
20664
|
},
|
|
20941
|
-
|
|
20665
|
+
reserveFunds: function reserveFunds(_ref) {
|
|
20942
20666
|
var _this2 = this;
|
|
20943
20667
|
|
|
20944
20668
|
var preauthorizationId = _ref.preauthorizationId,
|
|
@@ -20955,7 +20679,7 @@ var ReserveCardFunds = {
|
|
|
20955
20679
|
publicKey: publicKey,
|
|
20956
20680
|
customFields: customFields
|
|
20957
20681
|
};
|
|
20958
|
-
return CardAPI.
|
|
20682
|
+
return CardAPI.reserveFunds(chargeParams).then(function (response) {
|
|
20959
20683
|
// TODO: Log API Response
|
|
20960
20684
|
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20961
20685
|
return response;
|
|
@@ -20995,7 +20719,7 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20995
20719
|
loadPusher(); // TODO: Analytics
|
|
20996
20720
|
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20997
20721
|
|
|
20998
|
-
Object.assign(this,
|
|
20722
|
+
Object.assign(this, CardPreauthorization);
|
|
20999
20723
|
}
|
|
21000
20724
|
|
|
21001
20725
|
_createClass(PreauthorizationInstance, [{
|