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

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 and can be installed by running `npm i @paystack/checkout-js@latest` while the `dev` branch is published under the `dev` tag and 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
 
@@ -18757,21 +18768,23 @@ var Paystack = (function (exports) {
18757
18768
  },
18758
18769
  sendSavedCardsOTP: function sendSavedCardsOTP(_ref6) {
18759
18770
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
18760
- var transaction, phone, channels, url, language, headers, data, response;
18771
+ var transaction, phone, channels, email, url, language, headers, data, response;
18761
18772
  return regeneratorRuntime.wrap(function _callee$(_context) {
18762
18773
  while (1) {
18763
18774
  switch (_context.prev = _context.next) {
18764
18775
  case 0:
18765
- transaction = _ref6.transaction, phone = _ref6.phone, channels = _ref6.channels;
18776
+ transaction = _ref6.transaction, phone = _ref6.phone, channels = _ref6.channels, email = _ref6.email;
18766
18777
  url = new URL('/saved_cards/authorize', configToUse.paystackApiUrl).toString();
18767
18778
  language = getLanguage();
18768
18779
  headers = _objectSpread2({}, language && {
18769
18780
  'Accept-Language': language
18770
18781
  });
18771
- data = _objectSpread2(_objectSpread2(_objectSpread2({}, phone && {
18782
+ data = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, phone && {
18772
18783
  phone: phone
18773
18784
  }), channels && {
18774
18785
  channels: channels
18786
+ }), email && {
18787
+ email: email
18775
18788
  }), {}, {
18776
18789
  transaction: transaction
18777
18790
  });
@@ -19116,45 +19129,48 @@ var Paystack = (function (exports) {
19116
19129
  };
19117
19130
  return this.listenForCharge(listenerOptions, callback);
19118
19131
  },
19119
- sendSavedCardsOTP: function sendSavedCardsOTP(phone) {
19132
+ sendSavedCardsOTP: function sendSavedCardsOTP(_ref4) {
19120
19133
  var _this9 = this;
19121
19134
 
19122
19135
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
19123
- var response;
19136
+ var phone, channels, email, response;
19124
19137
  return regeneratorRuntime.wrap(function _callee$(_context) {
19125
19138
  while (1) {
19126
19139
  switch (_context.prev = _context.next) {
19127
19140
  case 0:
19128
- _context.prev = 0;
19141
+ phone = _ref4.phone, channels = _ref4.channels, email = _ref4.email;
19142
+ _context.prev = 1;
19129
19143
 
19130
19144
  _this9.logAuth(savedCardMethods.authentication);
19131
19145
 
19132
- _context.next = 4;
19146
+ _context.next = 5;
19133
19147
  return CardAPI$1.sendSavedCardsOTP({
19134
19148
  phone: phone,
19135
- transaction: _this9.id
19149
+ transaction: _this9.id,
19150
+ channels: channels,
19151
+ email: email
19136
19152
  });
19137
19153
 
19138
- case 4:
19154
+ case 5:
19139
19155
  response = _context.sent;
19140
19156
  _this9.savedCardsTempAuthToken = response.data.token;
19141
19157
  return _context.abrupt("return", response);
19142
19158
 
19143
- case 9:
19144
- _context.prev = 9;
19145
- _context.t0 = _context["catch"](0);
19159
+ case 10:
19160
+ _context.prev = 10;
19161
+ _context.t0 = _context["catch"](1);
19146
19162
  _this9.savedCardsTempAuthToken = null;
19147
19163
  throw _context.t0;
19148
19164
 
19149
- case 13:
19165
+ case 14:
19150
19166
  case "end":
19151
19167
  return _context.stop();
19152
19168
  }
19153
19169
  }
19154
- }, _callee, null, [[0, 9]]);
19170
+ }, _callee, null, [[1, 10]]);
19155
19171
  }))();
19156
19172
  },
19157
- verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
19173
+ verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
19158
19174
  var _this10 = this;
19159
19175
 
19160
19176
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
@@ -19163,7 +19179,7 @@ var Paystack = (function (exports) {
19163
19179
  while (1) {
19164
19180
  switch (_context2.prev = _context2.next) {
19165
19181
  case 0:
19166
- code = _ref4.code;
19182
+ code = _ref5.code;
19167
19183
  payload = {
19168
19184
  code: code,
19169
19185
  transaction: _this10.id,
@@ -19203,10 +19219,10 @@ var Paystack = (function (exports) {
19203
19219
  token: this.savedCardsToken
19204
19220
  });
19205
19221
  },
19206
- chargeSavedCard: function chargeSavedCard(_ref5) {
19207
- var cardCode = _ref5.cardCode,
19208
- _ref5$selectedCurrenc = _ref5.selectedCurrency,
19209
- selectedCurrency = _ref5$selectedCurrenc === void 0 ? this.currency : _ref5$selectedCurrenc;
19222
+ chargeSavedCard: function chargeSavedCard(_ref6) {
19223
+ var cardCode = _ref6.cardCode,
19224
+ _ref6$selectedCurrenc = _ref6.selectedCurrency,
19225
+ selectedCurrency = _ref6$selectedCurrenc === void 0 ? this.currency : _ref6$selectedCurrenc;
19210
19226
  this.logAttempt(savedCardMethods.payment);
19211
19227
  return CardAPI$1.chargeSavedCard({
19212
19228
  cardCode: cardCode,
@@ -19487,13 +19503,12 @@ var Paystack = (function (exports) {
19487
19503
  'Accept-Language': language
19488
19504
  });
19489
19505
 
19490
- var params = _objectSpread2({}, walletId ? {
19506
+ var params = walletId ? {
19491
19507
  wallet_id: walletId
19492
19508
  } : {
19493
19509
  phone_number: phoneNumber,
19494
19510
  token: payId
19495
- });
19496
-
19511
+ };
19497
19512
  var urlEncodedParams = formUrlencoded(params);
19498
19513
  return axiosInstance.post(url, urlEncodedParams, {
19499
19514
  headers: headers
@@ -20702,6 +20717,13 @@ var Paystack = (function (exports) {
20702
20717
  return response && response.data;
20703
20718
  });
20704
20719
  }
20720
+ }, {
20721
+ key: "initializeCustomerAuthorization",
20722
+ value: function initializeCustomerAuthorization(payload) {
20723
+ return TransactionAPI.initializeCustomerAuthorization(payload, this.merchant.key).then(function (response) {
20724
+ return response && response.data;
20725
+ });
20726
+ }
20705
20727
  }]);
20706
20728
 
20707
20729
  return TransactionInstance;
@@ -21189,7 +21211,7 @@ var Paystack = (function (exports) {
21189
21211
  }
21190
21212
  };
21191
21213
 
21192
- var PreauthorisationAPI = {
21214
+ var PreauthorizationAPI = {
21193
21215
  getByAccessCode: function getByAccessCode(accessCode) {
21194
21216
  var language = getLanguage();
21195
21217
 
@@ -21307,9 +21329,11 @@ var Paystack = (function (exports) {
21307
21329
  return this.saveLog();
21308
21330
  },
21309
21331
  logAPIResponse: function logAPIResponse(response, channel) {
21332
+ console.log('api response', response);
21333
+
21310
21334
  switch (response.status) {
21311
- case 'success':
21312
- return this.logSuccess(channel);
21335
+ case 'authorized':
21336
+ return this.logAuthorized(channel);
21313
21337
 
21314
21338
  case 'failed':
21315
21339
  return this.logError(response.message);
@@ -21353,8 +21377,8 @@ var Paystack = (function (exports) {
21353
21377
  });
21354
21378
  return this.saveLog();
21355
21379
  },
21356
- logSuccess: function logSuccess(channel) {
21357
- var message = 'Successfully preauthorised funds';
21380
+ logAuthorized: function logAuthorized(channel) {
21381
+ var message = 'Successfully preauthorized funds';
21358
21382
 
21359
21383
  if (channel) {
21360
21384
  message += " with ".concat(channel);
@@ -21362,7 +21386,7 @@ var Paystack = (function (exports) {
21362
21386
 
21363
21387
  this.log.success = true;
21364
21388
  this.log.history.push({
21365
- type: 'success',
21389
+ type: 'authorized',
21366
21390
  message: message,
21367
21391
  time: this.getTimeSpent()
21368
21392
  });
@@ -21399,6 +21423,8 @@ var Paystack = (function (exports) {
21399
21423
  }
21400
21424
  };
21401
21425
 
21426
+ var PAYMENT_METHOD = 'card';
21427
+
21402
21428
  var PreauthorizationInstance = /*#__PURE__*/function () {
21403
21429
  function PreauthorizationInstance(data) {
21404
21430
  _classCallCheck(this, PreauthorizationInstance);
@@ -21438,9 +21464,15 @@ var Paystack = (function (exports) {
21438
21464
  }, {
21439
21465
  key: "requery",
21440
21466
  value: function requery() {
21441
- return PreauthorisationAPI.requery({
21467
+ var _this = this;
21468
+
21469
+ return PreauthorizationAPI.requery({
21442
21470
  reference: this.reference,
21443
21471
  publicKey: this.merchant.key
21472
+ }).then(function (response) {
21473
+ _this.logAPIResponse(response, PAYMENT_METHOD);
21474
+
21475
+ return response;
21444
21476
  });
21445
21477
  }
21446
21478
  }, {
@@ -21470,7 +21502,7 @@ var Paystack = (function (exports) {
21470
21502
  case 2:
21471
21503
  deviceFingerprint = _context.sent;
21472
21504
  _context.next = 5;
21473
- return PreauthorisationAPI.getByAccessCode(accessCode);
21505
+ return PreauthorizationAPI.getByAccessCode(accessCode);
21474
21506
 
21475
21507
  case 5:
21476
21508
  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
 
@@ -18754,21 +18765,23 @@ var CardAPI$1 = {
18754
18765
  },
18755
18766
  sendSavedCardsOTP: function sendSavedCardsOTP(_ref6) {
18756
18767
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
18757
- var transaction, phone, channels, url, language, headers, data, response;
18768
+ var transaction, phone, channels, email, url, language, headers, data, response;
18758
18769
  return regeneratorRuntime.wrap(function _callee$(_context) {
18759
18770
  while (1) {
18760
18771
  switch (_context.prev = _context.next) {
18761
18772
  case 0:
18762
- transaction = _ref6.transaction, phone = _ref6.phone, channels = _ref6.channels;
18773
+ transaction = _ref6.transaction, phone = _ref6.phone, channels = _ref6.channels, email = _ref6.email;
18763
18774
  url = new URL('/saved_cards/authorize', configToUse.paystackApiUrl).toString();
18764
18775
  language = getLanguage();
18765
18776
  headers = _objectSpread2({}, language && {
18766
18777
  'Accept-Language': language
18767
18778
  });
18768
- data = _objectSpread2(_objectSpread2(_objectSpread2({}, phone && {
18779
+ data = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, phone && {
18769
18780
  phone: phone
18770
18781
  }), channels && {
18771
18782
  channels: channels
18783
+ }), email && {
18784
+ email: email
18772
18785
  }), {}, {
18773
18786
  transaction: transaction
18774
18787
  });
@@ -19113,45 +19126,48 @@ var CardCharge = {
19113
19126
  };
19114
19127
  return this.listenForCharge(listenerOptions, callback);
19115
19128
  },
19116
- sendSavedCardsOTP: function sendSavedCardsOTP(phone) {
19129
+ sendSavedCardsOTP: function sendSavedCardsOTP(_ref4) {
19117
19130
  var _this9 = this;
19118
19131
 
19119
19132
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
19120
- var response;
19133
+ var phone, channels, email, response;
19121
19134
  return regeneratorRuntime.wrap(function _callee$(_context) {
19122
19135
  while (1) {
19123
19136
  switch (_context.prev = _context.next) {
19124
19137
  case 0:
19125
- _context.prev = 0;
19138
+ phone = _ref4.phone, channels = _ref4.channels, email = _ref4.email;
19139
+ _context.prev = 1;
19126
19140
 
19127
19141
  _this9.logAuth(savedCardMethods.authentication);
19128
19142
 
19129
- _context.next = 4;
19143
+ _context.next = 5;
19130
19144
  return CardAPI$1.sendSavedCardsOTP({
19131
19145
  phone: phone,
19132
- transaction: _this9.id
19146
+ transaction: _this9.id,
19147
+ channels: channels,
19148
+ email: email
19133
19149
  });
19134
19150
 
19135
- case 4:
19151
+ case 5:
19136
19152
  response = _context.sent;
19137
19153
  _this9.savedCardsTempAuthToken = response.data.token;
19138
19154
  return _context.abrupt("return", response);
19139
19155
 
19140
- case 9:
19141
- _context.prev = 9;
19142
- _context.t0 = _context["catch"](0);
19156
+ case 10:
19157
+ _context.prev = 10;
19158
+ _context.t0 = _context["catch"](1);
19143
19159
  _this9.savedCardsTempAuthToken = null;
19144
19160
  throw _context.t0;
19145
19161
 
19146
- case 13:
19162
+ case 14:
19147
19163
  case "end":
19148
19164
  return _context.stop();
19149
19165
  }
19150
19166
  }
19151
- }, _callee, null, [[0, 9]]);
19167
+ }, _callee, null, [[1, 10]]);
19152
19168
  }))();
19153
19169
  },
19154
- verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
19170
+ verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
19155
19171
  var _this10 = this;
19156
19172
 
19157
19173
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
@@ -19160,7 +19176,7 @@ var CardCharge = {
19160
19176
  while (1) {
19161
19177
  switch (_context2.prev = _context2.next) {
19162
19178
  case 0:
19163
- code = _ref4.code;
19179
+ code = _ref5.code;
19164
19180
  payload = {
19165
19181
  code: code,
19166
19182
  transaction: _this10.id,
@@ -19200,10 +19216,10 @@ var CardCharge = {
19200
19216
  token: this.savedCardsToken
19201
19217
  });
19202
19218
  },
19203
- chargeSavedCard: function chargeSavedCard(_ref5) {
19204
- var cardCode = _ref5.cardCode,
19205
- _ref5$selectedCurrenc = _ref5.selectedCurrency,
19206
- selectedCurrency = _ref5$selectedCurrenc === void 0 ? this.currency : _ref5$selectedCurrenc;
19219
+ chargeSavedCard: function chargeSavedCard(_ref6) {
19220
+ var cardCode = _ref6.cardCode,
19221
+ _ref6$selectedCurrenc = _ref6.selectedCurrency,
19222
+ selectedCurrency = _ref6$selectedCurrenc === void 0 ? this.currency : _ref6$selectedCurrenc;
19207
19223
  this.logAttempt(savedCardMethods.payment);
19208
19224
  return CardAPI$1.chargeSavedCard({
19209
19225
  cardCode: cardCode,
@@ -19484,13 +19500,12 @@ var DigitalBankMandateAPI = {
19484
19500
  'Accept-Language': language
19485
19501
  });
19486
19502
 
19487
- var params = _objectSpread2({}, walletId ? {
19503
+ var params = walletId ? {
19488
19504
  wallet_id: walletId
19489
19505
  } : {
19490
19506
  phone_number: phoneNumber,
19491
19507
  token: payId
19492
- });
19493
-
19508
+ };
19494
19509
  var urlEncodedParams = formUrlencoded(params);
19495
19510
  return axiosInstance.post(url, urlEncodedParams, {
19496
19511
  headers: headers
@@ -20699,6 +20714,13 @@ var TransactionInstance = /*#__PURE__*/function () {
20699
20714
  return response && response.data;
20700
20715
  });
20701
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
+ }
20702
20724
  }]);
20703
20725
 
20704
20726
  return TransactionInstance;
@@ -21186,7 +21208,7 @@ var CardPreauthorization = {
21186
21208
  }
21187
21209
  };
21188
21210
 
21189
- var PreauthorisationAPI = {
21211
+ var PreauthorizationAPI = {
21190
21212
  getByAccessCode: function getByAccessCode(accessCode) {
21191
21213
  var language = getLanguage();
21192
21214
 
@@ -21304,9 +21326,11 @@ var AnalyticsFunctions = {
21304
21326
  return this.saveLog();
21305
21327
  },
21306
21328
  logAPIResponse: function logAPIResponse(response, channel) {
21329
+ console.log('api response', response);
21330
+
21307
21331
  switch (response.status) {
21308
- case 'success':
21309
- return this.logSuccess(channel);
21332
+ case 'authorized':
21333
+ return this.logAuthorized(channel);
21310
21334
 
21311
21335
  case 'failed':
21312
21336
  return this.logError(response.message);
@@ -21350,8 +21374,8 @@ var AnalyticsFunctions = {
21350
21374
  });
21351
21375
  return this.saveLog();
21352
21376
  },
21353
- logSuccess: function logSuccess(channel) {
21354
- var message = 'Successfully preauthorised funds';
21377
+ logAuthorized: function logAuthorized(channel) {
21378
+ var message = 'Successfully preauthorized funds';
21355
21379
 
21356
21380
  if (channel) {
21357
21381
  message += " with ".concat(channel);
@@ -21359,7 +21383,7 @@ var AnalyticsFunctions = {
21359
21383
 
21360
21384
  this.log.success = true;
21361
21385
  this.log.history.push({
21362
- type: 'success',
21386
+ type: 'authorized',
21363
21387
  message: message,
21364
21388
  time: this.getTimeSpent()
21365
21389
  });
@@ -21396,6 +21420,8 @@ var AnalyticsFunctions = {
21396
21420
  }
21397
21421
  };
21398
21422
 
21423
+ var PAYMENT_METHOD = 'card';
21424
+
21399
21425
  var PreauthorizationInstance = /*#__PURE__*/function () {
21400
21426
  function PreauthorizationInstance(data) {
21401
21427
  _classCallCheck(this, PreauthorizationInstance);
@@ -21435,9 +21461,15 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
21435
21461
  }, {
21436
21462
  key: "requery",
21437
21463
  value: function requery() {
21438
- return PreauthorisationAPI.requery({
21464
+ var _this = this;
21465
+
21466
+ return PreauthorizationAPI.requery({
21439
21467
  reference: this.reference,
21440
21468
  publicKey: this.merchant.key
21469
+ }).then(function (response) {
21470
+ _this.logAPIResponse(response, PAYMENT_METHOD);
21471
+
21472
+ return response;
21441
21473
  });
21442
21474
  }
21443
21475
  }, {
@@ -21467,7 +21499,7 @@ var Preauthorization = {
21467
21499
  case 2:
21468
21500
  deviceFingerprint = _context.sent;
21469
21501
  _context.next = 5;
21470
- return PreauthorisationAPI.getByAccessCode(accessCode);
21502
+ return PreauthorizationAPI.getByAccessCode(accessCode);
21471
21503
 
21472
21504
  case 5:
21473
21505
  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
 
@@ -18758,21 +18769,23 @@ var CardAPI$1 = {
18758
18769
  },
18759
18770
  sendSavedCardsOTP: function sendSavedCardsOTP(_ref6) {
18760
18771
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
18761
- var transaction, phone, channels, url, language, headers, data, response;
18772
+ var transaction, phone, channels, email, url, language, headers, data, response;
18762
18773
  return regeneratorRuntime.wrap(function _callee$(_context) {
18763
18774
  while (1) {
18764
18775
  switch (_context.prev = _context.next) {
18765
18776
  case 0:
18766
- transaction = _ref6.transaction, phone = _ref6.phone, channels = _ref6.channels;
18777
+ transaction = _ref6.transaction, phone = _ref6.phone, channels = _ref6.channels, email = _ref6.email;
18767
18778
  url = new URL('/saved_cards/authorize', configToUse.paystackApiUrl).toString();
18768
18779
  language = getLanguage();
18769
18780
  headers = _objectSpread2({}, language && {
18770
18781
  'Accept-Language': language
18771
18782
  });
18772
- data = _objectSpread2(_objectSpread2(_objectSpread2({}, phone && {
18783
+ data = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, phone && {
18773
18784
  phone: phone
18774
18785
  }), channels && {
18775
18786
  channels: channels
18787
+ }), email && {
18788
+ email: email
18776
18789
  }), {}, {
18777
18790
  transaction: transaction
18778
18791
  });
@@ -19117,45 +19130,48 @@ var CardCharge = {
19117
19130
  };
19118
19131
  return this.listenForCharge(listenerOptions, callback);
19119
19132
  },
19120
- sendSavedCardsOTP: function sendSavedCardsOTP(phone) {
19133
+ sendSavedCardsOTP: function sendSavedCardsOTP(_ref4) {
19121
19134
  var _this9 = this;
19122
19135
 
19123
19136
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
19124
- var response;
19137
+ var phone, channels, email, response;
19125
19138
  return regeneratorRuntime.wrap(function _callee$(_context) {
19126
19139
  while (1) {
19127
19140
  switch (_context.prev = _context.next) {
19128
19141
  case 0:
19129
- _context.prev = 0;
19142
+ phone = _ref4.phone, channels = _ref4.channels, email = _ref4.email;
19143
+ _context.prev = 1;
19130
19144
 
19131
19145
  _this9.logAuth(savedCardMethods.authentication);
19132
19146
 
19133
- _context.next = 4;
19147
+ _context.next = 5;
19134
19148
  return CardAPI$1.sendSavedCardsOTP({
19135
19149
  phone: phone,
19136
- transaction: _this9.id
19150
+ transaction: _this9.id,
19151
+ channels: channels,
19152
+ email: email
19137
19153
  });
19138
19154
 
19139
- case 4:
19155
+ case 5:
19140
19156
  response = _context.sent;
19141
19157
  _this9.savedCardsTempAuthToken = response.data.token;
19142
19158
  return _context.abrupt("return", response);
19143
19159
 
19144
- case 9:
19145
- _context.prev = 9;
19146
- _context.t0 = _context["catch"](0);
19160
+ case 10:
19161
+ _context.prev = 10;
19162
+ _context.t0 = _context["catch"](1);
19147
19163
  _this9.savedCardsTempAuthToken = null;
19148
19164
  throw _context.t0;
19149
19165
 
19150
- case 13:
19166
+ case 14:
19151
19167
  case "end":
19152
19168
  return _context.stop();
19153
19169
  }
19154
19170
  }
19155
- }, _callee, null, [[0, 9]]);
19171
+ }, _callee, null, [[1, 10]]);
19156
19172
  }))();
19157
19173
  },
19158
- verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
19174
+ verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
19159
19175
  var _this10 = this;
19160
19176
 
19161
19177
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
@@ -19164,7 +19180,7 @@ var CardCharge = {
19164
19180
  while (1) {
19165
19181
  switch (_context2.prev = _context2.next) {
19166
19182
  case 0:
19167
- code = _ref4.code;
19183
+ code = _ref5.code;
19168
19184
  payload = {
19169
19185
  code: code,
19170
19186
  transaction: _this10.id,
@@ -19204,10 +19220,10 @@ var CardCharge = {
19204
19220
  token: this.savedCardsToken
19205
19221
  });
19206
19222
  },
19207
- chargeSavedCard: function chargeSavedCard(_ref5) {
19208
- var cardCode = _ref5.cardCode,
19209
- _ref5$selectedCurrenc = _ref5.selectedCurrency,
19210
- selectedCurrency = _ref5$selectedCurrenc === void 0 ? this.currency : _ref5$selectedCurrenc;
19223
+ chargeSavedCard: function chargeSavedCard(_ref6) {
19224
+ var cardCode = _ref6.cardCode,
19225
+ _ref6$selectedCurrenc = _ref6.selectedCurrency,
19226
+ selectedCurrency = _ref6$selectedCurrenc === void 0 ? this.currency : _ref6$selectedCurrenc;
19211
19227
  this.logAttempt(savedCardMethods.payment);
19212
19228
  return CardAPI$1.chargeSavedCard({
19213
19229
  cardCode: cardCode,
@@ -19488,13 +19504,12 @@ var DigitalBankMandateAPI = {
19488
19504
  'Accept-Language': language
19489
19505
  });
19490
19506
 
19491
- var params = _objectSpread2({}, walletId ? {
19507
+ var params = walletId ? {
19492
19508
  wallet_id: walletId
19493
19509
  } : {
19494
19510
  phone_number: phoneNumber,
19495
19511
  token: payId
19496
- });
19497
-
19512
+ };
19498
19513
  var urlEncodedParams = formUrlencoded(params);
19499
19514
  return axiosInstance.post(url, urlEncodedParams, {
19500
19515
  headers: headers
@@ -20703,6 +20718,13 @@ var TransactionInstance = /*#__PURE__*/function () {
20703
20718
  return response && response.data;
20704
20719
  });
20705
20720
  }
20721
+ }, {
20722
+ key: "initializeCustomerAuthorization",
20723
+ value: function initializeCustomerAuthorization(payload) {
20724
+ return TransactionAPI.initializeCustomerAuthorization(payload, this.merchant.key).then(function (response) {
20725
+ return response && response.data;
20726
+ });
20727
+ }
20706
20728
  }]);
20707
20729
 
20708
20730
  return TransactionInstance;
@@ -21190,7 +21212,7 @@ var CardPreauthorization = {
21190
21212
  }
21191
21213
  };
21192
21214
 
21193
- var PreauthorisationAPI = {
21215
+ var PreauthorizationAPI = {
21194
21216
  getByAccessCode: function getByAccessCode(accessCode) {
21195
21217
  var language = getLanguage();
21196
21218
 
@@ -21308,9 +21330,11 @@ var AnalyticsFunctions = {
21308
21330
  return this.saveLog();
21309
21331
  },
21310
21332
  logAPIResponse: function logAPIResponse(response, channel) {
21333
+ console.log('api response', response);
21334
+
21311
21335
  switch (response.status) {
21312
- case 'success':
21313
- return this.logSuccess(channel);
21336
+ case 'authorized':
21337
+ return this.logAuthorized(channel);
21314
21338
 
21315
21339
  case 'failed':
21316
21340
  return this.logError(response.message);
@@ -21354,8 +21378,8 @@ var AnalyticsFunctions = {
21354
21378
  });
21355
21379
  return this.saveLog();
21356
21380
  },
21357
- logSuccess: function logSuccess(channel) {
21358
- var message = 'Successfully preauthorised funds';
21381
+ logAuthorized: function logAuthorized(channel) {
21382
+ var message = 'Successfully preauthorized funds';
21359
21383
 
21360
21384
  if (channel) {
21361
21385
  message += " with ".concat(channel);
@@ -21363,7 +21387,7 @@ var AnalyticsFunctions = {
21363
21387
 
21364
21388
  this.log.success = true;
21365
21389
  this.log.history.push({
21366
- type: 'success',
21390
+ type: 'authorized',
21367
21391
  message: message,
21368
21392
  time: this.getTimeSpent()
21369
21393
  });
@@ -21400,6 +21424,8 @@ var AnalyticsFunctions = {
21400
21424
  }
21401
21425
  };
21402
21426
 
21427
+ var PAYMENT_METHOD = 'card';
21428
+
21403
21429
  var PreauthorizationInstance = /*#__PURE__*/function () {
21404
21430
  function PreauthorizationInstance(data) {
21405
21431
  _classCallCheck(this, PreauthorizationInstance);
@@ -21439,9 +21465,15 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
21439
21465
  }, {
21440
21466
  key: "requery",
21441
21467
  value: function requery() {
21442
- return PreauthorisationAPI.requery({
21468
+ var _this = this;
21469
+
21470
+ return PreauthorizationAPI.requery({
21443
21471
  reference: this.reference,
21444
21472
  publicKey: this.merchant.key
21473
+ }).then(function (response) {
21474
+ _this.logAPIResponse(response, PAYMENT_METHOD);
21475
+
21476
+ return response;
21445
21477
  });
21446
21478
  }
21447
21479
  }, {
@@ -21471,7 +21503,7 @@ var Preauthorization = {
21471
21503
  case 2:
21472
21504
  deviceFingerprint = _context.sent;
21473
21505
  _context.next = 5;
21474
- return PreauthorisationAPI.getByAccessCode(accessCode);
21506
+ return PreauthorizationAPI.getByAccessCode(accessCode);
21475
21507
 
21476
21508
  case 5:
21477
21509
  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.11",
4
4
  "description": "Client-side JS library for billing on Paystack",
5
5
  "main": "lib/checkout.js",
6
6
  "module": "es/checkout.js",