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

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/es/checkout.js CHANGED
@@ -6430,37 +6430,6 @@ var configToEnvironmentMapping = {
6430
6430
  };
6431
6431
  var configToUse = configToEnvironmentMapping[env.paystackEnvironment] || productionConfig;
6432
6432
 
6433
- /* eslint-env browser */
6434
- // We use this function to load pusher.
6435
-
6436
- function loadPusher() {
6437
- if (!window) {
6438
- return Promise.reject(new Error('Window object not available'));
6439
- }
6440
-
6441
- return new Promise(function (resolve, reject) {
6442
- var xhr = new XMLHttpRequest();
6443
- xhr.open('GET', configToUse.pusherUrl);
6444
-
6445
- xhr.onload = function () {
6446
- if (xhr.status >= 200 && xhr.status < 300) {
6447
- var s = document.createElement('script');
6448
- s.appendChild(document.createTextNode(xhr.responseText));
6449
- document.head.appendChild(s);
6450
- resolve();
6451
- } else {
6452
- reject(xhr.statusText);
6453
- }
6454
- };
6455
-
6456
- xhr.onerror = function () {
6457
- return reject(xhr.statusText);
6458
- };
6459
-
6460
- xhr.send(null);
6461
- });
6462
- }
6463
-
6464
6433
  var noOp = function noOp() {
6465
6434
  return undefined;
6466
6435
  };
@@ -6634,6 +6603,83 @@ var ChargeResponses = {
6634
6603
  }
6635
6604
  };
6636
6605
 
6606
+ /* eslint-env browser */
6607
+ // We use this function to load pusher.
6608
+
6609
+ var loadPusher = function loadPusher() {
6610
+ if (!window) {
6611
+ return Promise.reject(new Error('Window object not available'));
6612
+ }
6613
+
6614
+ return new Promise(function (resolve, reject) {
6615
+ var xhr = new XMLHttpRequest();
6616
+ xhr.open('GET', configToUse.pusherUrl);
6617
+
6618
+ xhr.onload = function () {
6619
+ if (xhr.status >= 200 && xhr.status < 300) {
6620
+ var s = document.createElement('script');
6621
+ s.appendChild(document.createTextNode(xhr.responseText));
6622
+ document.head.appendChild(s);
6623
+ resolve();
6624
+ } else {
6625
+ reject(xhr.statusText);
6626
+ }
6627
+ };
6628
+
6629
+ xhr.onerror = function () {
6630
+ return reject(xhr.statusText);
6631
+ };
6632
+
6633
+ xhr.send(null);
6634
+ });
6635
+ }; // `context` is passed through to set the class property of `isListening` to true/false
6636
+ // and provide the logAPIResponse analytics function
6637
+ // eslint-disable-next-line consistent-return
6638
+
6639
+ var subscribeToChargeEvents = function subscribeToChargeEvents(options, context, callback) {
6640
+ var channel = options.channel,
6641
+ paymentMethod = options.paymentMethod;
6642
+ var pusher;
6643
+
6644
+ if (window && window.Pusher) {
6645
+ pusher = new window.Pusher(configToUse.pusherKey, {
6646
+ cluster: 'eu',
6647
+ disableStats: true
6648
+ });
6649
+ }
6650
+
6651
+ var pusherUndefinedError = {
6652
+ status: 'error',
6653
+ message: 'We could not listen for charge response.'
6654
+ };
6655
+ var pusherSubscriptionError = {
6656
+ status: 'error',
6657
+ message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
6658
+ };
6659
+
6660
+ var unsubscribeFromPusher = function unsubscribeFromPusher() {
6661
+ pusher.unsubscribe(channel);
6662
+ };
6663
+
6664
+ if (!pusher) {
6665
+ return callback(pusherUndefinedError, noOp);
6666
+ }
6667
+
6668
+ var pusherSubscription = pusher.subscribe(channel);
6669
+ pusherSubscription.bind('pusher:subscription_succeeded', function () {
6670
+ context.isListening = true;
6671
+ });
6672
+ pusherSubscription.bind('pusher:subscription_error', function () {
6673
+ context.isListening = false;
6674
+ callback(pusherSubscriptionError, noOp);
6675
+ });
6676
+ pusherSubscription.bind('response', function (response) {
6677
+ var formattedResponse = ChargeResponses.parse(response);
6678
+ context.logAPIResponse(formattedResponse, paymentMethod);
6679
+ callback(formattedResponse, unsubscribeFromPusher);
6680
+ });
6681
+ };
6682
+
6637
6683
  var uncurryThis$6 = functionUncurryThis;
