@paystack/checkout-js 1.19.0-dev.8 → 1.19.0
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 +3 -3
- package/es/checkout.js +181 -312
- package/lib/checkout.js +181 -311
- package/package.json +3 -3
package/lib/checkout.js
CHANGED
|
@@ -6407,16 +6407,14 @@ var devConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
|
6407
6407
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6408
6408
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6409
6409
|
pusherKey: '1c7b262ee18455815893',
|
|
6410
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6411
|
-
savedCardsApiUrl: 'https://saved-cards-api.private.paystack.studio/'
|
|
6410
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6412
6411
|
});
|
|
6413
6412
|
var stagingConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6414
6413
|
checkoutUrl: 'https://checkout-studio.paystack.com/',
|
|
6415
6414
|
paymentBaseUrl: 'https://legacy-staging.paystack.co/',
|
|
6416
6415
|
paystackApiUrl: 'https://studio-api.paystack.co/',
|
|
6417
6416
|
pusherKey: '1c7b262ee18455815893',
|
|
6418
|
-
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6419
|
-
savedCardsApiUrl: 'https://saved-cards-api.private.paystack.studio/'
|
|
6417
|
+
pusherUrl: 'https://s3-eu-west-1.amazonaws.com/pstk-public-files/js/pusher.min.js'
|
|
6420
6418
|
});
|
|
6421
6419
|
var productionConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
6422
6420
|
checkoutUrl: 'https://checkout.paystack.com/',
|
|
@@ -6434,37 +6432,6 @@ var configToEnvironmentMapping = {
|
|
|
6434
6432
|
};
|
|
6435
6433
|
var configToUse = configToEnvironmentMapping[env.paystackEnvironment] || productionConfig;
|
|
6436
6434
|
|
|
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
6435
|
var noOp = function noOp() {
|
|
6469
6436
|
return undefined;
|
|
6470
6437
|
};
|
|
@@ -6638,6 +6605,82 @@ var ChargeResponses = {
|
|
|
6638
6605
|
}
|
|
6639
6606
|
};
|
|
6640
6607
|
|
|
6608
|
+
/* eslint-env browser */
|
|
6609
|
+
|
|
6610
|
+
var loadPusher = function loadPusher() {
|
|
6611
|
+
if (!window) {
|
|
6612
|
+
return Promise.reject(new Error('Window object not available'));
|
|
6613
|
+
}
|
|
6614
|
+
|
|
6615
|
+
return new Promise(function (resolve, reject) {
|
|
6616
|
+
var xhr = new XMLHttpRequest();
|
|
6617
|
+
xhr.open('GET', configToUse.pusherUrl);
|
|
6618
|
+
|
|
6619
|
+
xhr.onload = function () {
|
|
6620
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
6621
|
+
var s = document.createElement('script');
|
|
6622
|
+
s.appendChild(document.createTextNode(xhr.responseText));
|
|
6623
|
+
document.head.appendChild(s);
|
|
6624
|
+
resolve();
|
|
6625
|
+
} else {
|
|
6626
|
+
reject(xhr.statusText);
|
|
6627
|
+
}
|
|
6628
|
+
};
|
|
6629
|
+
|
|
6630
|
+
xhr.onerror = function () {
|
|
6631
|
+
return reject(xhr.statusText);
|
|
6632
|
+
};
|
|
6633
|
+
|
|
6634
|
+
xhr.send(null);
|
|
6635
|
+
});
|
|
6636
|
+
}; // `context` is passed through to set the class property of `isListening` to true/false
|
|
6637
|
+
// and provide the logAPIResponse analytics function
|
|
6638
|
+
// eslint-disable-next-line consistent-return
|
|
6639
|
+
|
|
6640
|
+
var subscribeToChargeEvents = function subscribeToChargeEvents(options, context, callback) {
|
|
6641
|
+
var channel = options.channel,
|
|
6642
|
+
paymentMethod = options.paymentMethod;
|
|
6643
|
+
var pusher;
|
|
6644
|
+
|
|
6645
|
+
if (window && window.Pusher) {
|
|
6646
|
+
pusher = new window.Pusher(configToUse.pusherKey, {
|
|
6647
|
+
cluster: 'eu',
|
|
6648
|
+
disableStats: true
|
|
6649
|
+
});
|
|
6650
|
+
}
|
|
6651
|
+
|
|
6652
|
+
var pusherUndefinedError = {
|
|
6653
|
+
status: 'error',
|
|
6654
|
+
message: 'We could not listen for charge response.'
|
|
6655
|
+
};
|
|
6656
|
+
var pusherSubscriptionError = {
|
|
6657
|
+
status: 'error',
|
|
6658
|
+
message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
|
|
6659
|
+
};
|
|
6660
|
+
|
|
6661
|
+
var unsubscribeFromPusher = function unsubscribeFromPusher() {
|
|
6662
|
+
pusher.unsubscribe(channel);
|
|
6663
|
+
};
|
|
6664
|
+
|
|
6665
|
+
if (!pusher) {
|
|
6666
|
+
return callback(pusherUndefinedError, noOp);
|
|
6667
|
+
}
|
|
6668
|
+
|
|
6669
|
+
var pusherSubscription = pusher.subscribe(channel);
|
|
6670
|
+
pusherSubscription.bind('pusher:subscription_succeeded', function () {
|
|
6671
|
+
context.isListening = true;
|
|
6672
|
+
});
|
|
6673
|
+
pusherSubscription.bind('pusher:subscription_error', function () {
|
|
6674
|
+
context.isListening = false;
|
|
6675
|
+
callback(pusherSubscriptionError, noOp);
|
|
6676
|
+
});
|
|
6677
|
+
pusherSubscription.bind('response', function (response) {
|
|
6678
|
+
var formattedResponse = ChargeResponses.parse(response);
|
|
6679
|
+
context.logAPIResponse(formattedResponse, paymentMethod);
|
|
6680
|
+
callback(formattedResponse, unsubscribeFromPusher);
|
|
6681
|
+
});
|
|
6682
|
+
};
|
|
6683
|
+
|
|
6641
6684
|
var uncurryThis$6 = functionUncurryThis;
|
|
6642
6685
|
var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
|
|
6643
6686
|
var redefine$4 = redefine$a.exports;
|
|
@@ -18570,173 +18613,6 @@ var CardAPI = {
|
|
|
18570
18613
|
}).then(function (response) {
|
|
18571
18614
|
return ChargeResponses.parse(response.data);
|
|
18572
18615
|
});
|
|
18573
|
-
},
|
|
18574
|
-
requestOtpForSavedCards: function requestOtpForSavedCards(phoneNumber) {
|
|
18575
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18576
|
-
var url, language, headers, _yield$axiosInstance$, data;
|
|
18577
|
-
|
|
18578
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18579
|
-
while (1) {
|
|
18580
|
-
switch (_context.prev = _context.next) {
|
|
18581
|
-
case 0:
|
|
18582
|
-
url = new URL("/authorize/".concat(phoneNumber), configToUse.savedCardsApiUrl).toString();
|
|
18583
|
-
language = getLanguage();
|
|
18584
|
-
headers = _objectSpread2({}, language && {
|
|
18585
|
-
'Accept-Language': language
|
|
18586
|
-
});
|
|
18587
|
-
_context.next = 5;
|
|
18588
|
-
return axiosInstance.post(url, {
|
|
18589
|
-
headers: headers
|
|
18590
|
-
});
|
|
18591
|
-
|
|
18592
|
-
case 5:
|
|
18593
|
-
_yield$axiosInstance$ = _context.sent;
|
|
18594
|
-
data = _yield$axiosInstance$.data;
|
|
18595
|
-
return _context.abrupt("return", data);
|
|
18596
|
-
|
|
18597
|
-
case 8:
|
|
18598
|
-
case "end":
|
|
18599
|
-
return _context.stop();
|
|
18600
|
-
}
|
|
18601
|
-
}
|
|
18602
|
-
}, _callee);
|
|
18603
|
-
}))();
|
|
18604
|
-
},
|
|
18605
|
-
verifySavedCardsOtp: function verifySavedCardsOtp(_ref6) {
|
|
18606
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
18607
|
-
var code, phone, transaction, url, language, headers, data, response;
|
|
18608
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
18609
|
-
while (1) {
|
|
18610
|
-
switch (_context2.prev = _context2.next) {
|
|
18611
|
-
case 0:
|
|
18612
|
-
code = _ref6.code, phone = _ref6.phone, transaction = _ref6.transaction;
|
|
18613
|
-
url = new URL('/authorize/verify', configToUse.savedCardsApiUrl).toString();
|
|
18614
|
-
language = getLanguage();
|
|
18615
|
-
headers = _objectSpread2({}, language && {
|
|
18616
|
-
'Accept-Language': language
|
|
18617
|
-
});
|
|
18618
|
-
data = {
|
|
18619
|
-
code: code,
|
|
18620
|
-
phone: phone,
|
|
18621
|
-
transaction: transaction
|
|
18622
|
-
};
|
|
18623
|
-
_context2.next = 7;
|
|
18624
|
-
return axiosInstance.post(url, data, {
|
|
18625
|
-
headers: headers
|
|
18626
|
-
});
|
|
18627
|
-
|
|
18628
|
-
case 7:
|
|
18629
|
-
response = _context2.sent;
|
|
18630
|
-
return _context2.abrupt("return", response.data);
|
|
18631
|
-
|
|
18632
|
-
case 9:
|
|
18633
|
-
case "end":
|
|
18634
|
-
return _context2.stop();
|
|
18635
|
-
}
|
|
18636
|
-
}
|
|
18637
|
-
}, _callee2);
|
|
18638
|
-
}))();
|
|
18639
|
-
},
|
|
18640
|
-
getSavedCards: function getSavedCards(_ref7) {
|
|
18641
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
18642
|
-
var token, url, language, headers, response;
|
|
18643
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
18644
|
-
while (1) {
|
|
18645
|
-
switch (_context3.prev = _context3.next) {
|
|
18646
|
-
case 0:
|
|
18647
|
-
token = _ref7.token;
|
|
18648
|
-
url = new URL('/cards', configToUse.savedCardsApiUrl).toString();
|
|
18649
|
-
language = getLanguage();
|
|
18650
|
-
headers = _objectSpread2({
|
|
18651
|
-
Authorization: "Bearer ".concat(token),
|
|
18652
|
-
'jwt-auth': true
|
|
18653
|
-
}, language && {
|
|
18654
|
-
'Accept-Language': language
|
|
18655
|
-
});
|
|
18656
|
-
_context3.next = 6;
|
|
18657
|
-
return axiosInstance.get(url, {
|
|
18658
|
-
headers: headers
|
|
18659
|
-
});
|
|
18660
|
-
|
|
18661
|
-
case 6:
|
|
18662
|
-
response = _context3.sent;
|
|
18663
|
-
return _context3.abrupt("return", response.data);
|
|
18664
|
-
|
|
18665
|
-
case 8:
|
|
18666
|
-
case "end":
|
|
18667
|
-
return _context3.stop();
|
|
18668
|
-
}
|
|
18669
|
-
}
|
|
18670
|
-
}, _callee3);
|
|
18671
|
-
}))();
|
|
18672
|
-
},
|
|
18673
|
-
deleteSavedCard: function deleteSavedCard(_ref8) {
|
|
18674
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
18675
|
-
var cardCode, token, url, language, headers, response;
|
|
18676
|
-
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
18677
|
-
while (1) {
|
|
18678
|
-
switch (_context4.prev = _context4.next) {
|
|
18679
|
-
case 0:
|
|
18680
|
-
cardCode = _ref8.cardCode, token = _ref8.token;
|
|
18681
|
-
url = new URL("/cards/".concat(cardCode), configToUse.savedCardsApiUrl).toString();
|
|
18682
|
-
language = getLanguage();
|
|
18683
|
-
headers = _objectSpread2({
|
|
18684
|
-
Authorization: "Bearer ".concat(token),
|
|
18685
|
-
'jwt-auth': true
|
|
18686
|
-
}, language && {
|
|
18687
|
-
'Accept-Language': language
|
|
18688
|
-
});
|
|
18689
|
-
_context4.next = 6;
|
|
18690
|
-
return axiosInstance.delete(url, {
|
|
18691
|
-
headers: headers
|
|
18692
|
-
});
|
|
18693
|
-
|
|
18694
|
-
case 6:
|
|
18695
|
-
response = _context4.sent;
|
|
18696
|
-
return _context4.abrupt("return", response.data);
|
|
18697
|
-
|
|
18698
|
-
case 8:
|
|
18699
|
-
case "end":
|
|
18700
|
-
return _context4.stop();
|
|
18701
|
-
}
|
|
18702
|
-
}
|
|
18703
|
-
}, _callee4);
|
|
18704
|
-
}))();
|
|
18705
|
-
},
|
|
18706
|
-
chargeSavedCard: function chargeSavedCard(_ref9) {
|
|
18707
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
18708
|
-
var token, device, cardCode, transaction, selectedCurrency, url, language, headers, data;
|
|
18709
|
-
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
18710
|
-
while (1) {
|
|
18711
|
-
switch (_context5.prev = _context5.next) {
|
|
18712
|
-
case 0:
|
|
18713
|
-
token = _ref9.token, device = _ref9.device, cardCode = _ref9.cardCode, transaction = _ref9.transaction, selectedCurrency = _ref9.selectedCurrency;
|
|
18714
|
-
url = new URL("/cards/".concat(cardCode, "/charge"), configToUse.savedCardsApiUrl).toString();
|
|
18715
|
-
language = getLanguage();
|
|
18716
|
-
headers = _objectSpread2({
|
|
18717
|
-
Authorization: "Bearer ".concat(token),
|
|
18718
|
-
'jwt-auth': true
|
|
18719
|
-
}, language && {
|
|
18720
|
-
'Accept-Language': language
|
|
18721
|
-
});
|
|
18722
|
-
data = {
|
|
18723
|
-
device: device,
|
|
18724
|
-
transaction: transaction,
|
|
18725
|
-
selectedCurrency: selectedCurrency
|
|
18726
|
-
};
|
|
18727
|
-
return _context5.abrupt("return", axiosInstance.post(url, data, {
|
|
18728
|
-
headers: headers
|
|
18729
|
-
}).then(function (response) {
|
|
18730
|
-
return ChargeResponses.parse(response.data);
|
|
18731
|
-
}));
|
|
18732
|
-
|
|
18733
|
-
case 6:
|
|
18734
|
-
case "end":
|
|
18735
|
-
return _context5.stop();
|
|
18736
|
-
}
|
|
18737
|
-
}
|
|
18738
|
-
}, _callee5);
|
|
18739
|
-
}))();
|
|
18740
18616
|
}
|
|
18741
18617
|
};
|
|
18742
18618
|
|
|
@@ -18917,68 +18793,6 @@ var CardCharge = {
|
|
|
18917
18793
|
paymentMethod: paymentMethod$3
|
|
18918
18794
|
};
|
|
18919
18795
|
return this.listenForCharge(listenerOptions, callback);
|
|
18920
|
-
},
|
|
18921
|
-
requestOtpForSavedCards: function requestOtpForSavedCards(phoneNumber) {
|
|
18922
|
-
return CardAPI.requestOtpForSavedCards(phoneNumber);
|
|
18923
|
-
},
|
|
18924
|
-
verifySavedCardsOtp: function verifySavedCardsOtp(_ref4) {
|
|
18925
|
-
var _this9 = this;
|
|
18926
|
-
|
|
18927
|
-
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
18928
|
-
var code, phone, payload, response;
|
|
18929
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18930
|
-
while (1) {
|
|
18931
|
-
switch (_context.prev = _context.next) {
|
|
18932
|
-
case 0:
|
|
18933
|
-
code = _ref4.code, phone = _ref4.phone;
|
|
18934
|
-
payload = {
|
|
18935
|
-
code: code,
|
|
18936
|
-
phone: phone,
|
|
18937
|
-
transaction: _this9.id
|
|
18938
|
-
};
|
|
18939
|
-
_context.prev = 2;
|
|
18940
|
-
_context.next = 5;
|
|
18941
|
-
return CardAPI.verifySavedCardsOtp(payload);
|
|
18942
|
-
|
|
18943
|
-
case 5:
|
|
18944
|
-
response = _context.sent;
|
|
18945
|
-
_this9.savedCardsToken = response.data.token;
|
|
18946
|
-
return _context.abrupt("return", response);
|
|
18947
|
-
|
|
18948
|
-
case 10:
|
|
18949
|
-
_context.prev = 10;
|
|
18950
|
-
_context.t0 = _context["catch"](2);
|
|
18951
|
-
_this9.savedCardsToken = null;
|
|
18952
|
-
return _context.abrupt("return", _context.t0);
|
|
18953
|
-
|
|
18954
|
-
case 14:
|
|
18955
|
-
case "end":
|
|
18956
|
-
return _context.stop();
|
|
18957
|
-
}
|
|
18958
|
-
}
|
|
18959
|
-
}, _callee, null, [[2, 10]]);
|
|
18960
|
-
}))();
|
|
18961
|
-
},
|
|
18962
|
-
getSavedCards: function getSavedCards() {
|
|
18963
|
-
return CardAPI.getSavedCards({
|
|
18964
|
-
token: this.savedCardsToken
|
|
18965
|
-
});
|
|
18966
|
-
},
|
|
18967
|
-
deleteSavedCard: function deleteSavedCard(cardCode) {
|
|
18968
|
-
return CardAPI.deleteSavedCard({
|
|
18969
|
-
cardCode: cardCode,
|
|
18970
|
-
token: this.savedCardsToken
|
|
18971
|
-
});
|
|
18972
|
-
},
|
|
18973
|
-
chargeSavedCard: function chargeSavedCard(_ref5) {
|
|
18974
|
-
var cardCode = _ref5.cardCode;
|
|
18975
|
-
return CardAPI.chargeSavedCard({
|
|
18976
|
-
cardCode: cardCode,
|
|
18977
|
-
transaction: this.id,
|
|
18978
|
-
token: this.savedCardsToken,
|
|
18979
|
-
device: this.deviceFingerprint,
|
|
18980
|
-
selectedCurrency: this.currency
|
|
18981
|
-
});
|
|
18982
18796
|
}
|
|
18983
18797
|
};
|
|
18984
18798
|
|
|
@@ -20307,8 +20121,6 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20307
20121
|
this.subscription = data.subscription || null;
|
|
20308
20122
|
this.planDetails = data.plan_details || null;
|
|
20309
20123
|
this.exchangeRate = data.exchange_rate || null;
|
|
20310
|
-
this.savedCardsToken = null;
|
|
20311
|
-
this.isSavedCardsEnabled = data.saved_cards && data.saved_cards.enabled || null;
|
|
20312
20124
|
/**
|
|
20313
20125
|
* We initialize parameters we send to the API as empty strings
|
|
20314
20126
|
* when we don't have them instead of null because the API expects
|
|
@@ -20351,51 +20163,7 @@ var TransactionInstance = /*#__PURE__*/function () {
|
|
|
20351
20163
|
}, {
|
|
20352
20164
|
key: "listenForCharge",
|
|
20353
20165
|
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
|
-
});
|
|
20166
|
+
return subscribeToChargeEvents(options, this, callback);
|
|
20399
20167
|
}
|
|
20400
20168
|
}, {
|
|
20401
20169
|
key: "requery",
|
|
@@ -20693,7 +20461,109 @@ var Toolkit = /*#__PURE__*/function () {
|
|
|
20693
20461
|
return Toolkit;
|
|
20694
20462
|
}();
|
|
20695
20463
|
|
|
20464
|
+
var PreauthorizationInstance = /*#__PURE__*/function () {
|
|
20465
|
+
function PreauthorizationInstance(data) {
|
|
20466
|
+
_classCallCheck(this, PreauthorizationInstance);
|
|
20467
|
+
|
|
20468
|
+
this.email = data.email;
|
|
20469
|
+
this.status = data.status;
|
|
20470
|
+
this.reference = data.reference;
|
|
20471
|
+
this.amount = data.amount;
|
|
20472
|
+
this.currency = data.currency;
|
|
20473
|
+
this.metadata = data.metadata || {};
|
|
20474
|
+
this.customer = data.customer;
|
|
20475
|
+
this.channels = data.channels || ['card'];
|
|
20476
|
+
this.isListening = false;
|
|
20477
|
+
this.merchant = {
|
|
20478
|
+
id: data.merchant_id,
|
|
20479
|
+
logo: data.merchant_logo,
|
|
20480
|
+
name: data.merchant_name,
|
|
20481
|
+
key: data.merchant_key
|
|
20482
|
+
};
|
|
20483
|
+
loadPusher(); // TODO: Bind charge function to card channel
|
|
20484
|
+
// https://paystack.atlassian.net/browse/RAILS-2887
|
|
20485
|
+
}
|
|
20486
|
+
|
|
20487
|
+
_createClass(PreauthorizationInstance, [{
|
|
20488
|
+
key: "setMetadata",
|
|
20489
|
+
value: function setMetadata(key, value) {
|
|
20490
|
+
this.metadata[key] = value;
|
|
20491
|
+
}
|
|
20492
|
+
}, {
|
|
20493
|
+
key: "listenForCharge",
|
|
20494
|
+
value: function listenForCharge(options, callback) {
|
|
20495
|
+
return subscribeToChargeEvents(options, this, callback);
|
|
20496
|
+
}
|
|
20497
|
+
}]);
|
|
20498
|
+
|
|
20499
|
+
return PreauthorizationInstance;
|
|
20500
|
+
}();
|
|
20501
|
+
|
|
20502
|
+
var PreauthorisationAPI = {
|
|
20503
|
+
getByAccessCode: function getByAccessCode(accessCode) {
|
|
20504
|
+
var language = getLanguage();
|
|
20505
|
+
|
|
20506
|
+
var headers = _objectSpread2({}, language && {
|
|
20507
|
+
'Accept-Language': language
|
|
20508
|
+
});
|
|
20509
|
+
|
|
20510
|
+
var url = "".concat(configToUse.paystackApiUrl, "preauthorization/verify_access_code/").concat(accessCode);
|
|
20511
|
+
return axiosInstance.get(url, {
|
|
20512
|
+
headers: headers
|
|
20513
|
+
}).then(function (response) {
|
|
20514
|
+
return response.data;
|
|
20515
|
+
});
|
|
20516
|
+
},
|
|
20517
|
+
requery: function requery() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20518
|
+
},
|
|
20519
|
+
reserveFunds: function reserveFunds() {// TODO: https://paystack.atlassian.net/browse/RAILS-2887
|
|
20520
|
+
}
|
|
20521
|
+
};
|
|
20522
|
+
|
|
20523
|
+
var Preauthorization = {
|
|
20524
|
+
initialize: function initialize(data) {
|
|
20525
|
+
return Object.seal(new PreauthorizationInstance(data));
|
|
20526
|
+
},
|
|
20527
|
+
getByAccessCode: function getByAccessCode(accessCode) {
|
|
20528
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
20529
|
+
var response;
|
|
20530
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20531
|
+
while (1) {
|
|
20532
|
+
switch (_context.prev = _context.next) {
|
|
20533
|
+
case 0:
|
|
20534
|
+
_context.next = 2;
|
|
20535
|
+
return PreauthorisationAPI.getByAccessCode(accessCode);
|
|
20536
|
+
|
|
20537
|
+
case 2:
|
|
20538
|
+
response = _context.sent;
|
|
20539
|
+
return _context.abrupt("return", response && Object.seal(new PreauthorizationInstance(_objectSpread2({}, response.data))));
|
|
20540
|
+
|
|
20541
|
+
case 4:
|
|
20542
|
+
case "end":
|
|
20543
|
+
return _context.stop();
|
|
20544
|
+
}
|
|
20545
|
+
}
|
|
20546
|
+
}, _callee);
|
|
20547
|
+
}))();
|
|
20548
|
+
},
|
|
20549
|
+
verify: function verify() {// TODO: https://paystack.atlassian.net/browse/RAILS-2890
|
|
20550
|
+
|
|
20551
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
20552
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
20553
|
+
while (1) {
|
|
20554
|
+
switch (_context2.prev = _context2.next) {
|
|
20555
|
+
case 0:
|
|
20556
|
+
case "end":
|
|
20557
|
+
return _context2.stop();
|
|
20558
|
+
}
|
|
20559
|
+
}
|
|
20560
|
+
}, _callee2);
|
|
20561
|
+
}))();
|
|
20562
|
+
}
|
|
20563
|
+
};
|
|
20564
|
+
|
|
20696
20565
|
exports.BankAccount = BankAccount;
|
|
20697
20566
|
exports.Card = Card;
|
|
20567
|
+
exports.Preauthorization = Preauthorization;
|
|
20698
20568
|
exports.Toolkit = Toolkit;
|
|
20699
20569
|
exports.Transaction = Transaction;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paystack/checkout-js",
|
|
3
|
-
"version": "1.19.0
|
|
3
|
+
"version": "1.19.0",
|
|
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
|
},
|