@paystack/checkout-js 1.28.0-dev.1 → 1.28.0-dev.10

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/README.md CHANGED
@@ -48,6 +48,6 @@ Checkout JS is deployed to three environments:
48
48
 
49
49
  Checkout JS is automatically packaged and published to the NPM registry on every push to the `master` and `dev` branches.
50
50
 
51
- The `master` branch is publised under the `latest` tag so it can be installed by running `npm i @paystack/checkout-js@latest` while the `dev` branch is published under the `dev` tag so it can be installed using `npm i @paystack/checkout-js@dev`
51
+ The `master` branch is publised under the `latest` tag that can be installed by running `npm i @paystack/checkout-js@latest` while the `dev` branch is published under the `dev` tag so it can be installed using `npm i @paystack/checkout-js@dev`
52
52
 
53
53
  All published versions are listed here on NPM https://www.npmjs.com/package/@paystack/checkout-js
package/dist/checkout.js CHANGED
@@ -11552,6 +11552,17 @@ var Paystack = (function (exports) {
11552
11552
  }).then(function (response) {
11553
11553
  return response.data;
11554
11554
  });
11555
+ },
11556
+ initializeCustomerAuthorization: function initializeCustomerAuthorization(params, publicKey) {
11557
+ var headers = {
11558
+ Authorization: "Bearer ".concat(publicKey)
11559
+ };
11560
+ var url = new URL('/customer/authorization/initialize', configToUse.paystackApiUrl).toString();
11561
+ return axiosInstance.post(url, params, {
11562
+ headers: headers
11563
+ }).then(function (response) {
11564
+ return response.data;
11565
+ });
11555
11566
  }
11556
11567
  };
11557
11568
 
@@ -19116,7 +19127,7 @@ var Paystack = (function (exports) {
19116
19127
  };
19117
19128
  return this.listenForCharge(listenerOptions, callback);
19118
19129
  },