6638
6684
  var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
6639
6685
  var redefine$4 = redefine$a.exports;
@@ -18567,7 +18613,7 @@ var CardAPI = {
18567
18613
  return ChargeResponses.parse(response.data);
18568
18614
  });
18569
18615
  },
18570
- requestOtpForSavedCards: function requestOtpForSavedCards(phoneNumber) {
18616
+ requestSavedCardsOTP: function requestSavedCardsOTP(phoneNumber) {
18571
18617
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
18572
18618
  var url, language, headers, _yield$axiosInstance$, data;
18573
18619
 
@@ -18914,8 +18960,8 @@ var CardCharge = {
18914
18960
  };
18915
18961
  return this.listenForCharge(listenerOptions, callback);
18916
18962
  },
18917
- requestOtpForSavedCards: function requestOtpForSavedCards(phoneNumber) {
18918
- return CardAPI.requestOtpForSavedCards(phoneNumber);
18963
+ requestSavedCardsOTP: function requestSavedCardsOTP(phoneNumber) {
18964
+ return CardAPI.requestSavedCardsOTP(phoneNumber);
18919
18965
  },
18920
18966
  verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
18921
18967
  var _this9 = this;
@@ -20347,51 +20393,7 @@ var TransactionInstance = /*#__PURE__*/function () {
20347
20393
  }, {
20348
20394
  key: "listenForCharge",
20349
20395
  value: function listenForCharge(options, callback) {
20350
- var _this2 = this;
20351
-
20352
- var channel = options.channel,
20353
- paymentMethod = options.paymentMethod;
20354
- var pusher;
20355
-
20356
- if (window && window.Pusher) {
20357
- pusher = new window.Pusher(configToUse.pusherKey, {
20358
- cluster: 'eu',
20359
- disableStats: true
20360
- });
20361
- }
20362
-
20363
- var pusherUndefinedError = {
20364
- status: 'error',
20365
- message: 'We could not listen for charge response.'
20366
- };
20367
- var pusherSubscriptionError = {
20368
- status: 'error',
20369
- message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
20370
- };
20371
-
20372
- var unsubscribeFromPusher = function unsubscribeFromPusher() {
20373
- pusher.unsubscribe(channel);
20374
- };
20375
-
20376
- if (!pusher) {
20377
- return callback(pusherUndefinedError, noOp);
20378
- }
20379
-
20380
- var pusherSubscription = pusher.subscribe(channel);
20381
- pusherSubscription.bind('pusher:subscription_succeeded', function () {
20382
- _this2.isListening = true;
20383
- });
20384
- pusherSubscription.bind('pusher:subscription_error', function () {
20385
- _this2.isListening = false;
20386
- callback(pusherSubscriptionError, noOp);
20387
- });
20388
- pusherSubscription.bind('response', function (response) {
20389
- var formattedResponse = ChargeResponses.parse(response);
20390
-
20391
- _this2.logAPIResponse(formattedResponse, paymentMethod);
20392
-
20393
- callback(formattedResponse, unsubscribeFromPusher);
20394
- });
20396
+ return subscribeToChargeEvents(options, this, callback);
20395
20397
  }
20396
20398
  }, {
20397
20399
  key: "requery",
package/lib/checkout.js CHANGED
@@ -6434,37 +6434,6 @@ var configToEnvironmentMapping = {
6434
6434
  };
6435
6435
  var configToUse = configToEnvironmentMapping[env.paystackEnvironment] || productionConfig;
6436
6436
 
6437
- /* eslint-env browser */
6438
- // We use this function to load pusher.
6439
-
6440
- function loadPusher() {
6441
- if (!window) {
6442
- return Promise.reject(new Error('Window object not available'));
6443
- }
6444
-
6445
- return new Promise(function (resolve, reject) {
6446
- var xhr = new XMLHttpRequest();
6447
- xhr.open('GET', configToUse.pusherUrl);
6448
-
6449
- xhr.onload = function () {
6450
- if (xhr.status >= 200 && xhr.status < 300) {
6451
- var s = document.createElement('script');
6452
- s.appendChild(document.createTextNode(xhr.responseText));
6453
- document.head.appendChild(s);
6454
- resolve();
6455
- } else {
6456
- reject(xhr.statusText);
6457
- }
6458
- };
6459
-
6460
- xhr.onerror = function () {
6461
- return reject(xhr.statusText);
6462
- };
6463
-
6464
- xhr.send(null);
6465
- });
6466
- }
6467
-
6468
6437
  var noOp = function noOp() {
6469
6438
  return undefined;
6470
6439
  };
@@ -6638,6 +6607,83 @@ var ChargeResponses = {
6638
6607
  }
6639
6608
  };
6640
6609
 
6610
+ /* eslint-env browser */
6611
+ // We use this function to load pusher.
6612
+
6613
+ var loadPusher = function loadPusher() {
6614
+ if (!window) {
6615
+ return Promise.reject(new Error('Window object not available'));
6616
+ }
6617
+
6618
+ return new Promise(function (resolve, reject) {
6619
+ var xhr = new XMLHttpRequest();
6620
+ xhr.open('GET', configToUse.pusherUrl);
6621
+
6622
+ xhr.onload = function () {
6623
+ if (xhr.status >= 200 && xhr.status < 300) {
6624
+ var s = document.createElement('script');
6625
+ s.appendChild(document.createTextNode(xhr.responseText));
6626
+ document.head.appendChild(s);
6627
+ resolve();
6628
+ } else {
6629
+ reject(xhr.statusText);
6630
+ }
6631
+ };
6632
+
6633
+ xhr.onerror = function () {
6634
+ return reject(xhr.statusText);
6635
+ };
6636
+
6637
+ xhr.send(null);
6638
+ });
6639
+ }; // `context` is passed through to set the class property of `isListening` to true/false
6640
+ // and provide the logAPIResponse analytics function
6641
+ // eslint-disable-next-line consistent-return
6642
+
6643
+ var subscribeToChargeEvents = function subscribeToChargeEvents(options, context, callback) {
6644
+ var channel = options.channel,
6645
+ paymentMethod = options.paymentMethod;
6646
+ var pusher;
6647
+
6648
+ if (window && window.Pusher) {
6649
+ pusher = new window.Pusher(configToUse.pusherKey, {
6650
+ cluster: 'eu',
6651
+ disableStats: true
6652
+ });
6653
+ }
6654
+
6655
+ var pusherUndefinedError = {
6656
+ status: 'error',
6657
+ message: 'We could not listen for charge response.'
6658
+ };
6659
+ var pusherSubscriptionError = {
6660
+ status: 'error',
6661
+ message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
6662
+ };
6663
+
6664
+ var unsubscribeFromPusher = function unsubscribeFromPusher() {
6665
+ pusher.unsubscribe(channel);
6666
+ };
6667
+
6668
+ if (!pusher) {
6669
+ return callback(pusherUndefinedError, noOp);
6670
+ }
6671
+
6672
+ var pusherSubscription = pusher.subscribe(channel);
6673
+ pusherSubscription.bind('pusher:subscription_succeeded', function () {
6674
+ context.isListening = true;
6675
+ });
6676
+ pusherSubscription.bind('pusher:subscription_error', function () {
6677
+ context.isListening = false;
6678
+ callback(pusherSubscriptionError, noOp);
6679
+ });
6680
+ pusherSubscription.bind('response', function (response) {
6681
+ var formattedResponse = ChargeResponses.parse(response);
6682
+ context.logAPIResponse(formattedResponse, paymentMethod);
6683
+ callback(formattedResponse, unsubscribeFromPusher);
6684
+ });
6685
+ };
6686
+
6641
6687
  var uncurryThis$6 = functionUncurryThis;
6642
6688
  var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
6643
6689
  var redefine$4 = redefine$a.exports;
@@ -18571,7 +18617,7 @@ var CardAPI = {
18571
18617
  return ChargeResponses.parse(response.data);
18572
18618
  });
18573
18619
  },
