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