@paystack/checkout-js 1.19.0-dev.16 → 1.19.0-dev.17

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 CHANGED
@@ -20694,8 +20694,130 @@ var Paystack = (function (exports) {
20694
20694
  return Toolkit;
20695
20695
  }();
20696
20696
 
20697
+ var PreauthorizationInstance = /*#__PURE__*/function () {
20698
+ function PreauthorizationInstance(data) {
20699
+ _classCallCheck(this, PreauthorizationInstance);
20700
+
20701
+ this.email = data.email;
20702
+ this.status = data.status;
20703
+ this.reference = data.reference;
20704
+ this.amount = data.amount;
20705
+ this.currency = data.currency;
20706
+ this.metadata = data.metadata || {};
20707
+ this.customer = data.customer;
20708
+ this.channels = data.channels || ['card'];
20709
+ this.deviceFingerprint = data.deviceFingerprint || null;
20710
+ this.isListening = false;
20711
+ loadPusher();
20712
+ /**
20713
+ * We initialize parameters we send to the API as empty strings
20714
+ * when we don't have them instead of null because the API expects
20715
+ * these parameters as URL params which means parameters are eventually converted to strings
20716
+ */
20717
+ // TODO: Bind charge function to card channel
20718
+ // https://paystack.atlassian.net/browse/RAILS-2887
20719
+ }
20720
+
20721
+ _createClass(PreauthorizationInstance, [{
20722
+ key: "setMetadata",
20723
+ value: function setMetadata(key, value) {
20724
+ this.metadata[key] = value;
20725
+ }
20726
+ }, {
20727
+ key: "setDevice",
20728
+ value: function setDevice(uuid) {
20729
+ if (this.deviceFingerprint) {
20730
+ logMessage("Device ID has already been set by Checkout JS so there's no need to set this again");
20731
+ } else {
20732
+ this.deviceFingerprint = uuid;
20733
+ }
20734
+ } // eslint-disable-next-line consistent-return
20735
+
20736
+ }, {
20737
+ key: "listenForCharge",
20738
+ value: function listenForCharge(options, callback) {
20739
+ return subscribeToChargeEvents(options, this, callback);
20740
+ }
20741
+ }]);
20742
+
20743
+ return PreauthorizationInstance;
20744
+ }();
20745
+
20746
+ var PreauthorisationAPI = {
20747
+ getByAccessCode: function getByAccessCode(accessCode) {
20748
+ var language = getLanguage();
20749
+
20750
+ var headers = _objectSpread2({}, language && {
20751
+ 'Accept-Language': language
20752
+ });
20753
+
20754
+ var url = "".concat(configToUse.paystackApiUrl, "preauthorization/verify_access_code/").concat(accessCode);
20755
+ return axiosInstance.post(url, {
20756
+ headers: headers
20757
+ }).then(function (response) {
20758
+ return response.data;
20759
+ });
20760
+ },
20761
+ verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
20762
+ },
20763
+ requery: function requery() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
20764
+ },
20765
+ reserveFunds: function reserveFunds() {// TODO: https://paystack.atlassian.net/browse/RAILS-2887
20766
+ }
20767
+ };
20768
+
20769
+ var Preauthorization = {
20770
+ initialize: function initialize(data) {
20771
+ return Object.seal(new PreauthorizationInstance(data));
20772
+ },
20773
+ getByAccessCode: function getByAccessCode(accessCode) {
20774
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
20775
+ var deviceFingerprint, response;
20776
+ return regeneratorRuntime.wrap(function _callee$(_context) {
20777
+ while (1) {
20778
+ switch (_context.prev = _context.next) {
20779
+ case 0:
20780
+ _context.next = 2;
20781
+ return getDeviceFingerprint();
20782
+
20783
+ case 2:
20784
+ deviceFingerprint = _context.sent;
20785
+ _context.next = 5;
20786
+ return PreauthorisationAPI.getByAccessCode(accessCode);
20787
+
20788
+ case 5:
20789
+ response = _context.sent;
20790
+ return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2(_objectSpread2({}, response.data), {
20791
+ deviceFingerprint: deviceFingerprint
20792
+ }))));
20793
+
20794
+ case 7:
20795
+ case "end":
20796
+ return _context.stop();
20797
+ }
20798
+ }
20799
+ }, _callee);
20800
+ }))();
20801
+ },
20802
+ verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
20803
+
20804
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
20805
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
20806
+ while (1) {
20807
+ switch (_context2.prev = _context2.next) {
20808
+ case 0:
20809
+ case "end":
20810
+ return _context2.stop();
20811
+ }
20812
+ }
20813
+ }, _callee2);
20814
+ }))();
20815
+ }
20816
+ };
20817
+
20697
20818
  exports.BankAccount = BankAccount;
20698
20819
  exports.Card = Card;
20820
+ exports.Preauthorization = Preauthorization;
20699
20821
  exports.Toolkit = Toolkit;
20700
20822
  exports.Transaction = Transaction;
20701
20823
 