19119
- sendSavedCardsOTP: function sendSavedCardsOTP(phone) {
19130
+ sendSavedCardsOTP: function sendSavedCardsOTP(phone, channels) {
19120
19131
  var _this9 = this;
19121
19132
 
19122
19133
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
@@ -19132,7 +19143,8 @@ var Paystack = (function (exports) {
19132
19143
  _context.next = 4;
19133
19144
  return CardAPI$1.sendSavedCardsOTP({
19134
19145
  phone: phone,
19135
- transaction: _this9.id
19146
+ transaction: _this9.id,
19147
+ channels: channels
19136
19148
  });
19137
19149
 
19138
19150
  case 4:
@@ -19487,13 +19499,12 @@ var Paystack = (function (exports) {
19487
19499
  'Accept-Language': language
19488
19500
  });
19489
19501
 
19490
- var params = _objectSpread2({}, walletId ? {
19502
+ var params = walletId ? {
19491
19503
  wallet_id: walletId
19492
19504
  } : {
19493
19505
  phone_number: phoneNumber,
19494
19506
  token: payId
19495
- });
19496
-
19507
+ };
19497
19508
  var urlEncodedParams = formUrlencoded(params);
19498
19509
  return axiosInstance.post(url, urlEncodedParams, {
19499
19510
  headers: headers
@@ -20702,6 +20713,13 @@ var Paystack = (function (exports) {
20702
20713
  return response && response.data;
20703
20714
  });
20704
20715
  }
20716
+ }, {
20717
+ key: "initializeCustomerAuthorization",
20718
+ value: function initializeCustomerAuthorization(payload) {
20719
+ return TransactionAPI.initializeCustomerAuthorization(payload, this.merchant.key).then(function (response) {
20720
+ return response && response.data;
20721
+ });
20722
+ }
20705
20723
  }]);
20706
20724
 
20707
20725
  return TransactionInstance;
@@ -21189,7 +21207,7 @@ var Paystack = (function (exports) {
21189
21207
  }
21190
21208
  };
21191
21209
 
21192
- var PreauthorisationAPI = {
21210
+ var PreauthorizationAPI = {
21193
21211
  getByAccessCode: function getByAccessCode(accessCode) {
21194
21212
  var language = getLanguage();
21195
21213
 
@@ -21307,9 +21325,11 @@ var Paystack = (function (exports) {
21307
21325
  return this.saveLog();
21308
21326
  },
21309
21327
  logAPIResponse: function logAPIResponse(response, channel) {
21328
+ console.log('api response', response);
21329
+
21310
21330
  switch (response.status) {
21311
- case 'success':
21312
- return this.logSuccess(channel);
21331
+ case 'authorized':
21332
+ return this.logAuthorized(channel);
21313
21333
 
21314
21334
  case 'failed':
21315
21335
  return this.logError(response.message);
@@ -21353,8 +21373,8 @@ var Paystack = (function (exports) {
21353
21373
  });
21354
21374
  return this.saveLog();
21355
21375
  },
21356
- logSuccess: function logSuccess(channel) {
21357
- var message = 'Successfully preauthorised funds';
21376
+ logAuthorized: function logAuthorized(channel) {
21377
+ var message = 'Successfully preauthorized funds';
21358
21378
 
21359
21379
  if (channel) {
21360
21380
  message += " with ".concat(channel);
@@ -21362,7 +21382,7 @@ var Paystack = (function (exports) {
21362
21382
 
21363
21383
  this.log.success = true;
21364
21384
  this.log.history.push({
21365
- type: 'success',
21385
+ type: 'authorized',
21366
21386
  message: message,
21367
21387
  time: this.getTimeSpent()
21368
21388
  });
@@ -21399,6 +21419,8 @@ var Paystack = (function (exports) {
21399
21419
  }
21400
21420
  };
21401
21421
 
21422
+ var PAYMENT_METHOD = 'card';
21423
+
21402
21424
  var PreauthorizationInstance = /*#__PURE__*/function () {
21403
21425
  function PreauthorizationInstance(data) {
21404
21426
  _classCallCheck(this, PreauthorizationInstance);
@@ -21438,9 +21460,15 @@ var Paystack = (function (exports) {
21438
21460
  }, {
21439
21461
  key: "requery",
21440
21462
  value: function requery() {
21441
- return PreauthorisationAPI.requery({
21463
+ var _this = this;
21464
+
21465
+ return PreauthorizationAPI.requery({
21442
21466
  reference: this.reference,
21443
21467
  publicKey: this.merchant.key
21468
+ }).then(function (response) {
21469
+ _this.logAPIResponse(response, PAYMENT_METHOD);
21470
+
21471
+ return response;
21444
21472
  });
21445
21473
  }
21446
21474
  }, {
@@ -21470,7 +21498,7 @@ var Paystack = (function (exports) {
21470
21498
  case 2:
21471
21499
  deviceFingerprint = _context.sent;
21472
21500
  _context.next = 5;
21473
- return PreauthorisationAPI.getByAccessCode(accessCode);
21501
+ return PreauthorizationAPI.getByAccessCode(accessCode);
21474
21502
 
21475
21503
  case 5:
21476
21504
  response = _context.sent;
package/es/checkout.js CHANGED
@@ -11549,6 +11549,17 @@ var TransactionAPI = {
11549
11549
  }).then(function (response) {
11550
11550
  return response.data;
11551
11551
  });
11552
+ },
11553
+ initializeCustomerAuthorization: function initializeCustomerAuthorization(params, publicKey) {
11554
+ var headers = {
11555
+ Authorization: "Bearer ".concat(publicKey)
11556
+ };
11557
+ var url = new URL('/customer/authorization/initialize', configToUse.paystackApiUrl).toString();
11558
+ return axiosInstance.post(url, params, {
11559
+ headers: headers
11560
+ }).then(function (response) {
11561
+ return response.data;
11562
+ });
11552
11563
  }
11553
11564
  };
11554
11565
 
@@ -19113,7 +19124,7 @@ var CardCharge = {
19113
19124
  };
19114
19125
  return this.listenForCharge(listenerOptions, callback);
19115
19126
  },
19116
- sendSavedCardsOTP: function sendSavedCardsOTP(phone) {
19127
+ sendSavedCardsOTP: function sendSavedCardsOTP(phone, channels) {
19117
19128
  var _this9 = this;
19118
19129
 
19119
19130
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
@@ -19129,7 +19140,8 @@ var CardCharge = {
19129
19140
  _context.next = 4;
19130
19141
  return CardAPI$1.sendSavedCardsOTP({
19131
19142
  phone: phone,
19132
- transaction: _this9.id
19143
+ transaction: _this9.id,
19144
+ channels: channels
19133
19145
  });
19134
19146
 
19135
19147
  case 4:
@@ -19484,13 +19496,12 @@ var DigitalBankMandateAPI = {
19484
19496
  'Accept-Language': language
19485
19497
  });
19486
19498
 
19487
- var params = _objectSpread2({}, walletId ? {
19499
+ var params = walletId ? {
19488
19500
  wallet_id: walletId
19489
19501
  } : {
19490
19502
  phone_number: phoneNumber,
19491
19503
  token: payId
19492
- });
19493
-
19504
+ };
19494
19505
  var urlEncodedParams = formUrlencoded(params);
19495
19506
  return axiosInstance.post(url, urlEncodedParams, {
19496
19507
  headers: headers
@@ -20699,6 +20710,13 @@ var TransactionInstance = /*#__PURE__*/function () {
20699
20710
  return response && response.data;
20700
20711
  });
20701
20712
  }
20713
+ }, {
20714
+ key: "initializeCustomerAuthorization",
20715
+ value: function initializeCustomerAuthorization(payload) {
20716
+ return TransactionAPI.initializeCustomerAuthorization(payload, this.merchant.key).then(function (response) {
20717
+ return response && response.data;
20718
+ });
20719
+ }
20702
20720
  }]);
20703
20721
 
20704
20722
  return TransactionInstance;
@@ -21186,7 +21204,7 @@ var CardPreauthorization = {
21186
21204
  }
21187
21205
  };
21188
21206
 
21189
- var PreauthorisationAPI = {
21207
+ var PreauthorizationAPI = {
21190
21208
  getByAccessCode: function getByAccessCode(accessCode) {
21191
21209
  var language = getLanguage();
21192
21210
 
@@ -21304,9 +21322,11 @@ var AnalyticsFunctions = {
21304
21322
  return this.saveLog();
21305
21323
  },
21306
21324
  logAPIResponse: function logAPIResponse(response, channel) {
21325
+ console.log('api response', response);
21326
+
21307
21327
  switch (response.status) {
21308
- case 'success':
21309
- return this.logSuccess(channel);
21328
+ case 'authorized':
21329
+ return this.logAuthorized(channel);
21310
21330
 
21311
21331
  case 'failed':
21312
21332
  return this.logError(response.message);
@@ -21350,8 +21370,8 @@ var AnalyticsFunctions = {
21350
21370
  });
21351
21371
  return this.saveLog();
21352
21372
  },
21353
- logSuccess: function logSuccess(channel) {
21354
- var message = 'Successfully preauthorised funds';
21373
+ logAuthorized: function logAuthorized(channel) {
21374
+ var message = 'Successfully preauthorized funds';
21355
21375
 
21356
21376
  if (channel) {
21357
21377
  message += " with ".concat(channel);
@@ -21359,7 +21379,7 @@ var AnalyticsFunctions = {
21359
21379
 
21360
21380
  this.log.success = true;
21361
21381
  this.log.history.push({
21362
- type: 'success',
21382
+ type: 'authorized',
21363
21383
  message: message,
21364
21384
  time: this.getTimeSpent()
21365
21385
  });
@@ -21396,6 +21416,8 @@ var AnalyticsFunctions = {
21396
21416
  }
21397
21417
  };
21398
21418
 
21419
+ var PAYMENT_METHOD = 'card';
21420
+
21399
21421
  var PreauthorizationInstance = /*#__PURE__*/function () {
21400
21422
  function PreauthorizationInstance(data) {
21401
21423
  _classCallCheck(this, PreauthorizationInstance);
@@ -21435,9 +21457,15 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
21435
21457
  }, {
21436
21458
  key: "requery",
21437
21459
  value: function requery() {
21438
- return PreauthorisationAPI.requery({
21460
+ var _this = this;
21461
+
21462
+ return PreauthorizationAPI.requery({
21439
21463
  reference: this.reference,
21440
21464
  publicKey: this.merchant.key
21465
+ }).then(function (response) {
21466
+ _this.logAPIResponse(response, PAYMENT_METHOD);
21467
+
21468
+ return response;
21441
21469
  });
21442
21470
  }
21443
21471
  }, {
@@ -21467,7 +21495,7 @@ var Preauthorization = {
21467
21495
  case 2:
21468
21496
  deviceFingerprint = _context.sent;
21469
21497
  _context.next = 5;
21470
- return PreauthorisationAPI.getByAccessCode(accessCode);
21498
+ return PreauthorizationAPI.getByAccessCode(accessCode);
21471
21499
 
21472
21500
  case 5:
21473
21501
  response = _context.sent;
package/lib/checkout.js CHANGED
@@ -11553,6 +11553,17 @@ var TransactionAPI = {
11553
11553
  }).then(function (response) {
11554
11554
  return response.data;
11555
11555
  });
11556
+ },
11557
+ initializeCustomerAuthorization: function initializeCustomerAuthorization(params, publicKey) {
11558
+ var headers = {
11559
+ Authorization: "Bearer ".concat(publicKey)
11560
+ };
11561
+ var url = new URL('/customer/authorization/initialize', configToUse.paystackApiUrl).toString();
11562
+ return axiosInstance.post(url, params, {
11563
+ headers: headers
11564
+ }).then(function (response) {
11565
+ return response.data;
11566
+ });
11556
11567
  }
11557
11568
  };
11558
11569
 
@@ -19117,7 +19128,7 @@ var CardCharge = {
19117
19128
  };
19118
19129
  return this.listenForCharge(listenerOptions, callback);
19119
19130
  },
19120
- sendSavedCardsOTP: function sendSavedCardsOTP(phone) {
19131
+ sendSavedCardsOTP: function sendSavedCardsOTP(phone, channels) {
19121
19132
  var _this9 = this;
19122
19133
 
19123
19134
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
@@ -19133,7 +19144,8 @@ var CardCharge = {
19133
19144
  _context.next = 4;
19134
19145
  return CardAPI$1.sendSavedCardsOTP({
19135
19146
  phone: phone,
19136
- transaction: _this9.id
19147
+ transaction: _this9.id,
19148
+ channels: channels
19137
19149
  });
19138
19150
 
19139
19151
  case 4:
@@ -19488,13 +19500,12 @@ var DigitalBankMandateAPI = {
19488
19500
  'Accept-Language': language
19489
19501
  });
19490
19502
 
19491
- var params = _objectSpread2({}, walletId ? {
19503
+ var params = walletId ? {
19492
19504
  wallet_id: walletId
19493
19505
  } : {
19494
19506
  phone_number: phoneNumber,
19495
19507
  token: payId
19496
- });
19497
-
19508
+ };
19498
19509
  var urlEncodedParams = formUrlencoded(params);
19499
19510
  return axiosInstance.post(url, urlEncodedParams, {
19500
19511
  headers: headers
@@ -20703,6 +20714,13 @@ var TransactionInstance = /*#__PURE__*/function () {
20703
20714
  return response && response.data;
20704
20715
  });
20705
20716
  }
20717
+ }, {
20718
+ key: "initializeCustomerAuthorization",
20719
+ value: function initializeCustomerAuthorization(payload) {
20720
+ return TransactionAPI.initializeCustomerAuthorization(payload, this.merchant.key).then(function (response) {
20721
+ return response && response.data;
20722
+ });
20723
+ }
20706
20724
  }]);
20707
20725
 
20708
20726
  return TransactionInstance;
@@ -21190,7 +21208,7 @@ var CardPreauthorization = {
21190
21208
  }
21191
21209
  };
21192
21210
 
21193
- var PreauthorisationAPI = {
21211
+ var PreauthorizationAPI = {
21194
21212
  getByAccessCode: function getByAccessCode(accessCode) {
21195
21213
  var language = getLanguage();
21196
21214
 
@@ -21308,9 +21326,11 @@ var AnalyticsFunctions = {
21308
21326
  return this.saveLog();
21309
21327
  },
21310
21328
  logAPIResponse: function logAPIResponse(response, channel) {
21329
+ console.log('api response', response);
21330
+
21311
21331
  switch (response.status) {
21312
- case 'success':
21313
- return this.logSuccess(channel);
21332
+ case 'authorized':
21333
+ return this.logAuthorized(channel);
21314
21334
 
21315
21335
  case 'failed':
21316
21336
  return this.logError(response.message);
@@ -21354,8 +21374,8 @@ var AnalyticsFunctions = {
21354
21374
  });
21355
21375
  return this.saveLog();
21356
21376
  },
21357
- logSuccess: function logSuccess(channel) {
21358
- var message = 'Successfully preauthorised funds';
21377
+ logAuthorized: function logAuthorized(channel) {
21378
+ var message = 'Successfully preauthorized funds';
21359
21379
 
21360
21380
  if (channel) {
21361
21381
  message += " with ".concat(channel);
@@ -21363,7 +21383,7 @@ var AnalyticsFunctions = {
21363
21383
 
21364
21384
  this.log.success = true;
21365
21385
  this.log.history.push({
21366
- type: 'success',
21386
+ type: 'authorized',
21367
21387
  message: message,
21368
21388
  time: this.getTimeSpent()
21369
21389
  });
@@ -21400,6 +21420,8 @@ var AnalyticsFunctions = {
21400
21420
  }
21401
21421
  };
21402
21422
 
21423
+ var PAYMENT_METHOD = 'card';
21424
+
21403
21425
  var PreauthorizationInstance = /*#__PURE__*/function () {
21404
21426
  function PreauthorizationInstance(data) {
21405
21427
  _classCallCheck(this, PreauthorizationInstance);
@@ -21439,9 +21461,15 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
21439
21461
  }, {
21440
21462
  key: "requery",
21441
21463
  value: function requery() {
21442
- return PreauthorisationAPI.requery({
21464
+ var _this = this;
21465
+
21466
+ return PreauthorizationAPI.requery({
21443
21467
  reference: this.reference,
21444
21468
  publicKey: this.merchant.key
21469
+ }).then(function (response) {
21470
+ _this.logAPIResponse(response, PAYMENT_METHOD);
21471
+
21472
+ return response;
21445
21473
  });
21446
21474
  }
21447
21475
  }, {
@@ -21471,7 +21499,7 @@ var Preauthorization = {
21471
21499
  case 2:
21472
21500
  deviceFingerprint = _context.sent;
21473
21501
  _context.next = 5;
21474
- return PreauthorisationAPI.getByAccessCode(accessCode);
21502
+ return PreauthorizationAPI.getByAccessCode(accessCode);
21475
21503
 
21476
21504
  case 5:
21477
21505
  response = _context.sent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/checkout-js",
3
- "version": "1.28.0-dev.1",
3
+ "version": "1.28.0-dev.10",
4
4
  "description": "Client-side JS library for billing on Paystack",
5
5
  "main": "lib/checkout.js",
6
6
  "module": "es/checkout.js",