@paystack/checkout-js 1.19.0 → 1.20.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 +21087 -29
- package/es/checkout.js +634 -120
- package/lib/checkout.js +634 -120
- package/package.json +1 -1
package/es/checkout.js
CHANGED
|
@@ -6403,14 +6403,16 @@ var devConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
|
6403
6403
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6404
6404
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6405
6405
|
pusherKey: '1c7b262ee18455815893',
|
|
6406
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6406
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js',
|
|
6407
|
+
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6407
6408
|
});
|
|
6408
6409
|
var stagingConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6409
6410
|
checkoutUrl: 'https://checkout-studio.paystack.com/',
|
|
6410
6411
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6411
6412
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6412
6413
|
pusherKey: '1c7b262ee18455815893',
|
|
6413
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6414
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js',
|
|
6415
|
+
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6414
6416
|
});
|
|
6415
6417
|
var productionConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6416
6418
|
checkoutUrl: 'https://checkout.paystack.com/',
|
|
@@ -11641,7 +11643,7 @@ var PayattitudeAPI = {
|
|
|
11641
11643
|
}
|
|
11642
11644
|
};
|
|
11643
11645
|
|
|
11644
|
-
var paymentMethod$
|
|
11646
|
+
var paymentMethod$7 = 'payattitude';
|
|
11645
11647
|
var PayattitudeCharge = {
|
|
11646
11648
|
chargePayattitude: function chargePayattitude(_ref) {
|
|
11647
11649
|
var _this = this;
|
|
@@ -11652,7 +11654,7 @@ var PayattitudeCharge = {
|
|
|
11652
11654
|
phoneNumber: phoneNumber
|
|
11653
11655
|
};
|
|
11654
11656
|
return PayattitudeAPI.charge(params).then(function (response) {
|
|
11655
|
-
_this.logAPIResponse(response, paymentMethod$
|
|
11657
|
+
_this.logAPIResponse(response, paymentMethod$7);
|
|
11656
11658
|
|
|
11657
11659
|
return response;
|
|
11658
11660
|
});
|
|
@@ -11660,7 +11662,7 @@ var PayattitudeCharge = {
|
|
|
11660
11662
|
listenForPayattitudeCharge: function listenForPayattitudeCharge(callback) {
|
|
11661
11663
|
var pusherChannel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
11662
11664
|
var listenerOptions = {
|
|
11663
|
-
paymentMethod: paymentMethod$
|
|
11665
|
+
paymentMethod: paymentMethod$7,
|
|
11664
11666
|
channel: pusherChannel
|
|
11665
11667
|
};
|
|
11666
11668
|
return this.listenForCharge(listenerOptions, callback);
|
|
@@ -11743,7 +11745,7 @@ var ApplePayAPI = {
|
|
|
11743
11745
|
}
|
|
11744
11746
|
};
|
|
11745
11747
|
|
|
11746
|
-
var paymentMethod$
|
|
11748
|
+
var paymentMethod$6 = 'apple pay';
|
|
11747
11749
|
var ApplePayCharge = {
|
|
11748
11750
|
validateApplePaySession: function validateApplePaySession(_ref) {
|
|
11749
11751
|
var _this = this;
|
|
@@ -11751,7 +11753,7 @@ var ApplePayCharge = {
|
|
|
11751
11753
|
var sessionUrl = _ref.sessionUrl,
|
|
11752
11754
|
displayName = _ref.displayName,
|
|
11753
11755
|
domainName = _ref.domainName;
|
|
11754
|
-
this.logAttempt(paymentMethod$
|
|
11756
|
+
this.logAttempt(paymentMethod$6);
|
|
11755
11757
|
return ApplePayAPI.validateApplePaySession({
|
|
11756
11758
|
sessionUrl: sessionUrl,
|
|
11757
11759
|
displayName: displayName,
|
|
@@ -11772,7 +11774,7 @@ var ApplePayCharge = {
|
|
|
11772
11774
|
device: this.deviceFingerprint,
|
|
11773
11775
|
paymentObject: paymentObject
|
|
11774
11776
|
}).then(function (response) {
|
|
11775
|
-
_this2.logAPIResponse(response, paymentMethod$
|
|
11777
|
+
_this2.logAPIResponse(response, paymentMethod$6);
|
|
11776
11778
|
|
|
11777
11779
|
return response;
|
|
11778
11780
|
});
|
|
@@ -11828,12 +11830,12 @@ var PayPalAPI = {
|
|
|
11828
11830
|
}
|
|
11829
11831
|
};
|
|
11830
11832
|
|
|
11831
|
-
var paymentMethod$
|
|
11833
|
+
var paymentMethod$5 = 'paypal';
|
|
11832
11834
|
var PayPalCharge = {
|
|
11833
11835
|
createPayPalOrder: function createPayPalOrder() {
|
|
11834
11836
|
var _this = this;
|
|
11835
11837
|
|
|
11836
|
-
this.logAttempt(paymentMethod$
|
|
11838
|
+
this.logAttempt(paymentMethod$5);
|
|
11837
11839
|
return PayPalAPI.createOrder(this.id).then(function (response) {
|
|
11838
11840
|
_this.logAPIResponseMessage(response.message);
|
|
11839
11841
|
|
|
@@ -11844,7 +11846,7 @@ var PayPalCharge = {
|
|
|
11844
11846
|
var _this2 = this;
|
|
11845
11847
|
|
|
11846
11848
|
return PayPalAPI.captureOrder(this.id).then(function (response) {
|
|
11847
|
-
_this2.logAPIResponse(response, paymentMethod$
|
|
11849
|
+
_this2.logAPIResponse(response, paymentMethod$5);
|
|
11848
11850
|
|
|
11849
11851
|
return response;
|
|
11850
11852
|
});
|
|
@@ -18303,8 +18305,96 @@ cardValidator.creditCardType.addCard({
|
|
|
18303
18305
|
}
|
|
18304
18306
|
});
|
|
18305
18307
|
cardValidator.creditCardType.changeOrder('verve', 0);
|
|
18308
|
+
var Card$2 = {
|
|
18309
|
+
getEncryptedPin: function getEncryptedPin(pin) {
|
|
18310
|
+
return pin ? encrypt(pin) : undefined;
|
|
18311
|
+
},
|
|
18312
|
+
getLast4: function getLast4(number) {
|
|
18313
|
+
return number.substring(number.length - 4);
|
|
18314
|
+
},
|
|
18315
|
+
tokenize: function tokenize(_ref) {
|
|
18316
|
+
var number = _ref.number,
|
|
18317
|
+
cvv = _ref.cvv,
|
|
18318
|
+
month = _ref.month,
|
|
18319
|
+
year = _ref.year;
|
|
18320
|
+
return encrypt("".concat(number, "*").concat(cvv, "*").concat(month, "*").concat(year));
|
|
18321
|
+
},
|
|
18322
|
+
getType: function getType(value) {
|
|
18323
|
+
var response = cardValidator.number(value);
|
|
18306
18324
|
|
|
18307
|
-
|
|
18325
|
+
if (response && response.card) {
|
|
18326
|
+
return {
|
|
18327
|
+
type: response.card.type,
|
|
18328
|
+
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18329
|
+
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18330
|
+
};
|
|
18331
|
+
}
|
|
18332
|
+
|
|
18333
|
+
return {
|
|
18334
|
+
type: null,
|
|
18335
|
+
maxLength: 0
|
|
18336
|
+
};
|
|
18337
|
+
},
|
|
18338
|
+
validate: function validate(_ref2) {
|
|
18339
|
+
var number = _ref2.number,
|
|
18340
|
+
cvv = _ref2.cvv,
|
|
18341
|
+
month = _ref2.month,
|
|
18342
|
+
year = _ref2.year;
|
|
18343
|
+
|
|
18344
|
+
var _this$getType = this.getType(number),
|
|
18345
|
+
cardType = _this$getType.type;
|
|
18346
|
+
|
|
18347
|
+
var result = {
|
|
18348
|
+
number: this.isNumberValid(number),
|
|
18349
|
+
expiry: this.isExpiryValid({
|
|
18350
|
+
month: month,
|
|
18351
|
+
year: year
|
|
18352
|
+
}),
|
|
18353
|
+
cvv: this.isCvvValid(cvv, cardType)
|
|
18354
|
+
};
|
|
18355
|
+
var isValid = Object.values(result).every(function (value) {
|
|
18356
|
+
return value === true;
|
|
18357
|
+
});
|
|
18358
|
+
return {
|
|
18359
|
+
isValid: isValid,
|
|
18360
|
+
result: result
|
|
18361
|
+
};
|
|
18362
|
+
},
|
|
18363
|
+
validateNumber: function validateNumber(value) {
|
|
18364
|
+
return cardValidator.number(value);
|
|
18365
|
+
},
|
|
18366
|
+
isNumberValid: function isNumberValid(value) {
|
|
18367
|
+
return Card$2.validateNumber(value).isValid;
|
|
18368
|
+
},
|
|
18369
|
+
validateCVV: function validateCVV(cvv, cardType) {
|
|
18370
|
+
var isAmexCard = cardType === 'american-express';
|
|
18371
|
+
var cvvLength = isAmexCard ? 4 : 3;
|
|
18372
|
+
return cardValidator.cvv(cvv, cvvLength);
|
|
18373
|
+
},
|
|
18374
|
+
isCvvValid: function isCvvValid(cvv, cardType) {
|
|
18375
|
+
return Card$2.validateCVV(cvv, cardType).isValid;
|
|
18376
|
+
},
|
|
18377
|
+
validateExpiry: function validateExpiry(value) {
|
|
18378
|
+
if (_typeof$1(value) === 'object') {
|
|
18379
|
+
var month = value.month,
|
|
18380
|
+
year = value.year;
|
|
18381
|
+
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18382
|
+
}
|
|
18383
|
+
|
|
18384
|
+
return cardValidator.expirationDate(value);
|
|
18385
|
+
},
|
|
18386
|
+
isExpiryValid: function isExpiryValid(value) {
|
|
18387
|
+
return Card$2.validateExpiry(value).isValid;
|
|
18388
|
+
},
|
|
18389
|
+
findTestCard: function findTestCard(cardType) {
|
|
18390
|
+
var type = cardType || 'default';
|
|
18391
|
+
return testCards.find(function (card) {
|
|
18392
|
+
return card.type === type;
|
|
18393
|
+
});
|
|
18394
|
+
}
|
|
18395
|
+
};
|
|
18396
|
+
|
|
18397
|
+
var Card$1 = /*#__PURE__*/function () {
|
|
18308
18398
|
function Card(_ref) {
|
|
18309
18399
|
var number = _ref.number,
|
|
18310
18400
|
cvv = _ref.cvv,
|
|
@@ -18324,35 +18414,27 @@ var Card = /*#__PURE__*/function () {
|
|
|
18324
18414
|
_createClass(Card, [{
|
|
18325
18415
|
key: "getEncryptedPin",
|
|
18326
18416
|
value: function getEncryptedPin() {
|
|
18327
|
-
return
|
|
18417
|
+
return Card$2.getEncryptedPin(this.pin);
|
|
18328
18418
|
}
|
|
18329
18419
|
}, {
|
|
18330
18420
|
key: "getLast4",
|
|
18331
18421
|
value: function getLast4() {
|
|
18332
|
-
return
|
|
18422
|
+
return Card$2.getLast4(this.number);
|
|
18333
18423
|
}
|
|
18334
18424
|
}, {
|
|
18335
18425
|
key: "tokenize",
|
|
18336
18426
|
value: function tokenize() {
|
|
18337
|
-
return
|
|
18427
|
+
return Card$2.tokenize({
|
|
18428
|
+
number: this.number,
|
|
18429
|
+
cvv: this.cvv,
|
|
18430
|
+
month: this.month,
|
|
18431
|
+
year: this.year
|
|
18432
|
+
});
|
|
18338
18433
|
}
|
|
18339
18434
|
}], [{
|
|
18340
18435
|
key: "getType",
|
|
18341
18436
|
value: function getType(value) {
|
|
18342
|
-
|
|
18343
|
-
|
|
18344
|
-
if (response && response.card) {
|
|
18345
|
-
return {
|
|
18346
|
-
type: response.card.type,
|
|
18347
|
-
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18348
|
-
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18349
|
-
};
|
|
18350
|
-
}
|
|
18351
|
-
|
|
18352
|
-
return {
|
|
18353
|
-
type: null,
|
|
18354
|
-
maxLength: 0
|
|
18355
|
-
};
|
|
18437
|
+
return Card$2.getType(value);
|
|
18356
18438
|
}
|
|
18357
18439
|
}, {
|
|
18358
18440
|
key: "validate",
|
|
@@ -18361,79 +18443,54 @@ var Card = /*#__PURE__*/function () {
|
|
|
18361
18443
|
cvv = _ref2.cvv,
|
|
18362
18444
|
month = _ref2.month,
|
|
18363
18445
|
year = _ref2.year;
|
|
18364
|
-
|
|
18365
|
-
|
|
18366
|
-
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
number: Card.isNumberValid(number),
|
|
18370
|
-
expiry: Card.isExpiryValid({
|
|
18371
|
-
month: month,
|
|
18372
|
-
year: year
|
|
18373
|
-
}),
|
|
18374
|
-
cvv: Card.isCvvValid(cvv, cardType)
|
|
18375
|
-
};
|
|
18376
|
-
var isValid = Object.values(result).every(function (value) {
|
|
18377
|
-
return value === true;
|
|
18446
|
+
return Card$2.validate({
|
|
18447
|
+
number: number,
|
|
18448
|
+
cvv: cvv,
|
|
18449
|
+
month: month,
|
|
18450
|
+
year: year
|
|
18378
18451
|
});
|
|
18379
|
-
return {
|
|
18380
|
-
isValid: isValid,
|
|
18381
|
-
result: result
|
|
18382
|
-
};
|
|
18383
18452
|
}
|
|
18384
18453
|
}, {
|
|
18385
18454
|
key: "validateNumber",
|
|
18386
18455
|
value: function validateNumber(value) {
|
|
18387
|
-
return
|
|
18456
|
+
return Card$2.validateNumber(value);
|
|
18388
18457
|
}
|
|
18389
18458
|
}, {
|
|
18390
18459
|
key: "isNumberValid",
|
|
18391
18460
|
value: function isNumberValid(value) {
|
|
18392
|
-
return Card.
|
|
18461
|
+
return Card$2.isNumberValid(value);
|
|
18393
18462
|
}
|
|
18394
18463
|
}, {
|
|
18395
18464
|
key: "validateCVV",
|
|
18396
18465
|
value: function validateCVV(cvv, cardType) {
|
|
18397
|
-
|
|
18398
|
-
var cvvLength = isAmexCard ? 4 : 3;
|
|
18399
|
-
return cardValidator.cvv(cvv, cvvLength);
|
|
18466
|
+
return Card$2.validateCVV(cvv, cardType);
|
|
18400
18467
|
}
|
|
18401
18468
|
}, {
|
|
18402
18469
|
key: "isCvvValid",
|
|
18403
18470
|
value: function isCvvValid(cvv, cardType) {
|
|
18404
|
-
return Card.
|
|
18471
|
+
return Card$2.isCvvValid(cvv, cardType);
|
|
18405
18472
|
}
|
|
18406
18473
|
}, {
|
|
18407
18474
|
key: "validateExpiry",
|
|
18408
18475
|
value: function validateExpiry(value) {
|
|
18409
|
-
|
|
18410
|
-
var month = value.month,
|
|
18411
|
-
year = value.year;
|
|
18412
|
-
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18413
|
-
}
|
|
18414
|
-
|
|
18415
|
-
return cardValidator.expirationDate(value);
|
|
18476
|
+
return Card$2.validateExpiry(value);
|
|
18416
18477
|
}
|
|
18417
18478
|
}, {
|
|
18418
18479
|
key: "isExpiryValid",
|
|
18419
18480
|
value: function isExpiryValid(value) {
|
|
18420
|
-
return Card.
|
|
18481
|
+
return Card$2.isExpiryValid(value);
|
|
18421
18482
|
}
|
|
18422
18483
|
}, {
|
|
18423
18484
|
key: "generateTestCard",
|
|
18424
18485
|
value: function generateTestCard(cardType) {
|
|
18425
|
-
|
|
18426
|
-
var cardParams = testCards.find(function (card) {
|
|
18427
|
-
return card.type === type;
|
|
18428
|
-
});
|
|
18429
|
-
return new Card(cardParams);
|
|
18486
|
+
return new Card(Card$2.findTestCard(cardType));
|
|
18430
18487
|
}
|
|
18431
18488
|
}]);
|
|
18432
18489
|
|
|
18433
18490
|
return Card;
|
|
18434
18491
|
}();
|
|
18435
18492
|
|
|
18436
|
-
var CardAPI = {
|
|
18493
|
+
var CardAPI$1 = {
|
|
18437
18494
|
charge: function charge(_ref) {
|
|
18438
18495
|
var clientdata = _ref.clientdata,
|
|
18439
18496
|
last4 = _ref.last4,
|
|
@@ -18609,14 +18666,216 @@ var CardAPI = {
|
|
|
18609
18666
|
}).then(function (response) {
|
|
18610
18667
|
return ChargeResponses.parse(response.data);
|
|
18611
18668
|
});
|
|
18669
|
+
},
|
|
18670
|
+
sendSavedCardsOTP: function sendSavedCardsOTP(email) {
|
|
18671
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18672
|
+
var url, language, headers, _yield$axiosInstance$, data;
|
|
18673
|
+
|
|
18674
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18675
|
+
while (1) {
|
|
18676
|
+
switch (_context.prev = _context.next) {
|
|
18677
|
+
case 0:
|
|
18678
|
+
url = new URL("/authorize", configToUse.savedCardsApiUrl).toString();
|
|
18679
|
+
language = getLanguage();
|
|
18680
|
+
headers = _objectSpread2({}, language && {
|
|
18681
|
+
'Accept-Language': language
|
|
18682
|
+
});
|
|
18683
|
+
_context.next = 5;
|
|
18684
|
+
return axiosInstance.post(url, {
|
|
18685
|
+
email: email
|
|
18686
|
+
}, {
|
|
18687
|
+
headers: headers
|
|
18688
|
+
});
|
|
18689
|
+
|
|
18690
|
+
case 5:
|
|
18691
|
+
_yield$axiosInstance$ = _context.sent;
|
|
18692
|
+
data = _yield$axiosInstance$.data;
|
|
18693
|
+
return _context.abrupt("return", data);
|
|
18694
|
+
|
|
18695
|
+
case 8:
|
|
18696
|
+
case "end":
|
|
18697
|
+
return _context.stop();
|
|
18698
|
+
}
|
|
18699
|
+
}
|
|
18700
|
+
}, _callee);
|
|
18701
|
+
}))();
|
|
18702
|
+
},
|
|
18703
|
+
addUserToSavedCards: function addUserToSavedCards(_ref6) {
|
|
18704
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18705
|
+
var phone, email, url, language, headers, data, response;
|
|
18706
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18707
|
+
while (1) {
|
|
18708
|
+
switch (_context2.prev = _context2.next) {
|
|
18709
|
+
case 0:
|
|
18710
|
+
phone = _ref6.phone, email = _ref6.email;
|
|
18711
|
+
url = new URL('/user', configToUse.savedCardsApiUrl).toString();
|
|
18712
|
+
language = getLanguage();
|
|
18713
|
+
headers = _objectSpread2({}, language && {
|
|
18714
|
+
'Accept-Language': language
|
|
18715
|
+
});
|
|
18716
|
+
data = {
|
|
18717
|
+
phone: phone,
|
|
18718
|
+
email: email
|
|
18719
|
+
};
|
|
18720
|
+
_context2.next = 7;
|
|
18721
|
+
return axiosInstance.post(url, data, {
|
|
18722
|
+
headers: headers
|
|
18723
|
+
});
|
|
18724
|
+
|
|
18725
|
+
case 7:
|
|
18726
|
+
response = _context2.sent;
|
|
18727
|
+
return _context2.abrupt("return", response.data);
|
|
18728
|
+
|
|
18729
|
+
case 9:
|
|
18730
|
+
case "end":
|
|
18731
|
+
return _context2.stop();
|
|
18732
|
+
}
|
|
18733
|
+
}
|
|
18734
|
+
}, _callee2);
|
|
18735
|
+
}))();
|
|
18736
|
+
},
|
|
18737
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref7) {
|
|
18738
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18739
|
+
var code, transaction, url, language, headers, data, response;
|
|
18740
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18741
|
+
while (1) {
|
|
18742
|
+
switch (_context3.prev = _context3.next) {
|
|
18743
|
+
case 0:
|
|
18744
|
+
code = _ref7.code, transaction = _ref7.transaction;
|
|
18745
|
+
url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
|
|
18746
|
+
language = getLanguage();
|
|
18747
|
+
headers = _objectSpread2({}, language && {
|
|
18748
|
+
'Accept-Language': language
|
|
18749
|
+
});
|
|
18750
|
+
data = {
|
|
18751
|
+
code: code,
|
|
18752
|
+
transaction: transaction
|
|
18753
|
+
};
|
|
18754
|
+
_context3.next = 7;
|
|
18755
|
+
return axiosInstance.post(url, data, {
|
|
18756
|
+
headers: headers
|
|
18757
|
+
});
|
|
18758
|
+
|
|
18759
|
+
case 7:
|
|
18760
|
+
response = _context3.sent;
|
|
18761
|
+
return _context3.abrupt("return", response.data);
|
|
18762
|
+
|
|
18763
|
+
case 9:
|
|
18764
|
+
case "end":
|
|
18765
|
+
return _context3.stop();
|
|
18766
|
+
}
|
|
18767
|
+
}
|
|
18768
|
+
}, _callee3);
|
|
18769
|
+
}))();
|
|
18770
|
+
},
|
|
18771
|
+
getSavedCards: function getSavedCards(_ref8) {
|
|
18772
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18773
|
+
var token, url, language, headers, response;
|
|
18774
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18775
|
+
while (1) {
|
|
18776
|
+
switch (_context4.prev = _context4.next) {
|
|
18777
|
+
case 0:
|
|
18778
|
+
token = _ref8.token;
|
|
18779
|
+
url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
|
|
18780
|
+
language = getLanguage();
|
|
18781
|
+
headers = _objectSpread2({
|
|
18782
|
+
Authorization: "Bearer ".concat(token),
|
|
18783
|
+
'jwt-auth': true
|
|
18784
|
+
}, language && {
|
|
18785
|
+
'Accept-Language': language
|
|
18786
|
+
});
|
|
18787
|
+
_context4.next = 6;
|
|
18788
|
+
return axiosInstance.get(url, {
|
|
18789
|
+
headers: headers
|
|
18790
|
+
});
|
|
18791
|
+
|
|
18792
|
+
case 6:
|
|
18793
|
+
response = _context4.sent;
|
|
18794
|
+
return _context4.abrupt("return", response.data);
|
|
18795
|
+
|
|
18796
|
+
case 8:
|
|
18797
|
+
case "end":
|
|
18798
|
+
return _context4.stop();
|
|
18799
|
+
}
|
|
18800
|
+
}
|
|
18801
|
+
}, _callee4);
|
|
18802
|
+
}))();
|
|
18803
|
+
},
|
|
18804
|
+
deleteSavedCard: function deleteSavedCard(_ref9) {
|
|
18805
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
18806
|
+
var cardCode, token, url, language, headers, response;
|
|
18807
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
18808
|
+
while (1) {
|
|
18809
|
+
switch (_context5.prev = _context5.next) {
|
|
18810
|
+
case 0:
|
|
18811
|
+
cardCode = _ref9.cardCode, token = _ref9.token;
|
|
18812
|
+
url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
|
|
18813
|
+
language = getLanguage();
|
|
18814
|
+
headers = _objectSpread2({
|
|
18815
|
+
Authorization: "Bearer ".concat(token),
|
|
18816
|
+
'jwt-auth': true
|
|
18817
|
+
}, language && {
|
|
18818
|
+
'Accept-Language': language
|
|
18819
|
+
});
|
|
18820
|
+
_context5.next = 6;
|
|
18821
|
+
return axiosInstance.delete(url, {
|
|
18822
|
+
headers: headers
|
|
18823
|
+
});
|
|
18824
|
+
|
|
18825
|
+
case 6:
|
|
18826
|
+
response = _context5.sent;
|
|
18827
|
+
return _context5.abrupt("return", response.data);
|
|
18828
|
+
|
|
18829
|
+
case 8:
|
|
18830
|
+
case "end":
|
|
18831
|
+
return _context5.stop();
|
|
18832
|
+
}
|
|
18833
|
+
}
|
|
18834
|
+
}, _callee5);
|
|
18835
|
+
}))();
|
|
18836
|
+
},
|
|
18837
|
+
chargeSavedCard: function chargeSavedCard(_ref10) {
|
|
18838
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
18839
|
+
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data;
|
|
18840
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
18841
|
+
while (1) {
|
|
18842
|
+
switch (_context6.prev = _context6.next) {
|
|
18843
|
+
case 0:
|
|
18844
|
+
token = _ref10.token, device = _ref10.device, cardCode = _ref10.cardCode, transaction = _ref10.transaction, selectedCurrency = _ref10.selectedCurrency;
|
|
18845
|
+
url = new URL("/cards/".concat(cardCode, "/charge"), configToUse.savedCardsApiUrl).toString();
|
|
18846
|
+
language = getLanguage();
|
|
18847
|
+
headers = _objectSpread2({
|
|
18848
|
+
Authorization: "Bearer ".concat(token),
|
|
18849
|
+
'jwt-auth': true
|
|
18850
|
+
}, language && {
|
|
18851
|
+
'Accept-Language': language
|
|
18852
|
+
});
|
|
18853
|
+
data = {
|
|
18854
|
+
device: device,
|
|
18855
|
+
transaction: transaction,
|
|
18856
|
+
selectedCurrency: selectedCurrency
|
|
18857
|
+
};
|
|
18858
|
+
return _context6.abrupt("return", axiosInstance.post(url, data, {
|
|
18859
|
+
headers: headers
|
|
18860
|
+
}).then(function (response) {
|
|
18861
|
+
return ChargeResponses.parse(response.data);
|
|
18862
|
+
}));
|
|
18863
|
+
|
|
18864
|
+
case 6:
|
|
18865
|
+
case "end":
|
|
18866
|
+
return _context6.stop();
|
|
18867
|
+
}
|
|
18868
|
+
}
|
|
18869
|
+
}, _callee6);
|
|
18870
|
+
}))();
|
|
18612
18871
|
}
|
|
18613
18872
|
};
|
|
18614
18873
|
|
|
18615
|
-
var paymentMethod$
|
|
18874
|
+
var paymentMethod$4 = 'card';
|
|
18616
18875
|
|
|
18617
|
-
function validate$
|
|
18876
|
+
function validate$4(card, isSetter) {
|
|
18618
18877
|
return new Promise(function (resolve, reject) {
|
|
18619
|
-
var validation = Card.validate(card);
|
|
18878
|
+
var validation = Card$1.validate(card);
|
|
18620
18879
|
|
|
18621
18880
|
if (!validation.isValid) {
|
|
18622
18881
|
var throwValidation = isSetter || card.number;
|
|
@@ -18635,8 +18894,8 @@ var CardCharge = {
|
|
|
18635
18894
|
setCard: function setCard(params) {
|
|
18636
18895
|
var _this = this;
|
|
18637
18896
|
|
|
18638
|
-
return validate$
|
|
18639
|
-
_this.card = new Card(params);
|
|
18897
|
+
return validate$4(params, true).then(function () {
|
|
18898
|
+
_this.card = new Card$1(params);
|
|
18640
18899
|
});
|
|
18641
18900
|
},
|
|
18642
18901
|
rememberCard: function rememberCard() {
|
|
@@ -18651,8 +18910,8 @@ var CardCharge = {
|
|
|
18651
18910
|
return this.chargeCardWithPin(customFields);
|
|
18652
18911
|
}
|
|
18653
18912
|
|
|
18654
|
-
return validate$
|
|
18655
|
-
_this2.logAttempt(paymentMethod$
|
|
18913
|
+
return validate$4(this.card).then(function () {
|
|
18914
|
+
_this2.logAttempt(paymentMethod$4);
|
|
18656
18915
|
|
|
18657
18916
|
var chargeParams = {
|
|
18658
18917
|
clientdata: _this2.card.tokenize(),
|
|
@@ -18665,8 +18924,8 @@ var CardCharge = {
|
|
|
18665
18924
|
subscription: _this2.subscription,
|
|
18666
18925
|
customFields: customFields
|
|
18667
18926
|
};
|
|
18668
|
-
return CardAPI.charge(chargeParams).then(function (response) {
|
|
18669
|
-
_this2.logAPIResponse(response, paymentMethod$
|
|
18927
|
+
return CardAPI$1.charge(chargeParams).then(function (response) {
|
|
18928
|
+
_this2.logAPIResponse(response, paymentMethod$4);
|
|
18670
18929
|
|
|
18671
18930
|
return response;
|
|
18672
18931
|
});
|
|
@@ -18681,7 +18940,7 @@ var CardCharge = {
|
|
|
18681
18940
|
var _this3 = this;
|
|
18682
18941
|
|
|
18683
18942
|
var customFields = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18684
|
-
this.logAttempt(paymentMethod$
|
|
18943
|
+
this.logAttempt(paymentMethod$4);
|
|
18685
18944
|
var chargeParams = {
|
|
18686
18945
|
pin: encrypt(this.card.pin),
|
|
18687
18946
|
trans: this.id,
|
|
@@ -18691,8 +18950,8 @@ var CardCharge = {
|
|
|
18691
18950
|
subscription: this.subscription,
|
|
18692
18951
|
customFields: customFields
|
|
18693
18952
|
};
|
|
18694
|
-
return CardAPI.charge(chargeParams).then(function (response) {
|
|
18695
|
-
_this3.logAPIResponse(response, paymentMethod$
|
|
18953
|
+
return CardAPI$1.charge(chargeParams).then(function (response) {
|
|
18954
|
+
_this3.logAPIResponse(response, paymentMethod$4);
|
|
18696
18955
|
|
|
18697
18956
|
return response;
|
|
18698
18957
|
});
|
|
@@ -18704,7 +18963,7 @@ var CardCharge = {
|
|
|
18704
18963
|
authorizationCode = _ref.authorizationCode,
|
|
18705
18964
|
cardLast4 = _ref.cardLast4,
|
|
18706
18965
|
pin = _ref.pin;
|
|
18707
|
-
this.logAttempt(paymentMethod$
|
|
18966
|
+
this.logAttempt(paymentMethod$4);
|
|
18708
18967
|
var encryptedPin = encrypt(pin);
|
|
18709
18968
|
var chargeParams = {
|
|
18710
18969
|
authorizationCode: authorizationCode,
|
|
@@ -18716,8 +18975,8 @@ var CardCharge = {
|
|
|
18716
18975
|
transactionType: this.transactionType,
|
|
18717
18976
|
subscription: this.subscription
|
|
18718
18977
|
};
|
|
18719
|
-
return CardAPI.chargeRememberedCard(chargeParams).then(function (response) {
|
|
18720
|
-
_this4.logAPIResponse(response, paymentMethod$
|
|
18978
|
+
return CardAPI$1.chargeRememberedCard(chargeParams).then(function (response) {
|
|
18979
|
+
_this4.logAPIResponse(response, paymentMethod$4);
|
|
18721
18980
|
|
|
18722
18981
|
return response;
|
|
18723
18982
|
});
|
|
@@ -18735,8 +18994,8 @@ var CardCharge = {
|
|
|
18735
18994
|
device: this.deviceFingerprint
|
|
18736
18995
|
});
|
|
18737
18996
|
|
|
18738
|
-
return CardAPI.resumeCardCharge(params).then(function (response) {
|
|
18739
|
-
_this5.logAPIResponse(response, paymentMethod$
|
|
18997
|
+
return CardAPI$1.resumeCardCharge(params).then(function (response) {
|
|
18998
|
+
_this5.logAPIResponse(response, paymentMethod$4);
|
|
18740
18999
|
|
|
18741
19000
|
return response;
|
|
18742
19001
|
});
|
|
@@ -18748,8 +19007,8 @@ var CardCharge = {
|
|
|
18748
19007
|
authorizationId: authorizationId,
|
|
18749
19008
|
publicKey: this.merchant.key
|
|
18750
19009
|
};
|
|
18751
|
-
return CardAPI.forgetRememberedCard(params).then(function (response) {
|
|
18752
|
-
_this6.logAPIResponse(response, paymentMethod$
|
|
19010
|
+
return CardAPI$1.forgetRememberedCard(params).then(function (response) {
|
|
19011
|
+
_this6.logAPIResponse(response, paymentMethod$4);
|
|
18753
19012
|
|
|
18754
19013
|
return response;
|
|
18755
19014
|
});
|
|
@@ -18757,8 +19016,8 @@ var CardCharge = {
|
|
|
18757
19016
|
authenticateCard: function authenticateCard(token) {
|
|
18758
19017
|
var _this7 = this;
|
|
18759
19018
|
|
|
18760
|
-
return CardAPI.authenticate(this.id, token).then(function (response) {
|
|
18761
|
-
_this7.logAPIResponse(response, paymentMethod$
|
|
19019
|
+
return CardAPI$1.authenticate(this.id, token).then(function (response) {
|
|
19020
|
+
_this7.logAPIResponse(response, paymentMethod$4);
|
|
18762
19021
|
|
|
18763
19022
|
return response;
|
|
18764
19023
|
});
|
|
@@ -18777,8 +19036,8 @@ var CardCharge = {
|
|
|
18777
19036
|
zipCode: zipCode,
|
|
18778
19037
|
transactionId: this.id
|
|
18779
19038
|
};
|
|
18780
|
-
return CardAPI.verifyAddress(payload).then(function (response) {
|
|
18781
|
-
_this8.logAPIResponse(response, paymentMethod$
|
|
19039
|
+
return CardAPI$1.verifyAddress(payload).then(function (response) {
|
|
19040
|
+
_this8.logAPIResponse(response, paymentMethod$4);
|
|
18782
19041
|
|
|
18783
19042
|
return response;
|
|
18784
19043
|
});
|
|
@@ -18786,9 +19045,77 @@ var CardCharge = {
|
|
|
18786
19045
|
listenFor3DSCharge: function listenFor3DSCharge(callback) {
|
|
18787
19046
|
var listenerOptions = {
|
|
18788
19047
|
channel: "3DS_".concat(this.id),
|
|
18789
|
-
paymentMethod: paymentMethod$
|
|
19048
|
+
paymentMethod: paymentMethod$4
|
|
18790
19049
|
};
|
|
18791
19050
|
return this.listenForCharge(listenerOptions, callback);
|
|
19051
|
+
},
|
|
19052
|
+
sendSavedCardsOTP: function sendSavedCardsOTP() {
|
|
19053
|
+
return CardAPI$1.sendSavedCardsOTP(this.email);
|
|
19054
|
+
},
|
|
19055
|
+
addUserToSavedCards: function addUserToSavedCards(_ref4) {
|
|
19056
|
+
var phone = _ref4.phone;
|
|
19057
|
+
return CardAPI$1.addUserToSavedCards({
|
|
19058
|
+
phone: phone,
|
|
19059
|
+
email: this.email
|
|
19060
|
+
});
|
|
19061
|
+
},
|
|
19062
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
|
|
19063
|
+
var _this9 = this;
|
|
19064
|
+
|
|
19065
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
19066
|
+
var code, payload, response;
|
|
19067
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19068
|
+
while (1) {
|
|
19069
|
+
switch (_context.prev = _context.next) {
|
|
19070
|
+
case 0:
|
|
19071
|
+
code = _ref5.code;
|
|
19072
|
+
payload = {
|
|
19073
|
+
code: code,
|
|
19074
|
+
transaction: _this9.id
|
|
19075
|
+
};
|
|
19076
|
+
_context.prev = 2;
|
|
19077
|
+
_context.next = 5;
|
|
19078
|
+
return CardAPI$1.verifySavedCardsOtp(payload);
|
|
19079
|
+
|
|
19080
|
+
case 5:
|
|
19081
|
+
response = _context.sent;
|
|
19082
|
+
_this9.savedCardsToken = response.data.token;
|
|
19083
|
+
return _context.abrupt("return", response);
|
|
19084
|
+
|
|
19085
|
+
case 10:
|
|
19086
|
+
_context.prev = 10;
|
|
19087
|
+
_context.t0 = _context["catch"](2);
|
|
19088
|
+
_this9.savedCardsToken = null;
|
|
19089
|
+
throw _context.t0;
|
|
19090
|
+
|
|
19091
|
+
case 14:
|
|
19092
|
+
case "end":
|
|
19093
|
+
return _context.stop();
|
|
19094
|
+
}
|
|
19095
|
+
}
|
|
19096
|
+
}, _callee, null, [[2, 10]]);
|
|
19097
|
+
}))();
|
|
19098
|
+
},
|
|
19099
|
+
getSavedCards: function getSavedCards() {
|
|
19100
|
+
return CardAPI$1.getSavedCards({
|
|
19101
|
+
token: this.savedCardsToken
|
|
19102
|
+
});
|
|
19103
|
+
},
|
|
19104
|
+
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
19105
|
+
return CardAPI$1.deleteSavedCard({
|
|
19106
|
+
cardCode: cardCode,
|
|
19107
|
+
token: this.savedCardsToken
|
|
19108
|
+
});
|
|
19109
|
+
},
|
|
19110
|
+
chargeSavedCard: function chargeSavedCard(_ref6) {
|
|
19111
|
+
var cardCode = _ref6.cardCode;
|
|
19112
|
+
return CardAPI$1.chargeSavedCard({
|
|
19113
|
+
cardCode: cardCode,
|
|
19114
|
+
transaction: this.id,
|
|
19115
|
+
token: this.savedCardsToken,
|
|
19116
|
+
device: this.deviceFingerprint,
|
|
19117
|
+
selectedCurrency: this.currency
|
|
19118
|
+
});
|
|
18792
19119
|
}
|
|
18793
19120
|
};
|
|
18794
19121
|
|
|
@@ -18941,9 +19268,9 @@ var EMandateAPI = {
|
|
|
18941
19268
|
}
|
|
18942
19269
|
};
|
|
18943
19270
|
|
|
18944
|
-
var paymentMethod$
|
|
19271
|
+
var paymentMethod$3 = 'bank account';
|
|
18945
19272
|
|
|
18946
|
-
function validate$
|
|
19273
|
+
function validate$3(bankAccount, isSetter) {
|
|
18947
19274
|
return new Promise(function (resolve, reject) {
|
|
18948
19275
|
var validation = BankAccount.validate(bankAccount);
|
|
18949
19276
|
|
|
@@ -18961,15 +19288,15 @@ var EMandate = {
|
|
|
18961
19288
|
setBankAccount: function setBankAccount(params) {
|
|
18962
19289
|
var _this = this;
|
|
18963
19290
|
|
|
18964
|
-
return validate$
|
|
19291
|
+
return validate$3(params, true).then(function () {
|
|
18965
19292
|
_this.bankAccount = new BankAccount(params);
|
|
18966
19293
|
});
|
|
18967
19294
|
},
|
|
18968
19295
|
chargeBankAccount: function chargeBankAccount() {
|
|
18969
19296
|
var _this2 = this;
|
|
18970
19297
|
|
|
18971
|
-
return validate$
|
|
18972
|
-
_this2.logAttempt(paymentMethod$
|
|
19298
|
+
return validate$3(this.bankAccount).then(function () {
|
|
19299
|
+
_this2.logAttempt(paymentMethod$3);
|
|
18973
19300
|
|
|
18974
19301
|
var verifyParams = {
|
|
18975
19302
|
bankId: _this2.bankAccount.bankId,
|
|
@@ -18978,7 +19305,7 @@ var EMandate = {
|
|
|
18978
19305
|
device: _this2.deviceFingerprint
|
|
18979
19306
|
};
|
|
18980
19307
|
return EMandateAPI.verify(verifyParams).then(function (response) {
|
|
18981
|
-
_this2.logAPIResponse(response, paymentMethod$
|
|
19308
|
+
_this2.logAPIResponse(response, paymentMethod$3);
|
|
18982
19309
|
|
|
18983
19310
|
return response;
|
|
18984
19311
|
});
|
|
@@ -18987,7 +19314,7 @@ var EMandate = {
|
|
|
18987
19314
|
registerBankAccount: function registerBankAccount(birthday) {
|
|
18988
19315
|
var _this3 = this;
|
|
18989
19316
|
|
|
18990
|
-
return validate$
|
|
19317
|
+
return validate$3(this.bankAccount).then(function () {
|
|
18991
19318
|
var registerParams = {
|
|
18992
19319
|
bankId: _this3.bankAccount.bankId,
|
|
18993
19320
|
transactionId: _this3.id,
|
|
@@ -18995,7 +19322,7 @@ var EMandate = {
|
|
|
18995
19322
|
birthday: birthday
|
|
18996
19323
|
};
|
|
18997
19324
|
return EMandateAPI.register(registerParams).then(function (response) {
|
|
18998
|
-
_this3.logAPIResponse(response, paymentMethod$
|
|
19325
|
+
_this3.logAPIResponse(response, paymentMethod$3);
|
|
18999
19326
|
|
|
19000
19327
|
return response;
|
|
19001
19328
|
});
|
|
@@ -19004,7 +19331,7 @@ var EMandate = {
|
|
|
19004
19331
|
authenticateBankAccount: function authenticateBankAccount(token) {
|
|
19005
19332
|
var _this4 = this;
|
|
19006
19333
|
|
|
19007
|
-
return validate$
|
|
19334
|
+
return validate$3(this.bankAccount).then(function () {
|
|
19008
19335
|
var chargeParams = {
|
|
19009
19336
|
bankId: _this4.bankAccount.bankId,
|
|
19010
19337
|
transactionId: _this4.id,
|
|
@@ -19012,7 +19339,7 @@ var EMandate = {
|
|
|
19012
19339
|
device: _this4.deviceFingerprint
|
|
19013
19340
|
};
|
|
19014
19341
|
return EMandateAPI.authenticate(chargeParams).then(function (response) {
|
|
19015
|
-
_this4.logAPIResponse(response, paymentMethod$
|
|
19342
|
+
_this4.logAPIResponse(response, paymentMethod$3);
|
|
19016
19343
|
|
|
19017
19344
|
return response;
|
|
19018
19345
|
});
|
|
@@ -19073,7 +19400,7 @@ var DigitalBankMandateAPI = {
|
|
|
19073
19400
|
}
|
|
19074
19401
|
};
|
|
19075
19402
|
|
|
19076
|
-
var paymentMethod$
|
|
19403
|
+
var paymentMethod$2 = 'bank';
|
|
19077
19404
|
var DigitalBankMandate = {
|
|
19078
19405
|
chargeDigitalBankMandate: function chargeDigitalBankMandate(_ref) {
|
|
19079
19406
|
var _this = this;
|
|
@@ -19088,7 +19415,7 @@ var DigitalBankMandate = {
|
|
|
19088
19415
|
bankId: bankId
|
|
19089
19416
|
};
|
|
19090
19417
|
return DigitalBankMandateAPI.charge(params).then(function (response) {
|
|
19091
|
-
_this.logAPIResponse(response, paymentMethod$
|
|
19418
|
+
_this.logAPIResponse(response, paymentMethod$2);
|
|
19092
19419
|
|
|
19093
19420
|
return response;
|
|
19094
19421
|
});
|
|
@@ -19096,7 +19423,7 @@ var DigitalBankMandate = {
|
|
|
19096
19423
|
listenForDigitalBankMandateCharge: function listenForDigitalBankMandateCharge(callback) {
|
|
19097
19424
|
var pusherChannel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
19098
19425
|
var listenerOptions = {
|
|
19099
|
-
paymentMethod: paymentMethod$
|
|
19426
|
+
paymentMethod: paymentMethod$2,
|
|
19100
19427
|
channel: pusherChannel
|
|
19101
19428
|
};
|
|
19102
19429
|
return this.listenForCharge(listenerOptions, callback);
|
|
@@ -19229,7 +19556,7 @@ var QrAPI = {
|
|
|
19229
19556
|
}
|
|
19230
19557
|
};
|
|
19231
19558
|
|
|
19232
|
-
function validate$
|
|
19559
|
+
function validate$2(channel) {
|
|
19233
19560
|
return new Promise(function (resolve, reject) {
|
|
19234
19561
|
var allowedChannels = ['visa', 'MPASS_OLTI'];
|
|
19235
19562
|
|
|
@@ -19247,7 +19574,7 @@ var QRCharge = {
|
|
|
19247
19574
|
var _this = this;
|
|
19248
19575
|
|
|
19249
19576
|
var channel = _ref.channel;
|
|
19250
|
-
return validate$
|
|
19577
|
+
return validate$2(channel).then(function () {
|
|
19251
19578
|
if (_this.qr[channel]) {
|
|
19252
19579
|
return _this.qr[channel];
|
|
19253
19580
|
}
|
|
@@ -19269,7 +19596,7 @@ var QRCharge = {
|
|
|
19269
19596
|
var _this2 = this;
|
|
19270
19597
|
|
|
19271
19598
|
var channel = _ref2.channel;
|
|
19272
|
-
return validate$
|
|
19599
|
+
return validate$2(channel).then(function () {
|
|
19273
19600
|
if (!_this2.qr[channel]) {
|
|
19274
19601
|
return Promise.reject(Error('Please generate qr code with Transaction.getQRCode()'));
|
|
19275
19602
|
}
|
|
@@ -19390,7 +19717,7 @@ var MobileMoneyAPI = {
|
|
|
19390
19717
|
}
|
|
19391
19718
|
};
|
|
19392
19719
|
|
|
19393
|
-
function validate(phoneNumber) {
|
|
19720
|
+
function validate$1(phoneNumber) {
|
|
19394
19721
|
return new Promise(function (resolve, reject) {
|
|
19395
19722
|
var validation = PhoneNumber.validate(phoneNumber);
|
|
19396
19723
|
|
|
@@ -19411,7 +19738,7 @@ var MobileMoneyCharge = {
|
|
|
19411
19738
|
provider = _ref.provider,
|
|
19412
19739
|
voucher = _ref.voucher,
|
|
19413
19740
|
registrationToken = _ref.registrationToken;
|
|
19414
|
-
return validate(phoneNumber).then(function () {
|
|
19741
|
+
return validate$1(phoneNumber).then(function () {
|
|
19415
19742
|
_this.logAttempt('mobile money');
|
|
19416
19743
|
|
|
19417
19744
|
var params = {
|
|
@@ -19442,7 +19769,7 @@ var MobileMoneyCharge = {
|
|
|
19442
19769
|
var phoneNumber = payload.phoneNumber,
|
|
19443
19770
|
provider = payload.provider,
|
|
19444
19771
|
registrationToken = payload.registrationToken;
|
|
19445
|
-
return validate(phoneNumber).then(function () {
|
|
19772
|
+
return validate$1(phoneNumber).then(function () {
|
|
19446
19773
|
_this2.logMobileMoneyActions(payload);
|
|
19447
19774
|
|
|
19448
19775
|
var params = {
|
|
@@ -19582,7 +19909,7 @@ var DirectDebitAPI = {
|
|
|
19582
19909
|
}
|
|
19583
19910
|
};
|
|
19584
19911
|
|
|
19585
|
-
var paymentMethod = 'direct debit';
|
|
19912
|
+
var paymentMethod$1 = 'direct debit';
|
|
19586
19913
|
var DirectDebitCharge = {
|
|
19587
19914
|
loginToDirectDebitAccount: function loginToDirectDebitAccount(_ref) {
|
|
19588
19915
|
var _this = this;
|
|
@@ -19628,14 +19955,14 @@ var DirectDebitCharge = {
|
|
|
19628
19955
|
return Promise.reject(Error('Please login with Transaction.loginToDirectDebitAccount() to start a Direct debit charge'));
|
|
19629
19956
|
}
|
|
19630
19957
|
|
|
19631
|
-
this.logAttempt(paymentMethod);
|
|
19958
|
+
this.logAttempt(paymentMethod$1);
|
|
19632
19959
|
var params = {
|
|
19633
19960
|
account_code: accountCode,
|
|
19634
19961
|
transaction: this.id,
|
|
19635
19962
|
token: this.directDebit.token
|
|
19636
19963
|
};
|
|
19637
19964
|
return DirectDebitAPI.charge(params).then(function (response) {
|
|
19638
|
-
_this2.logAPIResponse(response, paymentMethod);
|
|
19965
|
+
_this2.logAPIResponse(response, paymentMethod$1);
|
|
19639
19966
|
|
|
19640
19967
|
if (response.status) {
|
|
19641
19968
|
_this2.directDebit.chargeResponse = response;
|
|
@@ -19648,7 +19975,7 @@ var DirectDebitCharge = {
|
|
|
19648
19975
|
var _this3 = this;
|
|
19649
19976
|
|
|
19650
19977
|
return DirectDebitAPI.getProvisionedAccounts(this.directDebit.token).then(function (response) {
|
|
19651
|
-
_this3.logAPIResponse(response, paymentMethod);
|
|
19978
|
+
_this3.logAPIResponse(response, paymentMethod$1);
|
|
19652
19979
|
|
|
19653
19980
|
var status = response.status,
|
|
19654
19981
|
data = response.data;
|
|
@@ -19673,7 +20000,7 @@ var DirectDebitCharge = {
|
|
|
19673
20000
|
token: this.directDebit.token
|
|
19674
20001
|
};
|
|
19675
20002
|
return DirectDebitAPI.authenticate(params).then(function (response) {
|
|
19676
|
-
_this4.logAPIResponse(response, paymentMethod);
|
|
20003
|
+
_this4.logAPIResponse(response, paymentMethod$1);
|
|
19677
20004
|
|
|
19678
20005
|
return response;
|
|
19679
20006
|
});
|
|
@@ -20117,6 +20444,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20117
20444
|
this.subscription = data.subscription || null;
|
|
20118
20445
|
this.planDetails = data.plan_details || null;
|
|
20119
20446
|
this.exchangeRate = data.exchange_rate || null;
|
|
20447
|
+
this.savedCardsConfig = data.saved_cards || {};
|
|
20448
|
+
this.savedCardsToken = null;
|
|
20120
20449
|
/**
|
|
20121
20450
|
* We initialize parameters we send to the API as empty strings
|
|
20122
20451
|
* when we don't have them instead of null because the API expects
|
|
@@ -20457,10 +20786,194 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20457
20786
|
return Toolkit;
|
|
20458
20787
|
}();
|
|
20459
20788
|
|
|
20789
|
+
var Card = /*#__PURE__*/function () {
|
|
20790
|
+
function Card(_ref) {
|
|
20791
|
+
var number = _ref.number,
|
|
20792
|
+
cvv = _ref.cvv,
|
|
20793
|
+
month = _ref.month,
|
|
20794
|
+
year = _ref.year,
|
|
20795
|
+
pin = _ref.pin;
|
|
20796
|
+
|
|
20797
|
+
_classCallCheck(this, Card);
|
|
20798
|
+
|
|
20799
|
+
this.number = number;
|
|
20800
|
+
this.cvv = cvv;
|
|
20801
|
+
this.month = month;
|
|
20802
|
+
this.year = year;
|
|
20803
|
+
this.pin = pin;
|
|
20804
|
+
}
|
|
20805
|
+
|
|
20806
|
+
_createClass(Card, [{
|
|
20807
|
+
key: "getEncryptedPin",
|
|
20808
|
+
value: function getEncryptedPin() {
|
|
20809
|
+
return Card$2.getEncryptedPin(this.pin);
|
|
20810
|
+
}
|
|
20811
|
+
}, {
|
|
20812
|
+
key: "getLast4",
|
|
20813
|
+
value: function getLast4() {
|
|
20814
|
+
return Card$2.getLast4(this.number);
|
|
20815
|
+
}
|
|
20816
|
+
}, {
|
|
20817
|
+
key: "tokenize",
|
|
20818
|
+
value: function tokenize() {
|
|
20819
|
+
return Card$2.tokenize({
|
|
20820
|
+
number: this.number,
|
|
20821
|
+
cvv: this.cvv,
|
|
20822
|
+
month: this.month,
|
|
20823
|
+
year: this.year
|
|
20824
|
+
});
|
|
20825
|
+
}
|
|
20826
|
+
}], [{
|
|
20827
|
+
key: "getType",
|
|
20828
|
+
value: function getType(value) {
|
|
20829
|
+
return Card$2.getType(value);
|
|
20830
|
+
}
|
|
20831
|
+
}, {
|
|
20832
|
+
key: "validate",
|
|
20833
|
+
value: function validate(_ref2) {
|
|
20834
|
+
var number = _ref2.number,
|
|
20835
|
+
cvv = _ref2.cvv,
|
|
20836
|
+
month = _ref2.month,
|
|
20837
|
+
year = _ref2.year;
|
|
20838
|
+
return Card$2.validate({
|
|
20839
|
+
number: number,
|
|
20840
|
+
cvv: cvv,
|
|
20841
|
+
month: month,
|
|
20842
|
+
year: year
|
|
20843
|
+
});
|
|
20844
|
+
}
|
|
20845
|
+
}, {
|
|
20846
|
+
key: "validateNumber",
|
|
20847
|
+
value: function validateNumber(value) {
|
|
20848
|
+
return Card$2.validateNumber(value);
|
|
20849
|
+
}
|
|
20850
|
+
}, {
|
|
20851
|
+
key: "isNumberValid",
|
|
20852
|
+
value: function isNumberValid(value) {
|
|
20853
|
+
return Card$2.isNumberValid(value);
|
|
20854
|
+
}
|
|
20855
|
+
}, {
|
|
20856
|
+
key: "validateCVV",
|
|
20857
|
+
value: function validateCVV(cvv, cardType) {
|
|
20858
|
+
return Card$2.validateCVV(cvv, cardType);
|
|
20859
|
+
}
|
|
20860
|
+
}, {
|
|
20861
|
+
key: "isCvvValid",
|
|
20862
|
+
value: function isCvvValid(cvv, cardType) {
|
|
20863
|
+
return Card$2.isCvvValid(cvv, cardType);
|
|
20864
|
+
}
|
|
20865
|
+
}, {
|
|
20866
|
+
key: "validateExpiry",
|
|
20867
|
+
value: function validateExpiry(value) {
|
|
20868
|
+
return Card$2.validateExpiry(value);
|
|
20869
|
+
}
|
|
20870
|
+
}, {
|
|
20871
|
+
key: "isExpiryValid",
|
|
20872
|
+
value: function isExpiryValid(value) {
|
|
20873
|
+
return Card$2.isExpiryValid(value);
|
|
20874
|
+
}
|
|
20875
|
+
}, {
|
|
20876
|
+
key: "generateTestCard",
|
|
20877
|
+
value: function generateTestCard(cardType) {
|
|
20878
|
+
return new Card(Card$2.findTestCard(cardType));
|
|
20879
|
+
}
|
|
20880
|
+
}]);
|
|
20881
|
+
|
|
20882
|
+
return Card;
|
|
20883
|
+
}();
|
|
20884
|
+
|
|
20885
|
+
var CardAPI = {
|
|
20886
|
+
reserve: function reserve(_ref) {
|
|
20887
|
+
var clientdata = _ref.clientdata,
|
|
20888
|
+
last4 = _ref.last4,
|
|
20889
|
+
preauthorizationId = _ref.preauthorizationId,
|
|
20890
|
+
publicKey = _ref.publicKey;
|
|
20891
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/reserve");
|
|
20892
|
+
var language = getLanguage();
|
|
20893
|
+
|
|
20894
|
+
var headers = _objectSpread2({
|
|
20895
|
+
Authorization: "Bearer ".concat(publicKey)
|
|
20896
|
+
}, language && {
|
|
20897
|
+
'Accept-Language': language
|
|
20898
|
+
});
|
|
20899
|
+
|
|
20900
|
+
return axiosInstance.post(url, {
|
|
20901
|
+
clientdata: clientdata,
|
|
20902
|
+
last4: last4,
|
|
20903
|
+
preauthorization: preauthorizationId
|
|
20904
|
+
}, {
|
|
20905
|
+
headers: headers
|
|
20906
|
+
}).then(function (response) {
|
|
20907
|
+
return ChargeResponses.parse(response.data);
|
|
20908
|
+
});
|
|
20909
|
+
}
|
|
20910
|
+
};
|
|
20911
|
+
|
|
20912
|
+
var paymentMethod = 'card';
|
|
20913
|
+
|
|
20914
|
+
function validate(card, isSetter) {
|
|
20915
|
+
return new Promise(function (resolve, reject) {
|
|
20916
|
+
var validation = Card.validate(card);
|
|
20917
|
+
|
|
20918
|
+
if (!validation.isValid) {
|
|
20919
|
+
var throwValidation = isSetter || card.number;
|
|
20920
|
+
var errors = Object.keys(validation.result).filter(function (value) {
|
|
20921
|
+
return validation.result[value] === false;
|
|
20922
|
+
});
|
|
20923
|
+
var errorMessage = "Invalid card details: ".concat(errors.join(', '));
|
|
20924
|
+
reject(Error(throwValidation ? errorMessage : 'Please set a valid card with setCard()'));
|
|
20925
|
+
}
|
|
20926
|
+
|
|
20927
|
+
resolve();
|
|
20928
|
+
});
|
|
20929
|
+
}
|
|
20930
|
+
|
|
20931
|
+
var ReserveCardFunds = {
|
|
20932
|
+
setCard: function setCard(params) {
|
|
20933
|
+
var _this = this;
|
|
20934
|
+
|
|
20935
|
+
return validate(params, true).then(function () {
|
|
20936
|
+
_this.card = new Card(params);
|
|
20937
|
+
});
|
|
20938
|
+
},
|
|
20939
|
+
reserve: function reserve(_ref) {
|
|
20940
|
+
var _this2 = this;
|
|
20941
|
+
|
|
20942
|
+
var preauthorizationId = _ref.preauthorizationId,
|
|
20943
|
+
publicKey = _ref.publicKey,
|
|
20944
|
+
_ref$customFields = _ref.customFields,
|
|
20945
|
+
customFields = _ref$customFields === void 0 ? {} : _ref$customFields;
|
|
20946
|
+
// TODO: Log payment method
|
|
20947
|
+
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20948
|
+
return validate(this.card).then(function () {
|
|
20949
|
+
var chargeParams = {
|
|
20950
|
+
clientdata: _this2.card.tokenize(),
|
|
20951
|
+
last4: _this2.card.getLast4(),
|
|
20952
|
+
preauthorizationId: preauthorizationId,
|
|
20953
|
+
publicKey: publicKey,
|
|
20954
|
+
customFields: customFields
|
|
20955
|
+
};
|
|
20956
|
+
return CardAPI.reserve(chargeParams).then(function (response) {
|
|
20957
|
+
// TODO: Log API Response
|
|
20958
|
+
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20959
|
+
return response;
|
|
20960
|
+
});
|
|
20961
|
+
});
|
|
20962
|
+
},
|
|
20963
|
+
listenFor3DSCharge: function listenFor3DSCharge(callback) {
|
|
20964
|
+
var listenerOptions = {
|
|
20965
|
+
channel: "3DS_".concat(this.id),
|
|
20966
|
+
paymentMethod: paymentMethod
|
|
20967
|
+
};
|
|
20968
|
+
return this.listenForCharge(listenerOptions, callback);
|
|
20969
|
+
}
|
|
20970
|
+
};
|
|
20971
|
+
|
|
20460
20972
|
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
20461
20973
|
function PreauthorizationInstance(data) {
|
|
20462
20974
|
_classCallCheck(this, PreauthorizationInstance);
|
|
20463
20975
|
|
|
20976
|
+
this.id = data.id;
|
|
20464
20977
|
this.email = data.email;
|
|
20465
20978
|
this.status = data.status;
|
|
20466
20979
|
this.reference = data.reference;
|
|
@@ -20476,8 +20989,11 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20476
20989
|
name: data.merchant_name,
|
|
20477
20990
|
key: data.merchant_key
|
|
20478
20991
|
};
|
|
20479
|
-
|
|
20480
|
-
//
|
|
20992
|
+
this.card = {};
|
|
20993
|
+
loadPusher(); // TODO: Analytics
|
|
20994
|
+
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
20995
|
+
|
|
20996
|
+
Object.assign(this, ReserveCardFunds);
|
|
20481
20997
|
}
|
|
20482
20998
|
|
|
20483
20999
|
_createClass(PreauthorizationInstance, [{
|
|
@@ -20511,8 +21027,6 @@ var PreauthorisationAPI = {
|
|
|
20511
21027
|
});
|
|
20512
21028
|
},
|
|
20513
21029
|
requery: function requery() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20514
|
-
},
|
|
20515
|
-
reserveFunds: function reserveFunds() {// TODO: https://paystack.atlassian.net/browse/RAILS-2887
|
|
20516
21030
|
}
|
|
20517
21031
|
};
|
|
20518
21032
|
|
|
@@ -20558,4 +21072,4 @@ var Preauthorization = {
|
|
|
20558
21072
|
}
|
|
20559
21073
|
};
|
|
20560
21074
|
|
|
20561
|
-
export { BankAccount, Card, Preauthorization, Toolkit, Transaction };
|
|
21075
|
+
export { BankAccount, Card$1 as Card, Preauthorization, Toolkit, Transaction };
|