package/es/checkout.js CHANGED
@@ -20691,4 +20691,125 @@ var Toolkit = /*#__PURE__*/function () {
20691
20691
  return Toolkit;
20692
20692
  }();
20693
20693
 
20694
- export { BankAccount, Card, Toolkit, Transaction };
20694
+ var PreauthorizationInstance = /*#__PURE__*/function () {
20695
+ function PreauthorizationInstance(data) {
20696
+ _classCallCheck(this, PreauthorizationInstance);
20697
+
20698
+ this.email = data.email;
20699
+ this.status = data.status;
20700
+ this.reference = data.reference;
20701
+ this.amount = data.amount;
20702
+ this.currency = data.currency;
20703
+ this.metadata = data.metadata || {};
20704
+ this.customer = data.customer;
20705
+ this.channels = data.channels || ['card'];
20706
+ this.deviceFingerprint = data.deviceFingerprint || null;
20707
+ this.isListening = false;
20708
+ loadPusher();
20709
+ /**
20710
+ * We initialize parameters we send to the API as empty strings
20711
+ * when we don't have them instead of null because the API expects
20712
+ * these parameters as URL params which means parameters are eventually converted to strings
20713
+ */
20714
+ // TODO: Bind charge function to card channel
20715
+ // https://paystack.atlassian.net/browse/RAILS-2887
20716
+ }
20717
+
20718
+ _createClass(PreauthorizationInstance, [{
20719
+ key: "setMetadata",
20720
+ value: function setMetadata(key, value) {
20721
+ this.metadata[key] = value;
20722
+ }
20723
+ }, {
20724
+ key: "setDevice",
20725
+ value: function setDevice(uuid) {
20726
+ if (this.deviceFingerprint) {
20727
+ logMessage("Device ID has already been set by Checkout JS so there's no need to set this again");
20728
+ } else {
20729
+ this.deviceFingerprint = uuid;
20730
+ }
20731
+ } // eslint-disable-next-line consistent-return
20732
+
20733
+ }, {
20734
+ key: "listenForCharge",
20735
+ value: function listenForCharge(options, callback) {
20736
+ return subscribeToChargeEvents(options, this, callback);
20737
+ }
20738
+ }]);
20739
+
20740
+ return PreauthorizationInstance;
20741
+ }();
20742
+
20743
+ var PreauthorisationAPI = {
20744
+ getByAccessCode: function getByAccessCode(accessCode) {
20745
+ var language = getLanguage();
20746
+
20747
+ var headers = _objectSpread2({}, language && {
20748
+ 'Accept-Language': language
20749
+ });
20750
+
20751
+ var url = "".concat(configToUse.paystackApiUrl, "preauthorization/verify_access_code/").concat(accessCode);
20752
+ return axiosInstance.post(url, {
20753
+ headers: headers
20754
+ }).then(function (response) {
20755
+ return response.data;
20756
+ });
20757
+ },
20758
+ verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
20759
+ },
20760
+ requery: function requery() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
20761
+ },
20762
+ reserveFunds: function reserveFunds() {// TODO: https://paystack.atlassian.net/browse/RAILS-2887
20763
+ }
20764
+ };
20765
+
20766
+ var Preauthorization = {
20767
+ initialize: function initialize(data) {
20768
+ return Object.seal(new PreauthorizationInstance(data));
20769
+ },
20770
+ getByAccessCode: function getByAccessCode(accessCode) {
20771
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
20772
+ var deviceFingerprint, response;
20773
+ return regeneratorRuntime.wrap(function _callee$(_context) {
20774
+ while (1) {
20775
+ switch (_context.prev = _context.next) {
20776
+ case 0:
20777
+ _context.next = 2;
20778
+ return getDeviceFingerprint();
20779
+
20780
+ case 2:
20781
+ deviceFingerprint = _context.sent;
20782
+ _context.next = 5;
20783
+ return PreauthorisationAPI.getByAccessCode(accessCode);
20784
+
20785
+ case 5:
20786
+ response = _context.sent;
20787
+ return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2(_objectSpread2({}, response.data), {
20788
+ deviceFingerprint: deviceFingerprint
20789
+ }))));
20790
+
20791
+ case 7:
20792
+ case "end":
20793
+ return _context.stop();
20794
+ }
20795
+ }
20796
+ }, _callee);
20797
+ }))();
20798
+ },
20799
+ verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
20800
+
20801
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
20802
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
20803
+ while (1) {
20804
+ switch (_context2.prev = _context2.next) {
20805
+ case 0:
20806
+ case "end":
20807
+ return _context2.stop();
20808
+ }
20809
+ }
20810
+ }, _callee2);
20811
+ }))();
20812
+ }
20813
+ };
20814
+
20815
+ export { BankAccount, Card, Preauthorization, Toolkit, Transaction };
package/lib/checkout.js CHANGED
@@ -20695,7 +20695,129 @@ var Toolkit = /*#__PURE__*/function () {
20695
20695
  return Toolkit;
20696
20696
  }();
