@paystack/checkout-js 1.19.0-dev.3 → 1.19.0-dev.5

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/lib/checkout.js CHANGED
@@ -18604,7 +18604,7 @@ var CardAPI = {
18604
18604
  },
18605
18605
  verifySavedCardsOtp: function verifySavedCardsOtp(_ref6) {
18606
18606
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
18607
- var code, phone, transaction, url, language, headers, urlEncodedData, response;
18607
+ var code, phone, transaction, url, language, headers, data, response;
18608
18608
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
18609
18609
  while (1) {
18610
18610
  switch (_context2.prev = _context2.next) {
@@ -18612,18 +18612,16 @@ var CardAPI = {
18612
18612
  code = _ref6.code, phone = _ref6.phone, transaction = _ref6.transaction;
18613
18613
  url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
18614
18614
  language = getLanguage();
18615
- headers = _objectSpread2({
18616
- 'Content-Type': 'application/x-www-form-urlencoded'
18617
- }, language && {
18615
+ headers = _objectSpread2({}, language && {
18618
18616
  'Accept-Language': language
18619
18617
  });
18620
- urlEncodedData = formUrlencoded({
18618
+ data = {
18621
18619
  code: code,
18622
18620
  phone: phone,
18623
18621
  transaction: transaction
18624
- });
18622
+ };
18625
18623
  _context2.next = 7;
18626
- return axiosInstance.post(url, urlEncodedData, {
18624
+ return axiosInstance.post(url, data, {
18627
18625
  headers: headers
18628
18626
  });
18629
18627
 
@@ -18709,7 +18707,7 @@ var CardAPI = {
18709
18707
 
18710
18708
  var paymentMethod$3 = 'card';
18711
18709
 
18712
- function validate$4(card, isSetter) {
18710
+ function validate$3(card, isSetter) {
18713
18711
  return new Promise(function (resolve, reject) {
18714
18712
  var validation = Card.validate(card);
18715
18713
 
@@ -18730,7 +18728,7 @@ var CardCharge = {
18730
18728
  setCard: function setCard(params) {
18731
18729
  var _this = this;
18732
18730
 
18733
- return validate$4(params, true).then(function () {
18731
+ return validate$3(params, true).then(function () {
18734
18732
  _this.card = new Card(params);
18735
18733
  });
18736
18734
  },
@@ -18746,7 +18744,7 @@ var CardCharge = {
18746
18744
  return this.chargeCardWithPin(customFields);
18747
18745
  }
18748
18746
 
18749
- return validate$4(this.card).then(function () {
18747
+ return validate$3(this.card).then(function () {
18750
18748
  _this2.logAttempt(paymentMethod$3);
18751
18749
 
18752
18750
  var chargeParams = {
@@ -19083,7 +19081,7 @@ var EMandateAPI = {
19083
19081
 
19084
19082
  var paymentMethod$2 = 'bank account';
19085
19083
 
19086
- function validate$3(bankAccount, isSetter) {
19084
+ function validate$2(bankAccount, isSetter) {
19087
19085
  return new Promise(function (resolve, reject) {
19088
19086
  var validation = BankAccount.validate(bankAccount);
19089
19087
 
@@ -19101,14 +19099,14 @@ var EMandate = {
19101
19099
  setBankAccount: function setBankAccount(params) {
19102
19100
  var _this = this;
19103
19101
 
19104
- return validate$3(params, true).then(function () {
19102
+ return validate$2(params, true).then(function () {
19105
19103
  _this.bankAccount = new BankAccount(params);
19106
19104
  });
19107
19105
  },
19108
19106
  chargeBankAccount: function chargeBankAccount() {
19109
19107
  var _this2 = this;
19110
19108
 
19111
- return validate$3(this.bankAccount).then(function () {
19109
+ return validate$2(this.bankAccount).then(function () {
19112
19110
  _this2.logAttempt(paymentMethod$2);
19113
19111
 
19114
19112
  var verifyParams = {
@@ -19127,7 +19125,7 @@ var EMandate = {
19127
19125
  registerBankAccount: function registerBankAccount(birthday) {
19128
19126
  var _this3 = this;
19129
19127
 
19130
- return validate$3(this.bankAccount).then(function () {
19128
+ return validate$2(this.bankAccount).then(function () {
19131
19129
  var registerParams = {
19132
19130
  bankId: _this3.bankAccount.bankId,
19133
19131
  transactionId: _this3.id,
@@ -19144,7 +19142,7 @@ var EMandate = {
19144
19142
  authenticateBankAccount: function authenticateBankAccount(token) {
19145
19143
  var _this4 = this;
19146
19144
 
19147
- return validate$3(this.bankAccount).then(function () {
19145
+ return validate$2(this.bankAccount).then(function () {
19148
19146
  var chargeParams = {
19149
19147
  bankId: _this4.bankAccount.bankId,
19150
19148
  transactionId: _this4.id,
@@ -19369,7 +19367,7 @@ var QrAPI = {
19369
19367
  }
19370
19368
  };
19371
19369
 
19372
- function validate$2(channel) {
19370
+ function validate$1(channel) {
19373
19371
  return new Promise(function (resolve, reject) {
19374
19372
  var allowedChannels = ['visa', 'MPASS_OLTI'];
19375
19373
 
@@ -19387,7 +19385,7 @@ var QRCharge = {
19387
19385
  var _this = this;
19388
19386
 
19389
19387
  var channel = _ref.channel;
19390
- return validate$2(channel).then(function () {
19388
+ return validate$1(channel).then(function () {
19391
19389
  if (_this.qr[channel]) {
19392
19390
  return _this.qr[channel];
19393
19391
  }
@@ -19409,7 +19407,7 @@ var QRCharge = {
19409
19407
  var _this2 = this;
19410
19408
 
19411
19409
  var channel = _ref2.channel;
19412
- return validate$2(channel).then(function () {
19410
+ return validate$1(channel).then(function () {
19413
19411
  if (!_this2.qr[channel]) {
19414
19412
  return Promise.reject(Error('Please generate qr code with Transaction.getQRCode()'));
19415
19413
  }
@@ -19530,7 +19528,7 @@ var MobileMoneyAPI = {
19530
19528
  }
19531
19529
  };
19532
19530
 
19533
- function validate$1(phoneNumber) {
19531
+ function validate(phoneNumber) {
19534
19532
  return new Promise(function (resolve, reject) {
19535
19533
  var validation = PhoneNumber.validate(phoneNumber);
19536
19534
 
@@ -19551,7 +19549,7 @@ var MobileMoneyCharge = {
19551
19549
  provider = _ref.provider,
19552
19550
  voucher = _ref.voucher,
19553
19551
  registrationToken = _ref.registrationToken;
19554
- return validate$1(phoneNumber).then(function () {
19552
+ return validate(phoneNumber).then(function () {
19555
19553
  _this.logAttempt('mobile money');
19556
19554
 
19557
19555
  var params = {
@@ -19582,7 +19580,7 @@ var MobileMoneyCharge = {
19582
19580
  var phoneNumber = payload.phoneNumber,
19583
19581
  provider = payload.provider,
19584
19582
  registrationToken = payload.registrationToken;
19585
- return validate$1(phoneNumber).then(function () {
19583
+ return validate(phoneNumber).then(function () {
19586
19584
  _this2.logMobileMoneyActions(payload);
19587
19585
 
19588
19586
  var params = {
@@ -19638,233 +19636,6 @@ var MobileMoneyCharge = {
19638
19636
  }
19639
19637
  };
19640
19638
 
19641
- var PhoneAPI = {
19642
- verify: function verify(phoneNumber, publicKey) {
19643
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/verify");
19644
- var language = getLanguage();
19645
-
19646
- var headers = _objectSpread2({
19647
- Authorization: "Bearer ".concat(publicKey)
19648
- }, language && {
19649
- 'Accept-Language': language
19650
- });
19651
-
19652
- return axiosInstance.post(url, {
19653
- phone: phoneNumber
19654
- }, {
19655
- headers: headers
19656
- }).then(function (response) {
19657
- return response.data;
19658
- });
19659
- },
19660
- deleteCard: function deleteCard(phoneNumber, publicKey, cardId) {
19661
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/remove_card");
19662
- var language = getLanguage();
19663
-
19664
- var headers = _objectSpread2({
19665
- Authorization: "Bearer ".concat(publicKey)
19666
- }, language && {
19667
- 'Accept-Language': language
19668
- });
19669
-
19670
- return axiosInstance.post(url, {
19671
- phone: phoneNumber,
19672
- id: cardId
19673
- }, {
19674
- headers: headers
19675
- }).then(function (response) {
19676
- return response.data;
19677
- });
19678
- },
19679
- authenticateOtp: function authenticateOtp(phoneNumber, publicKey, otp, transactionId) {
19680
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/validate_otp");
19681
- var language = getLanguage();
19682
-
19683
- var headers = _objectSpread2({
19684
- Authorization: "Bearer ".concat(publicKey)
19685
- }, language && {
19686
- 'Accept-Language': language
19687
- });
19688
-
19689
- return axiosInstance.post(url, {
19690
- phone: phoneNumber,
19691
- otp: otp,
19692
- transaction: transactionId
19693
- }, {
19694
- headers: headers
19695
- }).then(function (response) {
19696
- return response.data;
19697
- });
19698
- },
19699
- authenticatePin: function authenticatePin(phoneNumber, publicKey, pin, transactionId) {
19700
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/validate_pin");
19701
- var language = getLanguage();
19702
-
19703
- var headers = _objectSpread2({
19704
- Authorization: "Bearer ".concat(publicKey)
19705
- }, language && {
19706
- 'Accept-Language': language
19707
- });
19708
-
19709
- return axiosInstance.post(url, {
19710
- phone: phoneNumber,
19711
- pin: pin,
19712
- transaction: transactionId
19713
- }, {
19714
- headers: headers
19715
- }).then(function (response) {
19716
- return response.data;
19717
- });
19718
- },
19719
- setPin: function setPin(phoneNumber, publicKey, transactionToken, transactionId, pin) {
19720
- var language = getLanguage();
19721
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/set_pin");
19722
-
19723
- var headers = _objectSpread2({
19724
- Authorization: "Bearer ".concat(publicKey)
19725
- }, language && {
19726
- 'Accept-Language': language
19727
- });
19728
-
19729
- return axiosInstance.post(url, {
19730
- phone: phoneNumber,
19731
- token: transactionToken,
19732
- transaction: transactionId,
19733
- pin: pin
19734
- }, {
19735
- headers: headers
19736
- }).then(function (response) {
19737
- return response.data;
19738
- });
19739
- },
19740
- charge: function charge(authId, publicKey, token, transactionId, cvv, phoneNumber) {
19741
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/charge");
19742
- var language = getLanguage();
19743
-
19744
- var headers = _objectSpread2({
19745
- Authorization: "Bearer ".concat(publicKey)
19746
- }, language && {
19747
- 'Accept-Language': language
19748
- });
19749
-
19750
- return axiosInstance.post(url, {
19751
- id: authId,
19752
- token: token,
19753
- cvv: cvv,
19754
- transaction: transactionId,
19755
- phone: phoneNumber
19756
- }, {
19757
- headers: headers
19758
- }).then(function (response) {
19759
- return response.data;
19760
- });
19761
- },
19762
- enrollPhoneNumber: function enrollPhoneNumber(phoneNumber, publicKey, transactionId) {
19763
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/enroll");
19764
- var language = getLanguage();
19765
-
19766
- var headers = _objectSpread2({
19767
- Authorization: "Bearer ".concat(publicKey)
19768
- }, language && {
19769
- 'Accept-Language': language
19770
- });
19771
-
19772
- return axiosInstance.post(url, {
19773
- phone: phoneNumber,
19774
- transaction: transactionId
19775
- }, {
19776
- headers: headers
19777
- }).then(function (response) {
19778
- return response.data;
19779
- });
19780
- }
19781
- };
19782
-
19783
- /*
19784
- TODO:
19785
- Implement analytics for Pay with Phone. Since unique actions are takens here e.g
19786
- user verifies pay with phone account, user charged saved card, etc, these should
19787
- all be reflected as custom analytics actions
19788
- */
19789
-
19790
- function validate(phoneNumber) {
19791
- return new Promise(function (resolve, reject) {
19792
- var validation = PhoneNumber.validate(phoneNumber);
19793
-
19794
- if (!validation.isValid) {
19795
- var errorMessage = phoneNumber ? validation.errors[0] : 'Please set a valid customer with Transaction.setCustomer()';
19796
- reject(Error(errorMessage));
19797
- }
19798
-
19799
- resolve(validation);
19800
- });
19801
- }
19802
-
19803
- var PhoneNumberCharge = {
19804
- setCustomer: function setCustomer(_ref) {
19805
- var _this = this;
19806
-
19807
- var phoneNumber = _ref.phoneNumber;
19808
- return validate(phoneNumber).then(function () {
19809
- _this.customer = phoneNumber;
19810
- });
19811
- },
19812
- verifyCustomer: function verifyCustomer() {
19813
- var _this2 = this;
19814
-
19815
- return validate(this.customer).then(function () {
19816
- return PhoneAPI.verify(_this2.customer, _this2.merchant.key);
19817
- });
19818
- },
19819
- deleteSavedCard: function deleteSavedCard(cardId) {
19820
- var _this3 = this;
19821
-
19822
- return validate(this.customer).then(function () {
19823
- return PhoneAPI.deleteCard(_this3.customer, _this3.merchant.key, cardId);
19824
- });
19825
- },
19826
- authenticateCustomerOtp: function authenticateCustomerOtp(otp) {
19827
- var _this4 = this;
19828
-
19829
- return validate(this.customer).then(function () {
19830
- return PhoneAPI.authenticateOtp(_this4.customer, _this4.merchant.key, otp, _this4.id);
19831
- });
19832
- },
19833
- authenticateCustomerPin: function authenticateCustomerPin(pin) {
19834
- var _this5 = this;
19835
-
19836
- return validate(this.customer).then(function () {
19837
- return PhoneAPI.authenticatePin(_this5.customer, _this5.merchant.key, pin, _this5.id);
19838
- });
19839
- },
19840
- setCustomerPin: function setCustomerPin(_ref2) {
19841
- var _this6 = this;
19842
-
19843
- var pin = _ref2.pin,
19844
- token = _ref2.token;
19845
- return validate(this.customer).then(function () {
19846
- return PhoneAPI.setPin(_this6.customer, _this6.merchant.key, token, _this6.id, pin);
19847
- });
19848
- },
19849
- chargeSavedCard: function chargeSavedCard(_ref3) {
19850
- var _this7 = this;
19851
-
19852
- var cardId = _ref3.cardId,
19853
- token = _ref3.token,
19854
- cvv = _ref3.cvv;
19855
- return validate(this.customer).then(function () {
19856
- return PhoneAPI.charge(cardId, _this7.merchant.key, token, _this7.id, cvv, _this7.customer);
19857
- });
19858
- },
19859
- enrollPhoneNumber: function enrollPhoneNumber(number) {
19860
- var _this8 = this;
19861
-
19862
- return validate(this.customer).then(function () {
19863
- return PhoneAPI.enrollPhoneNumber(number, _this8.merchant.key, _this8.id);
19864
- });
19865
- }
19866
- };
19867
-
19868
19639
  var DirectDebitAPI = {
19869
19640
  loginToDirectDebitAccount: function loginToDirectDebitAccount(_ref) {
19870
19641
  var email = _ref.email,
@@ -20055,7 +19826,6 @@ var ChargeFunctions = {
20055
19826
  ussd: USSDCharge,
20056
19827
  qr: QRCharge,
20057
19828
  mobile_money: MobileMoneyCharge,
20058
- phone: PhoneNumberCharge,
20059
19829
  direct_debit: DirectDebitCharge,
20060
19830
  bank_transfer: PayWithTransferCharge,
20061
19831
  eft: EFT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/checkout-js",
3
- "version": "1.19.0-dev.3",
3
+ "version": "1.19.0-dev.5",
4
4
  "description": "Client-side JS library for billing on Paystack",
5
5
  "main": "lib/checkout.js",
6
6
  "module": "es/checkout.js",