@paystack/checkout-js 1.57.0-beta.2 → 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 +87 -10
- package/es/checkout.js +87 -10
- package/lib/checkout.js +87 -10
- package/package.json +1 -1
package/dist/checkout.js
CHANGED
|
@@ -6508,7 +6508,7 @@ var Paystack = (function (exports) {
|
|
|
6508
6508
|
if (response.status === 'incorrect-amount-sent' || response.message_type === 'INCORRECT_AMOUNT') {
|
|
6509
6509
|
return this.getCleanResponse(response, 'Incorrect amount sent');
|
|
6510
6510
|
}
|
|
6511
|
-
if (response.status
|
|
6511
|
+
if (['awaiting_registration_token', 'awaiting_ussd_confirmation'].includes(response.status)) {
|
|
6512
6512
|
return this.getCleanResponse(response);
|
|
6513
6513
|
}
|
|
6514
6514
|
if (response.auth && response.auth !== 'none') {
|
|
@@ -6562,6 +6562,58 @@ var Paystack = (function (exports) {
|
|
|
6562
6562
|
});
|
|
6563
6563
|
};
|
|
6564
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
|
+
|
|
6565
6617
|
var uncurryThis$7 = functionUncurryThis;
|
|
6566
6618
|
var PROPER_FUNCTION_NAME$2 = functionName.PROPER;
|
|
6567
6619
|
var redefine$4 = redefine$a.exports;
|
|
@@ -20386,6 +20438,10 @@ var Paystack = (function (exports) {
|
|
|
20386
20438
|
}
|
|
20387
20439
|
};
|
|
20388
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'];
|
|
20389
20445
|
function validate$1(phoneNumber) {
|
|
20390
20446
|
return new Promise(function (resolve, reject) {
|
|
20391
20447
|
var validation = PhoneNumber.validate(phoneNumber);
|
|
@@ -20425,11 +20481,11 @@ var Paystack = (function (exports) {
|
|
|
20425
20481
|
mobileMoneyChargeAPI: function mobileMoneyChargeAPI(params) {
|
|
20426
20482
|
var _this = this;
|
|
20427
20483
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
20428
|
-
if (response.status
|
|
20484
|
+
if (LISTENABLE_CHARGE_STATUSES.includes(response.status)) {
|
|
20429
20485
|
_this.mobileMoney = response;
|
|
20430
|
-
|
|
20431
|
-
|
|
20432
|
-
|
|
20486
|
+
}
|
|
20487
|
+
if (response.status === 'success' && response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
20488
|
+
_this.logTokenRequest('mobile money');
|
|
20433
20489
|
}
|
|
20434
20490
|
return response;
|
|
20435
20491
|
});
|
|
@@ -20502,17 +20558,33 @@ var Paystack = (function (exports) {
|
|
|
20502
20558
|
});
|
|
20503
20559
|
},
|
|
20504
20560
|
listenForMobileMoneyCharge: function listenForMobileMoneyCharge(callback) {
|
|
20505
|
-
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) {
|
|
20506
20569
|
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20507
20570
|
}
|
|
20508
|
-
var _this$mobileMoney$dat = this.mobileMoney.data,
|
|
20509
|
-
channel = _this$mobileMoney$dat.channel,
|
|
20510
|
-
channelName = _this$mobileMoney$dat.channel_name;
|
|
20511
20571
|
var listenerOptions = {
|
|
20512
|
-
channel:
|
|
20572
|
+
channel: listenerChannel,
|
|
20513
20573
|
paymentMethod: 'mobile_money'
|
|
20514
20574
|
};
|
|
20515
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);
|
|
20516
20588
|
}
|
|
20517
20589
|
};
|
|
20518
20590
|
|
|
@@ -21255,6 +21327,11 @@ var Paystack = (function (exports) {
|
|
|
21255
21327
|
return this.logError(response.message);
|
|
21256
21328
|
case 'auth':
|
|
21257
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);
|
|
21258
21335
|
default:
|
|
21259
21336
|
return false;
|
|
21260
21337
|
}
|
package/es/checkout.js
CHANGED
|
@@ -6505,7 +6505,7 @@ var ChargeResponses = {
|
|
|
6505
6505
|
if (response.status === 'incorrect-amount-sent' || response.message_type === 'INCORRECT_AMOUNT') {
|
|
6506
6506
|
return this.getCleanResponse(response, 'Incorrect amount sent');
|
|
6507
6507
|
}
|
|
6508
|
-
if (response.status
|
|
6508
|
+
if (['awaiting_registration_token', 'awaiting_ussd_confirmation'].includes(response.status)) {
|
|
6509
6509
|
return this.getCleanResponse(response);
|
|
6510
6510
|
}
|
|
6511
6511
|
if (response.auth && response.auth !== 'none') {
|
|
@@ -6559,6 +6559,58 @@ var subscribeToChargeEvents = function subscribeToChargeEvents(options, context,
|
|
|
6559
6559
|
});
|
|
6560
6560
|
};
|
|
6561
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
|
+
|
|
6562
6614
|
var uncurryThis$7 = functionUncurryThis;
|
|
6563
6615
|
var PROPER_FUNCTION_NAME$2 = functionName.PROPER;
|
|
6564
6616
|
var redefine$4 = redefine$a.exports;
|
|
@@ -20383,6 +20435,10 @@ var MobileMoneyAPI = {
|
|
|
20383
20435
|
}
|
|
20384
20436
|
};
|
|
20385
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'];
|
|
20386
20442
|
function validate$1(phoneNumber) {
|
|
20387
20443
|
return new Promise(function (resolve, reject) {
|
|
20388
20444
|
var validation = PhoneNumber.validate(phoneNumber);
|
|
@@ -20422,11 +20478,11 @@ var MobileMoneyCharge = {
|
|
|
20422
20478
|
mobileMoneyChargeAPI: function mobileMoneyChargeAPI(params) {
|
|
20423
20479
|
var _this = this;
|
|
20424
20480
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
20425
|
-
if (response.status
|
|
20481
|
+
if (LISTENABLE_CHARGE_STATUSES.includes(response.status)) {
|
|
20426
20482
|
_this.mobileMoney = response;
|
|
20427
|
-
|
|
20428
|
-
|
|
20429
|
-
|
|
20483
|
+
}
|
|
20484
|
+
if (response.status === 'success' && response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
20485
|
+
_this.logTokenRequest('mobile money');
|
|
20430
20486
|
}
|
|
20431
20487
|
return response;
|
|
20432
20488
|
});
|
|
@@ -20499,17 +20555,33 @@ var MobileMoneyCharge = {
|
|
|
20499
20555
|
});
|
|
20500
20556
|
},
|
|
20501
20557
|
listenForMobileMoneyCharge: function listenForMobileMoneyCharge(callback) {
|
|
20502
|
-
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) {
|
|
20503
20566
|
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20504
20567
|
}
|
|
20505
|
-
var _this$mobileMoney$dat = this.mobileMoney.data,
|
|
20506
|
-
channel = _this$mobileMoney$dat.channel,
|
|
20507
|
-
channelName = _this$mobileMoney$dat.channel_name;
|
|
20508
20568
|
var listenerOptions = {
|
|
20509
|
-
channel:
|
|
20569
|
+
channel: listenerChannel,
|
|
20510
20570
|
paymentMethod: 'mobile_money'
|
|
20511
20571
|
};
|
|
20512
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);
|
|
20513
20585
|
}
|
|
20514
20586
|
};
|
|
20515
20587
|
|
|
@@ -21252,6 +21324,11 @@ var AnalyticsFunctions$1 = _objectSpread2(_objectSpread2({}, CapitecPayAnalytics
|
|
|
21252
21324
|
return this.logError(response.message);
|
|
21253
21325
|
case 'auth':
|
|
21254
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);
|
|
21255
21332
|
default:
|
|
21256
21333
|
return false;
|
|
21257
21334
|
}
|
package/lib/checkout.js
CHANGED
|
@@ -6509,7 +6509,7 @@ var ChargeResponses = {
|
|
|
6509
6509
|
if (response.status === 'incorrect-amount-sent' || response.message_type === 'INCORRECT_AMOUNT') {
|
|
6510
6510
|
return this.getCleanResponse(response, 'Incorrect amount sent');
|
|
6511
6511
|
}
|
|
6512
|
-
if (response.status
|
|
6512
|
+
if (['awaiting_registration_token', 'awaiting_ussd_confirmation'].includes(response.status)) {
|
|
6513
6513
|
return this.getCleanResponse(response);
|
|
6514
6514
|
}
|
|
6515
6515
|
if (response.auth && response.auth !== 'none') {
|
|
@@ -6563,6 +6563,58 @@ var subscribeToChargeEvents = function subscribeToChargeEvents(options, context,
|
|
|
6563
6563
|
});
|
|
6564
6564
|
};
|
|
6565
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
|
+
|
|
6566
6618
|
var uncurryThis$7 = functionUncurryThis;
|
|
6567
6619
|
var PROPER_FUNCTION_NAME$2 = functionName.PROPER;
|
|
6568
6620
|
var redefine$4 = redefine$a.exports;
|
|
@@ -20387,6 +20439,10 @@ var MobileMoneyAPI = {
|
|
|
20387
20439
|
}
|
|
20388
20440
|
};
|
|
20389
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'];
|
|
20390
20446
|
function validate$1(phoneNumber) {
|
|
20391
20447
|
return new Promise(function (resolve, reject) {
|
|
20392
20448
|
var validation = PhoneNumber.validate(phoneNumber);
|
|
@@ -20426,11 +20482,11 @@ var MobileMoneyCharge = {
|
|
|
20426
20482
|
mobileMoneyChargeAPI: function mobileMoneyChargeAPI(params) {
|
|
20427
20483
|
var _this = this;
|
|
20428
20484
|
return MobileMoneyAPI.charge(params).then(function (response) {
|
|
20429
|
-
if (response.status
|
|
20485
|
+
if (LISTENABLE_CHARGE_STATUSES.includes(response.status)) {
|
|
20430
20486
|
_this.mobileMoney = response;
|
|
20431
|
-
|
|
20432
|
-
|
|
20433
|
-
|
|
20487
|
+
}
|
|
20488
|
+
if (response.status === 'success' && response.data && response.data.display && response.data.display.otpSentCount === 1) {
|
|
20489
|
+
_this.logTokenRequest('mobile money');
|
|
20434
20490
|
}
|
|
20435
20491
|
return response;
|
|
20436
20492
|
});
|
|
@@ -20503,17 +20559,33 @@ var MobileMoneyCharge = {
|
|
|
20503
20559
|
});
|
|
20504
20560
|
},
|
|
20505
20561
|
listenForMobileMoneyCharge: function listenForMobileMoneyCharge(callback) {
|
|
20506
|
-
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) {
|
|
20507
20570
|
return Promise.reject(Error('Please start a mobile money charge with Transaction.chargeMobileMoney()'));
|
|
20508
20571
|
}
|
|
20509
|
-
var _this$mobileMoney$dat = this.mobileMoney.data,
|
|
20510
|
-
channel = _this$mobileMoney$dat.channel,
|
|
20511
|
-
channelName = _this$mobileMoney$dat.channel_name;
|
|
20512
20572
|
var listenerOptions = {
|
|
20513
|
-
channel:
|
|
20573
|
+
channel: listenerChannel,
|
|
20514
20574
|
paymentMethod: 'mobile_money'
|
|
20515
20575
|
};
|
|
20516
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);
|
|
20517
20589
|
}
|
|
20518
20590
|
};
|
|
20519
20591
|
|
|
@@ -21256,6 +21328,11 @@ var AnalyticsFunctions$1 = _objectSpread2(_objectSpread2({}, CapitecPayAnalytics
|
|
|
21256
21328
|
return this.logError(response.message);
|
|
21257
21329
|
case 'auth':
|
|
21258
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);
|
|
21259
21336
|
default:
|
|
21260
21337
|
return false;
|
|
21261
21338
|
}
|