@paystack/checkout-js 1.19.0-dev.15 → 1.19.0-dev.17
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 +20827 -29
- package/es/checkout.js +200 -77
- package/lib/checkout.js +200 -76
- package/package.json +3 -3
package/es/checkout.js
CHANGED
|
@@ -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,83 @@ var ChargeResponses = {
|
|
|
6634
6603
|
}
|
|
6635
6604
|
};
|
|
6636
6605
|
|
|
6606
|
+
/* eslint-env browser */
|
|
6607
|
+
// We use this function to load pusher.
|
|
6608
|
+
|
|
6609
|
+
var loadPusher = function loadPusher() {
|
|
6610
|
+
if (!window) {
|
|
6611
|
+
return Promise.reject(new Error('Window object not available'));
|
|
6612
|
+
}
|
|
6613
|
+
|
|
6614
|
+
return new Promise(function (resolve, reject) {
|
|
6615
|
+
var xhr = new XMLHttpRequest();
|
|
6616
|
+
xhr.open('GET', configToUse.pusherUrl);
|
|
6617
|
+
|
|
6618
|
+
xhr.onload = function () {
|
|
6619
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
6620
|
+
var s = document.createElement('script');
|
|
6621
|
+
s.appendChild(document.createTextNode(xhr.responseText));
|
|
6622
|
+
document.head.appendChild(s);
|
|
6623
|
+
resolve();
|
|
6624
|
+
} else {
|
|
6625
|
+
reject(xhr.statusText);
|
|
6626
|
+
}
|
|
6627
|
+
};
|
|
6628
|
+
|
|
6629
|
+
xhr.onerror = function () {
|
|
6630
|
+
return reject(xhr.statusText);
|
|
6631
|
+
};
|
|
6632
|
+
|
|
6633
|
+
xhr.send(null);
|
|
6634
|
+
});
|
|
6635
|
+
}; // `context` is passed through to set the class property of `isListening` to true/false
|
|
6636
|
+
// and provide the logAPIResponse analytics function
|
|
6637
|
+
// eslint-disable-next-line consistent-return
|
|
6638
|
+
|
|
6639
|
+
var subscribeToChargeEvents = function subscribeToChargeEvents(options, context, callback) {
|
|
6640
|
+
var channel = options.channel,
|
|
6641
|
+
paymentMethod = options.paymentMethod;
|
|
6642
|
+
var pusher;
|
|
6643
|
+
|
|
6644
|
+
if (window && window.Pusher) {
|
|
6645
|
+
pusher = new window.Pusher(configToUse.pusherKey, {
|
|
6646
|
+
cluster: 'eu',
|
|
6647
|
+
disableStats: true
|
|
6648
|
+
});
|
|
6649
|
+
}
|
|
6650
|
+
|
|
6651
|
+
var pusherUndefinedError = {
|
|
6652
|
+
status: 'error',
|
|
6653
|
+
message: 'We could not listen for charge response.'
|
|
6654
|
+
};
|
|
6655
|
+
var pusherSubscriptionError = {
|
|
6656
|
+
status: 'error',
|
|
6657
|
+
message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
|
|
6658
|
+
};
|
|
6659
|
+
|
|
6660
|
+
var unsubscribeFromPusher = function unsubscribeFromPusher() {
|
|
6661
|
+
pusher.unsubscribe(channel);
|
|
6662
|
+
};
|
|
6663
|
+
|
|
6664
|
+
if (!pusher) {
|
|
6665
|
+
return callback(pusherUndefinedError, noOp);
|
|
6666
|
+
}
|
|
6667
|
+
|
|
6668
|
+
var pusherSubscription = pusher.subscribe(channel);
|
|
6669
|
+
pusherSubscription.bind('pusher:subscription_succeeded', function () {
|
|
6670
|
+
context.isListening = true;
|
|
6671
|
+
});
|
|
6672
|
+
pusherSubscription.bind('pusher:subscription_error', function () {
|
|
6673
|
+
context.isListening = false;
|
|
6674
|
+
callback(pusherSubscriptionError, noOp);
|
|
6675
|
+
});
|
|
6676
|
+
pusherSubscription.bind('response', function (response) {
|
|
6677
|
+
var formattedResponse = ChargeResponses.parse(response);
|
|
6678
|
+
context.logAPIResponse(formattedResponse, paymentMethod);
|
|
6679
|
+
callback(formattedResponse, unsubscribeFromPusher);
|
|
6680
|
+
});
|
|
6681
|
+
};
|
|
6682
|
+
|
|
6637
6683
|
var uncurryThis$6 = functionUncurryThis;
|
|
6638
6684
|
var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
|
|
6639
6685
|
var redefine$4 = redefine$a.exports;
|
|
@@ -20347,51 +20393,7 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20347
20393
|
}, {
|
|
20348
20394
|
key: "listenForCharge",
|
|
20349
20395
|
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
|
-
});
|
|
20396
|
+
return subscribeToChargeEvents(options, this, callback);
|
|
20395
20397
|
}
|
|
20396
20398
|
}, {
|
|
20397
20399
|
key: "requery",
|
|
@@ -20689,4 +20691,125 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20689
20691
|
return Toolkit;
|
|
20690
20692
|
}();
|
|
20691
20693
|
|
|
20692
|
-
|
|
20694
|
+
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
20695
|
+
function PreauthorizationInstance(data) {
|
|
20696
|
+
_classCallCheck(this, PreauthorizationInstance);
|
|
20697
|
+
|
|
20698
|
+
this.email = data.email;
|
|
20699
|
+
this.status = data.status;
|
|
20700
|
+
this.reference = data.reference;
|
|
20701
|
+
this.amount = data.amount;
|
|
20702
|
+
this.currency = data.currency;
|
|
20703
|
+
this.metadata = data.metadata || {};
|
|
20704
|
+
this.customer = data.customer;
|
|
20705
|
+
this.channels = data.channels || ['card'];
|
|
20706
|
+
this.deviceFingerprint = data.deviceFingerprint || null;
|
|
20707
|
+
this.isListening = false;
|
|
20708
|
+
loadPusher();
|
|
20709
|
+
/**
|
|
20710
|
+
* We initialize parameters we send to the API as empty strings
|
|
20711
|
+
* when we don't have them instead of null because the API expects
|
|
20712
|
+
* these parameters as URL params which means parameters are eventually converted to strings
|
|
20713
|
+
*/
|
|
20714
|
+
// TODO: Bind charge function to card channel
|
|
20715
|
+
// https://paystack.atlassian.net/browse/RAILS-2887
|
|
20716
|
+
}
|
|
20717
|
+
|
|
20718
|
+
_createClass(PreauthorizationInstance, [{
|
|
20719
|
+
key: "setMetadata",
|
|
20720
|
+
value: function setMetadata(key, value) {
|
|
20721
|
+
this.metadata[key] = value;
|
|
20722
|
+
}
|
|
20723
|
+
}, {
|
|
20724
|
+
key: "setDevice",
|
|
20725
|
+
value: function setDevice(uuid) {
|
|
20726
|
+
if (this.deviceFingerprint) {
|
|
20727
|
+
logMessage("Device ID has already been set by Checkout JS so there's no need to set this again");
|
|
20728
|
+
} else {
|
|
20729
|
+
this.deviceFingerprint = uuid;
|
|
20730
|
+
}
|
|
20731
|
+
} // eslint-disable-next-line consistent-return
|
|
20732
|
+
|
|
20733
|
+
}, {
|
|
20734
|
+
key: "listenForCharge",
|
|
20735
|
+
value: function listenForCharge(options, callback) {
|
|
20736
|
+
return subscribeToChargeEvents(options, this, callback);
|
|
20737
|
+
}
|
|
20738
|
+
}]);
|
|
20739
|
+
|
|
20740
|
+
return PreauthorizationInstance;
|
|
20741
|
+
}();
|
|
20742
|
+
|
|
20743
|
+
var PreauthorisationAPI = {
|
|
20744
|
+
getByAccessCode: function getByAccessCode(accessCode) {
|
|
20745
|
+
var language = getLanguage();
|
|
20746
|
+
|
|
20747
|
+
var headers = _objectSpread2({}, language && {
|
|
20748
|
+
'Accept-Language': language
|
|
20749
|
+
});
|
|
20750
|
+
|
|
20751
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/verify_access_code/").concat(accessCode);
|
|
20752
|
+
return axiosInstance.post(url, {
|
|
20753
|
+
headers: headers
|
|
20754
|
+
}).then(function (response) {
|
|
20755
|
+
return response.data;
|
|
20756
|
+
});
|
|
20757
|
+
},
|
|
20758
|
+
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20759
|
+
},
|
|
20760
|
+
requery: function requery() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20761
|
+
},
|
|
20762
|
+
reserveFunds: function reserveFunds() {// TODO: https://paystack.atlassian.net/browse/RAILS-2887
|
|
20763
|
+
}
|
|
20764
|
+
};
|
|
20765
|
+
|
|
20766
|
+
var Preauthorization = {
|
|
20767
|
+
initialize: function initialize(data) {
|
|
20768
|
+
return Object.seal(new PreauthorizationInstance(data));
|
|
20769
|
+
},
|
|
20770
|
+
getByAccessCode: function getByAccessCode(accessCode) {
|
|
20771
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
20772
|
+
var deviceFingerprint, response;
|
|
20773
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20774
|
+
while (1) {
|
|
20775
|
+
switch (_context.prev = _context.next) {
|
|
20776
|
+
case 0:
|
|
20777
|
+
_context.next = 2;
|
|
20778
|
+
return getDeviceFingerprint();
|
|
20779
|
+
|
|
20780
|
+
case 2:
|
|
20781
|
+
deviceFingerprint = _context.sent;
|
|
20782
|
+
_context.next = 5;
|
|
20783
|
+
return PreauthorisationAPI.getByAccessCode(accessCode);
|
|
20784
|
+
|
|
20785
|
+
case 5:
|
|
20786
|
+
response = _context.sent;
|
|
20787
|
+
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2(_objectSpread2({}, response.data), {
|
|
20788
|
+
deviceFingerprint: deviceFingerprint
|
|
20789
|
+
}))));
|
|
20790
|
+
|
|
20791
|
+
case 7:
|
|
20792
|
+
case "end":
|
|
20793
|
+
return _context.stop();
|
|
20794
|
+
}
|
|
20795
|
+
}
|
|
20796
|
+
}, _callee);
|
|
20797
|
+
}))();
|
|
20798
|
+
},
|
|
20799
|
+
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20800
|
+
|
|
20801
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
20802
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
20803
|
+
while (1) {
|
|
20804
|
+
switch (_context2.prev = _context2.next) {
|
|
20805
|
+
case 0:
|
|
20806
|
+
case "end":
|
|
20807
|
+
return _context2.stop();
|
|
20808
|
+
}
|
|
20809
|
+
}
|
|
20810
|
+
}, _callee2);
|
|
20811
|
+
}))();
|
|
20812
|
+
}
|
|
20813
|
+
};
|
|
20814
|
+
|
|
20815
|
+
export { BankAccount, Card, Preauthorization, Toolkit, Transaction };
|
package/lib/checkout.js
CHANGED
|
@@ -6434,37 +6434,6 @@ var configToEnvironmentMapping = {
|
|
|
6434
6434
|
};
|
|
6435
6435
|
var configToUse = configToEnvironmentMapping[env.paystackEnvironment] || productionConfig;
|
|
6436
6436
|
|
|
6437
|
-
/* eslint-env browser */
|
|
6438
|
-
// We use this function to load pusher.
|
|
6439
|
-
|
|
6440
|
-
function loadPusher() {
|
|
6441
|
-
if (!window) {
|
|
6442
|
-
return Promise.reject(new Error('Window object not available'));
|
|
6443
|
-
}
|
|
6444
|
-
|
|
6445
|
-
return new Promise(function (resolve, reject) {
|
|
6446
|
-
var xhr = new XMLHttpRequest();
|
|
6447
|
-
xhr.open('GET', configToUse.pusherUrl);
|
|
6448
|
-
|
|
6449
|
-
xhr.onload = function () {
|
|
6450
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
6451
|
-
var s = document.createElement('script');
|
|
6452
|
-
s.appendChild(document.createTextNode(xhr.responseText));
|
|
6453
|
-
document.head.appendChild(s);
|
|
6454
|
-
resolve();
|
|
6455
|
-
} else {
|
|
6456
|
-
reject(xhr.statusText);
|
|
6457
|
-
}
|
|
6458
|
-
};
|
|
6459
|
-
|
|
6460
|
-
xhr.onerror = function () {
|
|
6461
|
-
return reject(xhr.statusText);
|
|
6462
|
-
};
|
|
6463
|
-
|
|
6464
|
-
xhr.send(null);
|
|
6465
|
-
});
|
|
6466
|
-
}
|
|
6467
|
-
|
|
6468
6437
|
var noOp = function noOp() {
|
|
6469
6438
|
return undefined;
|
|
6470
6439
|
};
|
|
@@ -6638,6 +6607,83 @@ var ChargeResponses = {
|
|
|
6638
6607
|
}
|
|
6639
6608
|
};
|
|
6640
6609
|
|
|
6610
|
+
/* eslint-env browser */
|
|
6611
|
+
// We use this function to load pusher.
|
|
6612
|
+
|
|
6613
|
+
var loadPusher = function loadPusher() {
|
|
6614
|
+
if (!window) {
|
|
6615
|
+
return Promise.reject(new Error('Window object not available'));
|
|
6616
|
+
}
|
|
6617
|
+
|
|
6618
|
+
return new Promise(function (resolve, reject) {
|
|
6619
|
+
var xhr = new XMLHttpRequest();
|
|
6620
|
+
xhr.open('GET', configToUse.pusherUrl);
|
|
6621
|
+
|
|
6622
|
+
xhr.onload = function () {
|
|
6623
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
6624
|
+
var s = document.createElement('script');
|
|
6625
|
+
s.appendChild(document.createTextNode(xhr.responseText));
|
|
6626
|
+
document.head.appendChild(s);
|
|
6627
|
+
resolve();
|
|
6628
|
+
} else {
|
|
6629
|
+
reject(xhr.statusText);
|
|
6630
|
+
}
|
|
6631
|
+
};
|
|
6632
|
+
|
|
6633
|
+
xhr.onerror = function () {
|
|
6634
|
+
return reject(xhr.statusText);
|
|
6635
|
+
};
|
|
6636
|
+
|
|
6637
|
+
xhr.send(null);
|
|
6638
|
+
});
|
|
6639
|
+
}; // `context` is passed through to set the class property of `isListening` to true/false
|
|
6640
|
+
// and provide the logAPIResponse analytics function
|
|
6641
|
+
// eslint-disable-next-line consistent-return
|
|
6642
|
+
|
|
6643
|
+
var subscribeToChargeEvents = function subscribeToChargeEvents(options, context, callback) {
|
|
6644
|
+
var channel = options.channel,
|
|
6645
|
+
paymentMethod = options.paymentMethod;
|
|
6646
|
+
var pusher;
|
|
6647
|
+
|
|
6648
|
+
if (window && window.Pusher) {
|
|
6649
|
+
pusher = new window.Pusher(configToUse.pusherKey, {
|
|
6650
|
+
cluster: 'eu',
|
|
6651
|
+
disableStats: true
|
|
6652
|
+
});
|
|
6653
|
+
}
|
|
6654
|
+
|
|
6655
|
+
var pusherUndefinedError = {
|
|
6656
|
+
status: 'error',
|
|
6657
|
+
message: 'We could not listen for charge response.'
|
|
6658
|
+
};
|
|
6659
|
+
var pusherSubscriptionError = {
|
|
6660
|
+
status: 'error',
|
|
6661
|
+
message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
|
|
6662
|
+
};
|
|
6663
|
+
|
|
6664
|
+
var unsubscribeFromPusher = function unsubscribeFromPusher() {
|
|
6665
|
+
pusher.unsubscribe(channel);
|
|
6666
|
+
};
|
|
6667
|
+
|
|
6668
|
+
if (!pusher) {
|
|
6669
|
+
return callback(pusherUndefinedError, noOp);
|
|
6670
|
+
}
|
|
6671
|
+
|
|
6672
|
+
var pusherSubscription = pusher.subscribe(channel);
|
|
6673
|
+
pusherSubscription.bind('pusher:subscription_succeeded', function () {
|
|
6674
|
+
context.isListening = true;
|
|
6675
|
+
});
|
|
6676
|
+
pusherSubscription.bind('pusher:subscription_error', function () {
|
|
6677
|
+
context.isListening = false;
|
|
6678
|
+
callback(pusherSubscriptionError, noOp);
|
|
6679
|
+
});
|
|
6680
|
+
pusherSubscription.bind('response', function (response) {
|
|
6681
|
+
var formattedResponse = ChargeResponses.parse(response);
|
|
6682
|
+
context.logAPIResponse(formattedResponse, paymentMethod);
|
|
6683
|
+
callback(formattedResponse, unsubscribeFromPusher);
|
|
6684
|
+
});
|
|
6685
|
+
};
|
|
6686
|
+
|
|
6641
6687
|
var uncurryThis$6 = functionUncurryThis;
|
|
6642
6688
|
var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
|
|
6643
6689
|
var redefine$4 = redefine$a.exports;
|
|
@@ -20351,51 +20397,7 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20351
20397
|
}, {
|
|
20352
20398
|
key: "listenForCharge",
|
|
20353
20399
|
value: function listenForCharge(options, callback) {
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
var channel = options.channel,
|
|
20357
|
-
paymentMethod = options.paymentMethod;
|
|
20358
|
-
var pusher;
|
|
20359
|
-
|
|
20360
|
-
if (window && window.Pusher) {
|
|
20361
|
-
pusher = new window.Pusher(configToUse.pusherKey, {
|
|
20362
|
-
cluster: 'eu',
|
|
20363
|
-
disableStats: true
|
|
20364
|
-
});
|
|
20365
|
-
}
|
|
20366
|
-
|
|
20367
|
-
var pusherUndefinedError = {
|
|
20368
|
-
status: 'error',
|
|
20369
|
-
message: 'We could not listen for charge response.'
|
|
20370
|
-
};
|
|
20371
|
-
var pusherSubscriptionError = {
|
|
20372
|
-
status: 'error',
|
|
20373
|
-
message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
|
|
20374
|
-
};
|
|
20375
|
-
|
|
20376
|
-
var unsubscribeFromPusher = function unsubscribeFromPusher() {
|
|
20377
|
-
pusher.unsubscribe(channel);
|
|
20378
|
-
};
|
|
20379
|
-
|
|
20380
|
-
if (!pusher) {
|
|
20381
|
-
return callback(pusherUndefinedError, noOp);
|
|
20382
|
-
}
|
|
20383
|
-
|
|
20384
|
-
var pusherSubscription = pusher.subscribe(channel);
|
|
20385
|
-
pusherSubscription.bind('pusher:subscription_succeeded', function () {
|
|
20386
|
-
_this2.isListening = true;
|
|
20387
|
-
});
|
|
20388
|
-
pusherSubscription.bind('pusher:subscription_error', function () {
|
|
20389
|
-
_this2.isListening = false;
|
|
20390
|
-
callback(pusherSubscriptionError, noOp);
|
|
20391
|
-
});
|
|
20392
|
-
pusherSubscription.bind('response', function (response) {
|
|
20393
|
-
var formattedResponse = ChargeResponses.parse(response);
|
|
20394
|
-
|
|
20395
|
-
_this2.logAPIResponse(formattedResponse, paymentMethod);
|
|
20396
|
-
|
|
20397
|
-
callback(formattedResponse, unsubscribeFromPusher);
|
|
20398
|
-
});
|
|
20400
|
+
return subscribeToChargeEvents(options, this, callback);
|
|
20399
20401
|
}
|
|
20400
20402
|
}, {
|
|
20401
20403
|
key: "requery",
|
|
@@ -20693,7 +20695,129 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20693
20695
|
return Toolkit;
|
|
20694
20696
|
}();
|
|
20695
20697
|
|
|
20698
|
+
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
20699
|
+
function PreauthorizationInstance(data) {
|
|
20700
|
+
_classCallCheck(this, PreauthorizationInstance);
|
|
20701
|
+
|
|
20702
|
+
this.email = data.email;
|
|
20703
|
+
this.status = data.status;
|
|
20704
|
+
this.reference = data.reference;
|
|
20705
|
+
this.amount = data.amount;
|
|
20706
|
+
this.currency = data.currency;
|
|
20707
|
+
this.metadata = data.metadata || {};
|
|
20708
|
+
this.customer = data.customer;
|
|
20709
|
+
this.channels = data.channels || ['card'];
|
|
20710
|
+
this.deviceFingerprint = data.deviceFingerprint || null;
|
|
20711
|
+
this.isListening = false;
|
|
20712
|
+
loadPusher();
|
|
20713
|
+
/**
|
|
20714
|
+
* We initialize parameters we send to the API as empty strings
|
|
20715
|
+
* when we don't have them instead of null because the API expects
|
|
20716
|
+
* these parameters as URL params which means parameters are eventually converted to strings
|
|
20717
|
+
*/
|
|
20718
|
+
// TODO: Bind charge function to card channel
|
|
20719
|
+
// https://paystack.atlassian.net/browse/RAILS-2887
|
|
20720
|
+
}
|
|
20721
|
+
|
|
20722
|
+
_createClass(PreauthorizationInstance, [{
|
|
20723
|
+
key: "setMetadata",
|
|
20724
|
+
value: function setMetadata(key, value) {
|
|
20725
|
+
this.metadata[key] = value;
|
|
20726
|
+
}
|
|
20727
|
+
}, {
|
|
20728
|
+
key: "setDevice",
|
|
20729
|
+
value: function setDevice(uuid) {
|
|
20730
|
+
if (this.deviceFingerprint) {
|
|
20731
|
+
logMessage("Device ID has already been set by Checkout JS so there's no need to set this again");
|
|
20732
|
+
} else {
|
|
20733
|
+
this.deviceFingerprint = uuid;
|
|
20734
|
+
}
|
|
20735
|
+
} // eslint-disable-next-line consistent-return
|
|
20736
|
+
|
|
20737
|
+
}, {
|
|
20738
|
+
key: "listenForCharge",
|
|
20739
|
+
value: function listenForCharge(options, callback) {
|
|
20740
|
+
return subscribeToChargeEvents(options, this, callback);
|
|
20741
|
+
}
|
|
20742
|
+
}]);
|
|
20743
|
+
|
|
20744
|
+
return PreauthorizationInstance;
|
|
20745
|
+
}();
|
|
20746
|
+
|
|
20747
|
+
var PreauthorisationAPI = {
|
|
20748
|
+
getByAccessCode: function getByAccessCode(accessCode) {
|
|
20749
|
+
var language = getLanguage();
|
|
20750
|
+
|
|
20751
|
+
var headers = _objectSpread2({}, language && {
|
|
20752
|
+
'Accept-Language': language
|
|
20753
|
+
});
|
|
20754
|
+
|
|
20755
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/verify_access_code/").concat(accessCode);
|
|
20756
|
+
return axiosInstance.post(url, {
|
|
20757
|
+
headers: headers
|
|
20758
|
+
}).then(function (response) {
|
|
20759
|
+
return response.data;
|
|
20760
|
+
});
|
|
20761
|
+
},
|
|
20762
|
+
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20763
|
+
},
|
|
20764
|
+
requery: function requery() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20765
|
+
},
|
|
20766
|
+
reserveFunds: function reserveFunds() {// TODO: https://paystack.atlassian.net/browse/RAILS-2887
|
|
20767
|
+
}
|
|
20768
|
+
};
|
|
20769
|
+
|
|
20770
|
+
var Preauthorization = {
|
|
20771
|
+
initialize: function initialize(data) {
|
|
20772
|
+
return Object.seal(new PreauthorizationInstance(data));
|
|
20773
|
+
},
|
|
20774
|
+
getByAccessCode: function getByAccessCode(accessCode) {
|
|
20775
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
20776
|
+
var deviceFingerprint, response;
|
|
20777
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20778
|
+
while (1) {
|
|
20779
|
+
switch (_context.prev = _context.next) {
|
|
20780
|
+
case 0:
|
|
20781
|
+
_context.next = 2;
|
|
20782
|
+
return getDeviceFingerprint();
|
|
20783
|
+
|
|
20784
|
+
case 2:
|
|
20785
|
+
deviceFingerprint = _context.sent;
|
|
20786
|
+
_context.next = 5;
|
|
20787
|
+
return PreauthorisationAPI.getByAccessCode(accessCode);
|
|
20788
|
+
|
|
20789
|
+
case 5:
|
|
20790
|
+
response = _context.sent;
|
|
20791
|
+
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2(_objectSpread2({}, response.data), {
|
|
20792
|
+
deviceFingerprint: deviceFingerprint
|
|
20793
|
+
}))));
|
|
20794
|
+
|
|
20795
|
+
case 7:
|
|
20796
|
+
case "end":
|
|
20797
|
+
return _context.stop();
|
|
20798
|
+
}
|
|
20799
|
+
}
|
|
20800
|
+
}, _callee);
|
|
20801
|
+
}))();
|
|
20802
|
+
},
|
|
20803
|
+
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20804
|
+
|
|
20805
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
20806
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
20807
|
+
while (1) {
|
|
20808
|
+
switch (_context2.prev = _context2.next) {
|
|
20809
|
+
case 0:
|
|
20810
|
+
case "end":
|
|
20811
|
+
return _context2.stop();
|
|
20812
|
+
}
|
|
20813
|
+
}
|
|
20814
|
+
}, _callee2);
|
|
20815
|
+
}))();
|
|
20816
|
+
}
|
|
20817
|
+
};
|
|
20818
|
+
|
|
20696
20819
|
exports.BankAccount = BankAccount;
|
|
20697
20820
|
exports.Card = Card;
|
|
20821
|
+
exports.Preauthorization = Preauthorization;
|
|
20698
20822
|
exports.Toolkit = Toolkit;
|
|
20699
20823
|
exports.Transaction = Transaction;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paystack/checkout-js",
|
|
3
|
-
"version": "1.19.0-dev.
|
|
3
|
+
"version": "1.19.0-dev.17",
|
|
4
4
|
"description": "Client-side JS library for billing on Paystack",
|
|
5
5
|
"main": "lib/checkout.js",
|
|
6
6
|
"module": "es/checkout.js",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"build:cjs": "cross-env NODE_ENV=cjs rollup --config rollup.config.js -o lib/checkout.js",
|
|
75
75
|
"build:es": "cross-env NODE_ENV=es rollup --config rollup.config.js -o es/checkout.js",
|
|
76
76
|
"build:dist": "rollup --config rollup.config.js -o dist/checkout.js",
|
|
77
|
-
"build": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=production npm run build:dist",
|
|
77
|
+
"build:prod": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=production npm run build:dist",
|
|
78
78
|
"dev": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=dev npm run build:dist",
|
|
79
|
-
"staging": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=staging npm run build:dist",
|
|
79
|
+
"build:staging": "npm run build:cjs && npm run build:es && cross-env NODE_ENV=staging npm run build:dist",
|
|
80
80
|
"test": "jest",
|
|
81
81
|
"semantic-release": "semantic-release"
|
|
82
82
|
},
|