@paystack/checkout-js 1.57.0-beta.1 → 1.57.0-beta.3
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 +91 -26
- package/es/checkout.js +91 -26
- package/lib/checkout.js +91 -26
- package/package.json +1 -1
package/dist/checkout.js
CHANGED
|
@@ -6385,7 +6385,7 @@ var Paystack = (function (exports) {
|
|
|
6385
6385
|
_excluded2 = ["message", "status", "errors"],
|
|
6386
6386
|
_excluded3 = ["message", "status", "errors"],
|
|
6387
6387
|
_excluded4 = ["message", "status", "errors"],
|
|
6388
|
-
_excluded5 = ["status", "message", "otpmessage"];
|
|
6388
|
+
_excluded5 = ["status", "message", "otpmessage", "redirectUrl"];
|
|
6389
6389
|
var PREAUTHORIZATION_STATE_AUTHORIZED = 'authorized';
|
|
6390
6390
|
var ChargeResponses = {
|
|
6391
6391
|
authorized: function authorized(response) {
|
|
@@ -6436,8 +6436,9 @@ var Paystack = (function (exports) {
|
|
|
6436
6436
|
response.status;
|
|
6437
6437
|
var message = response.message,
|
|
6438
6438
|
otpmessage = response.otpmessage,
|
|
6439
|
+
redirectUrl = response.redirectUrl,
|
|
6439
6440
|
cleanResponse = _objectWithoutProperties(response, _excluded5);
|
|
6440
|
-
var authMessage = otpmessage || message;
|
|
6441
|
+
var authMessage = redirectUrl || otpmessage || message;
|
|
6441
6442
|
return {
|
|
6442
6443
|
status: 'auth',
|
|
6443
6444
|
message: authMessage || 'Authentication required',
|
|
@@ -6507,7 +6508,7 @@ var Paystack = (function (exports) {
|
|
|
6507
6508
|
if (response.status === 'incorrect-amount-sent' || response.message_type === 'INCORRECT_AMOUNT') {
|
|
6508
6509
|
return this.getCleanResponse(response, 'Incorrect amount sent');
|
|
6509
6510
|
}
|
|
6510
|
-
if (response.status
|
|
6511
|
+
if (['awaiting_registration_token', 'awaiting_ussd_confirmation'].includes(response.status)) {
|
|
6511
6512
|
return this.getCleanResponse(response);
|
|
6512
6513
|
}
|
|
6513
6514
|
if (response.auth && response.auth !== 'none') {
|
|
@@ -6561,6 +6562,58 @@ var Paystack = (function (exports) {
|
|
|
6561
6562
|
});
|
|
6562
6563
|
};
|
|
6563
6564
|
|
|
6565
|
+
// Duplicated from `subscribeToChargeEvents` on purpose. Hoisting that function's locals
|
|
6566
|
+
// to module scope so both could share them would modify the shared path, which
|
|
6567
|
+
// RAILS-12006 AC5 requires to stay byte-identical. Do not "clean this up".
|
|
6568
|
+
var confirmationUndefinedError = {
|
|
6569
|
+
status: 'error',
|
|
6570
|
+
message: 'We could not listen for charge response.'
|
|
6571
|
+
};
|
|
6572
|
+
var confirmationSubscriptionError = {
|
|
6573
|
+
status: 'error',
|
|
6574
|
+
message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
|
|
6575
|
+
};
|
|
6576
|
+
|
|
6577
|
+
// Dedicated listener for the Ghana mobile money USSD confirmation channel.
|
|
6578
|
+
// Deliberately separate from `subscribeToChargeEvents`: that function is the shared
|
|
6579
|
+
// path for every channel and market, and this flow needs an unsubscribe available
|
|
6580
|
+
// before any event arrives. `context` is used only for logAPIResponse -- unlike the
|
|
6581
|
+
// shared path this never writes `context.isListening`, because the confirmation
|
|
6582
|
+
// channel runs alongside the main charge subscription and the two would otherwise
|
|
6583
|
+
// fight over a single flag on the same transaction.
|
|
6584
|
+
var subscribeToConfirmationEvents = function subscribeToConfirmationEvents(options, context, callback) {
|
|
6585
|
+
var channel = options.channel,
|
|
6586
|
+
paymentMethod = options.paymentMethod;
|
|
6587
|
+
if (!window || !window.Pusher) {
|
|
6588
|
+
callback(confirmationUndefinedError, noOp);
|
|
6589
|
+
return noOp;
|
|
6590
|
+
}
|
|
6591
|
+
var pusher = new window.Pusher(configToUse.pusherKey, {
|
|
6592
|
+
cluster: 'eu',
|
|
6593
|
+
disableStats: true
|
|
6594
|
+
});
|
|
6595
|
+
var hasUnsubscribed = false;
|
|
6596
|
+
var unsubscribe = function unsubscribe() {
|
|
6597
|
+
if (hasUnsubscribed) {
|
|
6598
|
+
return;
|
|
6599
|
+
}
|
|
6600
|
+
hasUnsubscribed = true;
|
|
6601
|
+
pusher.unsubscribe(channel);
|
|
6602
|
+
pusher.disconnect();
|
|
6603
|
+
};
|
|
6604
|
+
var pusherSubscription = pusher.subscribe(channel);
|
|
6605
|
+
pusherSubscription.bind('pusher:subscription_error', function () {
|
|
6606
|
+
unsubscribe();
|
|
6607
|
+
callback(confirmationSubscriptionError, unsubscribe);
|
|
6608
|
+
});
|
|
6609
|
+
pusherSubscription.bind('response', function (response) {
|
|
6610
|
+
var formattedResponse = ChargeResponses.parse(response);
|
|
6611
|
+
context.logAPIResponse(formattedResponse, paymentMethod);
|
|
6612
|
+
callback(formattedResponse, unsubscribe);
|
|
6613
|
+
});
|
|
6614
|
+
return unsubscribe;
|
|
6615
|
+
};
|
|
6616
|
+
|
|
6564
6617
|
var uncurryThis$7 = functionUncurryThis;
|
|
6565
6618
|
var PROPER_FUNCTION_NAME$2 = functionName.PROPER;
|
|
6566
6619
|
var redefine$4 = redefine$a.exports;
|
|
@@ -12393,20 +12446,7 @@ var Paystack = (function (exports) {
|
|
|
12393
12446
|
return axiosInstance.post(url, urlEncodedParams, {
|
|
12394
12447
|
headers: headers
|
|
12395
12448
|
}).then(function (response) {
|
|
12396
|
-
|
|
12397
|
-
var raw = response.data;
|
|
12398
|
-
/*
|
|
12399
|
-
* A googlepay step-up is always 3DS, but the charge response can omit
|
|
12400
|
-
* the `auth` field the shared parser routes on — without it an auth
|
|
12401
|
-
* response falls through to error(). Default it so the response
|
|
12402
|
-
* normalizes through auth() exactly like card's.
|
|
12403
|
-
*/
|
|
12404
|
-
if ((raw === null || raw === void 0 ? void 0 : raw.status) === 'auth' && !raw.auth && !((_raw$data = raw.data) !== null && _raw$data !== void 0 && _raw$data.auth)) {
|
|
12405
|
-
return ChargeResponses.parse(_objectSpread2(_objectSpread2({}, raw), {}, {
|
|
12406
|
-
auth: '3DS'
|
|
12407
|
-
}));
|
|
12408
|
-
}
|
|
12409
|
-
return ChargeResponses.parse(raw);
|
|
12449
|
+
return ChargeResponses.parse(response.data);
|
|
12410
12450
|
});
|
|
12411
12451
|
}
|
|
12412
12452
|
};
|
|
@@ -20398,6 +20438,10 @@ var Paystack = (function (exports) {
|
|
|
20398
20438
|
}
|
|
20399
20439
|
};
|
|
20400
20440
|
|
|
20441
|
+
// Charge statuses that leave the transaction with a Pusher channel worth listening on.
|
|
20442
|
+
// `awaiting_ussd_confirmation` is mid-flight, not settled, but it still carries the
|
|
20443
|
+
// `channel_name` the outcome will arrive on.
|
|
20444
|
+
var LISTENABLE_CHARGE_STATUSES = ['success', 'awaiting_ussd_confirmation'];
|
|
20401
20445
|
function validate$1(phoneNumber) {
|
|
20402
20446
|
return new Promise(function (resolve, reject) {
|
|
20403
20447
|
var validation = PhoneNumber.validate(phoneNumber);
|
|
@@ -20437,11 +20481,11 @@ var Paystack = (function (exports) {
|
|
|
20437
20481
|
mobileMoneyChargeAPI: function mobileMoneyChargeAPI(params) {
|
|
20438
20482
|
var _this = this;
|
|
20439
20483
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
20440
|
-
if (response.status
|
|
20484
|
+
if (LISTENABLE_CHARGE_STATUSES.includes(response.status)) {
|
|
20441
20485
|
_this.mobileMoney = response;
|
|
20442
|
-
|
|
20443
|
-
|
|
20444
|
-
|
|
20486
|
+
}
|
|
20487
|
+
if (response.status === 'success' && response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
20488
|
+
_this.logTokenRequest('mobile money');
|
|
20445
20489
|
}
|
|
20446
20490
|
return response;
|
|
20447
20491
|
});
|
|
@@ -20514,17 +20558,33 @@ var Paystack = (function (exports) {
|
|
|
20514
20558
|
});
|
|
20515
20559
|
},
|
|
20516
20560
|
listenForMobileMoneyCharge: function listenForMobileMoneyCharge(callback) {
|
|
20517
|
-
if (this.mobileMoney.status
|
|
20561
|
+
if (!LISTENABLE_CHARGE_STATUSES.includes(this.mobileMoney.status)) {
|
|
20562
|
+
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20563
|
+
}
|
|
20564
|
+
var _ref2 = this.mobileMoney.data || {},
|
|
20565
|
+
channel = _ref2.channel,
|
|
20566
|
+
channelName = _ref2.channel_name;
|
|
20567
|
+
var listenerChannel = channel || channelName;
|
|
20568
|
+
if (!listenerChannel) {
|
|
20518
20569
|
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20519
20570
|
}
|
|
20520
|
-
var _this$mobileMoney$dat = this.mobileMoney.data,
|
|
20521
|
-
channel = _this$mobileMoney$dat.channel,
|
|
20522
|
-
channelName = _this$mobileMoney$dat.channel_name;
|
|
20523
20571
|
var listenerOptions = {
|
|
20524
|
-
channel:
|
|
20572
|
+
channel: listenerChannel,
|
|
20525
20573
|
paymentMethod: 'mobile_money'
|
|
20526
20574
|
};
|
|
20527
20575
|
return this.listenForCharge(listenerOptions, callback);
|
|
20576
|
+
},
|
|
20577
|
+
listenForMobileMoneyConfirmation: function listenForMobileMoneyConfirmation(callback, pusherChannel) {
|
|
20578
|
+
var data = this.mobileMoney.data;
|
|
20579
|
+
var confirmationChannel = pusherChannel || data && data.confirm_channel_name;
|
|
20580
|
+
if (!confirmationChannel) {
|
|
20581
|
+
throw new Error('Please provide the confirm_channel_name returned by Transaction.chargeMobileMoney()');
|
|
20582
|
+
}
|
|
20583
|
+
var listenerOptions = {
|
|
20584
|
+
channel: confirmationChannel,
|
|
20585
|
+
paymentMethod: 'mobile_money'
|
|
20586
|
+
};
|
|
20587
|
+
return subscribeToConfirmationEvents(listenerOptions, this, callback);
|
|
20528
20588
|
}
|
|
20529
20589
|
};
|
|
20530
20590
|
|
|
@@ -21267,6 +21327,11 @@ var Paystack = (function (exports) {
|
|
|
21267
21327
|
return this.logError(response.message);
|
|
21268
21328
|
case 'auth':
|
|
21269
21329
|
return this.logAuth(response.data.auth);
|
|
21330
|
+
case 'awaiting_ussd_confirmation':
|
|
21331
|
+
// The customer has been shown the USSD prompt but has not dialled yet. Logging
|
|
21332
|
+
// it gives the funnel denominator for the `pending` entry the confirmation
|
|
21333
|
+
// event writes when they do.
|
|
21334
|
+
return this.logAPIResponseMessage(response.message);
|
|
21270
21335
|
default:
|
|
21271
21336
|
return false;
|
|
21272
21337
|
}
|
package/es/checkout.js
CHANGED
|
@@ -6382,7 +6382,7 @@ var _excluded = ["message", "status", "errors"],
|
|
|
6382
6382
|
_excluded2 = ["message", "status", "errors"],
|
|
6383
6383
|
_excluded3 = ["message", "status", "errors"],
|
|
6384
6384
|
_excluded4 = ["message", "status", "errors"],
|
|
6385
|
-
_excluded5 = ["status", "message", "otpmessage"];
|
|
6385
|
+
_excluded5 = ["status", "message", "otpmessage", "redirectUrl"];
|
|
6386
6386
|
var PREAUTHORIZATION_STATE_AUTHORIZED = 'authorized';
|
|
6387
6387
|
var ChargeResponses = {
|
|
6388
6388
|
authorized: function authorized(response) {
|
|
@@ -6433,8 +6433,9 @@ var ChargeResponses = {
|
|
|
6433
6433
|
response.status;
|
|
6434
6434
|
var message = response.message,
|
|
6435
6435
|
otpmessage = response.otpmessage,
|
|
6436
|
+
redirectUrl = response.redirectUrl,
|
|
6436
6437
|
cleanResponse = _objectWithoutProperties(response, _excluded5);
|
|
6437
|
-
var authMessage = otpmessage || message;
|
|
6438
|
+
var authMessage = redirectUrl || otpmessage || message;
|
|
6438
6439
|
return {
|
|
6439
6440
|
status: 'auth',
|
|
6440
6441
|
message: authMessage || 'Authentication required',
|
|
@@ -6504,7 +6505,7 @@ var ChargeResponses = {
|
|
|
6504
6505
|
if (response.status === 'incorrect-amount-sent' || response.message_type === 'INCORRECT_AMOUNT') {
|
|
6505
6506
|
return this.getCleanResponse(response, 'Incorrect amount sent');
|
|
6506
6507
|
}
|
|
6507
|
-
if (response.status
|
|
6508
|
+
if (['awaiting_registration_token', 'awaiting_ussd_confirmation'].includes(response.status)) {
|
|
6508
6509
|
return this.getCleanResponse(response);
|
|
6509
6510
|
}
|
|
6510
6511
|
if (response.auth && response.auth !== 'none') {
|
|
@@ -6558,6 +6559,58 @@ var subscribeToChargeEvents = function subscribeToChargeEvents(options, context,
|
|
|
6558
6559
|
});
|
|
6559
6560
|
};
|
|
6560
6561
|
|
|
6562
|
+
// Duplicated from `subscribeToChargeEvents` on purpose. Hoisting that function's locals
|
|
6563
|
+
// to module scope so both could share them would modify the shared path, which
|
|
6564
|
+
// RAILS-12006 AC5 requires to stay byte-identical. Do not "clean this up".
|
|
6565
|
+
var confirmationUndefinedError = {
|
|
6566
|
+
status: 'error',
|
|
6567
|
+
message: 'We could not listen for charge response.'
|
|
6568
|
+
};
|
|
6569
|
+
var confirmationSubscriptionError = {
|
|
6570
|
+
status: 'error',
|
|
6571
|
+
message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
|
|
6572
|
+
};
|
|
6573
|
+
|
|
6574
|
+
// Dedicated listener for the Ghana mobile money USSD confirmation channel.
|
|
6575
|
+
// Deliberately separate from `subscribeToChargeEvents`: that function is the shared
|
|
6576
|
+
// path for every channel and market, and this flow needs an unsubscribe available
|
|
6577
|
+
// before any event arrives. `context` is used only for logAPIResponse -- unlike the
|
|
6578
|
+
// shared path this never writes `context.isListening`, because the confirmation
|
|
6579
|
+
// channel runs alongside the main charge subscription and the two would otherwise
|
|
6580
|
+
// fight over a single flag on the same transaction.
|
|
6581
|
+
var subscribeToConfirmationEvents = function subscribeToConfirmationEvents(options, context, callback) {
|
|
6582
|
+
var channel = options.channel,
|
|
6583
|
+
paymentMethod = options.paymentMethod;
|
|
6584
|
+
if (!window || !window.Pusher) {
|
|
6585
|
+
callback(confirmationUndefinedError, noOp);
|
|
6586
|
+
return noOp;
|
|
6587
|
+
}
|
|
6588
|
+
var pusher = new window.Pusher(configToUse.pusherKey, {
|
|
6589
|
+
cluster: 'eu',
|
|
6590
|
+
disableStats: true
|
|
6591
|
+
});
|
|
6592
|
+
var hasUnsubscribed = false;
|
|
6593
|
+
var unsubscribe = function unsubscribe() {
|
|
6594
|
+
if (hasUnsubscribed) {
|
|
6595
|
+
return;
|
|
6596
|
+
}
|
|
6597
|
+
hasUnsubscribed = true;
|
|
6598
|
+
pusher.unsubscribe(channel);
|
|
6599
|
+
pusher.disconnect();
|
|
6600
|
+
};
|
|
6601
|
+
var pusherSubscription = pusher.subscribe(channel);
|
|
6602
|
+
pusherSubscription.bind('pusher:subscription_error', function () {
|
|
6603
|
+
unsubscribe();
|
|
6604
|
+
callback(confirmationSubscriptionError, unsubscribe);
|
|
6605
|
+
});
|
|
6606
|
+
pusherSubscription.bind('response', function (response) {
|
|
6607
|
+
var formattedResponse = ChargeResponses.parse(response);
|
|
6608
|
+
context.logAPIResponse(formattedResponse, paymentMethod);
|
|
6609
|
+
callback(formattedResponse, unsubscribe);
|
|
6610
|
+
});
|
|
6611
|
+
return unsubscribe;
|
|
6612
|
+
};
|
|
6613
|
+
|
|
6561
6614
|
var uncurryThis$7 = functionUncurryThis;
|
|
6562
6615
|
var PROPER_FUNCTION_NAME$2 = functionName.PROPER;
|
|
6563
6616
|
var redefine$4 = redefine$a.exports;
|
|
@@ -12390,20 +12443,7 @@ var GooglePayAPI = {
|
|
|
12390
12443
|
return axiosInstance.post(url, urlEncodedParams, {
|
|
12391
12444
|
headers: headers
|
|
12392
12445
|
}).then(function (response) {
|
|
12393
|
-
|
|
12394
|
-
var raw = response.data;
|
|
12395
|
-
/*
|
|
12396
|
-
* A googlepay step-up is always 3DS, but the charge response can omit
|
|
12397
|
-
* the `auth` field the shared parser routes on — without it an auth
|
|
12398
|
-
* response falls through to error(). Default it so the response
|
|
12399
|
-
* normalizes through auth() exactly like card's.
|
|
12400
|
-
*/
|
|
12401
|
-
if ((raw === null || raw === void 0 ? void 0 : raw.status) === 'auth' && !raw.auth && !((_raw$data = raw.data) !== null && _raw$data !== void 0 && _raw$data.auth)) {
|
|
12402
|
-
return ChargeResponses.parse(_objectSpread2(_objectSpread2({}, raw), {}, {
|
|
12403
|
-
auth: '3DS'
|
|
12404
|
-
}));
|
|
12405
|
-
}
|
|
12406
|
-
return ChargeResponses.parse(raw);
|
|
12446
|
+
return ChargeResponses.parse(response.data);
|
|
12407
12447
|
});
|
|
12408
12448
|
}
|
|
12409
12449
|
};
|
|
@@ -20395,6 +20435,10 @@ var MobileMoneyAPI = {
|
|
|
20395
20435
|
}
|
|
20396
20436
|
};
|
|
20397
20437
|
|
|
20438
|
+
// Charge statuses that leave the transaction with a Pusher channel worth listening on.
|
|
20439
|
+
// `awaiting_ussd_confirmation` is mid-flight, not settled, but it still carries the
|
|
20440
|
+
// `channel_name` the outcome will arrive on.
|
|
20441
|
+
var LISTENABLE_CHARGE_STATUSES = ['success', 'awaiting_ussd_confirmation'];
|
|
20398
20442
|
function validate$1(phoneNumber) {
|
|
20399
20443
|
return new Promise(function (resolve, reject) {
|
|
20400
20444
|
var validation = PhoneNumber.validate(phoneNumber);
|
|
@@ -20434,11 +20478,11 @@ var MobileMoneyCharge = {
|
|
|
20434
20478
|
mobileMoneyChargeAPI: function mobileMoneyChargeAPI(params) {
|
|
20435
20479
|
var _this = this;
|
|
20436
20480
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
20437
|
-
if (response.status
|
|
20481
|
+
if (LISTENABLE_CHARGE_STATUSES.includes(response.status)) {
|
|
20438
20482
|
_this.mobileMoney = response;
|
|
20439
|
-
|
|
20440
|
-
|
|
20441
|
-
|
|
20483
|
+
}
|
|
20484
|
+
if (response.status === 'success' && response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
20485
|
+
_this.logTokenRequest('mobile money');
|
|
20442
20486
|
}
|
|
20443
20487
|
return response;
|
|
20444
20488
|
});
|
|
@@ -20511,17 +20555,33 @@ var MobileMoneyCharge = {
|
|
|
20511
20555
|
});
|
|
20512
20556
|
},
|
|
20513
20557
|
listenForMobileMoneyCharge: function listenForMobileMoneyCharge(callback) {
|
|
20514
|
-
if (this.mobileMoney.status
|
|
20558
|
+
if (!LISTENABLE_CHARGE_STATUSES.includes(this.mobileMoney.status)) {
|
|
20559
|
+
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20560
|
+
}
|
|
20561
|
+
var _ref2 = this.mobileMoney.data || {},
|
|
20562
|
+
channel = _ref2.channel,
|
|
20563
|
+
channelName = _ref2.channel_name;
|
|
20564
|
+
var listenerChannel = channel || channelName;
|
|
20565
|
+
if (!listenerChannel) {
|
|
20515
20566
|
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20516
20567
|
}
|
|
20517
|
-
var _this$mobileMoney$dat = this.mobileMoney.data,
|
|
20518
|
-
channel = _this$mobileMoney$dat.channel,
|
|
20519
|
-
channelName = _this$mobileMoney$dat.channel_name;
|
|
20520
20568
|
var listenerOptions = {
|
|
20521
|
-
channel:
|
|
20569
|
+
channel: listenerChannel,
|
|
20522
20570
|
paymentMethod: 'mobile_money'
|
|
20523
20571
|
};
|
|
20524
20572
|
return this.listenForCharge(listenerOptions, callback);
|
|
20573
|
+
},
|
|
20574
|
+
listenForMobileMoneyConfirmation: function listenForMobileMoneyConfirmation(callback, pusherChannel) {
|
|
20575
|
+
var data = this.mobileMoney.data;
|
|
20576
|
+
var confirmationChannel = pusherChannel || data && data.confirm_channel_name;
|
|
20577
|
+
if (!confirmationChannel) {
|
|
20578
|
+
throw new Error('Please provide the confirm_channel_name returned by Transaction.chargeMobileMoney()');
|
|
20579
|
+
}
|
|
20580
|
+
var listenerOptions = {
|
|
20581
|
+
channel: confirmationChannel,
|
|
20582
|
+
paymentMethod: 'mobile_money'
|
|
20583
|
+
};
|
|
20584
|
+
return subscribeToConfirmationEvents(listenerOptions, this, callback);
|
|
20525
20585
|
}
|
|
20526
20586
|
};
|
|
20527
20587
|
|
|
@@ -21264,6 +21324,11 @@ var AnalyticsFunctions$1 = _objectSpread2(_objectSpread2({}, CapitecPayAnalytics
|
|
|
21264
21324
|
return this.logError(response.message);
|
|
21265
21325
|
case 'auth':
|
|
21266
21326
|
return this.logAuth(response.data.auth);
|
|
21327
|
+
case 'awaiting_ussd_confirmation':
|
|
21328
|
+
// The customer has been shown the USSD prompt but has not dialled yet. Logging
|
|
21329
|
+
// it gives the funnel denominator for the `pending` entry the confirmation
|
|
21330
|
+
// event writes when they do.
|
|
21331
|
+
return this.logAPIResponseMessage(response.message);
|
|
21267
21332
|
default:
|
|
21268
21333
|
return false;
|
|
21269
21334
|
}
|
package/lib/checkout.js
CHANGED
|
@@ -6386,7 +6386,7 @@ var _excluded = ["message", "status", "errors"],
|
|
|
6386
6386
|
_excluded2 = ["message", "status", "errors"],
|
|
6387
6387
|
_excluded3 = ["message", "status", "errors"],
|
|
6388
6388
|
_excluded4 = ["message", "status", "errors"],
|
|
6389
|
-
_excluded5 = ["status", "message", "otpmessage"];
|
|
6389
|
+
_excluded5 = ["status", "message", "otpmessage", "redirectUrl"];
|
|
6390
6390
|
var PREAUTHORIZATION_STATE_AUTHORIZED = 'authorized';
|
|
6391
6391
|
var ChargeResponses = {
|
|
6392
6392
|
authorized: function authorized(response) {
|
|
@@ -6437,8 +6437,9 @@ var ChargeResponses = {
|
|
|
6437
6437
|
response.status;
|
|
6438
6438
|
var message = response.message,
|
|
6439
6439
|
otpmessage = response.otpmessage,
|
|
6440
|
+
redirectUrl = response.redirectUrl,
|
|
6440
6441
|
cleanResponse = _objectWithoutProperties(response, _excluded5);
|
|
6441
|
-
var authMessage = otpmessage || message;
|
|
6442
|
+
var authMessage = redirectUrl || otpmessage || message;
|
|
6442
6443
|
return {
|
|
6443
6444
|
status: 'auth',
|
|
6444
6445
|
message: authMessage || 'Authentication required',
|
|
@@ -6508,7 +6509,7 @@ var ChargeResponses = {
|
|
|
6508
6509
|
if (response.status === 'incorrect-amount-sent' || response.message_type === 'INCORRECT_AMOUNT') {
|
|
6509
6510
|
return this.getCleanResponse(response, 'Incorrect amount sent');
|
|
6510
6511
|
}
|
|
6511
|
-
if (response.status
|
|
6512
|
+
if (['awaiting_registration_token', 'awaiting_ussd_confirmation'].includes(response.status)) {
|
|
6512
6513
|
return this.getCleanResponse(response);
|
|
6513
6514
|
}
|
|
6514
6515
|
if (response.auth && response.auth !== 'none') {
|
|
@@ -6562,6 +6563,58 @@ var subscribeToChargeEvents = function subscribeToChargeEvents(options, context,
|
|
|
6562
6563
|
});
|
|
6563
6564
|
};
|
|
6564
6565
|
|
|
6566
|
+
// Duplicated from `subscribeToChargeEvents` on purpose. Hoisting that function's locals
|
|
6567
|
+
// to module scope so both could share them would modify the shared path, which
|
|
6568
|
+
// RAILS-12006 AC5 requires to stay byte-identical. Do not "clean this up".
|
|
6569
|
+
var confirmationUndefinedError = {
|
|
6570
|
+
status: 'error',
|
|
6571
|
+
message: 'We could not listen for charge response.'
|
|
6572
|
+
};
|
|
6573
|
+
var confirmationSubscriptionError = {
|
|
6574
|
+
status: 'error',
|
|
6575
|
+
message: 'We could not listen for charge response. Use transaction.requery() to check the status.'
|
|
6576
|
+
};
|
|
6577
|
+
|
|
6578
|
+
// Dedicated listener for the Ghana mobile money USSD confirmation channel.
|
|
6579
|
+
// Deliberately separate from `subscribeToChargeEvents`: that function is the shared
|
|
6580
|
+
// path for every channel and market, and this flow needs an unsubscribe available
|
|
6581
|
+
// before any event arrives. `context` is used only for logAPIResponse -- unlike the
|
|
6582
|
+
// shared path this never writes `context.isListening`, because the confirmation
|
|
6583
|
+
// channel runs alongside the main charge subscription and the two would otherwise
|
|
6584
|
+
// fight over a single flag on the same transaction.
|
|
6585
|
+
var subscribeToConfirmationEvents = function subscribeToConfirmationEvents(options, context, callback) {
|
|
6586
|
+
var channel = options.channel,
|
|
6587
|
+
paymentMethod = options.paymentMethod;
|
|
6588
|
+
if (!window || !window.Pusher) {
|
|
6589
|
+
callback(confirmationUndefinedError, noOp);
|
|
6590
|
+
return noOp;
|
|
6591
|
+
}
|
|
6592
|
+
var pusher = new window.Pusher(configToUse.pusherKey, {
|
|
6593
|
+
cluster: 'eu',
|
|
6594
|
+
disableStats: true
|
|
6595
|
+
});
|
|
6596
|
+
var hasUnsubscribed = false;
|
|
6597
|
+
var unsubscribe = function unsubscribe() {
|
|
6598
|
+
if (hasUnsubscribed) {
|
|
6599
|
+
return;
|
|
6600
|
+
}
|
|
6601
|
+
hasUnsubscribed = true;
|
|
6602
|
+
pusher.unsubscribe(channel);
|
|
6603
|
+
pusher.disconnect();
|
|
6604
|
+
};
|
|
6605
|
+
var pusherSubscription = pusher.subscribe(channel);
|
|
6606
|
+
pusherSubscription.bind('pusher:subscription_error', function () {
|
|
6607
|
+
unsubscribe();
|
|
6608
|
+
callback(confirmationSubscriptionError, unsubscribe);
|
|
6609
|
+
});
|
|
6610
|
+
pusherSubscription.bind('response', function (response) {
|
|
6611
|
+
var formattedResponse = ChargeResponses.parse(response);
|
|
6612
|
+
context.logAPIResponse(formattedResponse, paymentMethod);
|
|
6613
|
+
callback(formattedResponse, unsubscribe);
|
|
6614
|
+
});
|
|
6615
|
+
return unsubscribe;
|
|
6616
|
+
};
|
|
6617
|
+
|
|
6565
6618
|
var uncurryThis$7 = functionUncurryThis;
|
|
6566
6619
|
var PROPER_FUNCTION_NAME$2 = functionName.PROPER;
|
|
6567
6620
|
var redefine$4 = redefine$a.exports;
|
|
@@ -12394,20 +12447,7 @@ var GooglePayAPI = {
|
|
|
12394
12447
|
return axiosInstance.post(url, urlEncodedParams, {
|
|
12395
12448
|
headers: headers
|
|
12396
12449
|
}).then(function (response) {
|
|
12397
|
-
|
|
12398
|
-
var raw = response.data;
|
|
12399
|
-
/*
|
|
12400
|
-
* A googlepay step-up is always 3DS, but the charge response can omit
|
|
12401
|
-
* the `auth` field the shared parser routes on — without it an auth
|
|
12402
|
-
* response falls through to error(). Default it so the response
|
|
12403
|
-
* normalizes through auth() exactly like card's.
|
|
12404
|
-
*/
|
|
12405
|
-
if ((raw === null || raw === void 0 ? void 0 : raw.status) === 'auth' && !raw.auth && !((_raw$data = raw.data) !== null && _raw$data !== void 0 && _raw$data.auth)) {
|
|
12406
|
-
return ChargeResponses.parse(_objectSpread2(_objectSpread2({}, raw), {}, {
|
|
12407
|
-
auth: '3DS'
|
|
12408
|
-
}));
|
|
12409
|
-
}
|
|
12410
|
-
return ChargeResponses.parse(raw);
|
|
12450
|
+
return ChargeResponses.parse(response.data);
|
|
12411
12451
|
});
|
|
12412
12452
|
}
|
|
12413
12453
|
};
|
|
@@ -20399,6 +20439,10 @@ var MobileMoneyAPI = {
|
|
|
20399
20439
|
}
|
|
20400
20440
|
};
|
|
20401
20441
|
|
|
20442
|
+
// Charge statuses that leave the transaction with a Pusher channel worth listening on.
|
|
20443
|
+
// `awaiting_ussd_confirmation` is mid-flight, not settled, but it still carries the
|
|
20444
|
+
// `channel_name` the outcome will arrive on.
|
|
20445
|
+
var LISTENABLE_CHARGE_STATUSES = ['success', 'awaiting_ussd_confirmation'];
|
|
20402
20446
|
function validate$1(phoneNumber) {
|
|
20403
20447
|
return new Promise(function (resolve, reject) {
|
|
20404
20448
|
var validation = PhoneNumber.validate(phoneNumber);
|
|
@@ -20438,11 +20482,11 @@ var MobileMoneyCharge = {
|
|
|
20438
20482
|
mobileMoneyChargeAPI: function mobileMoneyChargeAPI(params) {
|
|
20439
20483
|
var _this = this;
|
|
20440
20484
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
20441
|
-
if (response.status
|
|
20485
|
+
if (LISTENABLE_CHARGE_STATUSES.includes(response.status)) {
|
|
20442
20486
|
_this.mobileMoney = response;
|
|
20443
|
-
|
|
20444
|
-
|
|
20445
|
-
|
|
20487
|
+
}
|
|
20488
|
+
if (response.status === 'success' && response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
20489
|
+
_this.logTokenRequest('mobile money');
|
|
20446
20490
|
}
|
|
20447
20491
|
return response;
|
|
20448
20492
|
});
|
|
@@ -20515,17 +20559,33 @@ var MobileMoneyCharge = {
|
|
|
20515
20559
|
});
|
|
20516
20560
|
},
|
|
20517
20561
|
listenForMobileMoneyCharge: function listenForMobileMoneyCharge(callback) {
|
|
20518
|
-
if (this.mobileMoney.status
|
|
20562
|
+
if (!LISTENABLE_CHARGE_STATUSES.includes(this.mobileMoney.status)) {
|
|
20563
|
+
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20564
|
+
}
|
|
20565
|
+
var _ref2 = this.mobileMoney.data || {},
|
|
20566
|
+
channel = _ref2.channel,
|
|
20567
|
+
channelName = _ref2.channel_name;
|
|
20568
|
+
var listenerChannel = channel || channelName;
|
|
20569
|
+
if (!listenerChannel) {
|
|
20519
20570
|
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20520
20571
|
}
|
|
20521
|
-
var _this$mobileMoney$dat = this.mobileMoney.data,
|
|
20522
|
-
channel = _this$mobileMoney$dat.channel,
|
|
20523
|
-
channelName = _this$mobileMoney$dat.channel_name;
|
|
20524
20572
|
var listenerOptions = {
|
|
20525
|
-
channel:
|
|
20573
|
+
channel: listenerChannel,
|
|
20526
20574
|
paymentMethod: 'mobile_money'
|
|
20527
20575
|
};
|
|
20528
20576
|
return this.listenForCharge(listenerOptions, callback);
|
|
20577
|
+
},
|
|
20578
|
+
listenForMobileMoneyConfirmation: function listenForMobileMoneyConfirmation(callback, pusherChannel) {
|
|
20579
|
+
var data = this.mobileMoney.data;
|
|
20580
|
+
var confirmationChannel = pusherChannel || data && data.confirm_channel_name;
|
|
20581
|
+
if (!confirmationChannel) {
|
|
20582
|
+
throw new Error('Please provide the confirm_channel_name returned by Transaction.chargeMobileMoney()');
|
|
20583
|
+
}
|
|
20584
|
+
var listenerOptions = {
|
|
20585
|
+
channel: confirmationChannel,
|
|
20586
|
+
paymentMethod: 'mobile_money'
|
|
20587
|
+
};
|
|
20588
|
+
return subscribeToConfirmationEvents(listenerOptions, this, callback);
|
|
20529
20589
|
}
|
|
20530
20590
|
};
|
|
20531
20591
|
|
|
@@ -21268,6 +21328,11 @@ var AnalyticsFunctions$1 = _objectSpread2(_objectSpread2({}, CapitecPayAnalytics
|
|
|
21268
21328
|
return this.logError(response.message);
|
|
21269
21329
|
case 'auth':
|
|
21270
21330
|
return this.logAuth(response.data.auth);
|
|
21331
|
+
case 'awaiting_ussd_confirmation':
|
|
21332
|
+
// The customer has been shown the USSD prompt but has not dialled yet. Logging
|
|
21333
|
+
// it gives the funnel denominator for the `pending` entry the confirmation
|
|
21334
|
+
// event writes when they do.
|
|
21335
|
+
return this.logAPIResponseMessage(response.message);
|
|
21271
21336
|
default:
|
|
21272
21337
|
return false;
|
|
21273
21338
|
}
|