@paystack/checkout-js 1.19.0-dev.1 → 1.19.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/dist/checkout.js +3 -3
- package/es/checkout.js +233 -282
- package/lib/checkout.js +233 -282
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -18568,49 +18568,177 @@ var CardAPI = {
|
|
|
18568
18568
|
});
|
|
18569
18569
|
},
|
|
18570
18570
|
requestOtpForSavedCards: function requestOtpForSavedCards(phoneNumber) {
|
|
18571
|
-
|
|
18572
|
-
|
|
18571
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18572
|
+
var url, language, headers, _yield$axiosInstance$, data;
|
|
18573
18573
|
|
|
18574
|
-
|
|
18575
|
-
|
|
18576
|
-
|
|
18574
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18575
|
+
while (1) {
|
|
18576
|
+
switch (_context.prev = _context.next) {
|
|
18577
|
+
case 0:
|
|
18578
|
+
url = new URL("/authorize/".concat(phoneNumber), configToUse.savedCardsApiUrl).toString();
|
|
18579
|
+
language = getLanguage();
|
|
18580
|
+
headers = _objectSpread2({}, language && {
|
|
18581
|
+
'Accept-Language': language
|
|
18582
|
+
});
|
|
18583
|
+
_context.next = 5;
|
|
18584
|
+
return axiosInstance.post(url, {
|
|
18585
|
+
headers: headers
|
|
18586
|
+
});
|
|
18577
18587
|
|
|
18578
|
-
|
|
18579
|
-
|
|
18580
|
-
|
|
18581
|
-
|
|
18582
|
-
|
|
18583
|
-
|
|
18588
|
+
case 5:
|
|
18589
|
+
_yield$axiosInstance$ = _context.sent;
|
|
18590
|
+
data = _yield$axiosInstance$.data;
|
|
18591
|
+
return _context.abrupt("return", data);
|
|
18592
|
+
|
|
18593
|
+
case 8:
|
|
18594
|
+
case "end":
|
|
18595
|
+
return _context.stop();
|
|
18596
|
+
}
|
|
18597
|
+
}
|
|
18598
|
+
}, _callee);
|
|
18599
|
+
}))();
|
|
18584
18600
|
},
|
|
18585
|
-
verifySavedCardsOtp: function verifySavedCardsOtp(
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18601
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref6) {
|
|
18602
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18603
|
+
var code, phone, transaction, url, language, headers, data, response;
|
|
18604
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18605
|
+
while (1) {
|
|
18606
|
+
switch (_context2.prev = _context2.next) {
|
|
18607
|
+
case 0:
|
|
18608
|
+
code = _ref6.code, phone = _ref6.phone, transaction = _ref6.transaction;
|
|
18609
|
+
url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
|
|
18610
|
+
language = getLanguage();
|
|
18611
|
+
headers = _objectSpread2({}, language && {
|
|
18612
|
+
'Accept-Language': language
|
|
18613
|
+
});
|
|
18614
|
+
data = {
|
|
18615
|
+
code: code,
|
|
18616
|
+
phone: phone,
|
|
18617
|
+
transaction: transaction
|
|
18618
|
+
};
|
|
18619
|
+
_context2.next = 7;
|
|
18620
|
+
return axiosInstance.post(url, data, {
|
|
18621
|
+
headers: headers
|
|
18622
|
+
});
|
|
18591
18623
|
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
'Accept-Language': language
|
|
18596
|
-
});
|
|
18624
|
+
case 7:
|
|
18625
|
+
response = _context2.sent;
|
|
18626
|
+
return _context2.abrupt("return", response.data);
|
|
18597
18627
|
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18628
|
+
case 9:
|
|
18629
|
+
case "end":
|
|
18630
|
+
return _context2.stop();
|
|
18631
|
+
}
|
|
18632
|
+
}
|
|
18633
|
+
}, _callee2);
|
|
18634
|
+
}))();
|
|
18635
|
+
},
|
|
18636
|
+
getSavedCards: function getSavedCards(_ref7) {
|
|
18637
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18638
|
+
var token, url, language, headers, response;
|
|
18639
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18640
|
+
while (1) {
|
|
18641
|
+
switch (_context3.prev = _context3.next) {
|
|
18642
|
+
case 0:
|
|
18643
|
+
token = _ref7.token;
|
|
18644
|
+
url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
|
|
18645
|
+
language = getLanguage();
|
|
18646
|
+
headers = _objectSpread2({
|
|
18647
|
+
Authorization: "Bearer ".concat(token),
|
|
18648
|
+
'jwt-auth': true
|
|
18649
|
+
}, language && {
|
|
18650
|
+
'Accept-Language': language
|
|
18651
|
+
});
|
|
18652
|
+
_context3.next = 6;
|
|
18653
|
+
return axiosInstance.get(url, {
|
|
18654
|
+
headers: headers
|
|
18655
|
+
});
|
|
18656
|
+
|
|
18657
|
+
case 6:
|
|
18658
|
+
response = _context3.sent;
|
|
18659
|
+
return _context3.abrupt("return", response.data);
|
|
18660
|
+
|
|
18661
|
+
case 8:
|
|
18662
|
+
case "end":
|
|
18663
|
+
return _context3.stop();
|
|
18664
|
+
}
|
|
18665
|
+
}
|
|
18666
|
+
}, _callee3);
|
|
18667
|
+
}))();
|
|
18668
|
+
},
|
|
18669
|
+
deleteSavedCard: function deleteSavedCard(_ref8) {
|
|
18670
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18671
|
+
var cardCode, token, url, language, headers, response;
|
|
18672
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18673
|
+
while (1) {
|
|
18674
|
+
switch (_context4.prev = _context4.next) {
|
|
18675
|
+
case 0:
|
|
18676
|
+
cardCode = _ref8.cardCode, token = _ref8.token;
|
|
18677
|
+
url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
|
|
18678
|
+
language = getLanguage();
|
|
18679
|
+
headers = _objectSpread2({
|
|
18680
|
+
Authorization: "Bearer ".concat(token),
|
|
18681
|
+
'jwt-auth': true
|
|
18682
|
+
}, language && {
|
|
18683
|
+
'Accept-Language': language
|
|
18684
|
+
});
|
|
18685
|
+
_context4.next = 6;
|
|
18686
|
+
return axiosInstance.delete(url, {
|
|
18687
|
+
headers: headers
|
|
18688
|
+
});
|
|
18689
|
+
|
|
18690
|
+
case 6:
|
|
18691
|
+
response = _context4.sent;
|
|
18692
|
+
return _context4.abrupt("return", response.data);
|
|
18693
|
+
|
|
18694
|
+
case 8:
|
|
18695
|
+
case "end":
|
|
18696
|
+
return _context4.stop();
|
|
18697
|
+
}
|
|
18698
|
+
}
|
|
18699
|
+
}, _callee4);
|
|
18700
|
+
}))();
|
|
18701
|
+
},
|
|
18702
|
+
chargeSavedCard: function chargeSavedCard(_ref9) {
|
|
18703
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
18704
|
+
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data;
|
|
18705
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
18706
|
+
while (1) {
|
|
18707
|
+
switch (_context5.prev = _context5.next) {
|
|
18708
|
+
case 0:
|
|
18709
|
+
token = _ref9.token, device = _ref9.device, cardCode = _ref9.cardCode, transaction = _ref9.transaction, selectedCurrency = _ref9.selectedCurrency;
|
|
18710
|
+
url = new URL("/cards/".concat(cardCode, "/charge"), configToUse.savedCardsApiUrl).toString();
|
|
18711
|
+
language = getLanguage();
|
|
18712
|
+
headers = _objectSpread2({
|
|
18713
|
+
Authorization: "Bearer ".concat(token),
|
|
18714
|
+
'jwt-auth': true
|
|
18715
|
+
}, language && {
|
|
18716
|
+
'Accept-Language': language
|
|
18717
|
+
});
|
|
18718
|
+
data = {
|
|
18719
|
+
device: device,
|
|
18720
|
+
transaction: transaction,
|
|
18721
|
+
selectedCurrency: selectedCurrency
|
|
18722
|
+
};
|
|
18723
|
+
return _context5.abrupt("return", axiosInstance.post(url, data, {
|
|
18724
|
+
headers: headers
|
|
18725
|
+
}).then(function (response) {
|
|
18726
|
+
return ChargeResponses.parse(response.data);
|
|
18727
|
+
}));
|
|
18728
|
+
|
|
18729
|
+
case 6:
|
|
18730
|
+
case "end":
|
|
18731
|
+
return _context5.stop();
|
|
18732
|
+
}
|
|
18733
|
+
}
|
|
18734
|
+
}, _callee5);
|
|
18735
|
+
}))();
|
|
18608
18736
|
}
|
|
18609
18737
|
};
|
|
18610
18738
|
|
|
18611
18739
|
var paymentMethod$3 = 'card';
|
|
18612
18740
|
|
|
18613
|
-
function validate$
|
|
18741
|
+
function validate$3(card, isSetter) {
|
|
18614
18742
|
return new Promise(function (resolve, reject) {
|
|
18615
18743
|
var validation = Card.validate(card);
|
|
18616
18744
|
|
|
@@ -18631,7 +18759,7 @@ var CardCharge = {
|
|
|
18631
18759
|
setCard: function setCard(params) {
|
|
18632
18760
|
var _this = this;
|
|
18633
18761
|
|
|
18634
|
-
return validate$
|
|
18762
|
+
return validate$3(params, true).then(function () {
|
|
18635
18763
|
_this.card = new Card(params);
|
|
18636
18764
|
});
|
|
18637
18765
|
},
|
|
@@ -18647,7 +18775,7 @@ var CardCharge = {
|
|
|
18647
18775
|
return this.chargeCardWithPin(customFields);
|
|
18648
18776
|
}
|
|
18649
18777
|
|
|
18650
|
-
return validate$
|
|
18778
|
+
return validate$3(this.card).then(function () {
|
|
18651
18779
|
_this2.logAttempt(paymentMethod$3);
|
|
18652
18780
|
|
|
18653
18781
|
var chargeParams = {
|
|
@@ -18790,14 +18918,63 @@ var CardCharge = {
|
|
|
18790
18918
|
return CardAPI.requestOtpForSavedCards(phoneNumber);
|
|
18791
18919
|
},
|
|
18792
18920
|
verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
|
|
18793
|
-
var
|
|
18794
|
-
|
|
18795
|
-
|
|
18796
|
-
|
|
18797
|
-
|
|
18798
|
-
|
|
18799
|
-
|
|
18800
|
-
|
|
18921
|
+
var _this9 = this;
|
|
18922
|
+
|
|
18923
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18924
|
+
var code, phone, payload, response;
|
|
18925
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18926
|
+
while (1) {
|
|
18927
|
+
switch (_context.prev = _context.next) {
|
|
18928
|
+
case 0:
|
|
18929
|
+
code = _ref4.code, phone = _ref4.phone;
|
|
18930
|
+
payload = {
|
|
18931
|
+
code: code,
|
|
18932
|
+
phone: phone,
|
|
18933
|
+
transaction: _this9.id
|
|
18934
|
+
};
|
|
18935
|
+
_context.prev = 2;
|
|
18936
|
+
_context.next = 5;
|
|
18937
|
+
return CardAPI.verifySavedCardsOtp(payload);
|
|
18938
|
+
|
|
18939
|
+
case 5:
|
|
18940
|
+
response = _context.sent;
|
|
18941
|
+
_this9.savedCardsToken = response.data.token;
|
|
18942
|
+
return _context.abrupt("return", response);
|
|
18943
|
+
|
|
18944
|
+
case 10:
|
|
18945
|
+
_context.prev = 10;
|
|
18946
|
+
_context.t0 = _context["catch"](2);
|
|
18947
|
+
_this9.savedCardsToken = null;
|
|
18948
|
+
throw new Error(_context.t0);
|
|
18949
|
+
|
|
18950
|
+
case 14:
|
|
18951
|
+
case "end":
|
|
18952
|
+
return _context.stop();
|
|
18953
|
+
}
|
|
18954
|
+
}
|
|
18955
|
+
}, _callee, null, [[2, 10]]);
|
|
18956
|
+
}))();
|
|
18957
|
+
},
|
|
18958
|
+
getSavedCards: function getSavedCards() {
|
|
18959
|
+
return CardAPI.getSavedCards({
|
|
18960
|
+
token: this.savedCardsToken
|
|
18961
|
+
});
|
|
18962
|
+
},
|
|
18963
|
+
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
18964
|
+
return CardAPI.deleteSavedCard({
|
|
18965
|
+
cardCode: cardCode,
|
|
18966
|
+
token: this.savedCardsToken
|
|
18967
|
+
});
|
|
18968
|
+
},
|
|
18969
|
+
chargeSavedCard: function chargeSavedCard(_ref5) {
|
|
18970
|
+
var cardCode = _ref5.cardCode;
|
|
18971
|
+
return CardAPI.chargeSavedCard({
|
|
18972
|
+
cardCode: cardCode,
|
|
18973
|
+
transaction: this.id,
|
|
18974
|
+
token: this.savedCardsToken,
|
|
18975
|
+
device: this.deviceFingerprint,
|
|
18976
|
+
selectedCurrency: this.currency
|
|
18977
|
+
});
|
|
18801
18978
|
}
|
|
18802
18979
|
};
|
|
18803
18980
|
|
|
@@ -18952,7 +19129,7 @@ var EMandateAPI = {
|
|
|
18952
19129
|
|
|
18953
19130
|
var paymentMethod$2 = 'bank account';
|
|
18954
19131
|
|
|
18955
|
-
function validate$
|
|
19132
|
+
function validate$2(bankAccount, isSetter) {
|
|
18956
19133
|
return new Promise(function (resolve, reject) {
|
|
18957
19134
|
var validation = BankAccount.validate(bankAccount);
|
|
18958
19135
|
|
|
@@ -18970,14 +19147,14 @@ var EMandate = {
|
|
|
18970
19147
|
setBankAccount: function setBankAccount(params) {
|
|
18971
19148
|
var _this = this;
|
|
18972
19149
|
|
|
18973
|
-
return validate$
|
|
19150
|
+
return validate$2(params, true).then(function () {
|
|
18974
19151
|
_this.bankAccount = new BankAccount(params);
|
|
18975
19152
|
});
|
|
18976
19153
|
},
|
|
18977
19154
|
chargeBankAccount: function chargeBankAccount() {
|
|
18978
19155
|
var _this2 = this;
|
|
18979
19156
|
|
|
18980
|
-
return validate$
|
|
19157
|
+
return validate$2(this.bankAccount).then(function () {
|
|
18981
19158
|
_this2.logAttempt(paymentMethod$2);
|
|
18982
19159
|
|
|
18983
19160
|
var verifyParams = {
|
|
@@ -18996,7 +19173,7 @@ var EMandate = {
|
|
|
18996
19173
|
registerBankAccount: function registerBankAccount(birthday) {
|
|
18997
19174
|
var _this3 = this;
|
|
18998
19175
|
|
|
18999
|
-
return validate$
|
|
19176
|
+
return validate$2(this.bankAccount).then(function () {
|
|
19000
19177
|
var registerParams = {
|
|
19001
19178
|
bankId: _this3.bankAccount.bankId,
|
|
19002
19179
|
transactionId: _this3.id,
|
|
@@ -19013,7 +19190,7 @@ var EMandate = {
|
|
|
19013
19190
|
authenticateBankAccount: function authenticateBankAccount(token) {
|
|
19014
19191
|
var _this4 = this;
|
|
19015
19192
|
|
|
19016
|
-
return validate$
|
|
19193
|
+
return validate$2(this.bankAccount).then(function () {
|
|
19017
19194
|
var chargeParams = {
|
|
19018
19195
|
bankId: _this4.bankAccount.bankId,
|
|
19019
19196
|
transactionId: _this4.id,
|
|
@@ -19238,7 +19415,7 @@ var QrAPI = {
|
|
|
19238
19415
|
}
|
|
19239
19416
|
};
|
|
19240
19417
|
|
|
19241
|
-
function validate$
|
|
19418
|
+
function validate$1(channel) {
|
|
19242
19419
|
return new Promise(function (resolve, reject) {
|
|
19243
19420
|
var allowedChannels = ['visa', 'MPASS_OLTI'];
|
|
19244
19421
|
|
|
@@ -19256,7 +19433,7 @@ var QRCharge = {
|
|
|
19256
19433
|
var _this = this;
|
|
19257
19434
|
|
|
19258
19435
|
var channel = _ref.channel;
|
|
19259
|
-
return validate$
|
|
19436
|
+
return validate$1(channel).then(function () {
|
|
19260
19437
|
if (_this.qr[channel]) {
|
|
19261
19438
|
return _this.qr[channel];
|
|
19262
19439
|
}
|
|
@@ -19278,7 +19455,7 @@ var QRCharge = {
|
|
|
19278
19455
|
var _this2 = this;
|
|
19279
19456
|
|
|
19280
19457
|
var channel = _ref2.channel;
|
|
19281
|
-
return validate$
|
|
19458
|
+
return validate$1(channel).then(function () {
|
|
19282
19459
|
if (!_this2.qr[channel]) {
|
|
19283
19460
|
return Promise.reject(Error('Please generate qr code with Transaction.getQRCode()'));
|
|
19284
19461
|
}
|
|
@@ -19399,7 +19576,7 @@ var MobileMoneyAPI = {
|
|
|
19399
19576
|
}
|
|
19400
19577
|
};
|
|
19401
19578
|
|
|
19402
|
-
function validate
|
|
19579
|
+
function validate(phoneNumber) {
|
|
19403
19580
|
return new Promise(function (resolve, reject) {
|
|
19404
19581
|
var validation = PhoneNumber.validate(phoneNumber);
|
|
19405
19582
|
|
|
@@ -19420,7 +19597,7 @@ var MobileMoneyCharge = {
|
|
|
19420
19597
|
provider = _ref.provider,
|
|
19421
19598
|
voucher = _ref.voucher,
|
|
19422
19599
|
registrationToken = _ref.registrationToken;
|
|
19423
|
-
return validate
|
|
19600
|
+
return validate(phoneNumber).then(function () {
|
|
19424
19601
|
_this.logAttempt('mobile money');
|
|
19425
19602
|
|
|
19426
19603
|
var params = {
|
|
@@ -19451,7 +19628,7 @@ var MobileMoneyCharge = {
|
|
|
19451
19628
|
var phoneNumber = payload.phoneNumber,
|
|
19452
19629
|
provider = payload.provider,
|
|
19453
19630
|
registrationToken = payload.registrationToken;
|
|
19454
|
-
return validate
|
|
19631
|
+
return validate(phoneNumber).then(function () {
|
|
19455
19632
|
_this2.logMobileMoneyActions(payload);
|
|
19456
19633
|
|
|
19457
19634
|
var params = {
|
|
@@ -19507,233 +19684,6 @@ var MobileMoneyCharge = {
|
|
|
19507
19684
|
}
|
|
19508
19685
|
};
|
|
19509
19686
|
|
|
19510
|
-
var PhoneAPI = {
|
|
19511
|
-
verify: function verify(phoneNumber, publicKey) {
|
|
19512
|
-
var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/verify");
|
|
19513
|
-
var language = getLanguage();
|
|
19514
|
-
|
|
19515
|
-
var headers = _objectSpread2({
|
|
19516
|
-
Authorization: "Bearer ".concat(publicKey)
|
|
19517
|
-
}, language && {
|
|
19518
|
-
'Accept-Language': language
|
|
19519
|
-
});
|
|
19520
|
-
|
|
19521
|
-
return axiosInstance.post(url, {
|
|
19522
|
-
phone: phoneNumber
|
|
19523
|
-
}, {
|
|
19524
|
-
headers: headers
|
|
19525
|
-
}).then(function (response) {
|
|
19526
|
-
return response.data;
|
|
19527
|
-
});
|
|
19528
|
-
},
|
|
19529
|
-
deleteCard: function deleteCard(phoneNumber, publicKey, cardId) {
|
|
19530
|
-
var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/remove_card");
|
|
19531
|
-
var language = getLanguage();
|
|
19532
|
-
|
|
19533
|
-
var headers = _objectSpread2({
|
|
19534
|
-
Authorization: "Bearer ".concat(publicKey)
|
|
19535
|
-
}, language && {
|
|
19536
|
-
'Accept-Language': language
|
|
19537
|
-
});
|
|
19538
|
-
|
|
19539
|
-
return axiosInstance.post(url, {
|
|
19540
|
-
phone: phoneNumber,
|
|
19541
|
-
id: cardId
|
|
19542
|
-
}, {
|
|
19543
|
-
headers: headers
|
|
19544
|
-
}).then(function (response) {
|
|
19545
|
-
return response.data;
|
|
19546
|
-
});
|
|
19547
|
-
},
|
|
19548
|
-
authenticateOtp: function authenticateOtp(phoneNumber, publicKey, otp, transactionId) {
|
|
19549
|
-
var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/validate_otp");
|
|
19550
|
-
var language = getLanguage();
|
|
19551
|
-
|
|
19552
|
-
var headers = _objectSpread2({
|
|
19553
|
-
Authorization: "Bearer ".concat(publicKey)
|
|
19554
|
-
}, language && {
|
|
19555
|
-
'Accept-Language': language
|
|
19556
|
-
});
|
|
19557
|
-
|
|
19558
|
-
return axiosInstance.post(url, {
|
|
19559
|
-
phone: phoneNumber,
|
|
19560
|
-
otp: otp,
|
|
19561
|
-
transaction: transactionId
|
|
19562
|
-
}, {
|
|
19563
|
-
headers: headers
|
|
19564
|
-
}).then(function (response) {
|
|
19565
|
-
return response.data;
|
|
19566
|
-
});
|
|
19567
|
-
},
|
|
19568
|
-
authenticatePin: function authenticatePin(phoneNumber, publicKey, pin, transactionId) {
|
|
19569
|
-
var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/validate_pin");
|
|
19570
|
-
var language = getLanguage();
|
|
19571
|
-
|
|
19572
|
-
var headers = _objectSpread2({
|
|
19573
|
-
Authorization: "Bearer ".concat(publicKey)
|
|
19574
|
-
}, language && {
|
|
19575
|
-
'Accept-Language': language
|
|
19576
|
-
});
|
|
19577
|
-
|
|
19578
|
-
return axiosInstance.post(url, {
|
|
19579
|
-
phone: phoneNumber,
|
|
19580
|
-
pin: pin,
|
|
19581
|
-
transaction: transactionId
|
|
19582
|
-
}, {
|
|
19583
|
-
headers: headers
|
|
19584
|
-
}).then(function (response) {
|
|
19585
|
-
return response.data;
|
|
19586
|
-
});
|
|
19587
|
-
},
|
|
19588
|
-
setPin: function setPin(phoneNumber, publicKey, transactionToken, transactionId, pin) {
|
|
19589
|
-
var language = getLanguage();
|
|
19590
|
-
var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/set_pin");
|
|
19591
|
-
|
|
19592
|
-
var headers = _objectSpread2({
|
|
19593
|
-
Authorization: "Bearer ".concat(publicKey)
|
|
19594
|
-
}, language && {
|
|
19595
|
-
'Accept-Language': language
|
|
19596
|
-
});
|
|
19597
|
-
|
|
19598
|
-
return axiosInstance.post(url, {
|
|
19599
|
-
phone: phoneNumber,
|
|
19600
|
-
token: transactionToken,
|
|
19601
|
-
transaction: transactionId,
|
|
19602
|
-
pin: pin
|
|
19603
|
-
}, {
|
|
19604
|
-
headers: headers
|
|
19605
|
-
}).then(function (response) {
|
|
19606
|
-
return response.data;
|
|
19607
|
-
});
|
|
19608
|
-
},
|
|
19609
|
-
charge: function charge(authId, publicKey, token, transactionId, cvv, phoneNumber) {
|
|
19610
|
-
var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/charge");
|
|
19611
|
-
var language = getLanguage();
|
|
19612
|
-
|
|
19613
|
-
var headers = _objectSpread2({
|
|
19614
|
-
Authorization: "Bearer ".concat(publicKey)
|
|
19615
|
-
}, language && {
|
|
19616
|
-
'Accept-Language': language
|
|
19617
|
-
});
|
|
19618
|
-
|
|
19619
|
-
return axiosInstance.post(url, {
|
|
19620
|
-
id: authId,
|
|
19621
|
-
token: token,
|
|
19622
|
-
cvv: cvv,
|
|
19623
|
-
transaction: transactionId,
|
|
19624
|
-
phone: phoneNumber
|
|
19625
|
-
}, {
|
|
19626
|
-
headers: headers
|
|
19627
|
-
}).then(function (response) {
|
|
19628
|
-
return response.data;
|
|
19629
|
-
});
|
|
19630
|
-
},
|
|
19631
|
-
enrollPhoneNumber: function enrollPhoneNumber(phoneNumber, publicKey, transactionId) {
|
|
19632
|
-
var url = "".concat(configToUse.paystackApiUrl, "checkout/pay_with_phone/enroll");
|
|
19633
|
-
var language = getLanguage();
|
|
19634
|
-
|
|
19635
|
-
var headers = _objectSpread2({
|
|
19636
|
-
Authorization: "Bearer ".concat(publicKey)
|
|
19637
|
-
}, language && {
|
|
19638
|
-
'Accept-Language': language
|
|
19639
|
-
});
|
|
19640
|
-
|
|
19641
|
-
return axiosInstance.post(url, {
|
|
19642
|
-
phone: phoneNumber,
|
|
19643
|
-
transaction: transactionId
|
|
19644
|
-
}, {
|
|
19645
|
-
headers: headers
|
|
19646
|
-
}).then(function (response) {
|
|
19647
|
-
return response.data;
|
|
19648
|
-
});
|
|
19649
|
-
}
|
|
19650
|
-
};
|
|
19651
|
-
|
|
19652
|
-
/*
|
|
19653
|
-
TODO:
|
|
19654
|
-
Implement analytics for Pay with Phone. Since unique actions are takens here e.g
|
|
19655
|
-
user verifies pay with phone account, user charged saved card, etc, these should
|
|
19656
|
-
all be reflected as custom analytics actions
|
|
19657
|
-
*/
|
|
19658
|
-
|
|
19659
|
-
function validate(phoneNumber) {
|
|
19660
|
-
return new Promise(function (resolve, reject) {
|
|
19661
|
-
var validation = PhoneNumber.validate(phoneNumber);
|
|
19662
|
-
|
|
19663
|
-
if (!validation.isValid) {
|
|
19664
|
-
var errorMessage = phoneNumber ? validation.errors[0] : 'Please set a valid customer with Transaction.setCustomer()';
|
|
19665
|
-
reject(Error(errorMessage));
|
|
19666
|
-
}
|
|
19667
|
-
|
|
19668
|
-
resolve(validation);
|
|
19669
|
-
});
|
|
19670
|
-
}
|
|
19671
|
-
|
|
19672
|
-
var PhoneNumberCharge = {
|
|
19673
|
-
setCustomer: function setCustomer(_ref) {
|
|
19674
|
-
var _this = this;
|
|
19675
|
-
|
|
19676
|
-
var phoneNumber = _ref.phoneNumber;
|
|
19677
|
-
return validate(phoneNumber).then(function () {
|
|
19678
|
-
_this.customer = phoneNumber;
|
|
19679
|
-
});
|
|
19680
|
-
},
|
|
19681
|
-
verifyCustomer: function verifyCustomer() {
|
|
19682
|
-
var _this2 = this;
|
|
19683
|
-
|
|
19684
|
-
return validate(this.customer).then(function () {
|
|
19685
|
-
return PhoneAPI.verify(_this2.customer, _this2.merchant.key);
|
|
19686
|
-
});
|
|
19687
|
-
},
|
|
19688
|
-
deleteSavedCard: function deleteSavedCard(cardId) {
|
|
19689
|
-
var _this3 = this;
|
|
19690
|
-
|
|
19691
|
-
return validate(this.customer).then(function () {
|
|
19692
|
-
return PhoneAPI.deleteCard(_this3.customer, _this3.merchant.key, cardId);
|
|
19693
|
-
});
|
|
19694
|
-
},
|
|
19695
|
-
authenticateCustomerOtp: function authenticateCustomerOtp(otp) {
|
|
19696
|
-
var _this4 = this;
|
|
19697
|
-
|
|
19698
|
-
return validate(this.customer).then(function () {
|
|
19699
|
-
return PhoneAPI.authenticateOtp(_this4.customer, _this4.merchant.key, otp, _this4.id);
|
|
19700
|
-
});
|
|
19701
|
-
},
|
|
19702
|
-
authenticateCustomerPin: function authenticateCustomerPin(pin) {
|
|
19703
|
-
var _this5 = this;
|
|
19704
|
-
|
|
19705
|
-
return validate(this.customer).then(function () {
|
|
19706
|
-
return PhoneAPI.authenticatePin(_this5.customer, _this5.merchant.key, pin, _this5.id);
|
|
19707
|
-
});
|
|
19708
|
-
},
|
|
19709
|
-
setCustomerPin: function setCustomerPin(_ref2) {
|
|
19710
|
-
var _this6 = this;
|
|
19711
|
-
|
|
19712
|
-
var pin = _ref2.pin,
|
|
19713
|
-
token = _ref2.token;
|
|
19714
|
-
return validate(this.customer).then(function () {
|
|
19715
|
-
return PhoneAPI.setPin(_this6.customer, _this6.merchant.key, token, _this6.id, pin);
|
|
19716
|
-
});
|
|
19717
|
-
},
|
|
19718
|
-
chargeSavedCard: function chargeSavedCard(_ref3) {
|
|
19719
|
-
var _this7 = this;
|
|
19720
|
-
|
|
19721
|
-
var cardId = _ref3.cardId,
|
|
19722
|
-
token = _ref3.token,
|
|
19723
|
-
cvv = _ref3.cvv;
|
|
19724
|
-
return validate(this.customer).then(function () {
|
|
19725
|
-
return PhoneAPI.charge(cardId, _this7.merchant.key, token, _this7.id, cvv, _this7.customer);
|
|
19726
|
-
});
|
|
19727
|
-
},
|
|
19728
|
-
enrollPhoneNumber: function enrollPhoneNumber(number) {
|
|
19729
|
-
var _this8 = this;
|
|
19730
|
-
|
|
19731
|
-
return validate(this.customer).then(function () {
|
|
19732
|
-
return PhoneAPI.enrollPhoneNumber(number, _this8.merchant.key, _this8.id);
|
|
19733
|
-
});
|
|
19734
|
-
}
|
|
19735
|
-
};
|
|
19736
|
-
|
|
19737
19687
|
var DirectDebitAPI = {
|
|
19738
19688
|
loginToDirectDebitAccount: function loginToDirectDebitAccount(_ref) {
|
|
19739
19689
|
var email = _ref.email,
|
|
@@ -19924,7 +19874,6 @@ var ChargeFunctions = {
|
|
|
19924
19874
|
ussd: USSDCharge,
|
|
19925
19875
|
qr: QRCharge,
|
|
19926
19876
|
mobile_money: MobileMoneyCharge,
|
|
19927
|
-
phone: PhoneNumberCharge,
|
|
19928
19877
|
direct_debit: DirectDebitCharge,
|
|
19929
19878
|
bank_transfer: PayWithTransferCharge,
|
|
19930
19879
|
eft: EFT,
|
|
@@ -20354,6 +20303,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20354
20303
|
this.subscription = data.subscription || null;
|
|
20355
20304
|
this.planDetails = data.plan_details || null;
|
|
20356
20305
|
this.exchangeRate = data.exchange_rate || null;
|
|
20306
|
+
this.savedCardsToken = null;
|
|
20307
|
+
this.isSavedCardsEnabled = data.saved_cards && data.saved_cards.enabled || null;
|
|
20357
20308
|
/**
|
|
20358
20309
|
* We initialize parameters we send to the API as empty strings
|
|
20359
20310
|
* when we don't have them instead of null because the API expects
|