@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/es/checkout.js CHANGED
@@ -18600,7 +18600,7 @@ var CardAPI = {
18600
18600
  },
18601
18601
  verifySavedCardsOtp: function verifySavedCardsOtp(_ref6) {
18602
18602
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
18603
- var code, phone, transaction, url, language, headers, urlEncodedData, response;
18603
+ var code, phone, transaction, url, language, headers, data, response;
18604
18604
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
18605
18605
  while (1) {
18606
18606
  switch (_context2.prev = _context2.next) {
@@ -18608,18 +18608,16 @@ var CardAPI = {
18608
18608
  code = _ref6.code, phone = _ref6.phone, transaction = _ref6.transaction;
18609
18609
  url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
18610
18610
  language = getLanguage();
18611
- headers = _objectSpread2({
18612
- 'Content-Type': 'application/x-www-form-urlencoded'
18613
- }, language && {
18611
+ headers = _objectSpread2({}, language && {
18614
18612
  'Accept-Language': language
18615
18613
  });
18616
- urlEncodedData = formUrlencoded({
18614
+ data = {
18617
18615
  code: code,
18618
18616
  phone: phone,
18619
18617
  transaction: transaction
18620
- });
18618
+ };
18621
18619
  _context2.next = 7;
18622
- return axiosInstance.post(url, urlEncodedData, {
18620
+ return axiosInstance.post(url, data, {
18623
18621
  headers: headers
18624
18622
  });
18625
18623
 
@@ -18705,7 +18703,7 @@ var CardAPI = {
18705
18703
 
18706
18704
  var paymentMethod$3 = 'card';
18707
18705
 
18708
- function validate$4(card, isSetter) {
18706
+ function validate$3(card, isSetter) {
18709
18707
  return new Promise(function (resolve, reject) {
18710
18708
  var validation = Card.validate(card);
18711
18709
 
@@ -18726,7 +18724,7 @@ var CardCharge = {
18726
18724
  setCard: function setCard(params) {
18727
18725
  var _this = this;
18728
18726
 
18729
- return validate$4(params, true).then(function () {
18727
+ return validate$3(params, true).then(function () {
18730
18728
  _this.card = new Card(params);
18731
18729
  });
18732
18730
  },
@@ -18742,7 +18740,7 @@ var CardCharge = {
18742
18740
  return this.chargeCardWithPin(customFields);
18743
18741
  }
18744
18742
 
18745
- return validate$4(this.card).then(function () {
18743
+ return validate$3(this.card).then(function () {
18746
18744
  _this2.logAttempt(paymentMethod$3);
18747
18745
 
18748
18746
  var chargeParams = {
@@ -19079,7 +19077,7 @@ var EMandateAPI = {
19079
19077
 
19080
19078
  var paymentMethod$2 = 'bank account';
19081
19079
 
19082
- function validate$3(bankAccount, isSetter) {
19080
+ function validate$2(bankAccount, isSetter) {
19083
19081
  return new Promise(function (resolve, reject) {
19084
19082
  var validation = BankAccount.validate(bankAccount);
19085
19083
 
@@ -19097,14 +19095,14 @@ var EMandate = {
19097
19095
  setBankAccount: function setBankAccount(params) {
19098
19096
  var _this = this;
19099
19097
 
19100
- return validate$3(params, true).then(function () {
19098
+ return validate$2(params, true).then(function () {
19101
19099
  _this.bankAccount = new BankAccount(params);
19102
19100
  });
19103
19101
  },
19104
19102
  chargeBankAccount: function chargeBankAccount() {
19105
19103
  var _this2 = this;
19106
19104
 
19107
- return validate$3(this.bankAccount).then(function () {
19105
+ return validate$2(this.bankAccount).then(function () {
19108
19106
  _this2.logAttempt(paymentMethod$2);
19109
19107
 
19110
19108
  var verifyParams = {
@@ -19123,7 +19121,7 @@ var EMandate = {
19123
19121
  registerBankAccount: function registerBankAccount(birthday) {
19124
19122
  var _this3 = this;
19125
19123
 
19126
- return validate$3(this.bankAccount).then(function () {
19124
+ return validate$2(this.bankAccount).then(function () {
19127
19125
  var registerParams = {
19128
19126
  bankId: _this3.bankAccount.bankId,
19129
19127
  transactionId: _this3.id,
@@ -19140,7 +19138,7 @@ var EMandate = {
19140
19138
  authenticateBankAccount: function authenticateBankAccount(token) {
19141
19139
  var _this4 = this;
19142
19140
 
19143
- return validate$3(this.bankAccount).then(function () {
19141
+ return validate$2(this.bankAccount).then(function () {
19144
19142
  var chargeParams = {
19145
19143
  bankId: _this4.bankAccount.bankId,
19146
19144
  transactionId: _this4.id,
@@ -19365,7 +19363,7 @@ var QrAPI = {
19365
19363
  }
19366
19364
  };
19367
19365
 
19368
- function validate$2(channel) {
19366
+ function validate$1(channel) {
19369
19367
  return new Promise(function (resolve, reject) {
19370
19368
  var allowedChannels = ['visa', 'MPASS_OLTI'];
19371
19369
 
@@ -19383,7 +19381,7 @@ var QRCharge = {
19383
19381
  var _this = this;
19384
19382
 
19385
19383
  var channel = _ref.channel;
19386
- return validate$2(channel).then(function () {
19384
+ return validate$1(channel).then(function () {
19387
19385
  if (_this.qr[channel]) {
19388
19386
  return _this.qr[channel];
19389
19387
  }
@@ -19405,7 +19403,7 @@ var QRCharge = {
19405
19403
  var _this2 = this;
19406
19404
 
19407
19405
  var channel = _ref2.channel;
19408
- return validate$2(channel).then(function () {
19406
+ return validate$1(channel).then(function () {
19409
19407
  if (!_this2.qr[channel]) {
19410
19408
  return Promise.reject(Error('Please generate qr code with Transaction.getQRCode()'));
19411
19409
  }
@@ -19526,7 +19524,7 @@ var MobileMoneyAPI = {
19526
19524
  }
19527
19525
  };
19528
19526
 
19529
- function validate$1(phoneNumber) {
19527
+ function validate(phoneNumber) {
19530
19528
  return new Promise(function (resolve, reject) {
19531
19529
  var validation = PhoneNumber.validate(phoneNumber);
19532
19530
 
@@ -19547,7 +19545,7 @@ var MobileMoneyCharge = {
19547
19545
  provider = _ref.provider,
19548
19546
  voucher = _ref.voucher,
19549
19547
  registrationToken = _ref.registrationToken;
19550
- return validate$1(phoneNumber).then(function () {
19548
+ return validate(phoneNumber).then(function () {
19551
19549
  _this.logAttempt('mobile money');
19552
19550
 
19553
19551
  var params = {
@@ -19578,7 +19576,7 @@ var MobileMoneyCharge = {
19578
19576
  var phoneNumber = payload.phoneNumber,
19579
19577
  provider = payload.provider,
19580
19578
  registrationToken = payload.registrationToken;
19581
- return validate$1(phoneNumber).then(function () {
19579
+ return validate(phoneNumber).then(function () {
19582
19580
  _this2.logMobileMoneyActions(payload);
19583
19581
 
19584
19582
  var params = {
@@ -19634,233 +19632,6 @@ var MobileMoneyCharge = {
19634
19632
  }
19635
19633
  };
19636
19634
 
19637
- var PhoneAPI = {
19638
- verify: function verify(phoneNumber, publicKey) {
19639
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/verify");
19640
- var language = getLanguage();
19641
-
19642
- var headers = _objectSpread2({
19643
- Authorization: "Bearer ".concat(publicKey)
19644
- }, language && {
19645
- 'Accept-Language': language
19646
- });
19647
-
19648
- return axiosInstance.post(url, {
19649
- phone: phoneNumber
19650
- }, {
19651
- headers: headers
19652
- }).then(function (response) {
19653
- return response.data;
19654
- });
19655
- },
19656
- deleteCard: function deleteCard(phoneNumber, publicKey, cardId) {
19657
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/remove_card");
19658
- var language = getLanguage();
19659
-
19660
- var headers = _objectSpread2({
19661
- Authorization: "Bearer ".concat(publicKey)
19662
- }, language && {
19663
- 'Accept-Language': language
19664
- });
19665
-
19666
- return axiosInstance.post(url, {
19667
- phone: phoneNumber,
19668
- id: cardId
19669
- }, {
19670
- headers: headers
19671
- }).then(function (response) {
19672
- return response.data;
19673
- });
19674
- },
19675
- authenticateOtp: function authenticateOtp(phoneNumber, publicKey, otp, transactionId) {
19676
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/validate_otp");
19677
- var language = getLanguage();
19678
-
19679
- var headers = _objectSpread2({
19680
- Authorization: "Bearer ".concat(publicKey)
19681
- }, language && {
19682
- 'Accept-Language': language
19683
- });
19684
-
19685
- return axiosInstance.post(url, {
19686
- phone: phoneNumber,
19687
- otp: otp,
19688
- transaction: transactionId
19689
- }, {
19690
- headers: headers
19691
- }).then(function (response) {
19692
- return response.data;
19693
- });
19694
- },
19695
- authenticatePin: function authenticatePin(phoneNumber, publicKey, pin, transactionId) {
19696
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/validate_pin");
19697
- var language = getLanguage();
19698
-
19699
- var headers = _objectSpread2({
19700
- Authorization: "Bearer ".concat(publicKey)
19701
- }, language && {
19702
- 'Accept-Language': language
19703
- });
19704
-
19705
- return axiosInstance.post(url, {
19706
- phone: phoneNumber,
19707
- pin: pin,
19708
- transaction: transactionId
19709
- }, {
19710
- headers: headers
19711
- }).then(function (response) {
19712
- return response.data;
19713
- });
19714
- },
19715
- setPin: function setPin(phoneNumber, publicKey, transactionToken, transactionId, pin) {
19716
- var language = getLanguage();
19717
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/set_pin");
19718
-
19719
- var headers = _objectSpread2({
19720
- Authorization: "Bearer ".concat(publicKey)
19721
- }, language && {
19722
- 'Accept-Language': language
19723
- });
19724
-
19725
- return axiosInstance.post(url, {
19726
- phone: phoneNumber,
19727
- token: transactionToken,
19728
- transaction: transactionId,
19729
- pin: pin
19730
- }, {
19731
- headers: headers
19732
- }).then(function (response) {
19733
- return response.data;
19734
- });
19735
- },
19736
- charge: function charge(authId, publicKey, token, transactionId, cvv, phoneNumber) {
19737
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/charge");
19738
- var language = getLanguage();
19739
-
19740
- var headers = _objectSpread2({
19741
- Authorization: "Bearer ".concat(publicKey)
19742
- }, language && {
19743
- 'Accept-Language': language
19744
- });
19745
-
19746
- return axiosInstance.post(url, {
19747
- id: authId,
19748
- token: token,
19749
- cvv: cvv,
19750
- transaction: transactionId,
19751
- phone: phoneNumber
19752
- }, {
19753
- headers: headers
19754
- }).then(function (response) {
19755
- return response.data;
19756
- });
19757
- },
19758
- enrollPhoneNumber: function enrollPhoneNumber(phoneNumber, publicKey, transactionId) {
19759
- var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/enroll");
19760
- var language = getLanguage();
19761
-
19762
- var headers = _objectSpread2({
19763
- Authorization: "Bearer ".concat(publicKey)
19764
- }, language && {
19765
- 'Accept-Language': language
19766
- });
19767
-
19768
- return axiosInstance.post(url, {
19769
- phone: phoneNumber,
19770
- transaction: transactionId
19771
- }, {
19772
- headers: headers
19773
- }).then(function (response) {
19774
- return response.data;
19775
- });
19776
- }
19777
- };
19778
-
19779
- /*
19780
- TODO:
19781
- Implement analytics for Pay with Phone. Since unique actions are takens here e.g
19782
- user verifies pay with phone account, user charged saved card, etc, these should
19783
- all be reflected as custom analytics actions
19784
- */
19785
-
19786
- function validate(phoneNumber) {
19787
- return new Promise(function (resolve, reject) {
19788
- var validation = PhoneNumber.validate(phoneNumber);
19789
-
19790
- if (!validation.isValid) {
19791
- var errorMessage = phoneNumber ? validation.errors[0] : 'Please set a valid customer with Transaction.setCustomer()';
19792
- reject(Error(errorMessage));
19793
- }
19794
-
19795
- resolve(validation);
19796
- });
19797
- }
19798
-
19799
- var PhoneNumberCharge = {
19800
- setCustomer: function setCustomer(_ref) {
19801
- var _this = this;
19802
-
19803
- var phoneNumber = _ref.phoneNumber;
19804
- return validate(phoneNumber).then(function () {
19805
- _this.customer = phoneNumber;
19806
- });
19807
- },
19808
- verifyCustomer: function verifyCustomer() {
19809
- var _this2 = this;
19810
-
19811
- return validate(this.customer).then(function () {
19812
- return PhoneAPI.verify(_this2.customer, _this2.merchant.key);
19813
- });
19814
- },
19815
- deleteSavedCard: function deleteSavedCard(cardId) {
19816
- var _this3 = this;
19817
-
19818
- return validate(this.customer).then(function () {
19819
- return PhoneAPI.deleteCard(_this3.customer, _this3.merchant.key, cardId);
19820
- });
19821
- },
19822
- authenticateCustomerOtp: function authenticateCustomerOtp(otp) {
19823
- var _this4 = this;
19824
-
19825
- return validate(this.customer).then(function () {
19826
- return PhoneAPI.authenticateOtp(_this4.customer, _this4.merchant.key, otp, _this4.id);
19827
- });
19828
- },
19829
- authenticateCustomerPin: function authenticateCustomerPin(pin) {
19830
- var _this5 = this;
19831
-
19832
- return validate(this.customer).then(function () {
19833
- return PhoneAPI.authenticatePin(_this5.customer, _this5.merchant.key, pin, _this5.id);
19834
- });
19835
- },
19836
- setCustomerPin: function setCustomerPin(_ref2) {
19837
- var _this6 = this;
19838
-
19839
- var pin = _ref2.pin,
19840
- token = _ref2.token;
19841
- return validate(this.customer).then(function () {
19842
- return PhoneAPI.setPin(_this6.customer, _this6.merchant.key, token, _this6.id, pin);
19843
- });
19844
- },
19845
- chargeSavedCard: function chargeSavedCard(_ref3) {
19846
- var _this7 = this;
19847
-
19848
- var cardId = _ref3.cardId,
19849
- token = _ref3.token,
19850
- cvv = _ref3.cvv;
19851
- return validate(this.customer).then(function () {
19852
- return PhoneAPI.charge(cardId, _this7.merchant.key, token, _this7.id, cvv, _this7.customer);
19853
- });
19854
- },
19855
- enrollPhoneNumber: function enrollPhoneNumber(number) {
19856
- var _this8 = this;
19857
-
19858
- return validate(this.customer).then(function () {
19859
- return PhoneAPI.enrollPhoneNumber(number, _this8.merchant.key, _this8.id);
19860
- });
19861
- }
19862
- };
19863
-
19864
19635
  var DirectDebitAPI = {
19865
19636
  loginToDirectDebitAccount: function loginToDirectDebitAccount(_ref) {
19866
19637
  var email = _ref.email,
@@ -20051,7 +19822,6 @@ var ChargeFunctions = {
20051
19822
  ussd: USSDCharge,
20052
19823
  qr: QRCharge,
20053
19824
  mobile_money: MobileMoneyCharge,
20054
- phone: PhoneNumberCharge,
20055
19825
  direct_debit: DirectDebitCharge,
20056
19826
  bank_transfer: PayWithTransferCharge,
20057
19827
  eft: EFT,