@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/lib/checkout.js CHANGED
@@ -6407,16 +6407,14 @@ 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',
6411
- savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
6410
+ pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
6412
6411
  });
6413
6412
  var stagingConfig = _objectSpread2(_objectSpread2({}, config), {}, {
6414
6413
  checkoutUrl: 'https://checkout-studio.paystack.com/',
6415
6414
  paymentBaseUrl: 'https://legacy-staging.paystack.co/',
6416
6415
  paystackApiUrl: 'https://studio-api.paystack.co/',
6417
6416
  pusherKey: '1c7b262ee18455815893',
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/'
6417
+ pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
6420
6418
  });
6421
6419
  var productionConfig = _objectSpread2(_objectSpread2({}, config), {}, {
6422
6420
  checkoutUrl: 'https://checkout.paystack.com/',
@@ -18379,7 +18377,7 @@ var Card$2 = {
18379
18377
  return Card$2.validateCVV(cvv, cardType).isValid;
18380
18378
  },
18381
18379
  validateExpiry: function validateExpiry(value) {
18382
- if (_typeof$1(value) === 'object') {
18380
+ if (value !== null && _typeof$1(value) === 'object') {
18383
18381
  var month = value.month,
18384
18382
  year = value.year;
18385
18383
  return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
@@ -18670,209 +18668,6 @@ var CardAPI$1 = {
18670
18668
  }).then(function (response) {
18671
18669
  return ChargeResponses.parse(response.data);
18672
18670
  });
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, email, 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, email = _ref7.email, 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
- email: email,
18757
- transaction: transaction
18758
- };
18759
- _context3.next = 7;
18760
- return axiosInstance.post(url, data, {
18761
- headers: headers
18762
- });
18763
-
18764
- case 7:
18765
- response = _context3.sent;
18766
- return _context3.abrupt("return", response.data);
18767
-
18768
- case 9:
18769
- case "end":
18770
- return _context3.stop();
18771
- }
18772
- }
18773
- }, _callee3);
18774
- }))();
18775
- },
18776
- getSavedCards: function getSavedCards(_ref8) {
18777
- return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
18778
- var token, url, language, headers, response;
18779
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
18780
- while (1) {
18781
- switch (_context4.prev = _context4.next) {
18782
- case 0:
18783
- token = _ref8.token;
18784
- url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
18785
- language = getLanguage();
18786
- headers = _objectSpread2({
18787
- Authorization: "Bearer ".concat(token),
18788
- 'jwt-auth': true
18789
- }, language && {
18790
- 'Accept-Language': language
18791
- });
18792
- _context4.next = 6;
18793
- return axiosInstance.get(url, {
18794
- headers: headers
18795
- });
18796
-
18797
- case 6:
18798
- response = _context4.sent;
18799
- return _context4.abrupt("return", response.data);
18800
-
18801
- case 8:
18802
- case "end":
18803
- return _context4.stop();
18804
- }
18805
- }
18806
- }, _callee4);
18807
- }))();
18808
- },
18809
- deleteSavedCard: function deleteSavedCard(_ref9) {
18810
- return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
18811
- var cardCode, token, url, language, headers, response;
18812
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
18813
- while (1) {
18814
- switch (_context5.prev = _context5.next) {
18815
- case 0:
18816
- cardCode = _ref9.cardCode, token = _ref9.token;
18817
- url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
18818
- language = getLanguage();
18819
- headers = _objectSpread2({
18820
- Authorization: "Bearer ".concat(token),
18821
- 'jwt-auth': true
18822
- }, language && {
18823
- 'Accept-Language': language
18824
- });
18825
- _context5.next = 6;
18826
- return axiosInstance.delete(url, {
18827
- headers: headers
18828
- });
18829
-
18830
- case 6:
18831
- response = _context5.sent;
18832
- return _context5.abrupt("return", response.data);
18833
-
18834
- case 8:
18835
- case "end":
18836
- return _context5.stop();
18837
- }
18838
- }
18839
- }, _callee5);
18840
- }))();
18841
- },
18842
- chargeSavedCard: function chargeSavedCard(_ref10) {
18843
- return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
18844
- var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data;
18845
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
18846
- while (1) {
18847
- switch (_context6.prev = _context6.next) {
18848
- case 0:
18849
- token = _ref10.token, device = _ref10.device, cardCode = _ref10.cardCode, transaction = _ref10.transaction, selectedCurrency = _ref10.selectedCurrency;
18850
- url = new URL("/cards/".concat(cardCode, "/charge"), configToUse.savedCardsApiUrl).toString();
18851
- language = getLanguage();
18852
- headers = _objectSpread2({
18853
- Authorization: "Bearer ".concat(token),
18854
- 'jwt-auth': true
18855
- }, language && {
18856
- 'Accept-Language': language
18857
- });
18858
- data = {
18859
- device: device,
18860
- transaction: transaction,
18861
- selectedCurrency: selectedCurrency
18862
- };
18863
- return _context6.abrupt("return", axiosInstance.post(url, data, {
18864
- headers: headers
18865
- }).then(function (response) {
18866
- return ChargeResponses.parse(response.data);
18867
- }));
18868
-
18869
- case 6:
18870
- case "end":
18871
- return _context6.stop();
18872
- }
18873
- }
18874
- }, _callee6);
18875
- }))();
18876
18671
  }
18877
18672
  };
18878
18673
 
@@ -19053,75 +18848,6 @@ var CardCharge = {
19053
18848
  paymentMethod: paymentMethod$4
19054
18849
  };
