@paystack/checkout-js 1.19.0-dev.9 → 1.20.0-dev.1
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/README.md +4 -12
- package/dist/checkout.js +21263 -29
- package/es/checkout.js +894 -335
- package/lib/checkout.js +895 -335
- package/package.json +3 -3
package/es/checkout.js
CHANGED
|
@@ -6404,7 +6404,7 @@ var devConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
|
6404
6404
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6405
6405
|
pusherKey: '1c7b262ee18455815893',
|
|
6406
6406
|
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js',
|
|
6407
|
-
savedCardsApiUrl: 'https://saved-cards-api.
|
|
6407
|
+
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6408
6408
|
});
|
|
6409
6409
|
var stagingConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6410
6410
|
checkoutUrl: 'https://checkout-studio.paystack.com/',
|
|
@@ -6412,7 +6412,7 @@ var stagingConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
|
6412
6412
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6413
6413
|
pusherKey: '1c7b262ee18455815893',
|
|
6414
6414
|
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js',
|
|
6415
|
-
savedCardsApiUrl: 'https://saved-cards-api.
|
|
6415
|
+
savedCardsApiUrl: 'https://saved-cards-api.public.paystack.studio/'
|
|
6416
6416
|
});
|
|
6417
6417
|
var productionConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6418
6418
|
checkoutUrl: 'https://checkout.paystack.com/',
|
|
@@ -6430,37 +6430,6 @@ var configToEnvironmentMapping = {
|
|
|
6430
6430
|
};
|
|
6431
6431
|
var configToUse = configToEnvironmentMapping[env.paystackEnvironment] || productionConfig;
|
|
6432
6432
|
|
|
6433
|
-
/* eslint-env browser */
|
|
6434
|
-
// We use this function to load pusher.
|
|
6435
|
-
|
|
6436
|
-
function loadPusher() {
|
|
6437
|
-
if (!window) {
|
|
6438
|
-
return Promise.reject(new Error('Window object not available'));
|
|
6439
|
-
}
|
|
6440
|
-
|
|
6441
|
-
return new Promise(function (resolve, reject) {
|
|
6442
|
-
var xhr = new XMLHttpRequest();
|
|
6443
|
-
xhr.open('GET', configToUse.pusherUrl);
|
|
6444
|
-
|
|
6445
|
-
xhr.onload = function () {
|
|
6446
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
6447
|
-
var s = document.createElement('script');
|
|
6448
|
-
s.appendChild(document.createTextNode(xhr.responseText));
|
|
6449
|
-
document.head.appendChild(s);
|
|
6450
|
-
resolve();
|
|
6451
|
-
} else {
|
|
6452
|
-
reject(xhr.statusText);
|
|
6453
|
-
}
|
|
6454
|
-
};
|
|
6455
|
-
|
|
6456
|
-
xhr.onerror = function () {
|
|
6457
|
-
return reject(xhr.statusText);
|
|
6458
|
-
};
|
|
6459
|
-
|
|
6460
|
-
xhr.send(null);
|
|
6461
|
-
});
|
|
6462
|
-
}
|
|
6463
|
-
|
|
6464
6433
|
var noOp = function noOp() {
|
|
6465
6434
|
return undefined;
|
|
6466
6435
|
};
|
|
@@ -6634,6 +6603,82 @@ var ChargeResponses = {
|
|
|
6634
6603
|
}
|
|
6635
6604
|
};
|
|
6636
6605
|
|
|
6606
|
+
/* eslint-env browser */
|
|
6607
|
+
|
|
6608
|
+
var loadPusher = function loadPusher() {
|
|
6609
|
+
if (!window) {
|
|
6610
|
+
return Promise.reject(new Error('Window object not available'));
|
|
6611
|
+
}
|
|
6612
|
+
|
|
6613
|
+
return new Promise(function (resolve, reject) {
|
|
6614
|
+
var xhr = new XMLHttpRequest();
|
|
6615
|
+
xhr.open('GET', configToUse.pusherUrl);
|
|
6616
|
+
|
|
6617
|
+
xhr.onload = function () {
|
|
6618
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
6619
|
+
var s = document.createElement('script');
|
|
6620
|
+
s.appendChild(document.createTextNode(xhr.responseText));
|
|
6621
|
+
document.head.appendChild(s);
|
|
6622
|
+
resolve();
|
|
6623
|
+
} else {
|
|
6624
|
+
reject(xhr.statusText);
|
|
6625
|
+
}
|
|
6626
|
+
};
|
|
6627
|
+
|
|
6628
|
+
xhr.onerror = function () {
|
|
6629
|
+
return reject(xhr.statusText);
|
|
6630
|
+
};
|
|
6631
|
+
|
|
6632
|
+
xhr.send(null);
|
|
6633
|
+
});
|
|
6634
|
+
}; // `context` is passed through to set the class property of `isListening` to true/false
|
|
6635
|
+
// and provide the logAPIResponse analytics function
|
|
6636
|
+
// eslint-disable-next-line consistent-return
|
|
6637
|
+
|
|
6638
|
+
var subscribeToChargeEvents = function subscribeToChargeEvents(options, context, callback) {
|
|
6639
|
+
var channel = options.channel,
|
|
6640
|
+
paymentMethod = options.paymentMethod;
|
|
6641
|
+
var pusher;
|
|
6642
|
+
|
|
6643
|
+
if (window && window.Pusher) {
|
|
6644
|
+
pusher = new window.Pusher(configToUse.pusherKey, {
|
|
6645
|
+
cluster: 'eu',
|
|
6646
|
+
disableStats: true
|
|
6647
|
+
});
|
|
6648
|
+
}
|
|
6649
|
+
|
|
6650
|
+
var pusherUndefinedError = {
|
|
6651
|
+
status: 'error',
|
|
6652
|
+
message: 'We could not listen for charge response.'
|
|
6653
|
+
};
|
|
6654
|
+
var pusherSubscriptionError = {
|
|
6655
|
+
status: 'error',
|
|
6656
|
+
message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
|
|
6657
|
+
};
|
|
6658
|
+
|
|
6659
|
+
var unsubscribeFromPusher = function unsubscribeFromPusher() {
|
|
6660
|
+
pusher.unsubscribe(channel);
|
|
6661
|
+
};
|
|
6662
|
+
|
|
6663
|
+
if (!pusher) {
|
|
6664
|
+
return callback(pusherUndefinedError, noOp);
|
|
6665
|
+
}
|
|
6666
|
+
|
|
6667
|
+
var pusherSubscription = pusher.subscribe(channel);
|
|
6668
|
+
pusherSubscription.bind('pusher:subscription_succeeded', function () {
|
|
6669
|
+
context.isListening = true;
|
|
6670
|
+
});
|
|
6671
|
+
pusherSubscription.bind('pusher:subscription_error', function () {
|
|
6672
|
+
context.isListening = false;
|
|
6673
|
+
callback(pusherSubscriptionError, noOp);
|
|
6674
|
+
});
|
|
6675
|
+
pusherSubscription.bind('response', function (response) {
|
|
6676
|
+
var formattedResponse = ChargeResponses.parse(response);
|
|
6677
|
+
context.logAPIResponse(formattedResponse, paymentMethod);
|
|
6678
|
+
callback(formattedResponse, unsubscribeFromPusher);
|
|
6679
|
+
});
|
|
6680
|
+
};
|
|
6681
|
+
|
|
6637
6682
|
var uncurryThis$6 = functionUncurryThis;
|
|
6638
6683
|
var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
|
|
6639
6684
|
var redefine$4 = redefine$a.exports;
|
|
@@ -11598,7 +11643,7 @@ var PayattitudeAPI = {
|
|
|
11598
11643
|
}
|
|
11599
11644
|
};
|
|
11600
11645
|
|
|
11601
|
-
var paymentMethod$
|
|
11646
|
+
var paymentMethod$7 = 'payattitude';
|
|
11602
11647
|
var PayattitudeCharge = {
|
|
11603
11648
|
chargePayattitude: function chargePayattitude(_ref) {
|
|
11604
11649
|
var _this = this;
|
|
@@ -11609,7 +11654,7 @@ var PayattitudeCharge = {
|
|
|
11609
11654
|
phoneNumber: phoneNumber
|
|
11610
11655
|
};
|
|
11611
11656
|
return PayattitudeAPI.charge(params).then(function (response) {
|
|
11612
|
-
_this.logAPIResponse(response, paymentMethod$
|
|
11657
|
+
_this.logAPIResponse(response, paymentMethod$7);
|
|
11613
11658
|
|
|
11614
11659
|
return response;
|
|
11615
11660
|
});
|
|
@@ -11617,7 +11662,7 @@ var PayattitudeCharge = {
|
|
|
11617
11662
|
listenForPayattitudeCharge: function listenForPayattitudeCharge(callback) {
|
|
11618
11663
|
var pusherChannel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
11619
11664
|
var listenerOptions = {
|
|
11620
|
-
paymentMethod: paymentMethod$
|
|
11665
|
+
paymentMethod: paymentMethod$7,
|
|
11621
11666
|
channel: pusherChannel
|
|
11622
11667
|
};
|
|
11623
11668
|
return this.listenForCharge(listenerOptions, callback);
|
|
@@ -11700,7 +11745,7 @@ var ApplePayAPI = {
|
|
|
11700
11745
|
}
|
|
11701
11746
|
};
|
|
11702
11747
|
|
|
11703
|
-
var paymentMethod$
|
|
11748
|
+
var paymentMethod$6 = 'apple pay';
|
|
11704
11749
|
var ApplePayCharge = {
|
|
11705
11750
|
validateApplePaySession: function validateApplePaySession(_ref) {
|
|
11706
11751
|
var _this = this;
|
|
@@ -11708,7 +11753,7 @@ var ApplePayCharge = {
|
|
|
11708
11753
|
var sessionUrl = _ref.sessionUrl,
|
|
11709
11754
|
displayName = _ref.displayName,
|
|
11710
11755
|
domainName = _ref.domainName;
|
|
11711
|
-
this.logAttempt(paymentMethod$
|
|
11756
|
+
this.logAttempt(paymentMethod$6);
|
|
11712
11757
|
return ApplePayAPI.validateApplePaySession({
|
|
11713
11758
|
sessionUrl: sessionUrl,
|
|
11714
11759
|
displayName: displayName,
|
|
@@ -11729,7 +11774,7 @@ var ApplePayCharge = {
|
|
|
11729
11774
|
device: this.deviceFingerprint,
|
|
11730
11775
|
paymentObject: paymentObject
|
|
11731
11776
|
}).then(function (response) {
|
|
11732
|
-
_this2.logAPIResponse(response, paymentMethod$
|
|
11777
|
+
_this2.logAPIResponse(response, paymentMethod$6);
|
|
11733
11778
|
|
|
11734
11779
|
return response;
|
|
11735
11780
|
});
|
|
@@ -11785,12 +11830,12 @@ var PayPalAPI = {
|
|
|
11785
11830
|
}
|
|
11786
11831
|
};
|
|
11787
11832
|
|
|
11788
|
-
var paymentMethod$
|
|
11833
|
+
var paymentMethod$5 = 'paypal';
|
|
11789
11834
|
var PayPalCharge = {
|
|
11790
11835
|
createPayPalOrder: function createPayPalOrder() {
|
|
11791
11836
|
var _this = this;
|
|
11792
11837
|
|
|
11793
|
-
this.logAttempt(paymentMethod$
|
|
11838
|
+
this.logAttempt(paymentMethod$5);
|
|
11794
11839
|
return PayPalAPI.createOrder(this.id).then(function (response) {
|
|
11795
11840
|
_this.logAPIResponseMessage(response.message);
|
|
11796
11841
|
|
|
@@ -11801,7 +11846,7 @@ var PayPalCharge = {
|
|
|
11801
11846
|
var _this2 = this;
|
|
11802
11847
|
|
|
11803
11848
|
return PayPalAPI.captureOrder(this.id).then(function (response) {
|
|
11804
|
-
_this2.logAPIResponse(response, paymentMethod$
|
|
11849
|
+
_this2.logAPIResponse(response, paymentMethod$5);
|
|
11805
11850
|
|
|
11806
11851
|
return response;
|
|
11807
11852
|
});
|
|
@@ -17189,55 +17234,7 @@ function encrypt(toEncrypt) {
|
|
|
17189
17234
|
return jsEncrypt.encrypt(toEncrypt);
|
|
17190
17235
|
}
|
|
17191
17236
|
|
|
17192
|
-
var DESCRIPTORS = descriptors;
|
|
17193
|
-
var uncurryThis$1 = functionUncurryThis;
|
|
17194
|
-
var objectKeys = objectKeys$3;
|
|
17195
|
-
var toIndexedObject = toIndexedObject$8;
|
|
17196
|
-
var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
17197
|
-
|
|
17198
|
-
var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
|
|
17199
|
-
var push = uncurryThis$1([].push);
|
|
17200
|
-
|
|
17201
|
-
// `Object.{ entries, values }` methods implementation
|
|
17202
|
-
var createMethod = function (TO_ENTRIES) {
|
|
17203
|
-
return function (it) {
|
|
17204
|
-
var O = toIndexedObject(it);
|
|
17205
|
-
var keys = objectKeys(O);
|
|
17206
|
-
var length = keys.length;
|
|
17207
|
-
var i = 0;
|
|
17208
|
-
var result = [];
|
|
17209
|
-
var key;
|
|
17210
|
-
while (length > i) {
|
|
17211
|
-
key = keys[i++];
|
|
17212
|
-
if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
|
|
17213
|
-
push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
|
17214
|
-
}
|
|
17215
|
-
}
|
|
17216
|
-
return result;
|
|
17217
|
-
};
|
|
17218
|
-
};
|
|
17219
|
-
|
|
17220
|
-
var objectToArray = {
|
|
17221
|
-
// `Object.entries` method
|
|
17222
|
-
// https://tc39.es/ecma262/#sec-object.entries
|
|
17223
|
-
entries: createMethod(true),
|
|
17224
|
-
// `Object.values` method
|
|
17225
|
-
// https://tc39.es/ecma262/#sec-object.values
|
|
17226
|
-
values: createMethod(false)
|
|
17227
|
-
};
|
|
17228
|
-
|
|
17229
17237
|
var $$2 = _export;
|
|
17230
|
-
var $values = objectToArray.values;
|
|
17231
|
-
|
|
17232
|
-
// `Object.values` method
|
|
17233
|
-
// https://tc39.es/ecma262/#sec-object.values
|
|
17234
|
-
$$2({ target: 'Object', stat: true }, {
|
|
17235
|
-
values: function values(O) {
|
|
17236
|
-
return $values(O);
|
|
17237
|
-
}
|
|
17238
|
-
});
|
|
17239
|
-
|
|
17240
|
-
var $$1 = _export;
|
|
17241
17238
|
var $find = arrayIteration.find;
|
|
17242
17239
|
var addToUnscopables = addToUnscopables$3;
|
|
17243
17240
|
|
|
@@ -17249,7 +17246,7 @@ if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
|
|
|
17249
17246
|
|
|
17250
17247
|
// `Array.prototype.find` method
|
|
17251
17248
|
// https://tc39.es/ecma262/#sec-array.prototype.find
|
|
17252
|
-
$$
|
|
17249
|
+
$$2({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
|
|
17253
17250
|
find: function find(callbackfn /* , that = undefined */) {
|
|
17254
17251
|
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
17255
17252
|
}
|
|
@@ -18197,56 +18194,136 @@ var cardValidator = {
|
|
|
18197
18194
|
creditCardType: creditCardType_1
|
|
18198
18195
|
};
|
|
18199
18196
|
|
|
18200
|
-
var
|
|
18201
|
-
|
|
18202
|
-
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
}
|
|
18236
|
-
|
|
18237
|
-
|
|
18238
|
-
|
|
18239
|
-
|
|
18240
|
-
|
|
18241
|
-
|
|
18242
|
-
}, {
|
|
18243
|
-
|
|
18244
|
-
|
|
18245
|
-
|
|
18246
|
-
|
|
18247
|
-
|
|
18248
|
-
|
|
18249
|
-
|
|
18197
|
+
var DESCRIPTORS = descriptors;
|
|
18198
|
+
var uncurryThis$1 = functionUncurryThis;
|
|
18199
|
+
var objectKeys = objectKeys$3;
|
|
18200
|
+
var toIndexedObject = toIndexedObject$8;
|
|
18201
|
+
var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
18202
|
+
|
|
18203
|
+
var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
|
|
18204
|
+
var push = uncurryThis$1([].push);
|
|
18205
|
+
|
|
18206
|
+
// `Object.{ entries, values }` methods implementation
|
|
18207
|
+
var createMethod = function (TO_ENTRIES) {
|
|
18208
|
+
return function (it) {
|
|
18209
|
+
var O = toIndexedObject(it);
|
|
18210
|
+
var keys = objectKeys(O);
|
|
18211
|
+
var length = keys.length;
|
|
18212
|
+
var i = 0;
|
|
18213
|
+
var result = [];
|
|
18214
|
+
var key;
|
|
18215
|
+
while (length > i) {
|
|
18216
|
+
key = keys[i++];
|
|
18217
|
+
if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
|
|
18218
|
+
push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
|
18219
|
+
}
|
|
18220
|
+
}
|
|
18221
|
+
return result;
|
|
18222
|
+
};
|
|
18223
|
+
};
|
|
18224
|
+
|
|
18225
|
+
var objectToArray = {
|
|
18226
|
+
// `Object.entries` method
|
|
18227
|
+
// https://tc39.es/ecma262/#sec-object.entries
|
|
18228
|
+
entries: createMethod(true),
|
|
18229
|
+
// `Object.values` method
|
|
18230
|
+
// https://tc39.es/ecma262/#sec-object.values
|
|
18231
|
+
values: createMethod(false)
|
|
18232
|
+
};
|
|
18233
|
+
|
|
18234
|
+
var $$1 = _export;
|
|
18235
|
+
var $values = objectToArray.values;
|
|
18236
|
+
|
|
18237
|
+
// `Object.values` method
|
|
18238
|
+
// https://tc39.es/ecma262/#sec-object.values
|
|
18239
|
+
$$1({ target: 'Object', stat: true }, {
|
|
18240
|
+
values: function values(O) {
|
|
18241
|
+
return $values(O);
|
|
18242
|
+
}
|
|
18243
|
+
});
|
|
18244
|
+
|
|
18245
|
+
var Card$2 = {
|
|
18246
|
+
getEncryptedPin: function getEncryptedPin(pin) {
|
|
18247
|
+
return pin ? encrypt(pin) : undefined;
|
|
18248
|
+
},
|
|
18249
|
+
getLast4: function getLast4(number) {
|
|
18250
|
+
return number.substring(number.length - 4);
|
|
18251
|
+
},
|
|
18252
|
+
tokenize: function tokenize(_ref) {
|
|
18253
|
+
var number = _ref.number,
|
|
18254
|
+
cvv = _ref.cvv,
|
|
18255
|
+
month = _ref.month,
|
|
18256
|
+
year = _ref.year;
|
|
18257
|
+
return encrypt("".concat(number, "*").concat(cvv, "*").concat(month, "*").concat(year));
|
|
18258
|
+
},
|
|
18259
|
+
getType: function getType(value) {
|
|
18260
|
+
var response = cardValidator.number(value);
|
|
18261
|
+
|
|
18262
|
+
if (response && response.card) {
|
|
18263
|
+
return {
|
|
18264
|
+
type: response.card.type,
|
|
18265
|
+
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18266
|
+
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18267
|
+
};
|
|
18268
|
+
}
|
|
18269
|
+
|
|
18270
|
+
return {
|
|
18271
|
+
type: null,
|
|
18272
|
+
maxLength: 0
|
|
18273
|
+
};
|
|
18274
|
+
},
|
|
18275
|
+
validate: function validate(_ref2) {
|
|
18276
|
+
var number = _ref2.number,
|
|
18277
|
+
cvv = _ref2.cvv,
|
|
18278
|
+
month = _ref2.month,
|
|
18279
|
+
year = _ref2.year;
|
|
18280
|
+
|
|
18281
|
+
var _this$getType = this.getType(number),
|
|
18282
|
+
cardType = _this$getType.type;
|
|
18283
|
+
|
|
18284
|
+
var result = {
|
|
18285
|
+
number: this.isNumberValid(number),
|
|
18286
|
+
expiry: this.isExpiryValid({
|
|
18287
|
+
month: month,
|
|
18288
|
+
year: year
|
|
18289
|
+
}),
|
|
18290
|
+
cvv: this.isCvvValid(cvv, cardType)
|
|
18291
|
+
};
|
|
18292
|
+
var isValid = Object.values(result).every(function (value) {
|
|
18293
|
+
return value === true;
|
|
18294
|
+
});
|
|
18295
|
+
return {
|
|
18296
|
+
isValid: isValid,
|
|
18297
|
+
result: result
|
|
18298
|
+
};
|
|
18299
|
+
},
|
|
18300
|
+
validateNumber: function validateNumber(value) {
|
|
18301
|
+
return cardValidator.number(value);
|
|
18302
|
+
},
|
|
18303
|
+
isNumberValid: function isNumberValid(value) {
|
|
18304
|
+
return Card$2.validateNumber(value).isValid;
|
|
18305
|
+
},
|
|
18306
|
+
validateCVV: function validateCVV(cvv, cardType) {
|
|
18307
|
+
var isAmexCard = cardType === 'american-express';
|
|
18308
|
+
var cvvLength = isAmexCard ? 4 : 3;
|
|
18309
|
+
return cardValidator.cvv(cvv, cvvLength);
|
|
18310
|
+
},
|
|
18311
|
+
isCvvValid: function isCvvValid(cvv, cardType) {
|
|
18312
|
+
return Card$2.validateCVV(cvv, cardType).isValid;
|
|
18313
|
+
},
|
|
18314
|
+
validateExpiry: function validateExpiry(value) {
|
|
18315
|
+
if (_typeof$1(value) === 'object') {
|
|
18316
|
+
var month = value.month,
|
|
18317
|
+
year = value.year;
|
|
18318
|
+
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18319
|
+
}
|
|
18320
|
+
|
|
18321
|
+
return cardValidator.expirationDate(value);
|
|
18322
|
+
},
|
|
18323
|
+
isExpiryValid: function isExpiryValid(value) {
|
|
18324
|
+
return Card$2.validateExpiry(value).isValid;
|
|
18325
|
+
}
|
|
18326
|
+
};
|
|
18250
18327
|
|
|
18251
18328
|
cardValidator.creditCardType.addCard({
|
|
18252
18329
|
niceType: 'Verve',
|
|
@@ -18261,7 +18338,7 @@ cardValidator.creditCardType.addCard({
|
|
|
18261
18338
|
});
|
|
18262
18339
|
cardValidator.creditCardType.changeOrder('verve', 0);
|
|
18263
18340
|
|
|
18264
|
-
var Card = /*#__PURE__*/function () {
|
|
18341
|
+
var Card$1 = /*#__PURE__*/function () {
|
|
18265
18342
|
function Card(_ref) {
|
|
18266
18343
|
var number = _ref.number,
|
|
18267
18344
|
cvv = _ref.cvv,
|
|
@@ -18281,35 +18358,27 @@ var Card = /*#__PURE__*/function () {
|
|
|
18281
18358
|
_createClass(Card, [{
|
|
18282
18359
|
key: "getEncryptedPin",
|
|
18283
18360
|
value: function getEncryptedPin() {
|
|
18284
|
-
return
|
|
18361
|
+
return Card$2.getEncryptedPin(this.pin);
|
|
18285
18362
|
}
|
|
18286
18363
|
}, {
|
|
18287
18364
|
key: "getLast4",
|
|
18288
18365
|
value: function getLast4() {
|
|
18289
|
-
return
|
|
18366
|
+
return Card$2.getLast4(this.number);
|
|
18290
18367
|
}
|
|
18291
18368
|
}, {
|
|
18292
18369
|
key: "tokenize",
|
|
18293
18370
|
value: function tokenize() {
|
|
18294
|
-
return
|
|
18371
|
+
return Card$2.tokenize({
|
|
18372
|
+
number: this.number,
|
|
18373
|
+
cvv: this.cvv,
|
|
18374
|
+
month: this.month,
|
|
18375
|
+
year: this.year
|
|
18376
|
+
});
|
|
18295
18377
|
}
|
|
18296
18378
|
}], [{
|
|
18297
18379
|
key: "getType",
|
|
18298
18380
|
value: function getType(value) {
|
|
18299
|
-
|
|
18300
|
-
|
|
18301
|
-
if (response && response.card) {
|
|
18302
|
-
return {
|
|
18303
|
-
type: response.card.type,
|
|
18304
|
-
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18305
|
-
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18306
|
-
};
|
|
18307
|
-
}
|
|
18308
|
-
|
|
18309
|
-
return {
|
|
18310
|
-
type: null,
|
|
18311
|
-
maxLength: 0
|
|
18312
|
-
};
|
|
18381
|
+
return Card$2.getType(value);
|
|
18313
18382
|
}
|
|
18314
18383
|
}, {
|
|
18315
18384
|
key: "validate",
|
|
@@ -18318,63 +18387,42 @@ var Card = /*#__PURE__*/function () {
|
|
|
18318
18387
|
cvv = _ref2.cvv,
|
|
18319
18388
|
month = _ref2.month,
|
|
18320
18389
|
year = _ref2.year;
|
|
18321
|
-
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
number: Card.isNumberValid(number),
|
|
18327
|
-
expiry: Card.isExpiryValid({
|
|
18328
|
-
month: month,
|
|
18329
|
-
year: year
|
|
18330
|
-
}),
|
|
18331
|
-
cvv: Card.isCvvValid(cvv, cardType)
|
|
18332
|
-
};
|
|
18333
|
-
var isValid = Object.values(result).every(function (value) {
|
|
18334
|
-
return value === true;
|
|
18390
|
+
return Card$2.validate({
|
|
18391
|
+
number: number,
|
|
18392
|
+
cvv: cvv,
|
|
18393
|
+
month: month,
|
|
18394
|
+
year: year
|
|
18335
18395
|
});
|
|
18336
|
-
return {
|
|
18337
|
-
isValid: isValid,
|
|
18338
|
-
result: result
|
|
18339
|
-
};
|
|
18340
18396
|
}
|
|
18341
18397
|
}, {
|
|
18342
18398
|
key: "validateNumber",
|
|
18343
18399
|
value: function validateNumber(value) {
|
|
18344
|
-
return
|
|
18400
|
+
return Card$2.validateNumber(value);
|
|
18345
18401
|
}
|
|
18346
18402
|
}, {
|
|
18347
18403
|
key: "isNumberValid",
|
|
18348
18404
|
value: function isNumberValid(value) {
|
|
18349
|
-
return Card.
|
|
18405
|
+
return Card$2.isNumberValid(value);
|
|
18350
18406
|
}
|
|
18351
18407
|
}, {
|
|
18352
18408
|
key: "validateCVV",
|
|
18353
18409
|
value: function validateCVV(cvv, cardType) {
|
|
18354
|
-
|
|
18355
|
-
var cvvLength = isAmexCard ? 4 : 3;
|
|
18356
|
-
return cardValidator.cvv(cvv, cvvLength);
|
|
18410
|
+
return Card$2.validateCVV(cvv, cardType);
|
|
18357
18411
|
}
|
|
18358
18412
|
}, {
|
|
18359
18413
|
key: "isCvvValid",
|
|
18360
18414
|
value: function isCvvValid(cvv, cardType) {
|
|
18361
|
-
return Card.
|
|
18415
|
+
return Card$2.isCvvValid(cvv, cardType);
|
|
18362
18416
|
}
|
|
18363
18417
|
}, {
|
|
18364
18418
|
key: "validateExpiry",
|
|
18365
18419
|
value: function validateExpiry(value) {
|
|
18366
|
-
|
|
18367
|
-
var month = value.month,
|
|
18368
|
-
year = value.year;
|
|
18369
|
-
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18370
|
-
}
|
|
18371
|
-
|
|
18372
|
-
return cardValidator.expirationDate(value);
|
|
18420
|
+
return Card$2.validateExpiry(value);
|
|
18373
18421
|
}
|
|
18374
18422
|
}, {
|
|
18375
18423
|
key: "isExpiryValid",
|
|
18376
18424
|
value: function isExpiryValid(value) {
|
|
18377
|
-
return Card.
|
|
18425
|
+
return Card$2.isExpiryValid(value);
|
|
18378
18426
|
}
|
|
18379
18427
|
}, {
|
|
18380
18428
|
key: "generateTestCard",
|
|
@@ -18390,7 +18438,7 @@ var Card = /*#__PURE__*/function () {
|
|
|
18390
18438
|
return Card;
|
|
18391
18439
|
}();
|
|
18392
18440
|
|
|
18393
|
-
var CardAPI = {
|
|
18441
|
+
var CardAPI$1 = {
|
|
18394
18442
|
charge: function charge(_ref) {
|
|
18395
18443
|
var clientdata = _ref.clientdata,
|
|
18396
18444
|
last4 = _ref.last4,
|
|
@@ -18567,7 +18615,7 @@ var CardAPI = {
|
|
|
18567
18615
|
return ChargeResponses.parse(response.data);
|
|
18568
18616
|
});
|
|
18569
18617
|
},
|
|
18570
|
-
|
|
18618
|
+
requestSavedCardsOTP: function requestSavedCardsOTP(phoneNumber) {
|
|
18571
18619
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18572
18620
|
var url, language, headers, _yield$axiosInstance$, data;
|
|
18573
18621
|
|
|
@@ -18598,23 +18646,22 @@ var CardAPI = {
|
|
|
18598
18646
|
}, _callee);
|
|
18599
18647
|
}))();
|
|
18600
18648
|
},
|
|
18601
|
-
|
|
18649
|
+
addUserToSavedCards: function addUserToSavedCards(_ref6) {
|
|
18602
18650
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18603
|
-
var
|
|
18651
|
+
var phone, email, url, language, headers, data, response;
|
|
18604
18652
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18605
18653
|
while (1) {
|
|
18606
18654
|
switch (_context2.prev = _context2.next) {
|
|
18607
18655
|
case 0:
|
|
18608
|
-
|
|
18609
|
-
url = new URL('/
|
|
18656
|
+
phone = _ref6.phone, email = _ref6.email;
|
|
18657
|
+
url = new URL('/user', configToUse.savedCardsApiUrl).toString();
|
|
18610
18658
|
language = getLanguage();
|
|
18611
18659
|
headers = _objectSpread2({}, language && {
|
|
18612
18660
|
'Accept-Language': language
|
|
18613
18661
|
});
|
|
18614
18662
|
data = {
|
|
18615
|
-
code: code,
|
|
18616
18663
|
phone: phone,
|
|
18617
|
-
|
|
18664
|
+
email: email
|
|
18618
18665
|
};
|
|
18619
18666
|
_context2.next = 7;
|
|
18620
18667
|
return axiosInstance.post(url, data, {
|
|
@@ -18633,32 +18680,34 @@ var CardAPI = {
|
|
|
18633
18680
|
}, _callee2);
|
|
18634
18681
|
}))();
|
|
18635
18682
|
},
|
|
18636
|
-
|
|
18683
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref7) {
|
|
18637
18684
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18638
|
-
var
|
|
18685
|
+
var code, phone, transaction, url, language, headers, data, response;
|
|
18639
18686
|
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18640
18687
|
while (1) {
|
|
18641
18688
|
switch (_context3.prev = _context3.next) {
|
|
18642
18689
|
case 0:
|
|
18643
|
-
|
|
18644
|
-
url = new URL('/
|
|
18690
|
+
code = _ref7.code, phone = _ref7.phone, transaction = _ref7.transaction;
|
|
18691
|
+
url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
|
|
18645
18692
|
language = getLanguage();
|
|
18646
|
-
headers = _objectSpread2({
|
|
18647
|
-
Authorization: "Bearer ".concat(token),
|
|
18648
|
-
'jwt-auth': true
|
|
18649
|
-
}, language && {
|
|
18693
|
+
headers = _objectSpread2({}, language && {
|
|
18650
18694
|
'Accept-Language': language
|
|
18651
18695
|
});
|
|
18652
|
-
|
|
18653
|
-
|
|
18696
|
+
data = {
|
|
18697
|
+
code: code,
|
|
18698
|
+
phone: phone,
|
|
18699
|
+
transaction: transaction
|
|
18700
|
+
};
|
|
18701
|
+
_context3.next = 7;
|
|
18702
|
+
return axiosInstance.post(url, data, {
|
|
18654
18703
|
headers: headers
|
|
18655
18704
|
});
|
|
18656
18705
|
|
|
18657
|
-
case
|
|
18706
|
+
case 7:
|
|
18658
18707
|
response = _context3.sent;
|
|
18659
18708
|
return _context3.abrupt("return", response.data);
|
|
18660
18709
|
|
|
18661
|
-
case
|
|
18710
|
+
case 9:
|
|
18662
18711
|
case "end":
|
|
18663
18712
|
return _context3.stop();
|
|
18664
18713
|
}
|
|
@@ -18666,15 +18715,15 @@ var CardAPI = {
|
|
|
18666
18715
|
}, _callee3);
|
|
18667
18716
|
}))();
|
|
18668
18717
|
},
|
|
18669
|
-
|
|
18718
|
+
getSavedCards: function getSavedCards(_ref8) {
|
|
18670
18719
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18671
|
-
var
|
|
18720
|
+
var token, url, language, headers, response;
|
|
18672
18721
|
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18673
18722
|
while (1) {
|
|
18674
18723
|
switch (_context4.prev = _context4.next) {
|
|
18675
18724
|
case 0:
|
|
18676
|
-
|
|
18677
|
-
url = new URL(
|
|
18725
|
+
token = _ref8.token;
|
|
18726
|
+
url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
|
|
18678
18727
|
language = getLanguage();
|
|
18679
18728
|
headers = _objectSpread2({
|
|
18680
18729
|
Authorization: "Bearer ".concat(token),
|
|
@@ -18683,7 +18732,7 @@ var CardAPI = {
|
|
|
18683
18732
|
'Accept-Language': language
|
|
18684
18733
|
});
|
|
18685
18734
|
_context4.next = 6;
|
|
18686
|
-
return axiosInstance.
|
|
18735
|
+
return axiosInstance.get(url, {
|
|
18687
18736
|
headers: headers
|
|
18688
18737
|
});
|
|
18689
18738
|
|
|
@@ -18699,15 +18748,15 @@ var CardAPI = {
|
|
|
18699
18748
|
}, _callee4);
|
|
18700
18749
|
}))();
|
|
18701
18750
|
},
|
|
18702
|
-
|
|
18751
|
+
deleteSavedCard: function deleteSavedCard(_ref9) {
|
|
18703
18752
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
18704
|
-
var
|
|
18753
|
+
var cardCode, token, url, language, headers, response;
|
|
18705
18754
|
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
18706
18755
|
while (1) {
|
|
18707
18756
|
switch (_context5.prev = _context5.next) {
|
|
18708
18757
|
case 0:
|
|
18709
|
-
|
|
18710
|
-
url = new URL("/cards/".concat(cardCode
|
|
18758
|
+
cardCode = _ref9.cardCode, token = _ref9.token;
|
|
18759
|
+
url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
|
|
18711
18760
|
language = getLanguage();
|
|
18712
18761
|
headers = _objectSpread2({
|
|
18713
18762
|
Authorization: "Bearer ".concat(token),
|
|
@@ -18715,32 +18764,65 @@ var CardAPI = {
|
|
|
18715
18764
|
}, language && {
|
|
18716
18765
|
'Accept-Language': language
|
|
18717
18766
|
});
|
|
18718
|
-
|
|
18719
|
-
|
|
18720
|
-
transaction: transaction,
|
|
18721
|
-
selectedCurrency: selectedCurrency
|
|
18722
|
-
};
|
|
18723
|
-
return _context5.abrupt("return", axiosInstance.post(url, data, {
|
|
18767
|
+
_context5.next = 6;
|
|
18768
|
+
return axiosInstance.delete(url, {
|
|
18724
18769
|
headers: headers
|
|
18725
|
-
})
|
|
18726
|
-
return ChargeResponses.parse(response.data);
|
|
18727
|
-
}));
|
|
18770
|
+
});
|
|
18728
18771
|
|
|
18729
18772
|
case 6:
|
|
18773
|
+
response = _context5.sent;
|
|
18774
|
+
return _context5.abrupt("return", response.data);
|
|
18775
|
+
|
|
18776
|
+
case 8:
|
|
18730
18777
|
case "end":
|
|
18731
18778
|
return _context5.stop();
|
|
18732
18779
|
}
|
|
18733
18780
|
}
|
|
18734
18781
|
}, _callee5);
|
|
18735
18782
|
}))();
|
|
18783
|
+
},
|
|
18784
|
+
chargeSavedCard: function chargeSavedCard(_ref10) {
|
|
18785
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
18786
|
+
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data;
|
|
18787
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
18788
|
+
while (1) {
|
|
18789
|
+
switch (_context6.prev = _context6.next) {
|
|
18790
|
+
case 0:
|
|
18791
|
+
token = _ref10.token, device = _ref10.device, cardCode = _ref10.cardCode, transaction = _ref10.transaction, selectedCurrency = _ref10.selectedCurrency;
|
|
18792
|
+
url = new URL("/cards/".concat(cardCode, "/charge"), configToUse.savedCardsApiUrl).toString();
|
|
18793
|
+
language = getLanguage();
|
|
18794
|
+
headers = _objectSpread2({
|
|
18795
|
+
Authorization: "Bearer ".concat(token),
|
|
18796
|
+
'jwt-auth': true
|
|
18797
|
+
}, language && {
|
|
18798
|
+
'Accept-Language': language
|
|
18799
|
+
});
|
|
18800
|
+
data = {
|
|
18801
|
+
device: device,
|
|
18802
|
+
transaction: transaction,
|
|
18803
|
+
selectedCurrency: selectedCurrency
|
|
18804
|
+
};
|
|
18805
|
+
return _context6.abrupt("return", axiosInstance.post(url, data, {
|
|
18806
|
+
headers: headers
|
|
18807
|
+
}).then(function (response) {
|
|
18808
|
+
return ChargeResponses.parse(response.data);
|
|
18809
|
+
}));
|
|
18810
|
+
|
|
18811
|
+
case 6:
|
|
18812
|
+
case "end":
|
|
18813
|
+
return _context6.stop();
|
|
18814
|
+
}
|
|
18815
|
+
}
|
|
18816
|
+
}, _callee6);
|
|
18817
|
+
}))();
|
|
18736
18818
|
}
|
|
18737
18819
|
};
|
|
18738
18820
|
|
|
18739
|
-
var paymentMethod$
|
|
18821
|
+
var paymentMethod$4 = 'card';
|
|
18740
18822
|
|
|
18741
|
-
function validate$
|
|
18823
|
+
function validate$4(card, isSetter) {
|
|
18742
18824
|
return new Promise(function (resolve, reject) {
|
|
18743
|
-
var validation = Card.validate(card);
|
|
18825
|
+
var validation = Card$1.validate(card);
|
|
18744
18826
|
|
|
18745
18827
|
if (!validation.isValid) {
|
|
18746
18828
|
var throwValidation = isSetter || card.number;
|
|
@@ -18759,8 +18841,8 @@ var CardCharge = {
|
|
|
18759
18841
|
setCard: function setCard(params) {
|
|
18760
18842
|
var _this = this;
|
|
18761
18843
|
|
|
18762
|
-
return validate$
|
|
18763
|
-
_this.card = new Card(params);
|
|
18844
|
+
return validate$4(params, true).then(function () {
|
|
18845
|
+
_this.card = new Card$1(params);
|
|
18764
18846
|
});
|
|
18765
18847
|
},
|
|
18766
18848
|
rememberCard: function rememberCard() {
|
|
@@ -18775,8 +18857,8 @@ var CardCharge = {
|
|
|
18775
18857
|
return this.chargeCardWithPin(customFields);
|
|
18776
18858
|
}
|
|
18777
18859
|
|
|
18778
|
-
return validate$
|
|
18779
|
-
_this2.logAttempt(paymentMethod$
|
|
18860
|
+
return validate$4(this.card).then(function () {
|
|
18861
|
+
_this2.logAttempt(paymentMethod$4);
|
|
18780
18862
|
|
|
18781
18863
|
var chargeParams = {
|
|
18782
18864
|
clientdata: _this2.card.tokenize(),
|
|
@@ -18789,8 +18871,8 @@ var CardCharge = {
|
|
|
18789
18871
|
subscription: _this2.subscription,
|
|
18790
18872
|
customFields: customFields
|
|
18791
18873
|
};
|
|
18792
|
-
return CardAPI.charge(chargeParams).then(function (response) {
|
|
18793
|
-
_this2.logAPIResponse(response, paymentMethod$
|
|
18874
|
+
return CardAPI$1.charge(chargeParams).then(function (response) {
|
|
18875
|
+
_this2.logAPIResponse(response, paymentMethod$4);
|
|
18794
18876
|
|
|
18795
18877
|
return response;
|
|
18796
18878
|
});
|
|
@@ -18805,7 +18887,7 @@ var CardCharge = {
|
|
|
18805
18887
|
var _this3 = this;
|
|
18806
18888
|
|
|
18807
18889
|
var customFields = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18808
|
-
this.logAttempt(paymentMethod$
|
|
18890
|
+
this.logAttempt(paymentMethod$4);
|
|
18809
18891
|
var chargeParams = {
|
|
18810
18892
|
pin: encrypt(this.card.pin),
|
|
18811
18893
|
trans: this.id,
|
|
@@ -18815,8 +18897,8 @@ var CardCharge = {
|
|
|
18815
18897
|
subscription: this.subscription,
|
|
18816
18898
|
customFields: customFields
|
|
18817
18899
|
};
|
|
18818
|
-
return CardAPI.charge(chargeParams).then(function (response) {
|
|
18819
|
-
_this3.logAPIResponse(response, paymentMethod$
|
|
18900
|
+
return CardAPI$1.charge(chargeParams).then(function (response) {
|
|
18901
|
+
_this3.logAPIResponse(response, paymentMethod$4);
|
|
18820
18902
|
|
|
18821
18903
|
return response;
|
|
18822
18904
|
});
|
|
@@ -18828,7 +18910,7 @@ var CardCharge = {
|
|
|
18828
18910
|
authorizationCode = _ref.authorizationCode,
|
|
18829
18911
|
cardLast4 = _ref.cardLast4,
|
|
18830
18912
|
pin = _ref.pin;
|
|
18831
|
-
this.logAttempt(paymentMethod$
|
|
18913
|
+
this.logAttempt(paymentMethod$4);
|
|
18832
18914
|
var encryptedPin = encrypt(pin);
|
|
18833
18915
|
var chargeParams = {
|
|
18834
18916
|
authorizationCode: authorizationCode,
|
|
@@ -18840,8 +18922,8 @@ var CardCharge = {
|
|
|
18840
18922
|
transactionType: this.transactionType,
|
|
18841
18923
|
subscription: this.subscription
|
|
18842
18924
|
};
|
|
18843
|
-
return CardAPI.chargeRememberedCard(chargeParams).then(function (response) {
|
|
18844
|
-
_this4.logAPIResponse(response, paymentMethod$
|
|
18925
|
+
return CardAPI$1.chargeRememberedCard(chargeParams).then(function (response) {
|
|
18926
|
+
_this4.logAPIResponse(response, paymentMethod$4);
|
|
18845
18927
|
|
|
18846
18928
|
return response;
|
|
18847
18929
|
});
|
|
@@ -18859,8 +18941,8 @@ var CardCharge = {
|
|
|
18859
18941
|
device: this.deviceFingerprint
|
|
18860
18942
|
});
|
|
18861
18943
|
|
|
18862
|
-
return CardAPI.resumeCardCharge(params).then(function (response) {
|
|
18863
|
-
_this5.logAPIResponse(response, paymentMethod$
|
|
18944
|
+
return CardAPI$1.resumeCardCharge(params).then(function (response) {
|
|
18945
|
+
_this5.logAPIResponse(response, paymentMethod$4);
|
|
18864
18946
|
|
|
18865
18947
|
return response;
|
|
18866
18948
|
});
|
|
@@ -18872,8 +18954,8 @@ var CardCharge = {
|
|
|
18872
18954
|
authorizationId: authorizationId,
|
|
18873
18955
|
publicKey: this.merchant.key
|
|
18874
18956
|
};
|
|
18875
|
-
return CardAPI.forgetRememberedCard(params).then(function (response) {
|
|
18876
|
-
_this6.logAPIResponse(response, paymentMethod$
|
|
18957
|
+
return CardAPI$1.forgetRememberedCard(params).then(function (response) {
|
|
18958
|
+
_this6.logAPIResponse(response, paymentMethod$4);
|
|
18877
18959
|
|
|
18878
18960
|
return response;
|
|
18879
18961
|
});
|
|
@@ -18881,8 +18963,8 @@ var CardCharge = {
|
|
|
18881
18963
|
authenticateCard: function authenticateCard(token) {
|
|
18882
18964
|
var _this7 = this;
|
|
18883
18965
|
|
|
18884
|
-
return CardAPI.authenticate(this.id, token).then(function (response) {
|
|
18885
|
-
_this7.logAPIResponse(response, paymentMethod$
|
|
18966
|
+
return CardAPI$1.authenticate(this.id, token).then(function (response) {
|
|
18967
|
+
_this7.logAPIResponse(response, paymentMethod$4);
|
|
18886
18968
|
|
|
18887
18969
|
return response;
|
|
18888
18970
|
});
|
|
@@ -18901,8 +18983,8 @@ var CardCharge = {
|
|
|
18901
18983
|
zipCode: zipCode,
|
|
18902
18984
|
transactionId: this.id
|
|
18903
18985
|
};
|
|
18904
|
-
return CardAPI.verifyAddress(payload).then(function (response) {
|
|
18905
|
-
_this8.logAPIResponse(response, paymentMethod$
|
|
18986
|
+
return CardAPI$1.verifyAddress(payload).then(function (response) {
|
|
18987
|
+
_this8.logAPIResponse(response, paymentMethod$4);
|
|
18906
18988
|
|
|
18907
18989
|
return response;
|
|
18908
18990
|
});
|
|
@@ -18910,14 +18992,21 @@ var CardCharge = {
|
|
|
18910
18992
|
listenFor3DSCharge: function listenFor3DSCharge(callback) {
|
|
18911
18993
|
var listenerOptions = {
|
|
18912
18994
|
channel: "3DS_".concat(this.id),
|
|
18913
|
-
paymentMethod: paymentMethod$
|
|
18995
|
+
paymentMethod: paymentMethod$4
|
|
18914
18996
|
};
|
|
18915
18997
|
return this.listenForCharge(listenerOptions, callback);
|
|
18916
18998
|
},
|
|
18917
|
-
|
|
18918
|
-
return CardAPI.
|
|
18999
|
+
requestSavedCardsOTP: function requestSavedCardsOTP(phoneNumber) {
|
|
19000
|
+
return CardAPI$1.requestSavedCardsOTP(phoneNumber);
|
|
19001
|
+
},
|
|
19002
|
+
addUserToSavedCards: function addUserToSavedCards(_ref4) {
|
|
19003
|
+
var phone = _ref4.phone;
|
|
19004
|
+
return CardAPI$1.addUserToSavedCards({
|
|
19005
|
+
phone: phone,
|
|
19006
|
+
email: this.email
|
|
19007
|
+
});
|
|
18919
19008
|
},
|
|
18920
|
-
verifySavedCardsOtp: function verifySavedCardsOtp(
|
|
19009
|
+
verifySavedCardsOtp: function verifySavedCardsOtp(_ref5) {
|
|
18921
19010
|
var _this9 = this;
|
|
18922
19011
|
|
|
18923
19012
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
@@ -18926,7 +19015,7 @@ var CardCharge = {
|
|
|
18926
19015
|
while (1) {
|
|
18927
19016
|
switch (_context.prev = _context.next) {
|
|
18928
19017
|
case 0:
|
|
18929
|
-
code =
|
|
19018
|
+
code = _ref5.code, phone = _ref5.phone;
|
|
18930
19019
|
payload = {
|
|
18931
19020
|
code: code,
|
|
18932
19021
|
phone: phone,
|
|
@@ -18934,7 +19023,7 @@ var CardCharge = {
|
|
|
18934
19023
|
};
|
|
18935
19024
|
_context.prev = 2;
|
|
18936
19025
|
_context.next = 5;
|
|
18937
|
-
return CardAPI.verifySavedCardsOtp(payload);
|
|
19026
|
+
return CardAPI$1.verifySavedCardsOtp(payload);
|
|
18938
19027
|
|
|
18939
19028
|
case 5:
|
|
18940
19029
|
response = _context.sent;
|
|
@@ -18945,7 +19034,7 @@ var CardCharge = {
|
|
|
18945
19034
|
_context.prev = 10;
|
|
18946
19035
|
_context.t0 = _context["catch"](2);
|
|
18947
19036
|
_this9.savedCardsToken = null;
|
|
18948
|
-
|
|
19037
|
+
throw _context.t0;
|
|
18949
19038
|
|
|
18950
19039
|
case 14:
|
|
18951
19040
|
case "end":
|
|
@@ -18956,19 +19045,19 @@ var CardCharge = {
|
|
|
18956
19045
|
}))();
|
|
18957
19046
|
},
|
|
18958
19047
|
getSavedCards: function getSavedCards() {
|
|
18959
|
-
return CardAPI.getSavedCards({
|
|
19048
|
+
return CardAPI$1.getSavedCards({
|
|
18960
19049
|
token: this.savedCardsToken
|
|
18961
19050
|
});
|
|
18962
19051
|
},
|
|
18963
19052
|
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
18964
|
-
return CardAPI.deleteSavedCard({
|
|
19053
|
+
return CardAPI$1.deleteSavedCard({
|
|
18965
19054
|
cardCode: cardCode,
|
|
18966
19055
|
token: this.savedCardsToken
|
|
18967
19056
|
});
|
|
18968
19057
|
},
|
|
18969
|
-
chargeSavedCard: function chargeSavedCard(
|
|
18970
|
-
var cardCode =
|
|
18971
|
-
return CardAPI.chargeSavedCard({
|
|
19058
|
+
chargeSavedCard: function chargeSavedCard(_ref6) {
|
|
19059
|
+
var cardCode = _ref6.cardCode;
|
|
19060
|
+
return CardAPI$1.chargeSavedCard({
|
|
18972
19061
|
cardCode: cardCode,
|
|
18973
19062
|
transaction: this.id,
|
|
18974
19063
|
token: this.savedCardsToken,
|
|
@@ -19127,9 +19216,9 @@ var EMandateAPI = {
|
|
|
19127
19216
|
}
|
|
19128
19217
|
};
|
|
19129
19218
|
|
|
19130
|
-
var paymentMethod$
|
|
19219
|
+
var paymentMethod$3 = 'bank account';
|
|
19131
19220
|
|
|
19132
|
-
function validate$
|
|
19221
|
+
function validate$3(bankAccount, isSetter) {
|
|
19133
19222
|
return new Promise(function (resolve, reject) {
|
|
19134
19223
|
var validation = BankAccount.validate(bankAccount);
|
|
19135
19224
|
|
|
@@ -19147,15 +19236,15 @@ var EMandate = {
|
|
|
19147
19236
|
setBankAccount: function setBankAccount(params) {
|
|
19148
19237
|
var _this = this;
|
|
19149
19238
|
|
|
19150
|
-
return validate$
|
|
19239
|
+
return validate$3(params, true).then(function () {
|
|
19151
19240
|
_this.bankAccount = new BankAccount(params);
|
|
19152
19241
|
});
|
|
19153
19242
|
},
|
|
19154
19243
|
chargeBankAccount: function chargeBankAccount() {
|
|
19155
19244
|
var _this2 = this;
|
|
19156
19245
|
|
|
19157
|
-
return validate$
|
|
19158
|
-
_this2.logAttempt(paymentMethod$
|
|
19246
|
+
return validate$3(this.bankAccount).then(function () {
|
|
19247
|
+
_this2.logAttempt(paymentMethod$3);
|
|
19159
19248
|
|
|
19160
19249
|
var verifyParams = {
|
|
19161
19250
|
bankId: _this2.bankAccount.bankId,
|
|
@@ -19164,7 +19253,7 @@ var EMandate = {
|
|
|
19164
19253
|
device: _this2.deviceFingerprint
|
|
19165
19254
|
};
|
|
19166
19255
|
return EMandateAPI.verify(verifyParams).then(function (response) {
|
|
19167
|
-
_this2.logAPIResponse(response, paymentMethod$
|
|
19256
|
+
_this2.logAPIResponse(response, paymentMethod$3);
|
|
19168
19257
|
|
|
19169
19258
|
return response;
|
|
19170
19259
|
});
|
|
@@ -19173,7 +19262,7 @@ var EMandate = {
|
|
|
19173
19262
|
registerBankAccount: function registerBankAccount(birthday) {
|
|
19174
19263
|
var _this3 = this;
|
|
19175
19264
|
|
|
19176
|
-
return validate$
|
|
19265
|
+
return validate$3(this.bankAccount).then(function () {
|
|
19177
19266
|
var registerParams = {
|
|
19178
19267
|
bankId: _this3.bankAccount.bankId,
|
|
19179
19268
|
transactionId: _this3.id,
|
|
@@ -19181,7 +19270,7 @@ var EMandate = {
|
|
|
19181
19270
|
birthday: birthday
|
|
19182
19271
|
};
|
|
19183
19272
|
return EMandateAPI.register(registerParams).then(function (response) {
|
|
19184
|
-
_this3.logAPIResponse(response, paymentMethod$
|
|
19273
|
+
_this3.logAPIResponse(response, paymentMethod$3);
|
|
19185
19274
|
|
|
19186
19275
|
return response;
|
|
19187
19276
|
});
|
|
@@ -19190,7 +19279,7 @@ var EMandate = {
|
|
|
19190
19279
|
authenticateBankAccount: function authenticateBankAccount(token) {
|
|
19191
19280
|
var _this4 = this;
|
|
19192
19281
|
|
|
19193
|
-
return validate$
|
|
19282
|
+
return validate$3(this.bankAccount).then(function () {
|
|
19194
19283
|
var chargeParams = {
|
|
19195
19284
|
bankId: _this4.bankAccount.bankId,
|
|
19196
19285
|
transactionId: _this4.id,
|
|
@@ -19198,7 +19287,7 @@ var EMandate = {
|
|
|
19198
19287
|
device: _this4.deviceFingerprint
|
|
19199
19288
|
};
|
|
19200
19289
|
return EMandateAPI.authenticate(chargeParams).then(function (response) {
|
|
19201
|
-
_this4.logAPIResponse(response, paymentMethod$
|
|
19290
|
+
_this4.logAPIResponse(response, paymentMethod$3);
|
|
19202
19291
|
|
|
19203
19292
|
return response;
|
|
19204
19293
|
});
|
|
@@ -19259,7 +19348,7 @@ var DigitalBankMandateAPI = {
|
|
|
19259
19348
|
}
|
|
19260
19349
|
};
|
|
19261
19350
|
|
|
19262
|
-
var paymentMethod$
|
|
19351
|
+
var paymentMethod$2 = 'bank';
|
|
19263
19352
|
var DigitalBankMandate = {
|
|
19264
19353
|
chargeDigitalBankMandate: function chargeDigitalBankMandate(_ref) {
|
|
19265
19354
|
var _this = this;
|
|
@@ -19274,7 +19363,7 @@ var DigitalBankMandate = {
|
|
|
19274
19363
|
bankId: bankId
|
|
19275
19364
|
};
|
|
19276
19365
|
return DigitalBankMandateAPI.charge(params).then(function (response) {
|
|
19277
|
-
_this.logAPIResponse(response, paymentMethod$
|
|
19366
|
+
_this.logAPIResponse(response, paymentMethod$2);
|
|
19278
19367
|
|
|
19279
19368
|
return response;
|
|
19280
19369
|
});
|
|
@@ -19282,7 +19371,7 @@ var DigitalBankMandate = {
|
|
|
19282
19371
|
listenForDigitalBankMandateCharge: function listenForDigitalBankMandateCharge(callback) {
|
|
19283
19372
|
var pusherChannel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
19284
19373
|
var listenerOptions = {
|
|
19285
|
-
paymentMethod: paymentMethod$
|
|
19374
|
+
paymentMethod: paymentMethod$2,
|
|
19286
19375
|
channel: pusherChannel
|
|
19287
19376
|
};
|
|
19288
19377
|
return this.listenForCharge(listenerOptions, callback);
|
|
@@ -19415,7 +19504,7 @@ var QrAPI = {
|
|
|
19415
19504
|
}
|
|
19416
19505
|
};
|
|
19417
19506
|
|
|
19418
|
-
function validate$
|
|
19507
|
+
function validate$2(channel) {
|
|
19419
19508
|
return new Promise(function (resolve, reject) {
|
|
19420
19509
|
var allowedChannels = ['visa', 'MPASS_OLTI'];
|
|
19421
19510
|
|
|
@@ -19433,7 +19522,7 @@ var QRCharge = {
|
|
|
19433
19522
|
var _this = this;
|
|
19434
19523
|
|
|
19435
19524
|
var channel = _ref.channel;
|
|
19436
|
-
return validate$
|
|
19525
|
+
return validate$2(channel).then(function () {
|
|
19437
19526
|
if (_this.qr[channel]) {
|
|
19438
19527
|
return _this.qr[channel];
|
|
19439
19528
|
}
|
|
@@ -19455,7 +19544,7 @@ var QRCharge = {
|
|
|
19455
19544
|
var _this2 = this;
|
|
19456
19545
|
|
|
19457
19546
|
var channel = _ref2.channel;
|
|
19458
|
-
return validate$
|
|
19547
|
+
return validate$2(channel).then(function () {
|
|
19459
19548
|
if (!_this2.qr[channel]) {
|
|
19460
19549
|
return Promise.reject(Error('Please generate qr code with Transaction.getQRCode()'));
|
|
19461
19550
|
}
|
|
@@ -19576,7 +19665,7 @@ var MobileMoneyAPI = {
|
|
|
19576
19665
|
}
|
|
19577
19666
|
};
|
|
19578
19667
|
|
|
19579
|
-
function validate(phoneNumber) {
|
|
19668
|
+
function validate$1(phoneNumber) {
|
|
19580
19669
|
return new Promise(function (resolve, reject) {
|
|
19581
19670
|
var validation = PhoneNumber.validate(phoneNumber);
|
|
19582
19671
|
|
|
@@ -19597,7 +19686,7 @@ var MobileMoneyCharge = {
|
|
|
19597
19686
|
provider = _ref.provider,
|
|
19598
19687
|
voucher = _ref.voucher,
|
|
19599
19688
|
registrationToken = _ref.registrationToken;
|
|
19600
|
-
return validate(phoneNumber).then(function () {
|
|
19689
|
+
return validate$1(phoneNumber).then(function () {
|
|
19601
19690
|
_this.logAttempt('mobile money');
|
|
19602
19691
|
|
|
19603
19692
|
var params = {
|
|
@@ -19628,7 +19717,7 @@ var MobileMoneyCharge = {
|
|
|
19628
19717
|
var phoneNumber = payload.phoneNumber,
|
|
19629
19718
|
provider = payload.provider,
|
|
19630
19719
|
registrationToken = payload.registrationToken;
|
|
19631
|
-
return validate(phoneNumber).then(function () {
|
|
19720
|
+
return validate$1(phoneNumber).then(function () {
|
|
19632
19721
|
_this2.logMobileMoneyActions(payload);
|
|
19633
19722
|
|
|
19634
19723
|
var params = {
|
|
@@ -19768,7 +19857,7 @@ var DirectDebitAPI = {
|
|
|
19768
19857
|
}
|
|
19769
19858
|
};
|
|
19770
19859
|
|
|
19771
|
-
var paymentMethod = 'direct debit';
|
|
19860
|
+
var paymentMethod$1 = 'direct debit';
|
|
19772
19861
|
var DirectDebitCharge = {
|
|
19773
19862
|
loginToDirectDebitAccount: function loginToDirectDebitAccount(_ref) {
|
|
19774
19863
|
var _this = this;
|
|
@@ -19814,14 +19903,14 @@ var DirectDebitCharge = {
|
|
|
19814
19903
|
return Promise.reject(Error('Please login with Transaction.loginToDirectDebitAccount() to start a Direct debit charge'));
|
|
19815
19904
|
}
|
|
19816
19905
|
|
|
19817
|
-
this.logAttempt(paymentMethod);
|
|
19906
|
+
this.logAttempt(paymentMethod$1);
|
|
19818
19907
|
var params = {
|
|
19819
19908
|
account_code: accountCode,
|
|
19820
19909
|
transaction: this.id,
|
|
19821
19910
|
token: this.directDebit.token
|
|
19822
19911
|
};
|
|
19823
19912
|
return DirectDebitAPI.charge(params).then(function (response) {
|
|
19824
|
-
_this2.logAPIResponse(response, paymentMethod);
|
|
19913
|
+
_this2.logAPIResponse(response, paymentMethod$1);
|
|
19825
19914
|
|
|
19826
19915
|
if (response.status) {
|
|
19827
19916
|
_this2.directDebit.chargeResponse = response;
|
|
@@ -19834,7 +19923,7 @@ var DirectDebitCharge = {
|
|
|
19834
19923
|
var _this3 = this;
|
|
19835
19924
|
|
|
19836
19925
|
return DirectDebitAPI.getProvisionedAccounts(this.directDebit.token).then(function (response) {
|
|
19837
|
-
_this3.logAPIResponse(response, paymentMethod);
|
|
19926
|
+
_this3.logAPIResponse(response, paymentMethod$1);
|
|
19838
19927
|
|
|
19839
19928
|
var status = response.status,
|
|
19840
19929
|
data = response.data;
|
|
@@ -19859,7 +19948,7 @@ var DirectDebitCharge = {
|
|
|
19859
19948
|
token: this.directDebit.token
|
|
19860
19949
|
};
|
|
19861
19950
|
return DirectDebitAPI.authenticate(params).then(function (response) {
|
|
19862
|
-
_this4.logAPIResponse(response, paymentMethod);
|
|
19951
|
+
_this4.logAPIResponse(response, paymentMethod$1);
|
|
19863
19952
|
|
|
19864
19953
|
return response;
|
|
19865
19954
|
});
|
|
@@ -20303,8 +20392,8 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20303
20392
|
this.subscription = data.subscription || null;
|
|
20304
20393
|
this.planDetails = data.plan_details || null;
|
|
20305
20394
|
this.exchangeRate = data.exchange_rate || null;
|
|
20395
|
+
this.savedCardsConfig = data.saved_cards || {};
|
|
20306
20396
|
this.savedCardsToken = null;
|
|
20307
|
-
this.isSavedCardsEnabled = data.saved_cards && data.saved_cards.enabled || null;
|
|
20308
20397
|
/**
|
|
20309
20398
|
* We initialize parameters we send to the API as empty strings
|
|
20310
20399
|
* when we don't have them instead of null because the API expects
|
|
@@ -20347,51 +20436,7 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20347
20436
|
}, {
|
|
20348
20437
|
key: "listenForCharge",
|
|
20349
20438
|
value: function listenForCharge(options, callback) {
|
|
20350
|
-
|
|
20351
|
-
|
|
20352
|
-
var channel = options.channel,
|
|
20353
|
-
paymentMethod = options.paymentMethod;
|
|
20354
|
-
var pusher;
|
|
20355
|
-
|
|
20356
|
-
if (window && window.Pusher) {
|
|
20357
|
-
pusher = new window.Pusher(configToUse.pusherKey, {
|
|
20358
|
-
cluster: 'eu',
|
|
20359
|
-
disableStats: true
|
|
20360
|
-
});
|
|
20361
|
-
}
|
|
20362
|
-
|
|
20363
|
-
var pusherUndefinedError = {
|
|
20364
|
-
status: 'error',
|
|
20365
|
-
message: 'We could not listen for charge response.'
|
|
20366
|
-
};
|
|
20367
|
-
var pusherSubscriptionError = {
|
|
20368
|
-
status: 'error',
|
|
20369
|
-
message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
|
|
20370
|
-
};
|
|
20371
|
-
|
|
20372
|
-
var unsubscribeFromPusher = function unsubscribeFromPusher() {
|
|
20373
|
-
pusher.unsubscribe(channel);
|
|
20374
|
-
};
|
|
20375
|
-
|
|
20376
|
-
if (!pusher) {
|
|
20377
|
-
return callback(pusherUndefinedError, noOp);
|
|
20378
|
-
}
|
|
20379
|
-
|
|
20380
|
-
var pusherSubscription = pusher.subscribe(channel);
|
|
20381
|
-
pusherSubscription.bind('pusher:subscription_succeeded', function () {
|
|
20382
|
-
_this2.isListening = true;
|
|
20383
|
-
});
|
|
20384
|
-
pusherSubscription.bind('pusher:subscription_error', function () {
|
|
20385
|
-
_this2.isListening = false;
|
|
20386
|
-
callback(pusherSubscriptionError, noOp);
|
|
20387
|
-
});
|
|
20388
|
-
pusherSubscription.bind('response', function (response) {
|
|
20389
|
-
var formattedResponse = ChargeResponses.parse(response);
|
|
20390
|
-
|
|
20391
|
-
_this2.logAPIResponse(formattedResponse, paymentMethod);
|
|
20392
|
-
|
|
20393
|
-
callback(formattedResponse, unsubscribeFromPusher);
|
|
20394
|
-
});
|
|
20439
|
+
return subscribeToChargeEvents(options, this, callback);
|
|
20395
20440
|
}
|
|
20396
20441
|
}, {
|
|
20397
20442
|
key: "requery",
|
|
@@ -20689,4 +20734,518 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20689
20734
|
return Toolkit;
|
|
20690
20735
|
}();
|
|
20691
20736
|
|
|
20692
|
-
|
|
20737
|
+
cardValidator.creditCardType.addCard({
|
|
20738
|
+
niceType: 'Verve',
|
|
20739
|
+
type: 'verve',
|
|
20740
|
+
patterns: [[506000, 507999], [650000, 650009]],
|
|
20741
|
+
gaps: [4, 8, 12, 16],
|
|
20742
|
+
lengths: [16, 18, 19],
|
|
20743
|
+
code: {
|
|
20744
|
+
name: 'CVV',
|
|
20745
|
+
size: 3
|
|
20746
|
+
}
|
|
20747
|
+
});
|
|
20748
|
+
cardValidator.creditCardType.changeOrder('verve', 0);
|
|
20749
|
+
|
|
20750
|
+
var Card = /*#__PURE__*/function () {
|
|
20751
|
+
function Card(_ref) {
|
|
20752
|
+
var number = _ref.number,
|
|
20753
|
+
cvv = _ref.cvv,
|
|
20754
|
+
month = _ref.month,
|
|
20755
|
+
year = _ref.year,
|
|
20756
|
+
pin = _ref.pin;
|
|
20757
|
+
|
|
20758
|
+
_classCallCheck(this, Card);
|
|
20759
|
+
|
|
20760
|
+
this.number = number;
|
|
20761
|
+
this.cvv = cvv;
|
|
20762
|
+
this.month = month;
|
|
20763
|
+
this.year = year;
|
|
20764
|
+
this.pin = pin;
|
|
20765
|
+
}
|
|
20766
|
+
|
|
20767
|
+
_createClass(Card, [{
|
|
20768
|
+
key: "getEncryptedPin",
|
|
20769
|
+
value: function getEncryptedPin() {
|
|
20770
|
+
return Card$2.getEncryptedPin(this.pin);
|
|
20771
|
+
}
|
|
20772
|
+
}, {
|
|
20773
|
+
key: "getLast4",
|
|
20774
|
+
value: function getLast4() {
|
|
20775
|
+
return Card$2.getLast4(this.number);
|
|
20776
|
+
}
|
|
20777
|
+
}, {
|
|
20778
|
+
key: "tokenize",
|
|
20779
|
+
value: function tokenize() {
|
|
20780
|
+
return Card$2.tokenize({
|
|
20781
|
+
number: this.number,
|
|
20782
|
+
cvv: this.cvv,
|
|
20783
|
+
month: this.month,
|
|
20784
|
+
year: this.year
|
|
20785
|
+
});
|
|
20786
|
+
}
|
|
20787
|
+
}], [{
|
|
20788
|
+
key: "getType",
|
|
20789
|
+
value: function getType(value) {
|
|
20790
|
+
return Card$2.getType(value);
|
|
20791
|
+
}
|
|
20792
|
+
}, {
|
|
20793
|
+
key: "validate",
|
|
20794
|
+
value: function validate(_ref2) {
|
|
20795
|
+
var number = _ref2.number,
|
|
20796
|
+
cvv = _ref2.cvv,
|
|
20797
|
+
month = _ref2.month,
|
|
20798
|
+
year = _ref2.year;
|
|
20799
|
+
return Card$2.validate({
|
|
20800
|
+
number: number,
|
|
20801
|
+
cvv: cvv,
|
|
20802
|
+
month: month,
|
|
20803
|
+
year: year
|
|
20804
|
+
});
|
|
20805
|
+
}
|
|
20806
|
+
}, {
|
|
20807
|
+
key: "validateNumber",
|
|
20808
|
+
value: function validateNumber(value) {
|
|
20809
|
+
return Card$2.validateNumber(value);
|
|
20810
|
+
}
|
|
20811
|
+
}, {
|
|
20812
|
+
key: "isNumberValid",
|
|
20813
|
+
value: function isNumberValid(value) {
|
|
20814
|
+
return Card$2.isNumberValid(value);
|
|
20815
|
+
}
|
|
20816
|
+
}, {
|
|
20817
|
+
key: "validateCVV",
|
|
20818
|
+
value: function validateCVV(cvv, cardType) {
|
|
20819
|
+
return Card$2.validateCVV(cvv, cardType);
|
|
20820
|
+
}
|
|
20821
|
+
}, {
|
|
20822
|
+
key: "isCvvValid",
|
|
20823
|
+
value: function isCvvValid(cvv, cardType) {
|
|
20824
|
+
return Card$2.isCvvValid(cvv, cardType);
|
|
20825
|
+
}
|
|
20826
|
+
}, {
|
|
20827
|
+
key: "validateExpiry",
|
|
20828
|
+
value: function validateExpiry(value) {
|
|
20829
|
+
return Card$2.validateExpiry(value);
|
|
20830
|
+
}
|
|
20831
|
+
}, {
|
|
20832
|
+
key: "isExpiryValid",
|
|
20833
|
+
value: function isExpiryValid(value) {
|
|
20834
|
+
return Card$2.isExpiryValid(value);
|
|
20835
|
+
}
|
|
20836
|
+
}, {
|
|
20837
|
+
key: "generateTestCard",
|
|
20838
|
+
value: function generateTestCard(cardType) {
|
|
20839
|
+
var type = cardType || 'default';
|
|
20840
|
+
var cardParams = testCards.find(function (card) {
|
|
20841
|
+
return card.type === type;
|
|
20842
|
+
});
|
|
20843
|
+
return new Card(cardParams);
|
|
20844
|
+
}
|
|
20845
|
+
}]);
|
|
20846
|
+
|
|
20847
|
+
return Card;
|
|
20848
|
+
}();
|
|
20849
|
+
|
|
20850
|
+
var CardAPI = {
|
|
20851
|
+
reserve: function reserve(_ref) {
|
|
20852
|
+
var clientdata = _ref.clientdata,
|
|
20853
|
+
last4 = _ref.last4,
|
|
20854
|
+
preauthorizationId = _ref.preauthorizationId;
|
|
20855
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/reserve");
|
|
20856
|
+
var language = getLanguage();
|
|
20857
|
+
|
|
20858
|
+
var headers = _objectSpread2({}, language && {
|
|
20859
|
+
'Accept-Language': language
|
|
20860
|
+
});
|
|
20861
|
+
|
|
20862
|
+
return axiosInstance.post(url, {
|
|
20863
|
+
clientdata: clientdata,
|
|
20864
|
+
last4: last4,
|
|
20865
|
+
preauthorization: preauthorizationId
|
|
20866
|
+
}, {
|
|
20867
|
+
headers: headers
|
|
20868
|
+
}).then(function (response) {
|
|
20869
|
+
return ChargeResponses.parse(response.data);
|
|
20870
|
+
});
|
|
20871
|
+
} // charge({
|
|
20872
|
+
// clientdata,
|
|
20873
|
+
// last4,
|
|
20874
|
+
// pin,
|
|
20875
|
+
// trans,
|
|
20876
|
+
// device,
|
|
20877
|
+
// rememberCard,
|
|
20878
|
+
// transactionType,
|
|
20879
|
+
// subscription,
|
|
20880
|
+
// customFields,
|
|
20881
|
+
// }) {
|
|
20882
|
+
// const url = `${config.paymentBaseUrl}charge/`;
|
|
20883
|
+
// const language = getLanguage();
|
|
20884
|
+
// const headers = {
|
|
20885
|
+
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
20886
|
+
// ...(language && { 'Accept-Language': language }),
|
|
20887
|
+
// };
|
|
20888
|
+
// const chargeParams = {
|
|
20889
|
+
// clientdata,
|
|
20890
|
+
// last4,
|
|
20891
|
+
// trans,
|
|
20892
|
+
// device,
|
|
20893
|
+
// offset: new Date().getTimezoneOffset(),
|
|
20894
|
+
// remember_card: rememberCard,
|
|
20895
|
+
// ...(transactionType && { transaction_type: transactionType }),
|
|
20896
|
+
// ...(subscription && { subscription }),
|
|
20897
|
+
// ...(customFields && customFields),
|
|
20898
|
+
// };
|
|
20899
|
+
// if (pin) {
|
|
20900
|
+
// chargeParams.handle = pin;
|
|
20901
|
+
// }
|
|
20902
|
+
// const urlEncodedParams = formurlencoded(chargeParams);
|
|
20903
|
+
// return axiosInstance
|
|
20904
|
+
// .post(url, urlEncodedParams, { headers })
|
|
20905
|
+
// .then((response) => ChargeResponses.parse(response.data));
|
|
20906
|
+
// },
|
|
20907
|
+
// resumeCardCharge({ device, accessCode, pin }) {
|
|
20908
|
+
// const url = `${config.paymentBaseUrl}charge/resume/${accessCode}`;
|
|
20909
|
+
// const language = getLanguage();
|
|
20910
|
+
// const headers = {
|
|
20911
|
+
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
20912
|
+
// ...(language && { 'Accept-Language': language }),
|
|
20913
|
+
// };
|
|
20914
|
+
// const data = { device, ...(pin && { handle: pin }) };
|
|
20915
|
+
// const urlEncodedData = formurlencoded(data);
|
|
20916
|
+
// return axiosInstance
|
|
20917
|
+
// .post(url, urlEncodedData, { headers })
|
|
20918
|
+
// .then((response) => ChargeResponses.parse(response.data));
|
|
20919
|
+
// },
|
|
20920
|
+
// chargeRememberedCard({
|
|
20921
|
+
// last4,
|
|
20922
|
+
// trans,
|
|
20923
|
+
// device,
|
|
20924
|
+
// authorizationCode,
|
|
20925
|
+
// cvv,
|
|
20926
|
+
// pin,
|
|
20927
|
+
// transactionType,
|
|
20928
|
+
// subscription,
|
|
20929
|
+
// }) {
|
|
20930
|
+
// const url = `${config.paymentBaseUrl}charge/`;
|
|
20931
|
+
// const language = getLanguage();
|
|
20932
|
+
// const headers = {
|
|
20933
|
+
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
20934
|
+
// ...(language && { 'Accept-Language': language }),
|
|
20935
|
+
// };
|
|
20936
|
+
// const chargeParams = {
|
|
20937
|
+
// last4,
|
|
20938
|
+
// trans,
|
|
20939
|
+
// device,
|
|
20940
|
+
// cvv,
|
|
20941
|
+
// handle: pin,
|
|
20942
|
+
// authorization_code: authorizationCode,
|
|
20943
|
+
// ...(transactionType && { transaction_type: transactionType }),
|
|
20944
|
+
// ...(subscription && { subscription }),
|
|
20945
|
+
// };
|
|
20946
|
+
// const urlEncodedParams = formurlencoded(chargeParams);
|
|
20947
|
+
// return axiosInstance
|
|
20948
|
+
// .post(url, urlEncodedParams, { headers })
|
|
20949
|
+
// .then((response) => ChargeResponses.parse(response.data));
|
|
20950
|
+
// },
|
|
20951
|
+
// verifyAddress({ address, city, state, zipCode, transactionId }) {
|
|
20952
|
+
// const url = `${config.paymentBaseUrl}charge/avs`;
|
|
20953
|
+
// const language = getLanguage();
|
|
20954
|
+
// const headers = {
|
|
20955
|
+
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
20956
|
+
// ...(language && { 'Accept-Language': language }),
|
|
20957
|
+
// };
|
|
20958
|
+
// const data = {
|
|
20959
|
+
// city,
|
|
20960
|
+
// state,
|
|
20961
|
+
// address,
|
|
20962
|
+
// zip_code: zipCode,
|
|
20963
|
+
// trans: transactionId,
|
|
20964
|
+
// };
|
|
20965
|
+
// const urlEncodedData = formurlencoded(data);
|
|
20966
|
+
// return axiosInstance
|
|
20967
|
+
// .post(url, urlEncodedData, { headers })
|
|
20968
|
+
// .then((response) => ChargeResponses.parse(response.data));
|
|
20969
|
+
// },
|
|
20970
|
+
// forgetRememberedCard({ authorizationId, publicKey }) {
|
|
20971
|
+
// const language = getLanguage();
|
|
20972
|
+
// const headers = {
|
|
20973
|
+
// Authorization: `Bearer ${publicKey}`,
|
|
20974
|
+
// ...(language && { 'Accept-Language': language }),
|
|
20975
|
+
// };
|
|
20976
|
+
// const params = {
|
|
20977
|
+
// authorization_id: authorizationId,
|
|
20978
|
+
// };
|
|
20979
|
+
// const url = `${config.paystackApiUrl}rememberme/forget_card`;
|
|
20980
|
+
// return axiosInstance
|
|
20981
|
+
// .post(url, params, { headers })
|
|
20982
|
+
// .then((response) => ChargeResponses.parse(response.data));
|
|
20983
|
+
// },
|
|
20984
|
+
|
|
20985
|
+
};
|
|
20986
|
+
|
|
20987
|
+
var paymentMethod = 'card';
|
|
20988
|
+
|
|
20989
|
+
function validate(card, isSetter) {
|
|
20990
|
+
return new Promise(function (resolve, reject) {
|
|
20991
|
+
var validation = Card.validate(card);
|
|
20992
|
+
|
|
20993
|
+
if (!validation.isValid) {
|
|
20994
|
+
var throwValidation = isSetter || card.number;
|
|
20995
|
+
var errors = Object.keys(validation.result).filter(function (value) {
|
|
20996
|
+
return validation.result[value] === false;
|
|
20997
|
+
});
|
|
20998
|
+
var errorMessage = "Invalid card details: ".concat(errors.join(', '));
|
|
20999
|
+
reject(Error(throwValidation ? errorMessage : 'Please set a valid card with setCard()'));
|
|
21000
|
+
}
|
|
21001
|
+
|
|
21002
|
+
resolve();
|
|
21003
|
+
});
|
|
21004
|
+
}
|
|
21005
|
+
|
|
21006
|
+
var ReserveCardFunds = {
|
|
21007
|
+
setCard: function setCard(params) {
|
|
21008
|
+
var _this = this;
|
|
21009
|
+
|
|
21010
|
+
return validate(params, true).then(function () {
|
|
21011
|
+
_this.card = new Card(params);
|
|
21012
|
+
});
|
|
21013
|
+
},
|
|
21014
|
+
reserve: function reserve(preauthorizationId) {
|
|
21015
|
+
var _this2 = this;
|
|
21016
|
+
|
|
21017
|
+
var customFields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21018
|
+
// TODO: Log payment method
|
|
21019
|
+
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
21020
|
+
return validate(this.card).then(function () {
|
|
21021
|
+
var chargeParams = {
|
|
21022
|
+
clientdata: _this2.card.tokenize(),
|
|
21023
|
+
last4: _this2.card.getLast4(),
|
|
21024
|
+
preauthorization: preauthorizationId,
|
|
21025
|
+
customFields: customFields
|
|
21026
|
+
};
|
|
21027
|
+
return CardAPI.charge(chargeParams).then(function (response) {
|
|
21028
|
+
// TODO: Log API Response
|
|
21029
|
+
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
21030
|
+
return response;
|
|
21031
|
+
});
|
|
21032
|
+
});
|
|
21033
|
+
},
|
|
21034
|
+
listenFor3DSCharge: function listenFor3DSCharge(callback) {
|
|
21035
|
+
var listenerOptions = {
|
|
21036
|
+
channel: "3DS_".concat(this.id),
|
|
21037
|
+
paymentMethod: paymentMethod
|
|
21038
|
+
};
|
|
21039
|
+
return this.listenForCharge(listenerOptions, callback);
|
|
21040
|
+
} // rememberCard() {
|
|
21041
|
+
// this.remember_card = true;
|
|
21042
|
+
// },
|
|
21043
|
+
// chargeCard(customFields = {}) {
|
|
21044
|
+
// if (!this.card.number && this.card.pin) {
|
|
21045
|
+
// return this.chargeCardWithPin(customFields);
|
|
21046
|
+
// }
|
|
21047
|
+
// return validate(this.card).then(() => {
|
|
21048
|
+
// this.logAttempt(paymentMethod);
|
|
21049
|
+
// const chargeParams = {
|
|
21050
|
+
// clientdata: this.card.tokenize(),
|
|
21051
|
+
// last4: this.card.getLast4(),
|
|
21052
|
+
// pin: this.card.getEncryptedPin(),
|
|
21053
|
+
// trans: this.id,
|
|
21054
|
+
// device: this.deviceFingerprint,
|
|
21055
|
+
// rememberCard: this.remember_card,
|
|
21056
|
+
// transactionType: this.transactionType,
|
|
21057
|
+
// subscription: this.subscription,
|
|
21058
|
+
// customFields,
|
|
21059
|
+
// };
|
|
21060
|
+
// return CardAPI.charge(chargeParams).then((response) => {
|
|
21061
|
+
// this.logAPIResponse(response, paymentMethod);
|
|
21062
|
+
// return response;
|
|
21063
|
+
// });
|
|
21064
|
+
// });
|
|
21065
|
+
// },
|
|
21066
|
+
|
|
21067
|
+
/**
|
|
21068
|
+
* Handles submitting a card pin after
|
|
21069
|
+
* other card details have been previously submitted.
|
|
21070
|
+
*/
|
|
21071
|
+
// chargeCardWithPin(customFields = {}) {
|
|
21072
|
+
// this.logAttempt(paymentMethod);
|
|
21073
|
+
// const chargeParams = {
|
|
21074
|
+
// pin: encrypt(this.card.pin),
|
|
21075
|
+
// trans: this.id,
|
|
21076
|
+
// device: this.deviceFingerprint,
|
|
21077
|
+
// rememberCard: this.remember_card,
|
|
21078
|
+
// transactionType: this.transactionType,
|
|
21079
|
+
// subscription: this.subscription,
|
|
21080
|
+
// customFields,
|
|
21081
|
+
// };
|
|
21082
|
+
// return CardAPI.charge(chargeParams).then((response) => {
|
|
21083
|
+
// this.logAPIResponse(response, paymentMethod);
|
|
21084
|
+
// return response;
|
|
21085
|
+
// });
|
|
21086
|
+
// },
|
|
21087
|
+
// chargeRememberedCard({ cvv, authorizationCode, cardLast4, pin }) {
|
|
21088
|
+
// this.logAttempt(paymentMethod);
|
|
21089
|
+
// const encryptedPin = encrypt(pin);
|
|
21090
|
+
// const chargeParams = {
|
|
21091
|
+
// authorizationCode,
|
|
21092
|
+
// cvv,
|
|
21093
|
+
// last4: cardLast4,
|
|
21094
|
+
// trans: this.id,
|
|
21095
|
+
// device: this.deviceFingerprint,
|
|
21096
|
+
// pin: encryptedPin,
|
|
21097
|
+
// transactionType: this.transactionType,
|
|
21098
|
+
// subscription: this.subscription,
|
|
21099
|
+
// };
|
|
21100
|
+
// return CardAPI.chargeRememberedCard(chargeParams).then((response) => {
|
|
21101
|
+
// this.logAPIResponse(response, paymentMethod);
|
|
21102
|
+
// return response;
|
|
21103
|
+
// });
|
|
21104
|
+
// },
|
|
21105
|
+
// resumeCardCharge({ accessCode, pin }) {
|
|
21106
|
+
// const params = {
|
|
21107
|
+
// ...(pin && { pin: encrypt(pin) }),
|
|
21108
|
+
// accessCode,
|
|
21109
|
+
// device: this.deviceFingerprint,
|
|
21110
|
+
// };
|
|
21111
|
+
// return CardAPI.resumeCardCharge(params).then((response) => {
|
|
21112
|
+
// this.logAPIResponse(response, paymentMethod);
|
|
21113
|
+
// return response;
|
|
21114
|
+
// });
|
|
21115
|
+
// },
|
|
21116
|
+
// forgetRememberedCard(authorizationId) {
|
|
21117
|
+
// const params = {
|
|
21118
|
+
// authorizationId,
|
|
21119
|
+
// publicKey: this.merchant.key,
|
|
21120
|
+
// };
|
|
21121
|
+
// return CardAPI.forgetRememberedCard(params).then((response) => {
|
|
21122
|
+
// this.logAPIResponse(response, paymentMethod);
|
|
21123
|
+
// return response;
|
|
21124
|
+
// });
|
|
21125
|
+
// },
|
|
21126
|
+
// authenticateCard(token) {
|
|
21127
|
+
// return CardAPI.authenticate(this.id, token).then((response) => {
|
|
21128
|
+
// this.logAPIResponse(response, paymentMethod);
|
|
21129
|
+
// return response;
|
|
21130
|
+
// });
|
|
21131
|
+
// },
|
|
21132
|
+
// verifyAddress({ address, city, state, zipCode }) {
|
|
21133
|
+
// const payload = {
|
|
21134
|
+
// city,
|
|
21135
|
+
// state,
|
|
21136
|
+
// address,
|
|
21137
|
+
// zipCode,
|
|
21138
|
+
// transactionId: this.id,
|
|
21139
|
+
// };
|
|
21140
|
+
// return CardAPI.verifyAddress(payload).then((response) => {
|
|
21141
|
+
// this.logAPIResponse(response, paymentMethod);
|
|
21142
|
+
// return response;
|
|
21143
|
+
// });
|
|
21144
|
+
// },
|
|
21145
|
+
|
|
21146
|
+
};
|
|
21147
|
+
|
|
21148
|
+
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
21149
|
+
function PreauthorizationInstance(data) {
|
|
21150
|
+
_classCallCheck(this, PreauthorizationInstance);
|
|
21151
|
+
|
|
21152
|
+
this.email = data.email;
|
|
21153
|
+
this.status = data.status;
|
|
21154
|
+
this.reference = data.reference;
|
|
21155
|
+
this.amount = data.amount;
|
|
21156
|
+
this.currency = data.currency;
|
|
21157
|
+
this.metadata = data.metadata || {};
|
|
21158
|
+
this.customer = data.customer;
|
|
21159
|
+
this.channels = data.channels || ['card'];
|
|
21160
|
+
this.isListening = false;
|
|
21161
|
+
this.merchant = {
|
|
21162
|
+
id: data.merchant_id,
|
|
21163
|
+
logo: data.merchant_logo,
|
|
21164
|
+
name: data.merchant_name,
|
|
21165
|
+
key: data.merchant_key
|
|
21166
|
+
};
|
|
21167
|
+
loadPusher(); // TODO: Analytics
|
|
21168
|
+
// https://paystack.atlassian.net/browse/RAILS-3070
|
|
21169
|
+
|
|
21170
|
+
Object.assign(this, ReserveCardFunds);
|
|
21171
|
+
}
|
|
21172
|
+
|
|
21173
|
+
_createClass(PreauthorizationInstance, [{
|
|
21174
|
+
key: "setMetadata",
|
|
21175
|
+
value: function setMetadata(key, value) {
|
|
21176
|
+
this.metadata[key] = value;
|
|
21177
|
+
}
|
|
21178
|
+
}, {
|
|
21179
|
+
key: "listenForCharge",
|
|
21180
|
+
value: function listenForCharge(options, callback) {
|
|
21181
|
+
return subscribeToChargeEvents(options, this, callback);
|
|
21182
|
+
}
|
|
21183
|
+
}]);
|
|
21184
|
+
|
|
21185
|
+
return PreauthorizationInstance;
|
|
21186
|
+
}();
|
|
21187
|
+
|
|
21188
|
+
var PreauthorisationAPI = {
|
|
21189
|
+
getByAccessCode: function getByAccessCode(accessCode) {
|
|
21190
|
+
var language = getLanguage();
|
|
21191
|
+
|
|
21192
|
+
var headers = _objectSpread2({}, language && {
|
|
21193
|
+
'Accept-Language': language
|
|
21194
|
+
});
|
|
21195
|
+
|
|
21196
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/verify_access_code/").concat(accessCode);
|
|
21197
|
+
return axiosInstance.get(url, {
|
|
21198
|
+
headers: headers
|
|
21199
|
+
}).then(function (response) {
|
|
21200
|
+
return response.data;
|
|
21201
|
+
});
|
|
21202
|
+
},
|
|
21203
|
+
requery: function requery() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
21204
|
+
},
|
|
21205
|
+
reserveFunds: function reserveFunds() {// TODO: https://paystack.atlassian.net/browse/RAILS-2887
|
|
21206
|
+
}
|
|
21207
|
+
};
|
|
21208
|
+
|
|
21209
|
+
var Preauthorization = {
|
|
21210
|
+
initialize: function initialize(data) {
|
|
21211
|
+
return Object.seal(new PreauthorizationInstance(data));
|
|
21212
|
+
},
|
|
21213
|
+
getByAccessCode: function getByAccessCode(accessCode) {
|
|
21214
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
21215
|
+
var response;
|
|
21216
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
21217
|
+
while (1) {
|
|
21218
|
+
switch (_context.prev = _context.next) {
|
|
21219
|
+
case 0:
|
|
21220
|
+
_context.next = 2;
|
|
21221
|
+
return PreauthorisationAPI.getByAccessCode(accessCode);
|
|
21222
|
+
|
|
21223
|
+
case 2:
|
|
21224
|
+
response = _context.sent;
|
|
21225
|
+
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2({}, response.data))));
|
|
21226
|
+
|
|
21227
|
+
case 4:
|
|
21228
|
+
case "end":
|
|
21229
|
+
return _context.stop();
|
|
21230
|
+
}
|
|
21231
|
+
}
|
|
21232
|
+
}, _callee);
|
|
21233
|
+
}))();
|
|
21234
|
+
},
|
|
21235
|
+
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
21236
|
+
|
|
21237
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
21238
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
21239
|
+
while (1) {
|
|
21240
|
+
switch (_context2.prev = _context2.next) {
|
|
21241
|
+
case 0:
|
|
21242
|
+
case "end":
|
|
21243
|
+
return _context2.stop();
|
|
21244
|
+
}
|
|
21245
|
+
}
|
|
21246
|
+
}, _callee2);
|
|
21247
|
+
}))();
|
|
21248
|
+
}
|
|
21249
|
+
};
|
|
21250
|
+
|
|
21251
|
+
export { BankAccount, Card$1 as Card, Preauthorization, Toolkit, Transaction };
|