@paystack/checkout-js 1.19.0-dev.20 → 1.19.0-dev.22
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 +185 -152
- package/es/checkout.js +185 -152
- package/lib/checkout.js +185 -152
- package/package.json +1 -1
package/dist/checkout.js
CHANGED
|
@@ -17237,75 +17237,6 @@ var Paystack = (function (exports) {
|
|
|
17237
17237
|
return jsEncrypt.encrypt(toEncrypt);
|
|
17238
17238
|
}
|
|
17239
17239
|
|
|
17240
|
-
var DESCRIPTORS = descriptors;
|
|
17241
|
-
var uncurryThis$1 = functionUncurryThis;
|
|
17242
|
-
var objectKeys = objectKeys$3;
|
|
17243
|
-
var toIndexedObject = toIndexedObject$8;
|
|
17244
|
-
var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
17245
|
-
|
|
17246
|
-
var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
|
|
17247
|
-
var push = uncurryThis$1([].push);
|
|
17248
|
-
|
|
17249
|
-
// `Object.{ entries, values }` methods implementation
|
|
17250
|
-
var createMethod = function (TO_ENTRIES) {
|
|
17251
|
-
return function (it) {
|
|
17252
|
-
var O = toIndexedObject(it);
|
|
17253
|
-
var keys = objectKeys(O);
|
|
17254
|
-
var length = keys.length;
|
|
17255
|
-
var i = 0;
|
|
17256
|
-
var result = [];
|
|
17257
|
-
var key;
|
|
17258
|
-
while (length > i) {
|
|
17259
|
-
key = keys[i++];
|
|
17260
|
-
if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
|
|
17261
|
-
push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
|
17262
|
-
}
|
|
17263
|
-
}
|
|
17264
|
-
return result;
|
|
17265
|
-
};
|
|
17266
|
-
};
|
|
17267
|
-
|
|
17268
|
-
var objectToArray = {
|
|
17269
|
-
// `Object.entries` method
|
|
17270
|
-
// https://tc39.es/ecma262/#sec-object.entries
|
|
17271
|
-
entries: createMethod(true),
|
|
17272
|
-
// `Object.values` method
|
|
17273
|
-
// https://tc39.es/ecma262/#sec-object.values
|
|
17274
|
-
values: createMethod(false)
|
|
17275
|
-
};
|
|
17276
|
-
|
|
17277
|
-
var $$2 = _export;
|
|
17278
|
-
var $values = objectToArray.values;
|
|
17279
|
-
|
|
17280
|
-
// `Object.values` method
|
|
17281
|
-
// https://tc39.es/ecma262/#sec-object.values
|
|
17282
|
-
$$2({ target: 'Object', stat: true }, {
|
|
17283
|
-
values: function values(O) {
|
|
17284
|
-
return $values(O);
|
|
17285
|
-
}
|
|
17286
|
-
});
|
|
17287
|
-
|
|
17288
|
-
var $$1 = _export;
|
|
17289
|
-
var $find = arrayIteration.find;
|
|
17290
|
-
var addToUnscopables = addToUnscopables$3;
|
|
17291
|
-
|
|
17292
|
-
var FIND = 'find';
|
|
17293
|
-
var SKIPS_HOLES = true;
|
|
17294
|
-
|
|
17295
|
-
// Shouldn't skip holes
|
|
17296
|
-
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
|
|
17297
|
-
|
|
17298
|
-
// `Array.prototype.find` method
|
|
17299
|
-
// https://tc39.es/ecma262/#sec-array.prototype.find
|
|
17300
|
-
$$1({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
|
|
17301
|
-
find: function find(callbackfn /* , that = undefined */) {
|
|
17302
|
-
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
17303
|
-
}
|
|
17304
|
-
});
|
|
17305
|
-
|
|
17306
|
-
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
17307
|
-
addToUnscopables(FIND);
|
|
17308
|
-
|
|
17309
17240
|
/*
|
|
17310
17241
|
* Luhn algorithm implementation in JavaScript
|
|
17311
17242
|
* Copyright (c) 2009 Nicholas C. Zakas
|
|
@@ -18245,6 +18176,75 @@ var Paystack = (function (exports) {
|
|
|
18245
18176
|
creditCardType: creditCardType_1
|
|
18246
18177
|
};
|
|
18247
18178
|
|
|
18179
|
+
var DESCRIPTORS = descriptors;
|
|
18180
|
+
var uncurryThis$1 = functionUncurryThis;
|
|
18181
|
+
var objectKeys = objectKeys$3;
|
|
18182
|
+
var toIndexedObject = toIndexedObject$8;
|
|
18183
|
+
var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
18184
|
+
|
|
18185
|
+
var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
|
|
18186
|
+
var push = uncurryThis$1([].push);
|
|
18187
|
+
|
|
18188
|
+
// `Object.{ entries, values }` methods implementation
|
|
18189
|
+
var createMethod = function (TO_ENTRIES) {
|
|
18190
|
+
return function (it) {
|
|
18191
|
+
var O = toIndexedObject(it);
|
|
18192
|
+
var keys = objectKeys(O);
|
|
18193
|
+
var length = keys.length;
|
|
18194
|
+
var i = 0;
|
|
18195
|
+
var result = [];
|
|
18196
|
+
var key;
|
|
18197
|
+
while (length > i) {
|
|
18198
|
+
key = keys[i++];
|
|
18199
|
+
if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
|
|
18200
|
+
push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
|
18201
|
+
}
|
|
18202
|
+
}
|
|
18203
|
+
return result;
|
|
18204
|
+
};
|
|
18205
|
+
};
|
|
18206
|
+
|
|
18207
|
+
var objectToArray = {
|
|
18208
|
+
// `Object.entries` method
|
|
18209
|
+
// https://tc39.es/ecma262/#sec-object.entries
|
|
18210
|
+
entries: createMethod(true),
|
|
18211
|
+
// `Object.values` method
|
|
18212
|
+
// https://tc39.es/ecma262/#sec-object.values
|
|
18213
|
+
values: createMethod(false)
|
|
18214
|
+
};
|
|
18215
|
+
|
|
18216
|
+
var $$2 = _export;
|
|
18217
|
+
var $values = objectToArray.values;
|
|
18218
|
+
|
|
18219
|
+
// `Object.values` method
|
|
18220
|
+
// https://tc39.es/ecma262/#sec-object.values
|
|
18221
|
+
$$2({ target: 'Object', stat: true }, {
|
|
18222
|
+
values: function values(O) {
|
|
18223
|
+
return $values(O);
|
|
18224
|
+
}
|
|
18225
|
+
});
|
|
18226
|
+
|
|
18227
|
+
var $$1 = _export;
|
|
18228
|
+
var $find = arrayIteration.find;
|
|
18229
|
+
var addToUnscopables = addToUnscopables$3;
|
|
18230
|
+
|
|
18231
|
+
var FIND = 'find';
|
|
18232
|
+
var SKIPS_HOLES = true;
|
|
18233
|
+
|
|
18234
|
+
// Shouldn't skip holes
|
|
18235
|
+
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
|
|
18236
|
+
|
|
18237
|
+
// `Array.prototype.find` method
|
|
18238
|
+
// https://tc39.es/ecma262/#sec-array.prototype.find
|
|
18239
|
+
$$1({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
|
|
18240
|
+
find: function find(callbackfn /* , that = undefined */) {
|
|
18241
|
+
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
18242
|
+
}
|
|
18243
|
+
});
|
|
18244
|
+
|
|
18245
|
+
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
18246
|
+
addToUnscopables(FIND);
|
|
18247
|
+
|
|
18248
18248
|
var testCards = [{
|
|
18249
18249
|
type: 'bank_auth',
|
|
18250
18250
|
name: 'Bank authorization',
|
|
@@ -18296,6 +18296,96 @@ var Paystack = (function (exports) {
|
|
|
18296
18296
|
year: '30'
|
|
18297
18297
|
}];
|
|
18298
18298
|
|
|
18299
|
+
var Card$1 = {
|
|
18300
|
+
getEncryptedPin: function getEncryptedPin(pin) {
|
|
18301
|
+
return pin ? encrypt(pin) : undefined;
|
|
18302
|
+
},
|
|
18303
|
+
getLast4: function getLast4(number) {
|
|
18304
|
+
return number.substring(number.length - 4);
|
|
18305
|
+
},
|
|
18306
|
+
tokenize: function tokenize(_ref) {
|
|
18307
|
+
var number = _ref.number,
|
|
18308
|
+
cvv = _ref.cvv,
|
|
18309
|
+
month = _ref.month,
|
|
18310
|
+
year = _ref.year;
|
|
18311
|
+
return encrypt("".concat(number, "*").concat(cvv, "*").concat(month, "*").concat(year));
|
|
18312
|
+
},
|
|
18313
|
+
getType: function getType(value) {
|
|
18314
|
+
var response = cardValidator.number(value);
|
|
18315
|
+
|
|
18316
|
+
if (response && response.card) {
|
|
18317
|
+
return {
|
|
18318
|
+
type: response.card.type,
|
|
18319
|
+
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18320
|
+
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18321
|
+
};
|
|
18322
|
+
}
|
|
18323
|
+
|
|
18324
|
+
return {
|
|
18325
|
+
type: null,
|
|
18326
|
+
maxLength: 0
|
|
18327
|
+
};
|
|
18328
|
+
},
|
|
18329
|
+
validate: function validate(_ref2) {
|
|
18330
|
+
var number = _ref2.number,
|
|
18331
|
+
cvv = _ref2.cvv,
|
|
18332
|
+
month = _ref2.month,
|
|
18333
|
+
year = _ref2.year;
|
|
18334
|
+
|
|
18335
|
+
var _this$getType = this.getType(number),
|
|
18336
|
+
cardType = _this$getType.type;
|
|
18337
|
+
|
|
18338
|
+
var result = {
|
|
18339
|
+
number: this.isNumberValid(number),
|
|
18340
|
+
expiry: this.isExpiryValid({
|
|
18341
|
+
month: month,
|
|
18342
|
+
year: year
|
|
18343
|
+
}),
|
|
18344
|
+
cvv: this.isCvvValid(cvv, cardType)
|
|
18345
|
+
};
|
|
18346
|
+
var isValid = Object.values(result).every(function (value) {
|
|
18347
|
+
return value === true;
|
|
18348
|
+
});
|
|
18349
|
+
return {
|
|
18350
|
+
isValid: isValid,
|
|
18351
|
+
result: result
|
|
18352
|
+
};
|
|
18353
|
+
},
|
|
18354
|
+
validateNumber: function validateNumber(value) {
|
|
18355
|
+
return cardValidator.number(value);
|
|
18356
|
+
},
|
|
18357
|
+
isNumberValid: function isNumberValid(value) {
|
|
18358
|
+
return Card$1.validateNumber(value).isValid;
|
|
18359
|
+
},
|
|
18360
|
+
validateCVV: function validateCVV(cvv, cardType) {
|
|
18361
|
+
var isAmexCard = cardType === 'american-express';
|
|
18362
|
+
var cvvLength = isAmexCard ? 4 : 3;
|
|
18363
|
+
return cardValidator.cvv(cvv, cvvLength);
|
|
18364
|
+
},
|
|
18365
|
+
isCvvValid: function isCvvValid(cvv, cardType) {
|
|
18366
|
+
return Card$1.validateCVV(cvv, cardType).isValid;
|
|
18367
|
+
},
|
|
18368
|
+
validateExpiry: function validateExpiry(value) {
|
|
18369
|
+
if (_typeof$1(value) === 'object') {
|
|
18370
|
+
var month = value.month,
|
|
18371
|
+
year = value.year;
|
|
18372
|
+
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18373
|
+
}
|
|
18374
|
+
|
|
18375
|
+
return cardValidator.expirationDate(value);
|
|
18376
|
+
},
|
|
18377
|
+
isExpiryValid: function isExpiryValid(value) {
|
|
18378
|
+
return Card$1.validateExpiry(value).isValid;
|
|
18379
|
+
},
|
|
18380
|
+
generateTestCard: function generateTestCard(cardType) {
|
|
18381
|
+
var type = cardType || 'default';
|
|
18382
|
+
var cardParams = testCards.find(function (card) {
|
|
18383
|
+
return card.type === type;
|
|
18384
|
+
});
|
|
18385
|
+
return new Card$1(cardParams);
|
|
18386
|
+
}
|
|
18387
|
+
};
|
|
18388
|
+
|
|
18299
18389
|
cardValidator.creditCardType.addCard({
|
|
18300
18390
|
niceType: 'Verve',
|
|
18301
18391
|
type: 'verve',
|
|
@@ -18329,35 +18419,27 @@ var Paystack = (function (exports) {
|
|
|
18329
18419
|
_createClass(Card, [{
|
|
18330
18420
|
key: "getEncryptedPin",
|
|
18331
18421
|
value: function getEncryptedPin() {
|
|
18332
|
-
return
|
|
18422
|
+
return Card$1.getEncryptedPin(this.pin);
|
|
18333
18423
|
}
|
|
18334
18424
|
}, {
|
|
18335
18425
|
key: "getLast4",
|
|
18336
18426
|
value: function getLast4() {
|
|
18337
|
-
return
|
|
18427
|
+
return Card$1.getLast4(this.number);
|
|
18338
18428
|
}
|
|
18339
18429
|
}, {
|
|
18340
18430
|
key: "tokenize",
|
|
18341
18431
|
value: function tokenize() {
|
|
18342
|
-
return
|
|
18432
|
+
return Card$1.tokenize({
|
|
18433
|
+
number: this.number,
|
|
18434
|
+
cvv: this.cvv,
|
|
18435
|
+
month: this.month,
|
|
18436
|
+
year: this.year
|
|
18437
|
+
});
|
|
18343
18438
|
}
|
|
18344
18439
|
}], [{
|
|
18345
18440
|
key: "getType",
|
|
18346
18441
|
value: function getType(value) {
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
if (response && response.card) {
|
|
18350
|
-
return {
|
|
18351
|
-
type: response.card.type,
|
|
18352
|
-
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18353
|
-
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18354
|
-
};
|
|
18355
|
-
}
|
|
18356
|
-
|
|
18357
|
-
return {
|
|
18358
|
-
type: null,
|
|
18359
|
-
maxLength: 0
|
|
18360
|
-
};
|
|
18442
|
+
return Card$1.getType(value);
|
|
18361
18443
|
}
|
|
18362
18444
|
}, {
|
|
18363
18445
|
key: "validate",
|
|
@@ -18366,72 +18448,47 @@ var Paystack = (function (exports) {
|
|
|
18366
18448
|
cvv = _ref2.cvv,
|
|
18367
18449
|
month = _ref2.month,
|
|
18368
18450
|
year = _ref2.year;
|
|
18369
|
-
|
|
18370
|
-
|
|
18371
|
-
|
|
18372
|
-
|
|
18373
|
-
|
|
18374
|
-
number: Card.isNumberValid(number),
|
|
18375
|
-
expiry: Card.isExpiryValid({
|
|
18376
|
-
month: month,
|
|
18377
|
-
year: year
|
|
18378
|
-
}),
|
|
18379
|
-
cvv: Card.isCvvValid(cvv, cardType)
|
|
18380
|
-
};
|
|
18381
|
-
var isValid = Object.values(result).every(function (value) {
|
|
18382
|
-
return value === true;
|
|
18451
|
+
return Card$1.validate({
|
|
18452
|
+
number: number,
|
|
18453
|
+
cvv: cvv,
|
|
18454
|
+
month: month,
|
|
18455
|
+
year: year
|
|
18383
18456
|
});
|
|
18384
|
-
return {
|
|
18385
|
-
isValid: isValid,
|
|
18386
|
-
result: result
|
|
18387
|
-
};
|
|
18388
18457
|
}
|
|
18389
18458
|
}, {
|
|
18390
18459
|
key: "validateNumber",
|
|
18391
18460
|
value: function validateNumber(value) {
|
|
18392
|
-
return
|
|
18461
|
+
return Card$1.validateNumber(value);
|
|
18393
18462
|
}
|
|
18394
18463
|
}, {
|
|
18395
18464
|
key: "isNumberValid",
|
|
18396
18465
|
value: function isNumberValid(value) {
|
|
18397
|
-
return Card.
|
|
18466
|
+
return Card$1.isNumberValid(value);
|
|
18398
18467
|
}
|
|
18399
18468
|
}, {
|
|
18400
18469
|
key: "validateCVV",
|
|
18401
18470
|
value: function validateCVV(cvv, cardType) {
|
|
18402
|
-
|
|
18403
|
-
var cvvLength = isAmexCard ? 4 : 3;
|
|
18404
|
-
return cardValidator.cvv(cvv, cvvLength);
|
|
18471
|
+
return Card$1.validateCVV(cvv, cardType);
|
|
18405
18472
|
}
|
|
18406
18473
|
}, {
|
|
18407
18474
|
key: "isCvvValid",
|
|
18408
18475
|
value: function isCvvValid(cvv, cardType) {
|
|
18409
|
-
return Card.
|
|
18476
|
+
return Card$1.isCvvValid(cvv, cardType);
|
|
18410
18477
|
}
|
|
18411
18478
|
}, {
|
|
18412
18479
|
key: "validateExpiry",
|
|
18413
18480
|
value: function validateExpiry(value) {
|
|
18414
|
-
|
|
18415
|
-
var month = value.month,
|
|
18416
|
-
year = value.year;
|
|
18417
|
-
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18418
|
-
}
|
|
18419
|
-
|
|
18420
|
-
return cardValidator.expirationDate(value);
|
|
18481
|
+
return Card$1.validateExpiry(value);
|
|
18421
18482
|
}
|
|
18422
18483
|
}, {
|
|
18423
18484
|
key: "isExpiryValid",
|
|
18424
18485
|
value: function isExpiryValid(value) {
|
|
18425
|
-
return Card.
|
|
18486
|
+
return Card$1.isExpiryValid(value);
|
|
18426
18487
|
}
|
|
18427
18488
|
}, {
|
|
18428
18489
|
key: "generateTestCard",
|
|
18429
18490
|
value: function generateTestCard(cardType) {
|
|
18430
|
-
|
|
18431
|
-
var cardParams = testCards.find(function (card) {
|
|
18432
|
-
return card.type === type;
|
|
18433
|
-
});
|
|
18434
|
-
return new Card(cardParams);
|
|
18491
|
+
return Card$1.generateTestCard(cardType);
|
|
18435
18492
|
}
|
|
18436
18493
|
}]);
|
|
18437
18494
|
|
|
@@ -20705,7 +20762,6 @@ var Paystack = (function (exports) {
|
|
|
20705
20762
|
this.metadata = data.metadata || {};
|
|
20706
20763
|
this.customer = data.customer;
|
|
20707
20764
|
this.channels = data.channels || ['card'];
|
|
20708
|
-
this.deviceFingerprint = data.deviceFingerprint || null;
|
|
20709
20765
|
this.isListening = false;
|
|
20710
20766
|
this.merchant = {
|
|
20711
20767
|
id: data.merchant_id,
|
|
@@ -20713,13 +20769,7 @@ var Paystack = (function (exports) {
|
|
|
20713
20769
|
name: data.merchant_name,
|
|
20714
20770
|
key: data.merchant_key
|
|
20715
20771
|
};
|
|
20716
|
-
loadPusher();
|
|
20717
|
-
/**
|
|
20718
|
-
* We initialize parameters we send to the API as empty strings
|
|
20719
|
-
* when we don't have them instead of null because the API expects
|
|
20720
|
-
* these parameters as URL params which means parameters are eventually converted to strings
|
|
20721
|
-
*/
|
|
20722
|
-
// TODO: Bind charge function to card channel
|
|
20772
|
+
loadPusher(); // TODO: Bind charge function to card channel
|
|
20723
20773
|
// https://paystack.atlassian.net/browse/RAILS-2887
|
|
20724
20774
|
}
|
|
20725
20775
|
|
|
@@ -20728,16 +20778,6 @@ var Paystack = (function (exports) {
|
|
|
20728
20778
|
value: function setMetadata(key, value) {
|
|
20729
20779
|
this.metadata[key] = value;
|
|
20730
20780
|
}
|
|
20731
|
-
}, {
|
|
20732
|
-
key: "setDevice",
|
|
20733
|
-
value: function setDevice(uuid) {
|
|
20734
|
-
if (this.deviceFingerprint) {
|
|
20735
|
-
logMessage("Device ID has already been set by Checkout JS so there's no need to set this again");
|
|
20736
|
-
} else {
|
|
20737
|
-
this.deviceFingerprint = uuid;
|
|
20738
|
-
}
|
|
20739
|
-
} // eslint-disable-next-line consistent-return
|
|
20740
|
-
|
|
20741
20781
|
}, {
|
|
20742
20782
|
key: "listenForCharge",
|
|
20743
20783
|
value: function listenForCharge(options, callback) {
|
|
@@ -20775,26 +20815,19 @@ var Paystack = (function (exports) {
|
|
|
20775
20815
|
},
|
|
20776
20816
|
getByAccessCode: function getByAccessCode(accessCode) {
|
|
20777
20817
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
20778
|
-
var
|
|
20818
|
+
var response;
|
|
20779
20819
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20780
20820
|
while (1) {
|
|
20781
20821
|
switch (_context.prev = _context.next) {
|
|
20782
20822
|
case 0:
|
|
20783
20823
|
_context.next = 2;
|
|
20784
|
-
return getDeviceFingerprint();
|
|
20785
|
-
|
|
20786
|
-
case 2:
|
|
20787
|
-
deviceFingerprint = _context.sent;
|
|
20788
|
-
_context.next = 5;
|
|
20789
20824
|
return PreauthorisationAPI.getByAccessCode(accessCode);
|
|
20790
20825
|
|
|
20791
|
-
case
|
|
20826
|
+
case 2:
|
|
20792
20827
|
response = _context.sent;
|
|
20793
|
-
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2(
|
|
20794
|
-
deviceFingerprint: deviceFingerprint
|
|
20795
|
-
}))));
|
|
20828
|
+
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2({}, response.data))));
|
|
20796
20829
|
|
|
20797
|
-
case
|
|
20830
|
+
case 4:
|
|
20798
20831
|
case "end":
|
|
20799
20832
|
return _context.stop();
|
|
20800
20833
|
}
|
package/es/checkout.js
CHANGED
|
@@ -17234,75 +17234,6 @@ function encrypt(toEncrypt) {
|
|
|
17234
17234
|
return jsEncrypt.encrypt(toEncrypt);
|
|
17235
17235
|
}
|
|
17236
17236
|
|
|
17237
|
-
var DESCRIPTORS = descriptors;
|
|
17238
|
-
var uncurryThis$1 = functionUncurryThis;
|
|
17239
|
-
var objectKeys = objectKeys$3;
|
|
17240
|
-
var toIndexedObject = toIndexedObject$8;
|
|
17241
|
-
var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
17242
|
-
|
|
17243
|
-
var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
|
|
17244
|
-
var push = uncurryThis$1([].push);
|
|
17245
|
-
|
|
17246
|
-
// `Object.{ entries, values }` methods implementation
|
|
17247
|
-
var createMethod = function (TO_ENTRIES) {
|
|
17248
|
-
return function (it) {
|
|
17249
|
-
var O = toIndexedObject(it);
|
|
17250
|
-
var keys = objectKeys(O);
|
|
17251
|
-
var length = keys.length;
|
|
17252
|
-
var i = 0;
|
|
17253
|
-
var result = [];
|
|
17254
|
-
var key;
|
|
17255
|
-
while (length > i) {
|
|
17256
|
-
key = keys[i++];
|
|
17257
|
-
if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
|
|
17258
|
-
push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
|
17259
|
-
}
|
|
17260
|
-
}
|
|
17261
|
-
return result;
|
|
17262
|
-
};
|
|
17263
|
-
};
|
|
17264
|
-
|
|
17265
|
-
var objectToArray = {
|
|
17266
|
-
// `Object.entries` method
|
|
17267
|
-
// https://tc39.es/ecma262/#sec-object.entries
|
|
17268
|
-
entries: createMethod(true),
|
|
17269
|
-
// `Object.values` method
|
|
17270
|
-
// https://tc39.es/ecma262/#sec-object.values
|
|
17271
|
-
values: createMethod(false)
|
|
17272
|
-
};
|
|
17273
|
-
|
|
17274
|
-
var $$2 = _export;
|
|
17275
|
-
var $values = objectToArray.values;
|
|
17276
|
-
|
|
17277
|
-
// `Object.values` method
|
|
17278
|
-
// https://tc39.es/ecma262/#sec-object.values
|
|
17279
|
-
$$2({ target: 'Object', stat: true }, {
|
|
17280
|
-
values: function values(O) {
|
|
17281
|
-
return $values(O);
|
|
17282
|
-
}
|
|
17283
|
-
});
|
|
17284
|
-
|
|
17285
|
-
var $$1 = _export;
|
|
17286
|
-
var $find = arrayIteration.find;
|
|
17287
|
-
var addToUnscopables = addToUnscopables$3;
|
|
17288
|
-
|
|
17289
|
-
var FIND = 'find';
|
|
17290
|
-
var SKIPS_HOLES = true;
|
|
17291
|
-
|
|
17292
|
-
// Shouldn't skip holes
|
|
17293
|
-
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
|
|
17294
|
-
|
|
17295
|
-
// `Array.prototype.find` method
|
|
17296
|
-
// https://tc39.es/ecma262/#sec-array.prototype.find
|
|
17297
|
-
$$1({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
|
|
17298
|
-
find: function find(callbackfn /* , that = undefined */) {
|
|
17299
|
-
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
17300
|
-
}
|
|
17301
|
-
});
|
|
17302
|
-
|
|
17303
|
-
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
17304
|
-
addToUnscopables(FIND);
|
|
17305
|
-
|
|
17306
17237
|
/*
|
|
17307
17238
|
* Luhn algorithm implementation in JavaScript
|
|
17308
17239
|
* Copyright (c) 2009 Nicholas C. Zakas
|
|
@@ -18242,6 +18173,75 @@ var cardValidator = {
|
|
|
18242
18173
|
creditCardType: creditCardType_1
|
|
18243
18174
|
};
|
|
18244
18175
|
|
|
18176
|
+
var DESCRIPTORS = descriptors;
|
|
18177
|
+
var uncurryThis$1 = functionUncurryThis;
|
|
18178
|
+
var objectKeys = objectKeys$3;
|
|
18179
|
+
var toIndexedObject = toIndexedObject$8;
|
|
18180
|
+
var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
18181
|
+
|
|
18182
|
+
var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
|
|
18183
|
+
var push = uncurryThis$1([].push);
|
|
18184
|
+
|
|
18185
|
+
// `Object.{ entries, values }` methods implementation
|
|
18186
|
+
var createMethod = function (TO_ENTRIES) {
|
|
18187
|
+
return function (it) {
|
|
18188
|
+
var O = toIndexedObject(it);
|
|
18189
|
+
var keys = objectKeys(O);
|
|
18190
|
+
var length = keys.length;
|
|
18191
|
+
var i = 0;
|
|
18192
|
+
var result = [];
|
|
18193
|
+
var key;
|
|
18194
|
+
while (length > i) {
|
|
18195
|
+
key = keys[i++];
|
|
18196
|
+
if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
|
|
18197
|
+
push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
|
18198
|
+
}
|
|
18199
|
+
}
|
|
18200
|
+
return result;
|
|
18201
|
+
};
|
|
18202
|
+
};
|
|
18203
|
+
|
|
18204
|
+
var objectToArray = {
|
|
18205
|
+
// `Object.entries` method
|
|
18206
|
+
// https://tc39.es/ecma262/#sec-object.entries
|
|
18207
|
+
entries: createMethod(true),
|
|
18208
|
+
// `Object.values` method
|
|
18209
|
+
// https://tc39.es/ecma262/#sec-object.values
|
|
18210
|
+
values: createMethod(false)
|
|
18211
|
+
};
|
|
18212
|
+
|
|
18213
|
+
var $$2 = _export;
|
|
18214
|
+
var $values = objectToArray.values;
|
|
18215
|
+
|
|
18216
|
+
// `Object.values` method
|
|
18217
|
+
// https://tc39.es/ecma262/#sec-object.values
|
|
18218
|
+
$$2({ target: 'Object', stat: true }, {
|
|
18219
|
+
values: function values(O) {
|
|
18220
|
+
return $values(O);
|
|
18221
|
+
}
|
|
18222
|
+
});
|
|
18223
|
+
|
|
18224
|
+
var $$1 = _export;
|
|
18225
|
+
var $find = arrayIteration.find;
|
|
18226
|
+
var addToUnscopables = addToUnscopables$3;
|
|
18227
|
+
|
|
18228
|
+
var FIND = 'find';
|
|
18229
|
+
var SKIPS_HOLES = true;
|
|
18230
|
+
|
|
18231
|
+
// Shouldn't skip holes
|
|
18232
|
+
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
|
|
18233
|
+
|
|
18234
|
+
// `Array.prototype.find` method
|
|
18235
|
+
// https://tc39.es/ecma262/#sec-array.prototype.find
|
|
18236
|
+
$$1({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
|
|
18237
|
+
find: function find(callbackfn /* , that = undefined */) {
|
|
18238
|
+
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
18239
|
+
}
|
|
18240
|
+
});
|
|
18241
|
+
|
|
18242
|
+
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
18243
|
+
addToUnscopables(FIND);
|
|
18244
|
+
|
|
18245
18245
|
var testCards = [{
|
|
18246
18246
|
type: 'bank_auth',
|
|
18247
18247
|
name: 'Bank authorization',
|
|
@@ -18293,6 +18293,96 @@ var testCards = [{
|
|
|
18293
18293
|
year: '30'
|
|
18294
18294
|
}];
|
|
18295
18295
|
|
|
18296
|
+
var Card$1 = {
|
|
18297
|
+
getEncryptedPin: function getEncryptedPin(pin) {
|
|
18298
|
+
return pin ? encrypt(pin) : undefined;
|
|
18299
|
+
},
|
|
18300
|
+
getLast4: function getLast4(number) {
|
|
18301
|
+
return number.substring(number.length - 4);
|
|
18302
|
+
},
|
|
18303
|
+
tokenize: function tokenize(_ref) {
|
|
18304
|
+
var number = _ref.number,
|
|
18305
|
+
cvv = _ref.cvv,
|
|
18306
|
+
month = _ref.month,
|
|
18307
|
+
year = _ref.year;
|
|
18308
|
+
return encrypt("".concat(number, "*").concat(cvv, "*").concat(month, "*").concat(year));
|
|
18309
|
+
},
|
|
18310
|
+
getType: function getType(value) {
|
|
18311
|
+
var response = cardValidator.number(value);
|
|
18312
|
+
|
|
18313
|
+
if (response && response.card) {
|
|
18314
|
+
return {
|
|
18315
|
+
type: response.card.type,
|
|
18316
|
+
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18317
|
+
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18318
|
+
};
|
|
18319
|
+
}
|
|
18320
|
+
|
|
18321
|
+
return {
|
|
18322
|
+
type: null,
|
|
18323
|
+
maxLength: 0
|
|
18324
|
+
};
|
|
18325
|
+
},
|
|
18326
|
+
validate: function validate(_ref2) {
|
|
18327
|
+
var number = _ref2.number,
|
|
18328
|
+
cvv = _ref2.cvv,
|
|
18329
|
+
month = _ref2.month,
|
|
18330
|
+
year = _ref2.year;
|
|
18331
|
+
|
|
18332
|
+
var _this$getType = this.getType(number),
|
|
18333
|
+
cardType = _this$getType.type;
|
|
18334
|
+
|
|
18335
|
+
var result = {
|
|
18336
|
+
number: this.isNumberValid(number),
|
|
18337
|
+
expiry: this.isExpiryValid({
|
|
18338
|
+
month: month,
|
|
18339
|
+
year: year
|
|
18340
|
+
}),
|
|
18341
|
+
cvv: this.isCvvValid(cvv, cardType)
|
|
18342
|
+
};
|
|
18343
|
+
var isValid = Object.values(result).every(function (value) {
|
|
18344
|
+
return value === true;
|
|
18345
|
+
});
|
|
18346
|
+
return {
|
|
18347
|
+
isValid: isValid,
|
|
18348
|
+
result: result
|
|
18349
|
+
};
|
|
18350
|
+
},
|
|
18351
|
+
validateNumber: function validateNumber(value) {
|
|
18352
|
+
return cardValidator.number(value);
|
|
18353
|
+
},
|
|
18354
|
+
isNumberValid: function isNumberValid(value) {
|
|
18355
|
+
return Card$1.validateNumber(value).isValid;
|
|
18356
|
+
},
|
|
18357
|
+
validateCVV: function validateCVV(cvv, cardType) {
|
|
18358
|
+
var isAmexCard = cardType === 'american-express';
|
|
18359
|
+
var cvvLength = isAmexCard ? 4 : 3;
|
|
18360
|
+
return cardValidator.cvv(cvv, cvvLength);
|
|
18361
|
+
},
|
|
18362
|
+
isCvvValid: function isCvvValid(cvv, cardType) {
|
|
18363
|
+
return Card$1.validateCVV(cvv, cardType).isValid;
|
|
18364
|
+
},
|
|
18365
|
+
validateExpiry: function validateExpiry(value) {
|
|
18366
|
+
if (_typeof$1(value) === 'object') {
|
|
18367
|
+
var month = value.month,
|
|
18368
|
+
year = value.year;
|
|
18369
|
+
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18370
|
+
}
|
|
18371
|
+
|
|
18372
|
+
return cardValidator.expirationDate(value);
|
|
18373
|
+
},
|
|
18374
|
+
isExpiryValid: function isExpiryValid(value) {
|
|
18375
|
+
return Card$1.validateExpiry(value).isValid;
|
|
18376
|
+
},
|
|
18377
|
+
generateTestCard: function generateTestCard(cardType) {
|
|
18378
|
+
var type = cardType || 'default';
|
|
18379
|
+
var cardParams = testCards.find(function (card) {
|
|
18380
|
+
return card.type === type;
|
|
18381
|
+
});
|
|
18382
|
+
return new Card$1(cardParams);
|
|
18383
|
+
}
|
|
18384
|
+
};
|
|
18385
|
+
|
|
18296
18386
|
cardValidator.creditCardType.addCard({
|
|
18297
18387
|
niceType: 'Verve',
|
|
18298
18388
|
type: 'verve',
|
|
@@ -18326,35 +18416,27 @@ var Card = /*#__PURE__*/function () {
|
|
|
18326
18416
|
_createClass(Card, [{
|
|
18327
18417
|
key: "getEncryptedPin",
|
|
18328
18418
|
value: function getEncryptedPin() {
|
|
18329
|
-
return
|
|
18419
|
+
return Card$1.getEncryptedPin(this.pin);
|
|
18330
18420
|
}
|
|
18331
18421
|
}, {
|
|
18332
18422
|
key: "getLast4",
|
|
18333
18423
|
value: function getLast4() {
|
|
18334
|
-
return
|
|
18424
|
+
return Card$1.getLast4(this.number);
|
|
18335
18425
|
}
|
|
18336
18426
|
}, {
|
|
18337
18427
|
key: "tokenize",
|
|
18338
18428
|
value: function tokenize() {
|
|
18339
|
-
return
|
|
18429
|
+
return Card$1.tokenize({
|
|
18430
|
+
number: this.number,
|
|
18431
|
+
cvv: this.cvv,
|
|
18432
|
+
month: this.month,
|
|
18433
|
+
year: this.year
|
|
18434
|
+
});
|
|
18340
18435
|
}
|
|
18341
18436
|
}], [{
|
|
18342
18437
|
key: "getType",
|
|
18343
18438
|
value: function getType(value) {
|
|
18344
|
-
|
|
18345
|
-
|
|
18346
|
-
if (response && response.card) {
|
|
18347
|
-
return {
|
|
18348
|
-
type: response.card.type,
|
|
18349
|
-
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18350
|
-
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18351
|
-
};
|
|
18352
|
-
}
|
|
18353
|
-
|
|
18354
|
-
return {
|
|
18355
|
-
type: null,
|
|
18356
|
-
maxLength: 0
|
|
18357
|
-
};
|
|
18439
|
+
return Card$1.getType(value);
|
|
18358
18440
|
}
|
|
18359
18441
|
}, {
|
|
18360
18442
|
key: "validate",
|
|
@@ -18363,72 +18445,47 @@ var Card = /*#__PURE__*/function () {
|
|
|
18363
18445
|
cvv = _ref2.cvv,
|
|
18364
18446
|
month = _ref2.month,
|
|
18365
18447
|
year = _ref2.year;
|
|
18366
|
-
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
18370
|
-
|
|
18371
|
-
number: Card.isNumberValid(number),
|
|
18372
|
-
expiry: Card.isExpiryValid({
|
|
18373
|
-
month: month,
|
|
18374
|
-
year: year
|
|
18375
|
-
}),
|
|
18376
|
-
cvv: Card.isCvvValid(cvv, cardType)
|
|
18377
|
-
};
|
|
18378
|
-
var isValid = Object.values(result).every(function (value) {
|
|
18379
|
-
return value === true;
|
|
18448
|
+
return Card$1.validate({
|
|
18449
|
+
number: number,
|
|
18450
|
+
cvv: cvv,
|
|
18451
|
+
month: month,
|
|
18452
|
+
year: year
|
|
18380
18453
|
});
|
|
18381
|
-
return {
|
|
18382
|
-
isValid: isValid,
|
|
18383
|
-
result: result
|
|
18384
|
-
};
|
|
18385
18454
|
}
|
|
18386
18455
|
}, {
|
|
18387
18456
|
key: "validateNumber",
|
|
18388
18457
|
value: function validateNumber(value) {
|
|
18389
|
-
return
|
|
18458
|
+
return Card$1.validateNumber(value);
|
|
18390
18459
|
}
|
|
18391
18460
|
}, {
|
|
18392
18461
|
key: "isNumberValid",
|
|
18393
18462
|
value: function isNumberValid(value) {
|
|
18394
|
-
return Card.
|
|
18463
|
+
return Card$1.isNumberValid(value);
|
|
18395
18464
|
}
|
|
18396
18465
|
}, {
|
|
18397
18466
|
key: "validateCVV",
|
|
18398
18467
|
value: function validateCVV(cvv, cardType) {
|
|
18399
|
-
|
|
18400
|
-
var cvvLength = isAmexCard ? 4 : 3;
|
|
18401
|
-
return cardValidator.cvv(cvv, cvvLength);
|
|
18468
|
+
return Card$1.validateCVV(cvv, cardType);
|
|
18402
18469
|
}
|
|
18403
18470
|
}, {
|
|
18404
18471
|
key: "isCvvValid",
|
|
18405
18472
|
value: function isCvvValid(cvv, cardType) {
|
|
18406
|
-
return Card.
|
|
18473
|
+
return Card$1.isCvvValid(cvv, cardType);
|
|
18407
18474
|
}
|
|
18408
18475
|
}, {
|
|
18409
18476
|
key: "validateExpiry",
|
|
18410
18477
|
value: function validateExpiry(value) {
|
|
18411
|
-
|
|
18412
|
-
var month = value.month,
|
|
18413
|
-
year = value.year;
|
|
18414
|
-
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18415
|
-
}
|
|
18416
|
-
|
|
18417
|
-
return cardValidator.expirationDate(value);
|
|
18478
|
+
return Card$1.validateExpiry(value);
|
|
18418
18479
|
}
|
|
18419
18480
|
}, {
|
|
18420
18481
|
key: "isExpiryValid",
|
|
18421
18482
|
value: function isExpiryValid(value) {
|
|
18422
|
-
return Card.
|
|
18483
|
+
return Card$1.isExpiryValid(value);
|
|
18423
18484
|
}
|
|
18424
18485
|
}, {
|
|
18425
18486
|
key: "generateTestCard",
|
|
18426
18487
|
value: function generateTestCard(cardType) {
|
|
18427
|
-
|
|
18428
|
-
var cardParams = testCards.find(function (card) {
|
|
18429
|
-
return card.type === type;
|
|
18430
|
-
});
|
|
18431
|
-
return new Card(cardParams);
|
|
18488
|
+
return Card$1.generateTestCard(cardType);
|
|
18432
18489
|
}
|
|
18433
18490
|
}]);
|
|
18434
18491
|
|
|
@@ -20702,7 +20759,6 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20702
20759
|
this.metadata = data.metadata || {};
|
|
20703
20760
|
this.customer = data.customer;
|
|
20704
20761
|
this.channels = data.channels || ['card'];
|
|
20705
|
-
this.deviceFingerprint = data.deviceFingerprint || null;
|
|
20706
20762
|
this.isListening = false;
|
|
20707
20763
|
this.merchant = {
|
|
20708
20764
|
id: data.merchant_id,
|
|
@@ -20710,13 +20766,7 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20710
20766
|
name: data.merchant_name,
|
|
20711
20767
|
key: data.merchant_key
|
|
20712
20768
|
};
|
|
20713
|
-
loadPusher();
|
|
20714
|
-
/**
|
|
20715
|
-
* We initialize parameters we send to the API as empty strings
|
|
20716
|
-
* when we don't have them instead of null because the API expects
|
|
20717
|
-
* these parameters as URL params which means parameters are eventually converted to strings
|
|
20718
|
-
*/
|
|
20719
|
-
// TODO: Bind charge function to card channel
|
|
20769
|
+
loadPusher(); // TODO: Bind charge function to card channel
|
|
20720
20770
|
// https://paystack.atlassian.net/browse/RAILS-2887
|
|
20721
20771
|
}
|
|
20722
20772
|
|
|
@@ -20725,16 +20775,6 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20725
20775
|
value: function setMetadata(key, value) {
|
|
20726
20776
|
this.metadata[key] = value;
|
|
20727
20777
|
}
|
|
20728
|
-
}, {
|
|
20729
|
-
key: "setDevice",
|
|
20730
|
-
value: function setDevice(uuid) {
|
|
20731
|
-
if (this.deviceFingerprint) {
|
|
20732
|
-
logMessage("Device ID has already been set by Checkout JS so there's no need to set this again");
|
|
20733
|
-
} else {
|
|
20734
|
-
this.deviceFingerprint = uuid;
|
|
20735
|
-
}
|
|
20736
|
-
} // eslint-disable-next-line consistent-return
|
|
20737
|
-
|
|
20738
20778
|
}, {
|
|
20739
20779
|
key: "listenForCharge",
|
|
20740
20780
|
value: function listenForCharge(options, callback) {
|
|
@@ -20772,26 +20812,19 @@ var Preauthorization = {
|
|
|
20772
20812
|
},
|
|
20773
20813
|
getByAccessCode: function getByAccessCode(accessCode) {
|
|
20774
20814
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
20775
|
-
var
|
|
20815
|
+
var response;
|
|
20776
20816
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20777
20817
|
while (1) {
|
|
20778
20818
|
switch (_context.prev = _context.next) {
|
|
20779
20819
|
case 0:
|
|
20780
20820
|
_context.next = 2;
|
|
20781
|
-
return getDeviceFingerprint();
|
|
20782
|
-
|
|
20783
|
-
case 2:
|
|
20784
|
-
deviceFingerprint = _context.sent;
|
|
20785
|
-
_context.next = 5;
|
|
20786
20821
|
return PreauthorisationAPI.getByAccessCode(accessCode);
|
|
20787
20822
|
|
|
20788
|
-
case
|
|
20823
|
+
case 2:
|
|
20789
20824
|
response = _context.sent;
|
|
20790
|
-
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2(
|
|
20791
|
-
deviceFingerprint: deviceFingerprint
|
|
20792
|
-
}))));
|
|
20825
|
+
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2({}, response.data))));
|
|
20793
20826
|
|
|
20794
|
-
case
|
|
20827
|
+
case 4:
|
|
20795
20828
|
case "end":
|
|
20796
20829
|
return _context.stop();
|
|
20797
20830
|
}
|
package/lib/checkout.js
CHANGED
|
@@ -17238,75 +17238,6 @@ function encrypt(toEncrypt) {
|
|
|
17238
17238
|
return jsEncrypt.encrypt(toEncrypt);
|
|
17239
17239
|
}
|
|
17240
17240
|
|
|
17241
|
-
var DESCRIPTORS = descriptors;
|
|
17242
|
-
var uncurryThis$1 = functionUncurryThis;
|
|
17243
|
-
var objectKeys = objectKeys$3;
|
|
17244
|
-
var toIndexedObject = toIndexedObject$8;
|
|
17245
|
-
var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
17246
|
-
|
|
17247
|
-
var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
|
|
17248
|
-
var push = uncurryThis$1([].push);
|
|
17249
|
-
|
|
17250
|
-
// `Object.{ entries, values }` methods implementation
|
|
17251
|
-
var createMethod = function (TO_ENTRIES) {
|
|
17252
|
-
return function (it) {
|
|
17253
|
-
var O = toIndexedObject(it);
|
|
17254
|
-
var keys = objectKeys(O);
|
|
17255
|
-
var length = keys.length;
|
|
17256
|
-
var i = 0;
|
|
17257
|
-
var result = [];
|
|
17258
|
-
var key;
|
|
17259
|
-
while (length > i) {
|
|
17260
|
-
key = keys[i++];
|
|
17261
|
-
if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
|
|
17262
|
-
push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
|
17263
|
-
}
|
|
17264
|
-
}
|
|
17265
|
-
return result;
|
|
17266
|
-
};
|
|
17267
|
-
};
|
|
17268
|
-
|
|
17269
|
-
var objectToArray = {
|
|
17270
|
-
// `Object.entries` method
|
|
17271
|
-
// https://tc39.es/ecma262/#sec-object.entries
|
|
17272
|
-
entries: createMethod(true),
|
|
17273
|
-
// `Object.values` method
|
|
17274
|
-
// https://tc39.es/ecma262/#sec-object.values
|
|
17275
|
-
values: createMethod(false)
|
|
17276
|
-
};
|
|
17277
|
-
|
|
17278
|
-
var $$2 = _export;
|
|
17279
|
-
var $values = objectToArray.values;
|
|
17280
|
-
|
|
17281
|
-
// `Object.values` method
|
|
17282
|
-
// https://tc39.es/ecma262/#sec-object.values
|
|
17283
|
-
$$2({ target: 'Object', stat: true }, {
|
|
17284
|
-
values: function values(O) {
|
|
17285
|
-
return $values(O);
|
|
17286
|
-
}
|
|
17287
|
-
});
|
|
17288
|
-
|
|
17289
|
-
var $$1 = _export;
|
|
17290
|
-
var $find = arrayIteration.find;
|
|
17291
|
-
var addToUnscopables = addToUnscopables$3;
|
|
17292
|
-
|
|
17293
|
-
var FIND = 'find';
|
|
17294
|
-
var SKIPS_HOLES = true;
|
|
17295
|
-
|
|
17296
|
-
// Shouldn't skip holes
|
|
17297
|
-
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
|
|
17298
|
-
|
|
17299
|
-
// `Array.prototype.find` method
|
|
17300
|
-
// https://tc39.es/ecma262/#sec-array.prototype.find
|
|
17301
|
-
$$1({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
|
|
17302
|
-
find: function find(callbackfn /* , that = undefined */) {
|
|
17303
|
-
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
17304
|
-
}
|
|
17305
|
-
});
|
|
17306
|
-
|
|
17307
|
-
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
17308
|
-
addToUnscopables(FIND);
|
|
17309
|
-
|
|
17310
17241
|
/*
|
|
17311
17242
|
* Luhn algorithm implementation in JavaScript
|
|
17312
17243
|
* Copyright (c) 2009 Nicholas C. Zakas
|
|
@@ -18246,6 +18177,75 @@ var cardValidator = {
|
|
|
18246
18177
|
creditCardType: creditCardType_1
|
|
18247
18178
|
};
|
|
18248
18179
|
|
|
18180
|
+
var DESCRIPTORS = descriptors;
|
|
18181
|
+
var uncurryThis$1 = functionUncurryThis;
|
|
18182
|
+
var objectKeys = objectKeys$3;
|
|
18183
|
+
var toIndexedObject = toIndexedObject$8;
|
|
18184
|
+
var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
18185
|
+
|
|
18186
|
+
var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
|
|
18187
|
+
var push = uncurryThis$1([].push);
|
|
18188
|
+
|
|
18189
|
+
// `Object.{ entries, values }` methods implementation
|
|
18190
|
+
var createMethod = function (TO_ENTRIES) {
|
|
18191
|
+
return function (it) {
|
|
18192
|
+
var O = toIndexedObject(it);
|
|
18193
|
+
var keys = objectKeys(O);
|
|
18194
|
+
var length = keys.length;
|
|
18195
|
+
var i = 0;
|
|
18196
|
+
var result = [];
|
|
18197
|
+
var key;
|
|
18198
|
+
while (length > i) {
|
|
18199
|
+
key = keys[i++];
|
|
18200
|
+
if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
|
|
18201
|
+
push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
|
18202
|
+
}
|
|
18203
|
+
}
|
|
18204
|
+
return result;
|
|
18205
|
+
};
|
|
18206
|
+
};
|
|
18207
|
+
|
|
18208
|
+
var objectToArray = {
|
|
18209
|
+
// `Object.entries` method
|
|
18210
|
+
// https://tc39.es/ecma262/#sec-object.entries
|
|
18211
|
+
entries: createMethod(true),
|
|
18212
|
+
// `Object.values` method
|
|
18213
|
+
// https://tc39.es/ecma262/#sec-object.values
|
|
18214
|
+
values: createMethod(false)
|
|
18215
|
+
};
|
|
18216
|
+
|
|
18217
|
+
var $$2 = _export;
|
|
18218
|
+
var $values = objectToArray.values;
|
|
18219
|
+
|
|
18220
|
+
// `Object.values` method
|
|
18221
|
+
// https://tc39.es/ecma262/#sec-object.values
|
|
18222
|
+
$$2({ target: 'Object', stat: true }, {
|
|
18223
|
+
values: function values(O) {
|
|
18224
|
+
return $values(O);
|
|
18225
|
+
}
|
|
18226
|
+
});
|
|
18227
|
+
|
|
18228
|
+
var $$1 = _export;
|
|
18229
|
+
var $find = arrayIteration.find;
|
|
18230
|
+
var addToUnscopables = addToUnscopables$3;
|
|
18231
|
+
|
|
18232
|
+
var FIND = 'find';
|
|
18233
|
+
var SKIPS_HOLES = true;
|
|
18234
|
+
|
|
18235
|
+
// Shouldn't skip holes
|
|
18236
|
+
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
|
|
18237
|
+
|
|
18238
|
+
// `Array.prototype.find` method
|
|
18239
|
+
// https://tc39.es/ecma262/#sec-array.prototype.find
|
|
18240
|
+
$$1({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
|
|
18241
|
+
find: function find(callbackfn /* , that = undefined */) {
|
|
18242
|
+
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
18243
|
+
}
|
|
18244
|
+
});
|
|
18245
|
+
|
|
18246
|
+
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
18247
|
+
addToUnscopables(FIND);
|
|
18248
|
+
|
|
18249
18249
|
var testCards = [{
|
|
18250
18250
|
type: 'bank_auth',
|
|
18251
18251
|
name: 'Bank authorization',
|
|
@@ -18297,6 +18297,96 @@ var testCards = [{
|
|
|
18297
18297
|
year: '30'
|
|
18298
18298
|
}];
|
|
18299
18299
|
|
|
18300
|
+
var Card$1 = {
|
|
18301
|
+
getEncryptedPin: function getEncryptedPin(pin) {
|
|
18302
|
+
return pin ? encrypt(pin) : undefined;
|
|
18303
|
+
},
|
|
18304
|
+
getLast4: function getLast4(number) {
|
|
18305
|
+
return number.substring(number.length - 4);
|
|
18306
|
+
},
|
|
18307
|
+
tokenize: function tokenize(_ref) {
|
|
18308
|
+
var number = _ref.number,
|
|
18309
|
+
cvv = _ref.cvv,
|
|
18310
|
+
month = _ref.month,
|
|
18311
|
+
year = _ref.year;
|
|
18312
|
+
return encrypt("".concat(number, "*").concat(cvv, "*").concat(month, "*").concat(year));
|
|
18313
|
+
},
|
|
18314
|
+
getType: function getType(value) {
|
|
18315
|
+
var response = cardValidator.number(value);
|
|
18316
|
+
|
|
18317
|
+
if (response && response.card) {
|
|
18318
|
+
return {
|
|
18319
|
+
type: response.card.type,
|
|
18320
|
+
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18321
|
+
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18322
|
+
};
|
|
18323
|
+
}
|
|
18324
|
+
|
|
18325
|
+
return {
|
|
18326
|
+
type: null,
|
|
18327
|
+
maxLength: 0
|
|
18328
|
+
};
|
|
18329
|
+
},
|
|
18330
|
+
validate: function validate(_ref2) {
|
|
18331
|
+
var number = _ref2.number,
|
|
18332
|
+
cvv = _ref2.cvv,
|
|
18333
|
+
month = _ref2.month,
|
|
18334
|
+
year = _ref2.year;
|
|
18335
|
+
|
|
18336
|
+
var _this$getType = this.getType(number),
|
|
18337
|
+
cardType = _this$getType.type;
|
|
18338
|
+
|
|
18339
|
+
var result = {
|
|
18340
|
+
number: this.isNumberValid(number),
|
|
18341
|
+
expiry: this.isExpiryValid({
|
|
18342
|
+
month: month,
|
|
18343
|
+
year: year
|
|
18344
|
+
}),
|
|
18345
|
+
cvv: this.isCvvValid(cvv, cardType)
|
|
18346
|
+
};
|
|
18347
|
+
var isValid = Object.values(result).every(function (value) {
|
|
18348
|
+
return value === true;
|
|
18349
|
+
});
|
|
18350
|
+
return {
|
|
18351
|
+
isValid: isValid,
|
|
18352
|
+
result: result
|
|
18353
|
+
};
|
|
18354
|
+
},
|
|
18355
|
+
validateNumber: function validateNumber(value) {
|
|
18356
|
+
return cardValidator.number(value);
|
|
18357
|
+
},
|
|
18358
|
+
isNumberValid: function isNumberValid(value) {
|
|
18359
|
+
return Card$1.validateNumber(value).isValid;
|
|
18360
|
+
},
|
|
18361
|
+
validateCVV: function validateCVV(cvv, cardType) {
|
|
18362
|
+
var isAmexCard = cardType === 'american-express';
|
|
18363
|
+
var cvvLength = isAmexCard ? 4 : 3;
|
|
18364
|
+
return cardValidator.cvv(cvv, cvvLength);
|
|
18365
|
+
},
|
|
18366
|
+
isCvvValid: function isCvvValid(cvv, cardType) {
|
|
18367
|
+
return Card$1.validateCVV(cvv, cardType).isValid;
|
|
18368
|
+
},
|
|
18369
|
+
validateExpiry: function validateExpiry(value) {
|
|
18370
|
+
if (_typeof$1(value) === 'object') {
|
|
18371
|
+
var month = value.month,
|
|
18372
|
+
year = value.year;
|
|
18373
|
+
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18374
|
+
}
|
|
18375
|
+
|
|
18376
|
+
return cardValidator.expirationDate(value);
|
|
18377
|
+
},
|
|
18378
|
+
isExpiryValid: function isExpiryValid(value) {
|
|
18379
|
+
return Card$1.validateExpiry(value).isValid;
|
|
18380
|
+
},
|
|
18381
|
+
generateTestCard: function generateTestCard(cardType) {
|
|
18382
|
+
var type = cardType || 'default';
|
|
18383
|
+
var cardParams = testCards.find(function (card) {
|
|
18384
|
+
return card.type === type;
|
|
18385
|
+
});
|
|
18386
|
+
return new Card$1(cardParams);
|
|
18387
|
+
}
|
|
18388
|
+
};
|
|
18389
|
+
|
|
18300
18390
|
cardValidator.creditCardType.addCard({
|
|
18301
18391
|
niceType: 'Verve',
|
|
18302
18392
|
type: 'verve',
|
|
@@ -18330,35 +18420,27 @@ var Card = /*#__PURE__*/function () {
|
|
|
18330
18420
|
_createClass(Card, [{
|
|
18331
18421
|
key: "getEncryptedPin",
|
|
18332
18422
|
value: function getEncryptedPin() {
|
|
18333
|
-
return
|
|
18423
|
+
return Card$1.getEncryptedPin(this.pin);
|
|
18334
18424
|
}
|
|
18335
18425
|
}, {
|
|
18336
18426
|
key: "getLast4",
|
|
18337
18427
|
value: function getLast4() {
|
|
18338
|
-
return
|
|
18428
|
+
return Card$1.getLast4(this.number);
|
|
18339
18429
|
}
|
|
18340
18430
|
}, {
|
|
18341
18431
|
key: "tokenize",
|
|
18342
18432
|
value: function tokenize() {
|
|
18343
|
-
return
|
|
18433
|
+
return Card$1.tokenize({
|
|
18434
|
+
number: this.number,
|
|
18435
|
+
cvv: this.cvv,
|
|
18436
|
+
month: this.month,
|
|
18437
|
+
year: this.year
|
|
18438
|
+
});
|
|
18344
18439
|
}
|
|
18345
18440
|
}], [{
|
|
18346
18441
|
key: "getType",
|
|
18347
18442
|
value: function getType(value) {
|
|
18348
|
-
|
|
18349
|
-
|
|
18350
|
-
if (response && response.card) {
|
|
18351
|
-
return {
|
|
18352
|
-
type: response.card.type,
|
|
18353
|
-
maxLength: Math.max.apply(Math, _toConsumableArray(response.card.lengths)),
|
|
18354
|
-
minLength: Math.min.apply(Math, _toConsumableArray(response.card.lengths))
|
|
18355
|
-
};
|
|
18356
|
-
}
|
|
18357
|
-
|
|
18358
|
-
return {
|
|
18359
|
-
type: null,
|
|
18360
|
-
maxLength: 0
|
|
18361
|
-
};
|
|
18443
|
+
return Card$1.getType(value);
|
|
18362
18444
|
}
|
|
18363
18445
|
}, {
|
|
18364
18446
|
key: "validate",
|
|
@@ -18367,72 +18449,47 @@ var Card = /*#__PURE__*/function () {
|
|
|
18367
18449
|
cvv = _ref2.cvv,
|
|
18368
18450
|
month = _ref2.month,
|
|
18369
18451
|
year = _ref2.year;
|
|
18370
|
-
|
|
18371
|
-
|
|
18372
|
-
|
|
18373
|
-
|
|
18374
|
-
|
|
18375
|
-
number: Card.isNumberValid(number),
|
|
18376
|
-
expiry: Card.isExpiryValid({
|
|
18377
|
-
month: month,
|
|
18378
|
-
year: year
|
|
18379
|
-
}),
|
|
18380
|
-
cvv: Card.isCvvValid(cvv, cardType)
|
|
18381
|
-
};
|
|
18382
|
-
var isValid = Object.values(result).every(function (value) {
|
|
18383
|
-
return value === true;
|
|
18452
|
+
return Card$1.validate({
|
|
18453
|
+
number: number,
|
|
18454
|
+
cvv: cvv,
|
|
18455
|
+
month: month,
|
|
18456
|
+
year: year
|
|
18384
18457
|
});
|
|
18385
|
-
return {
|
|
18386
|
-
isValid: isValid,
|
|
18387
|
-
result: result
|
|
18388
|
-
};
|
|
18389
18458
|
}
|
|
18390
18459
|
}, {
|
|
18391
18460
|
key: "validateNumber",
|
|
18392
18461
|
value: function validateNumber(value) {
|
|
18393
|
-
return
|
|
18462
|
+
return Card$1.validateNumber(value);
|
|
18394
18463
|
}
|
|
18395
18464
|
}, {
|
|
18396
18465
|
key: "isNumberValid",
|
|
18397
18466
|
value: function isNumberValid(value) {
|
|
18398
|
-
return Card.
|
|
18467
|
+
return Card$1.isNumberValid(value);
|
|
18399
18468
|
}
|
|
18400
18469
|
}, {
|
|
18401
18470
|
key: "validateCVV",
|
|
18402
18471
|
value: function validateCVV(cvv, cardType) {
|
|
18403
|
-
|
|
18404
|
-
var cvvLength = isAmexCard ? 4 : 3;
|
|
18405
|
-
return cardValidator.cvv(cvv, cvvLength);
|
|
18472
|
+
return Card$1.validateCVV(cvv, cardType);
|
|
18406
18473
|
}
|
|
18407
18474
|
}, {
|
|
18408
18475
|
key: "isCvvValid",
|
|
18409
18476
|
value: function isCvvValid(cvv, cardType) {
|
|
18410
|
-
return Card.
|
|
18477
|
+
return Card$1.isCvvValid(cvv, cardType);
|
|
18411
18478
|
}
|
|
18412
18479
|
}, {
|
|
18413
18480
|
key: "validateExpiry",
|
|
18414
18481
|
value: function validateExpiry(value) {
|
|
18415
|
-
|
|
18416
|
-
var month = value.month,
|
|
18417
|
-
year = value.year;
|
|
18418
|
-
return cardValidator.expirationMonth(month) && cardValidator.expirationYear(year);
|
|
18419
|
-
}
|
|
18420
|
-
|
|
18421
|
-
return cardValidator.expirationDate(value);
|
|
18482
|
+
return Card$1.validateExpiry(value);
|
|
18422
18483
|
}
|
|
18423
18484
|
}, {
|
|
18424
18485
|
key: "isExpiryValid",
|
|
18425
18486
|
value: function isExpiryValid(value) {
|
|
18426
|
-
return Card.
|
|
18487
|
+
return Card$1.isExpiryValid(value);
|
|
18427
18488
|
}
|
|
18428
18489
|
}, {
|
|
18429
18490
|
key: "generateTestCard",
|
|
18430
18491
|
value: function generateTestCard(cardType) {
|
|
18431
|
-
|
|
18432
|
-
var cardParams = testCards.find(function (card) {
|
|
18433
|
-
return card.type === type;
|
|
18434
|
-
});
|
|
18435
|
-
return new Card(cardParams);
|
|
18492
|
+
return Card$1.generateTestCard(cardType);
|
|
18436
18493
|
}
|
|
18437
18494
|
}]);
|
|
18438
18495
|
|
|
@@ -20706,7 +20763,6 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20706
20763
|
this.metadata = data.metadata || {};
|
|
20707
20764
|
this.customer = data.customer;
|
|
20708
20765
|
this.channels = data.channels || ['card'];
|
|
20709
|
-
this.deviceFingerprint = data.deviceFingerprint || null;
|
|
20710
20766
|
this.isListening = false;
|
|
20711
20767
|
this.merchant = {
|
|
20712
20768
|
id: data.merchant_id,
|
|
@@ -20714,13 +20770,7 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20714
20770
|
name: data.merchant_name,
|
|
20715
20771
|
key: data.merchant_key
|
|
20716
20772
|
};
|
|
20717
|
-
loadPusher();
|
|
20718
|
-
/**
|
|
20719
|
-
* We initialize parameters we send to the API as empty strings
|
|
20720
|
-
* when we don't have them instead of null because the API expects
|
|
20721
|
-
* these parameters as URL params which means parameters are eventually converted to strings
|
|
20722
|
-
*/
|
|
20723
|
-
// TODO: Bind charge function to card channel
|
|
20773
|
+
loadPusher(); // TODO: Bind charge function to card channel
|
|
20724
20774
|
// https://paystack.atlassian.net/browse/RAILS-2887
|
|
20725
20775
|
}
|
|
20726
20776
|
|
|
@@ -20729,16 +20779,6 @@ var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
|
20729
20779
|
value: function setMetadata(key, value) {
|
|
20730
20780
|
this.metadata[key] = value;
|
|
20731
20781
|
}
|
|
20732
|
-
}, {
|
|
20733
|
-
key: "setDevice",
|
|
20734
|
-
value: function setDevice(uuid) {
|
|
20735
|
-
if (this.deviceFingerprint) {
|
|
20736
|
-
logMessage("Device ID has already been set by Checkout JS so there's no need to set this again");
|
|
20737
|
-
} else {
|
|
20738
|
-
this.deviceFingerprint = uuid;
|
|
20739
|
-
}
|
|
20740
|
-
} // eslint-disable-next-line consistent-return
|
|
20741
|
-
|
|
20742
20782
|
}, {
|
|
20743
20783
|
key: "listenForCharge",
|
|
20744
20784
|
value: function listenForCharge(options, callback) {
|
|
@@ -20776,26 +20816,19 @@ var Preauthorization = {
|
|
|
20776
20816
|
},
|
|
20777
20817
|
getByAccessCode: function getByAccessCode(accessCode) {
|
|
20778
20818
|
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
20779
|
-
var
|
|
20819
|
+
var response;
|
|
20780
20820
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20781
20821
|
while (1) {
|
|
20782
20822
|
switch (_context.prev = _context.next) {
|
|
20783
20823
|
case 0:
|
|
20784
20824
|
_context.next = 2;
|
|
20785
|
-
return getDeviceFingerprint();
|
|
20786
|
-
|
|
20787
|
-
case 2:
|
|
20788
|
-
deviceFingerprint = _context.sent;
|
|
20789
|
-
_context.next = 5;
|
|
20790
20825
|
return PreauthorisationAPI.getByAccessCode(accessCode);
|
|
20791
20826
|
|
|
20792
|
-
case
|
|
20827
|
+
case 2:
|
|
20793
20828
|
response = _context.sent;
|
|
20794
|
-
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2(
|
|
20795
|
-
deviceFingerprint: deviceFingerprint
|
|
20796
|
-
}))));
|
|
20829
|
+
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2({}, response.data))));
|
|
20797
20830
|
|
|
20798
|
-
case
|
|
20831
|
+
case 4:
|
|
20799
20832
|
case "end":
|
|
20800
20833
|
return _context.stop();
|
|
20801
20834
|
}
|