19055
18850
  return this.listenForCharge(listenerOptions, callback);
19056
- },
19057
- sendSavedCardsOTP: function sendSavedCardsOTP() {
19058
- return CardAPI$1.sendSavedCardsOTP(this.email);
19059
- },
19060
- addUserToSavedCards: function addUserToSavedCards(_ref4) {
19061
- var phone = _ref4.phone;
19062
- return CardAPI$1.addUserToSavedCards({
19063
- phone: phone,
19064
- email: this.email
19065
- });
19066
- },
19067
- verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
19068
- var _this9 = this;
19069
-
19070
- return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
19071
- var code, payload, response;
19072
- return regeneratorRuntime.wrap(function _callee$(_context) {
19073
- while (1) {
19074
- switch (_context.prev = _context.next) {
19075
- case 0:
19076
- code = _ref5.code;
19077
- payload = {
19078
- code: code,
19079
- email: _this9.email,
19080
- transaction: _this9.id
19081
- };
19082
- _context.prev = 2;
19083
- _context.next = 5;
19084
- return CardAPI$1.verifySavedCardsOtp(payload);
19085
-
19086
- case 5:
19087
- response = _context.sent;
19088
- _this9.savedCardsToken = response.data.token;
19089
- return _context.abrupt("return", response);
19090
-
19091
- case 10:
19092
- _context.prev = 10;
19093
- _context.t0 = _context["catch"](2);
19094
- _this9.savedCardsToken = null;
19095
- throw _context.t0;
19096
-
19097
- case 14:
19098
- case "end":
19099
- return _context.stop();
19100
- }
19101
- }
19102
- }, _callee, null, [[2, 10]]);
19103
- }))();
19104
- },
19105
- getSavedCards: function getSavedCards() {
19106
- return CardAPI$1.getSavedCards({
19107
- token: this.savedCardsToken
19108
- });
19109
- },
19110
- deleteSavedCard: function deleteSavedCard(cardCode) {
19111
- return CardAPI$1.deleteSavedCard({
19112
- cardCode: cardCode,
19113
- token: this.savedCardsToken
19114
- });
19115
- },
19116
- chargeSavedCard: function chargeSavedCard(_ref6) {
19117
- var cardCode = _ref6.cardCode;
19118
- return CardAPI$1.chargeSavedCard({
19119
- cardCode: cardCode,
19120
- transaction: this.id,
19121
- token: this.savedCardsToken,
19122
- device: this.deviceFingerprint,
19123
- selectedCurrency: this.currency
19124
- });
19125
18851
  }
19126
18852
  };
19127
18853
 
@@ -20450,8 +20176,6 @@ var TransactionInstance = /*#__PURE__*/function () {
20450
20176
  this.subscription = data.subscription || null;
20451
20177
  this.planDetails = data.plan_details || null;
20452
20178
  this.exchangeRate = data.exchange_rate || null;
20453
- this.savedCardsConfig = data.saved_cards || {};
20454
- this.savedCardsToken = null;
20455
20179
  /**
20456
20180
  * We initialize parameters we send to the API as empty strings
20457
20181
  * when we don't have them instead of null because the API expects
@@ -20889,7 +20613,7 @@ var Card = /*#__PURE__*/function () {
20889
20613
  }();
20890
20614
 
20891
20615
  var CardAPI = {
20892
- reserve: function reserve(_ref) {
20616
+ reserveFunds: function reserveFunds(_ref) {
20893
20617
  var clientdata = _ref.clientdata,
20894
20618
  last4 = _ref.last4,
20895
20619
  preauthorizationId = _ref.preauthorizationId,
@@ -20934,7 +20658,7 @@ function validate(card, isSetter) {
20934
20658
  });
20935
20659
  }
20936
20660
 
20937
- var ReserveCardFunds = {
20661
+ var CardPreauthorization = {
20938
20662
  setCard: function setCard(params) {
20939
20663
  var _this = this;
20940
20664
 
@@ -20942,7 +20666,7 @@ var ReserveCardFunds = {
20942
20666
  _this.card = new Card(params);
20943
20667
  });
20944
20668
  },
20945
- reserve: function reserve(_ref) {
20669
+ reserveFunds: function reserveFunds(_ref) {
20946
20670
  var _this2 = this;
20947
20671
 
20948
20672
  var preauthorizationId = _ref.preauthorizationId,
@@ -20959,7 +20683,7 @@ var ReserveCardFunds = {
20959
20683
  publicKey: publicKey,
20960
20684
  customFields: customFields
20961
20685
  };
20962
- return CardAPI.reserve(chargeParams).then(function (response) {
20686
+ return CardAPI.reserveFunds(chargeParams).then(function (response) {
20963
20687
  // TODO: Log API Response
20964
20688
  // https://paystack.atlassian.net/browse/RAILS-3070
20965
20689
  return response;
@@ -20999,7 +20723,7 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
20999
20723
  loadPusher(); // TODO: Analytics
21000
20724
  // https://paystack.atlassian.net/browse/RAILS-3070
21001
20725
 
21002
- Object.assign(this, ReserveCardFunds);
20726
+ Object.assign(this, CardPreauthorization);
21003
20727
  }
21004
20728
 
21005
20729
  _createClass(PreauthorizationInstance, [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/checkout-js",
3
- "version": "1.20.0-dev.9",
3
+ "version": "1.20.1",
4
4
  "description": "Client-side JS library for billing on Paystack",
5
5
  "main": "lib/checkout.js",
6
6
  "module": "es/checkout.js",