20697
20697
 
20698
+ var PreauthorizationInstance = /*#__PURE__*/function () {
20699
+ function PreauthorizationInstance(data) {
20700
+ _classCallCheck(this, PreauthorizationInstance);
20701
+
20702
+ this.email = data.email;
20703
+ this.status = data.status;
20704
+ this.reference = data.reference;
20705
+ this.amount = data.amount;
20706
+ this.currency = data.currency;
20707
+ this.metadata = data.metadata || {};
20708
+ this.customer = data.customer;
20709
+ this.channels = data.channels || ['card'];
20710
+ this.deviceFingerprint = data.deviceFingerprint || null;
20711
+ this.isListening = false;
20712
+ loadPusher();
20713
+ /**
20714
+ * We initialize parameters we send to the API as empty strings
20715
+ * when we don't have them instead of null because the API expects
20716
+ * these parameters as URL params which means parameters are eventually converted to strings
20717
+ */
20718
+ // TODO: Bind charge function to card channel
20719
+ // https://paystack.atlassian.net/browse/RAILS-2887
20720
+ }
20721
+
20722
+ _createClass(PreauthorizationInstance, [{
20723
+ key: "setMetadata",
20724
+ value: function setMetadata(key, value) {
20725
+ this.metadata[key] = value;
20726
+ }
20727
+ }, {
20728
+ key: "setDevice",
20729
+ value: function setDevice(uuid) {
20730
+ if (this.deviceFingerprint) {
20731
+ logMessage("Device ID has already been set by Checkout JS so there's no need to set this again");
20732
+ } else {
20733
+ this.deviceFingerprint = uuid;
20734
+ }
20735
+ } // eslint-disable-next-line consistent-return
20736
+
20737
+ }, {
20738
+ key: "listenForCharge",
20739
+ value: function listenForCharge(options, callback) {
20740
+ return subscribeToChargeEvents(options, this, callback);
20741
+ }
20742
+ }]);
20743
+
20744
+ return PreauthorizationInstance;
20745
+ }();
20746
+
20747
+ var PreauthorisationAPI = {
20748
+ getByAccessCode: function getByAccessCode(accessCode) {
20749
+ var language = getLanguage();
20750
+
20751
+ var headers = _objectSpread2({}, language && {
20752
+ 'Accept-Language': language
20753
+ });
20754
+
20755
+ var url = "".concat(configToUse.paystackApiUrl, "preauthorization/verify_access_code/").concat(accessCode);
20756
+ return axiosInstance.post(url, {
20757
+ headers: headers
20758
+ }).then(function (response) {
20759
+ return response.data;
20760
+ });
20761
+ },
20762
+ verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
20763
+ },
20764
+ requery: function requery() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
20765
+ },
20766
+ reserveFunds: function reserveFunds() {// TODO: https://paystack.atlassian.net/browse/RAILS-2887
20767
+ }
20768
+ };
20769
+
20770
+ var Preauthorization = {
20771
+ initialize: function initialize(data) {
20772
+ return Object.seal(new PreauthorizationInstance(data));
20773
+ },
20774
+ getByAccessCode: function getByAccessCode(accessCode) {
20775
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
20776
+ var deviceFingerprint, response;
20777
+ return regeneratorRuntime.wrap(function _callee$(_context) {
20778
+ while (1) {
20779
+ switch (_context.prev = _context.next) {
20780
+ case 0:
20781
+ _context.next = 2;
20782
+ return getDeviceFingerprint();
20783
+
20784
+ case 2:
20785
+ deviceFingerprint = _context.sent;
20786
+ _context.next = 5;
20787
+ return PreauthorisationAPI.getByAccessCode(accessCode);
20788
+
20789
+ case 5:
20790
+ response = _context.sent;
20791
+ return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2(_objectSpread2({}, response.data), {
20792
+ deviceFingerprint: deviceFingerprint
20793
+ }))));
20794
+
20795
+ case 7:
20796
+ case "end":
20797
+ return _context.stop();
20798
+ }
20799
+ }
20800
+ }, _callee);
20801
+ }))();
20802
+ },
20803
+ verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
20804
+
20805
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
20806
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
20807
+ while (1) {
20808
+ switch (_context2.prev = _context2.next) {
20809
+ case 0:
20810
+ case "end":
20811
+ return _context2.stop();
20812
+ }
20813
+ }
20814
+ }, _callee2);
20815
+ }))();
20816
+ }
20817
+ };
20818
+
20698
20819
  exports.BankAccount = BankAccount;
20699
20820
  exports.Card = Card;
20821
+ exports.Preauthorization = Preauthorization;
20700
20822
  exports.Toolkit = Toolkit;
20701
20823
  exports.Transaction = Transaction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/checkout-js",
3
- "version": "1.19.0-dev.16",
3
+ "version": "1.19.0-dev.17",
4
4
  "description": "Client-side JS library for billing on Paystack",
5
5
  "main": "lib/checkout.js",
6
6
  "module": "es/checkout.js",