18574
- requestOtpForSavedCards: function requestOtpForSavedCards(phoneNumber) {
18620
+ requestSavedCardsOTP: function requestSavedCardsOTP(phoneNumber) {
18575
18621
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
18576
18622
  var url, language, headers, _yield$axiosInstance$, data;
18577
18623
 
@@ -18918,8 +18964,8 @@ var CardCharge = {
18918
18964
  };
18919
18965
  return this.listenForCharge(listenerOptions, callback);
18920
18966
  },
18921
- requestOtpForSavedCards: function requestOtpForSavedCards(phoneNumber) {
18922
- return CardAPI.requestOtpForSavedCards(phoneNumber);
18967
+ requestSavedCardsOTP: function requestSavedCardsOTP(phoneNumber) {
18968
+ return CardAPI.requestSavedCardsOTP(phoneNumber);
18923
18969
  },
18924
18970
  verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
18925
18971
  var _this9 = this;
@@ -20351,51 +20397,7 @@ var TransactionInstance = /*#__PURE__*/function () {
20351
20397
  }, {
20352
20398
  key: "listenForCharge",
20353
20399
  value: function listenForCharge(options, callback) {
20354
- var _this2 = this;
20355
-
20356
- var channel = options.channel,
20357
- paymentMethod = options.paymentMethod;
20358
- var pusher;
20359
-
20360
- if (window && window.Pusher) {
20361
- pusher = new window.Pusher(configToUse.pusherKey, {
20362
- cluster: 'eu',
20363
- disableStats: true
20364
- });
20365
- }
20366
-
20367
- var pusherUndefinedError = {
20368
- status: 'error',
20369
- message: 'We could not listen for charge response.'
20370
- };
20371
- var pusherSubscriptionError = {
20372
- status: 'error',
20373
- message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
20374
- };
20375
-
20376
- var unsubscribeFromPusher = function unsubscribeFromPusher() {
20377
- pusher.unsubscribe(channel);
20378
- };
20379
-
20380
- if (!pusher) {
20381
- return callback(pusherUndefinedError, noOp);
20382
- }
20383
-
20384
- var pusherSubscription = pusher.subscribe(channel);
20385
- pusherSubscription.bind('pusher:subscription_succeeded', function () {
20386
- _this2.isListening = true;
20387
- });
20388
- pusherSubscription.bind('pusher:subscription_error', function () {
20389
- _this2.isListening = false;
20390
- callback(pusherSubscriptionError, noOp);
20391
- });
20392
- pusherSubscription.bind('response', function (response) {
20393
- var formattedResponse = ChargeResponses.parse(response);
20394
-
20395
- _this2.logAPIResponse(formattedResponse, paymentMethod);
20396
-
20397
- callback(formattedResponse, unsubscribeFromPusher);
20398
- });
20400
+ return subscribeToChargeEvents(options, this, callback);
20399
20401
  }
20400
20402
  }, {
20401
20403
  key: "requery",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/checkout-js",
3
- "version": "1.19.0-dev.14",
3
+ "version": "1.19.0-dev.16",
4
4
  "description": "Client-side JS library for billing on Paystack",
5
5
  "main": "lib/checkout.js",
6
6
  "module": "es/checkout.js",
@@ -74,9 +74,9 @@
74
74
  "build:cjs": "cross-env NODE_ENV=cjs rollup --config rollup.config.js -o lib/checkout.js",
75
75
  "build:es": "cross-env NODE_ENV=es rollup --config rollup.config.js -o es/checkout.js",
76
76
  "build:dist": "rollup --config rollup.config.js -o dist/checkout.js",
77
- "build": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=production npm run build:dist",
77
+ "build:prod": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=production npm run build:dist",
78
78
  "dev": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=dev npm run build:dist",
79
- "staging": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=staging npm run build:dist",
79
+ "build:staging": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=staging npm run build:dist",
80
80
  "test": "jest",
81
81
  "semantic-release": "semantic-release"
82
82
  },