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

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