@paystack/inline-js 2.25.0-dev.5 → 2.25.0-dev.7
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 +55 -14
- package/dist/inline.js +93 -82
- package/es/inline.js +93 -82
- package/lib/inline.js +93 -82
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,7 +108,7 @@ paystackInstance.newTransaction({
|
|
|
108
108
|
| id | Autogenerated id for the Popup instance | `String` |
|
|
109
109
|
| backgroundDiv | A placeholder div that shows a loading indicator when the main checkout iFrame is loading | `domElement` |
|
|
110
110
|
| checkoutIframe | The iframe where the payment happens | `domElement` |
|
|
111
|
-
| paymentRequestContainer | The div container for wallet payment buttons i.e Apple Pay
|
|
111
|
+
| paymentRequestContainer | The div container for wallet payment buttons i.e Apple Pay and Google Pay | `domElement` \| `null` |
|
|
112
112
|
|
|
113
113
|
## Object Methods
|
|
114
114
|
|
|
@@ -139,7 +139,7 @@ This method starts a new transaction on the checkout form.
|
|
|
139
139
|
| lastName | False | `String` | The last name of the customer |
|
|
140
140
|
| phone | False | `String` | The phone number of the customer |
|
|
141
141
|
| customerCode | False | `String` | A valid Paystack customer code. If provided, this overrides all the customer information above |
|
|
142
|
-
| channels | False | `Array` | An array of payment channels to use. By default, all options available in
|
|
142
|
+
| channels | False | `Array` | An array of payment channels to use. By default, all options available in PaystackPop.CHANNELS are used. `google_pay` has to be passed alongside `card`. On its own the transaction will not initialize |
|
|
143
143
|
| paymentRequest | False | `String` | A valid Paystack payment request id |
|
|
144
144
|
| paymentPage | False | `String` | A valid Paystack payment page id |
|
|
145
145
|
| metadata | False | Object | A valid object of extra information that you want to be saved to the transaction. To show this on the dashboard, see [Seeing your metadata on the dashboard](#tip-seeing-your-metadata-on-the-dashboard) |
|
|
@@ -318,7 +318,7 @@ try {
|
|
|
318
318
|
|
|
319
319
|
# PaystackPop.checkout({options})
|
|
320
320
|
|
|
321
|
-
This method loads a transaction on the checkout form
|
|
321
|
+
This method loads a transaction on the checkout form.
|
|
322
322
|
|
|
323
323
|
## Configuration Options
|
|
324
324
|
|
|
@@ -380,7 +380,7 @@ async function checkout(amount) {
|
|
|
380
380
|
|
|
381
381
|
# PaystackPop.paymentRequest({options})
|
|
382
382
|
|
|
383
|
-
This method mounts
|
|
383
|
+
This method mounts wallet payment buttons e.g Apple Pay, Google Pay on a provided div, and also provides the option to allow a provided button open the checkout form.
|
|
384
384
|
|
|
385
385
|
## General Configuration Options
|
|
386
386
|
|
|
@@ -390,15 +390,49 @@ All General and Custom configuration options that are accepted by [PaystackPop.n
|
|
|
390
390
|
|
|
391
391
|
| Option | Required | Type | Description |
|
|
392
392
|
| ----------------------------- | -------------- | --------------------| ---------------------------------------------------- |
|
|
393
|
-
| container | True | `String` | ID of div to mount the payment request
|
|
393
|
+
| container | True | `String` | ID of div to mount the payment request buttons |
|
|
394
394
|
| loadPaystackCheckoutButton | False | `String` | ID of button to open checkout form |
|
|
395
|
-
| styles | False | `Object` |
|
|
395
|
+
| styles | False | `Object` | Layout and button styling. See [Styling Options](#styling-options) |
|
|
396
|
+
|
|
397
|
+
### Styling Options
|
|
398
|
+
|
|
399
|
+
| Option | Type | Default | Description |
|
|
400
|
+
| ----------- | ----------------------------- | -------------- | -------------------------------------------------------------------------------------------------------- |
|
|
401
|
+
| theme | `'dark'` or `'light'` | `'dark'` | Sets both buttons to their black or white variant |
|
|
402
|
+
| orientation | `'horizontal'` or `'vertical'` | `'horizontal'` | Horizontal shares the row equally between the buttons. Vertical stacks them, each at its natural width |
|
|
403
|
+
| applePay | `Object` | See below | Apple Pay button styling |
|
|
404
|
+
| googlePay | `Object` | See below | Google Pay button styling |
|
|
405
|
+
|
|
406
|
+
#### styles.applePay
|
|
407
|
+
|
|
408
|
+
| Option | Type | Default |
|
|
409
|
+
| ------------ | -------- | --------- |
|
|
410
|
+
| width | `String` | `'auto'` |
|
|
411
|
+
| height | `String` | `'50px'` |
|
|
412
|
+
| borderRadius | `String` | `'3px'` |
|
|
413
|
+
| padding | `String` | `'10px'` |
|
|
414
|
+
| type | `String` | `'pay'` |
|
|
415
|
+
| locale | `String` | `'en'` |
|
|
416
|
+
|
|
417
|
+
#### styles.googlePay
|
|
418
|
+
|
|
419
|
+
`width` and `height` size the button. Every other key is passed straight through to Google's [`createButton`](https://developers.google.com/pay/api/web/reference/client#createButton), so anything it accepts works here, including overriding the defaults below.
|
|
420
|
+
|
|
421
|
+
| Option | Type | Default |
|
|
422
|
+
| -------------- | -------- | -------------------- |
|
|
423
|
+
| width | `String` | `'auto'` |
|
|
424
|
+
| height | `String` | `'50px'` |
|
|
425
|
+
| buttonType | `String` | `'pay'` |
|
|
426
|
+
| buttonRadius | `Number` | `3` |
|
|
427
|
+
| buttonColor | `String` | Follows `styles.theme` |
|
|
428
|
+
| buttonSizeMode | `String` | `'fill'` |
|
|
429
|
+
|
|
396
430
|
|
|
397
431
|
### Configuration Options for Callbacks
|
|
432
|
+
|
|
398
433
|
| Event name | Description | Response properties |
|
|
399
434
|
| ---------------------------- | -------------------------------------------------------- | -----------------------------------|
|
|
400
|
-
| onElementsMount | Called
|
|
401
|
-
|
|
435
|
+
| onElementsMount | Called once mounting has finished for both wallets | `{ applePay: Boolean, googlePay: Boolean }`, or `null` if mounting failed |
|
|
402
436
|
|
|
403
437
|
## Method Response
|
|
404
438
|
|
|
@@ -406,7 +440,7 @@ This method returns a Promise which resolves to a [PopupTransaction Instance](#t
|
|
|
406
440
|
|
|
407
441
|
## For Example
|
|
408
442
|
|
|
409
|
-
Mount
|
|
443
|
+
Mount the wallet buttons, and change the text of the button to open the checkout form if either of them appears
|
|
410
444
|
|
|
411
445
|
```html
|
|
412
446
|
<div id="payment-request-buttons"></div>
|
|
@@ -417,28 +451,35 @@ Mount a payment button and change the text of the button to open the checkout fo
|
|
|
417
451
|
const paystackPop = new PaystackPop();
|
|
418
452
|
|
|
419
453
|
const onElementsMount = (elements) => {
|
|
420
|
-
if (elements && elements.applePay) {
|
|
454
|
+
if (elements && (elements.applePay || elements.googlePay)) {
|
|
421
455
|
document.querySelector("#pay-button").innerText = "More Payment Options";
|
|
422
456
|
}
|
|
423
457
|
}
|
|
424
458
|
|
|
425
|
-
async function
|
|
459
|
+
async function loadPaymentRequestButtons() {
|
|
426
460
|
try {
|
|
427
461
|
await paystackPop.paymentRequest({
|
|
428
462
|
key: config.publicLiveKey,
|
|
429
463
|
email: 'testuser@paystack.com',
|
|
430
464
|
amount: 10000,
|
|
431
465
|
currency: "NGN",
|
|
466
|
+
// google_pay needs card alongside it to show
|
|
467
|
+
channels: ["card", "apple_pay", "google_pay"],
|
|
432
468
|
container: 'payment-request-buttons',
|
|
433
469
|
loadPaystackCheckoutButton: 'pay-button',
|
|
434
470
|
styles: {
|
|
435
471
|
theme: 'dark',
|
|
472
|
+
orientation: 'horizontal',
|
|
436
473
|
applePay: {
|
|
437
|
-
width: '100%',
|
|
438
474
|
height: '50px',
|
|
439
475
|
borderRadius: '3px',
|
|
440
476
|
type: 'plain',
|
|
441
477
|
locale: 'en'
|
|
478
|
+
},
|
|
479
|
+
googlePay: {
|
|
480
|
+
height: '50px',
|
|
481
|
+
buttonRadius: 3,
|
|
482
|
+
buttonType: 'pay'
|
|
442
483
|
}
|
|
443
484
|
},
|
|
444
485
|
onElementsMount,
|
|
@@ -448,7 +489,7 @@ async function loadApplePayButton() {
|
|
|
448
489
|
}
|
|
449
490
|
}
|
|
450
491
|
|
|
451
|
-
|
|
492
|
+
loadPaymentRequestButtons()
|
|
452
493
|
```
|
|
453
494
|
|
|
454
495
|
---
|
|
@@ -493,4 +534,4 @@ Paystack Inline is designed to support all recent versions of major browsers. Th
|
|
|
493
534
|
|
|
494
535
|
If you have an issue with Paystack Inline on a specific browser, kindly reach out to us so we can quickly resolve any issues.
|
|
495
536
|
|
|
496
|
-
* We don't support Opera Mini because Javascript is disabled in it. We support the Opera browser however, except in super saver mode where JS is disabled as well.
|
|
537
|
+
* We don't support Opera Mini because Javascript is disabled in it. We support the Opera browser however, except in super saver mode where JS is disabled as well.
|
package/dist/inline.js
CHANGED
|
@@ -948,7 +948,6 @@ var PaystackPop = (function () {
|
|
|
948
948
|
}));
|
|
949
949
|
var buttonContainer = document.createElement('div');
|
|
950
950
|
buttonContainer.id = 'google-pay-button-container';
|
|
951
|
-
container.appendChild(buttonContainer);
|
|
952
951
|
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
|
|
953
952
|
var button = client.createButton(_objectSpread2(_objectSpread2({
|
|
954
953
|
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black',
|
|
@@ -959,6 +958,7 @@ var PaystackPop = (function () {
|
|
|
959
958
|
onClick: onClick,
|
|
960
959
|
allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
|
|
961
960
|
}));
|
|
961
|
+
container.appendChild(buttonContainer);
|
|
962
962
|
var buttonWrapper = document.createElement('div');
|
|
963
963
|
buttonWrapper.id = 'google-pay-button';
|
|
964
964
|
buttonWrapper.appendChild(button);
|
|
@@ -1750,7 +1750,8 @@ var PaystackPop = (function () {
|
|
|
1750
1750
|
}();
|
|
1751
1751
|
|
|
1752
1752
|
var _excluded = ["preload", "inlineTransaction", "transactionData"],
|
|
1753
|
-
_excluded2 = ["container", "styles", "onElementsMount"]
|
|
1753
|
+
_excluded2 = ["container", "styles", "onElementsMount"],
|
|
1754
|
+
_excluded3 = ["data"];
|
|
1754
1755
|
var inlineInstance;
|
|
1755
1756
|
function findResumableTransaction(transactions, parameters) {
|
|
1756
1757
|
if (!transactions.length) {
|
|
@@ -1864,8 +1865,9 @@ var PaystackPop = (function () {
|
|
|
1864
1865
|
transactionData = _ref.transactionData,
|
|
1865
1866
|
options = _objectWithoutProperties(_ref, _excluded);
|
|
1866
1867
|
var hasPaymentRequestButtons = this.hasMountedPaymentRequestButtons();
|
|
1867
|
-
|
|
1868
|
-
|
|
1868
|
+
var activeTransaction = this.activeTransaction();
|
|
1869
|
+
if (activeTransaction && !hasPaymentRequestButtons && activeTransaction !== inlineTransaction) {
|
|
1870
|
+
activeTransaction.cancel();
|
|
1869
1871
|
}
|
|
1870
1872
|
if (inlineTransaction && transactionData) {
|
|
1871
1873
|
if (!this.transactions.includes(inlineTransaction)) {
|
|
@@ -1919,6 +1921,7 @@ var PaystackPop = (function () {
|
|
|
1919
1921
|
}, {
|
|
1920
1922
|
key: "paymentRequest",
|
|
1921
1923
|
value: function paymentRequest(parameters) {
|
|
1924
|
+
var _this3 = this;
|
|
1922
1925
|
var container = parameters.container,
|
|
1923
1926
|
styles = parameters.styles,
|
|
1924
1927
|
onElementsMount = parameters.onElementsMount,
|
|
@@ -1945,10 +1948,10 @@ var PaystackPop = (function () {
|
|
|
1945
1948
|
transaction: transaction,
|
|
1946
1949
|
styles: styles,
|
|
1947
1950
|
onClickApplePayButton: function onClickApplePayButton() {
|
|
1948
|
-
return
|
|
1951
|
+
return _this3.startApplePay();
|
|
1949
1952
|
},
|
|
1950
1953
|
onClickGooglePayButton: function onClickGooglePayButton() {
|
|
1951
|
-
return
|
|
1954
|
+
return _this3.startGooglePay();
|
|
1952
1955
|
}
|
|
1953
1956
|
}).then(function (mountedElements) {
|
|
1954
1957
|
if (onElementsMount) {
|
|
@@ -1987,81 +1990,88 @@ var PaystackPop = (function () {
|
|
|
1987
1990
|
}, {
|
|
1988
1991
|
key: "startGooglePay",
|
|
1989
1992
|
value: function startGooglePay() {
|
|
1990
|
-
var
|
|
1993
|
+
var _this4 = this;
|
|
1991
1994
|
var paymentMethod = 'google pay';
|
|
1992
1995
|
var transaction = this.activeTransaction();
|
|
1993
|
-
if (
|
|
1994
|
-
|
|
1995
|
-
return;
|
|
1996
|
-
}
|
|
1997
|
-
if (this.isCharging) {
|
|
1998
|
-
return;
|
|
1999
|
-
}
|
|
2000
|
-
this.isCharging = true;
|
|
2001
|
-
var analyticsPayload = {
|
|
2002
|
-
channel: CHANNELS.GOOGLE_PAY,
|
|
2003
|
-
currency: transaction.response.currency,
|
|
2004
|
-
amount: getChannelAmount(transaction.response, CHANNELS.GOOGLE_PAY)
|
|
2005
|
-
};
|
|
2006
|
-
transaction.logAttempt(paymentMethod);
|
|
2007
|
-
this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2008
|
-
paymentMethod: paymentMethod
|
|
2009
|
-
}));
|
|
2010
|
-
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response.domain === TRANSACTION_DOMAIN.TEST));
|
|
2011
|
-
client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
|
|
2012
|
-
toggleGooglePayLoadingState(_this3.paymentRequestContainer, true);
|
|
2013
|
-
return chargeGooglePay({
|
|
2014
|
-
transactionId: transaction.id,
|
|
2015
|
-
paymentData: paymentData
|
|
2016
|
-
});
|
|
2017
|
-
}).then(function (response) {
|
|
2018
|
-
toggleGooglePayLoadingState(_this3.paymentRequestContainer, false);
|
|
2019
|
-
_this3.isCharging = false;
|
|
2020
|
-
transaction.logAPIResponse(response, paymentMethod);
|
|
2021
|
-
if (response.status === TRANSACTION_STATUS.SUCCESS) {
|
|
2022
|
-
transaction.onSuccess(response);
|
|
2023
|
-
_this3.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2024
|
-
timeSpent: transaction.getTimeSpent()
|
|
2025
|
-
}));
|
|
1996
|
+
if (transaction) {
|
|
1997
|
+
if (this.isCharging) {
|
|
2026
1998
|
return;
|
|
2027
1999
|
}
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
// than leaving the customer holding a token with nowhere to go.
|
|
2031
|
-
var message = response.status === TRANSACTION_STATUS.AUTH ? 'This card requires additional authentication, which is not supported here. Please use another payment method.' : response && response.message || 'Transaction attempt failed';
|
|
2032
|
-
transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
|
|
2033
|
-
message: message
|
|
2034
|
-
}));
|
|
2035
|
-
_this3.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2000
|
+
this.isCharging = true;
|
|
2001
|
+
var analyticsPayload = {
|
|
2036
2002
|
channel: CHANNELS.GOOGLE_PAY,
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2003
|
+
currency: transaction.response.currency,
|
|
2004
|
+
amount: getChannelAmount(transaction.response, CHANNELS.GOOGLE_PAY)
|
|
2005
|
+
};
|
|
2006
|
+
try {
|
|
2007
|
+
transaction.logAttempt(paymentMethod);
|
|
2008
|
+
this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2009
|
+
paymentMethod: paymentMethod
|
|
2010
|
+
}));
|
|
2011
|
+
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
|
|
2012
|
+
client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
|
|
2013
|
+
toggleGooglePayLoadingState(_this4.paymentRequestContainer, true);
|
|
2014
|
+
return chargeGooglePay({
|
|
2015
|
+
transactionId: transaction.id,
|
|
2016
|
+
paymentData: paymentData
|
|
2017
|
+
});
|
|
2018
|
+
}).then(function (response) {
|
|
2019
|
+
toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
|
|
2020
|
+
_this4.isCharging = false;
|
|
2021
|
+
transaction.logAPIResponse(response, paymentMethod);
|
|
2022
|
+
if (response.status === TRANSACTION_STATUS.SUCCESS) {
|
|
2023
|
+
var data = response.data,
|
|
2024
|
+
envelope = _objectWithoutProperties(response, _excluded3);
|
|
2025
|
+
transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
|
|
2026
|
+
_this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2027
|
+
timeSpent: transaction.getTimeSpent()
|
|
2028
|
+
}));
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
// `auth` means a step-up we cannot render here, so say so rather
|
|
2033
|
+
// than leaving the customer holding a token with nowhere to go.
|
|
2034
|
+
var message = response.status === TRANSACTION_STATUS.AUTH ? 'This card requires additional authentication, which is not supported here. Please use another payment method.' : response && response.message || 'Transaction attempt failed';
|
|
2035
|
+
transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
|
|
2036
|
+
message: message
|
|
2037
|
+
}));
|
|
2038
|
+
_this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2039
|
+
channel: CHANNELS.GOOGLE_PAY,
|
|
2040
|
+
message: message
|
|
2041
|
+
});
|
|
2042
|
+
}).catch(function (error) {
|
|
2043
|
+
toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
|
|
2044
|
+
_this4.isCharging = false;
|
|
2045
|
+
if (error && error.statusCode === GOOGLE_PAY_STATUS_CODE.CANCELED) {
|
|
2046
|
+
transaction.onCancel();
|
|
2047
|
+
return;
|
|
2048
|
+
}
|
|
2049
|
+
var statusCode = error && error.statusCode;
|
|
2050
|
+
if (statusCode === GOOGLE_PAY_STATUS_CODE.DEVELOPER_ERROR || statusCode === GOOGLE_PAY_STATUS_CODE.MERCHANT_ACCOUNT_ERROR) {
|
|
2051
|
+
logWarning("Google Pay: ".concat(statusCode, ". Google rejected the merchant or the origin serving the button. Check that the merchant ID and domain saved in Dashboard > Developers > Google Pay match this page."));
|
|
2052
|
+
}
|
|
2053
|
+
var message = error && (error.statusMessage || error.message) || 'Could not complete the Google Pay payment';
|
|
2054
|
+
transaction.onSetupError({
|
|
2055
|
+
status: false,
|
|
2056
|
+
message: message
|
|
2057
|
+
});
|
|
2058
|
+
_this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2059
|
+
channel: CHANNELS.GOOGLE_PAY,
|
|
2060
|
+
message: message
|
|
2061
|
+
});
|
|
2062
|
+
});
|
|
2063
|
+
} catch (error) {
|
|
2064
|
+
this.isCharging = false;
|
|
2065
|
+
transaction.onSetupError(error);
|
|
2049
2066
|
}
|
|
2050
|
-
|
|
2051
|
-
transaction
|
|
2052
|
-
|
|
2053
|
-
message: message
|
|
2054
|
-
});
|
|
2055
|
-
_this3.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2056
|
-
channel: CHANNELS.GOOGLE_PAY,
|
|
2057
|
-
message: message
|
|
2058
|
-
});
|
|
2059
|
-
});
|
|
2067
|
+
} else {
|
|
2068
|
+
handleError('Could not initiate google pay transaction');
|
|
2069
|
+
}
|
|
2060
2070
|
}
|
|
2061
2071
|
}, {
|
|
2062
2072
|
key: "startApplePay",
|
|
2063
2073
|
value: function startApplePay() {
|
|
2064
|
-
var
|
|
2074
|
+
var _this5 = this;
|
|
2065
2075
|
var paymentMethod = 'apple pay';
|
|
2066
2076
|
var transaction = this.activeTransaction();
|
|
2067
2077
|
if (transaction) {
|
|
@@ -2095,18 +2105,19 @@ var PaystackPop = (function () {
|
|
|
2095
2105
|
});
|
|
2096
2106
|
validateSession.then(function (response) {
|
|
2097
2107
|
if (response.status !== TRANSACTION_STATUS.SUCCESS) {
|
|
2098
|
-
|
|
2108
|
+
_this5.isCharging = false;
|
|
2099
2109
|
transaction.onSetupError(response);
|
|
2100
2110
|
} else {
|
|
2101
2111
|
applePaySession.completeMerchantValidation(response.data);
|
|
2102
2112
|
}
|
|
2103
2113
|
transaction.logValidationResponse(response.message);
|
|
2104
2114
|
}).catch(function (error) {
|
|
2115
|
+
_this5.isCharging = false;
|
|
2105
2116
|
transaction.onSetupError(error);
|
|
2106
2117
|
});
|
|
2107
2118
|
};
|
|
2108
2119
|
applePaySession.oncancel = function () {
|
|
2109
|
-
|
|
2120
|
+
_this5.isCharging = false;
|
|
2110
2121
|
transaction.onCancel();
|
|
2111
2122
|
};
|
|
2112
2123
|
applePaySession.onpaymentauthorized = function (_ref3) {
|
|
@@ -2117,26 +2128,26 @@ var PaystackPop = (function () {
|
|
|
2117
2128
|
});
|
|
2118
2129
|
charge.then(function (response) {
|
|
2119
2130
|
transaction.logAPIResponse(response, paymentMethod);
|
|
2120
|
-
|
|
2131
|
+
_this5.isCharging = false;
|
|
2121
2132
|
if (response.status === TRANSACTION_STATUS.SUCCESS) {
|
|
2122
2133
|
applePaySession.completePayment(applePaySession.STATUS_SUCCESS);
|
|
2123
2134
|
transaction.onSuccess(response);
|
|
2124
|
-
|
|
2135
|
+
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2125
2136
|
timeSpent: transaction.getTimeSpent()
|
|
2126
2137
|
}));
|
|
2127
2138
|
} else {
|
|
2128
2139
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2129
2140
|
transaction.onSetupError(response);
|
|
2130
|
-
|
|
2141
|
+
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2131
2142
|
channel: CHANNELS.APPLE_PAY,
|
|
2132
2143
|
message: response && response.message || 'Transaction attempt failed'
|
|
2133
2144
|
});
|
|
2134
2145
|
}
|
|
2135
2146
|
}).catch(function (error) {
|
|
2136
|
-
|
|
2147
|
+
_this5.isCharging = false;
|
|
2137
2148
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2138
2149
|
transaction.onSetupError(error);
|
|
2139
|
-
|
|
2150
|
+
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2140
2151
|
channel: CHANNELS.APPLE_PAY,
|
|
2141
2152
|
message: error && error.message || 'Error occurred'
|
|
2142
2153
|
});
|
|
@@ -2294,7 +2305,7 @@ var PaystackPop = (function () {
|
|
|
2294
2305
|
}, {
|
|
2295
2306
|
key: "animateCheckoutIn",
|
|
2296
2307
|
value: function animateCheckoutIn$1() {
|
|
2297
|
-
var
|
|
2308
|
+
var _this6 = this;
|
|
2298
2309
|
if (!this.isOpen) {
|
|
2299
2310
|
var checkoutIframe = this.checkoutIframe,
|
|
2300
2311
|
backgroundIframe = this.backgroundIframe;
|
|
@@ -2302,7 +2313,7 @@ var PaystackPop = (function () {
|
|
|
2302
2313
|
checkoutIframe: checkoutIframe,
|
|
2303
2314
|
backgroundIframe: backgroundIframe
|
|
2304
2315
|
}).then(function () {
|
|
2305
|
-
|
|
2316
|
+
_this6.checkoutIframe.contentWindow.postMessage('render', '*');
|
|
2306
2317
|
});
|
|
2307
2318
|
this.isOpen = true;
|
|
2308
2319
|
}
|
|
@@ -2325,7 +2336,7 @@ var PaystackPop = (function () {
|
|
|
2325
2336
|
}, {
|
|
2326
2337
|
key: "close",
|
|
2327
2338
|
value: function close() {
|
|
2328
|
-
var
|
|
2339
|
+
var _this7 = this;
|
|
2329
2340
|
if (!this.isOpen) {
|
|
2330
2341
|
return;
|
|
2331
2342
|
}
|
|
@@ -2335,7 +2346,7 @@ var PaystackPop = (function () {
|
|
|
2335
2346
|
checkoutIframe: checkoutIframe,
|
|
2336
2347
|
backgroundIframe: backgroundIframe
|
|
2337
2348
|
}).then(function () {
|
|
2338
|
-
|
|
2349
|
+
_this7.checkoutIframe.contentWindow.postMessage('close', '*');
|
|
2339
2350
|
});
|
|
2340
2351
|
this.isOpen = false;
|
|
2341
2352
|
}
|
package/es/inline.js
CHANGED
|
@@ -945,7 +945,6 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
945
945
|
}));
|
|
946
946
|
var buttonContainer = document.createElement('div');
|
|
947
947
|
buttonContainer.id = 'google-pay-button-container';
|
|
948
|
-
container.appendChild(buttonContainer);
|
|
949
948
|
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
|
|
950
949
|
var button = client.createButton(_objectSpread2(_objectSpread2({
|
|
951
950
|
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black',
|
|
@@ -956,6 +955,7 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
956
955
|
onClick: onClick,
|
|
957
956
|
allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
|
|
958
957
|
}));
|
|
958
|
+
container.appendChild(buttonContainer);
|
|
959
959
|
var buttonWrapper = document.createElement('div');
|
|
960
960
|
buttonWrapper.id = 'google-pay-button';
|
|
961
961
|
buttonWrapper.appendChild(button);
|
|
@@ -1747,7 +1747,8 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1747
1747
|
}();
|
|
1748
1748
|
|
|
1749
1749
|
var _excluded = ["preload", "inlineTransaction", "transactionData"],
|
|
1750
|
-
_excluded2 = ["container", "styles", "onElementsMount"]
|
|
1750
|
+
_excluded2 = ["container", "styles", "onElementsMount"],
|
|
1751
|
+
_excluded3 = ["data"];
|
|
1751
1752
|
var inlineInstance;
|
|
1752
1753
|
function findResumableTransaction(transactions, parameters) {
|
|
1753
1754
|
if (!transactions.length) {
|
|
@@ -1861,8 +1862,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1861
1862
|
transactionData = _ref.transactionData,
|
|
1862
1863
|
options = _objectWithoutProperties(_ref, _excluded);
|
|
1863
1864
|
var hasPaymentRequestButtons = this.hasMountedPaymentRequestButtons();
|
|
1864
|
-
|
|
1865
|
-
|
|
1865
|
+
var activeTransaction = this.activeTransaction();
|
|
1866
|
+
if (activeTransaction && !hasPaymentRequestButtons && activeTransaction !== inlineTransaction) {
|
|
1867
|
+
activeTransaction.cancel();
|
|
1866
1868
|
}
|
|
1867
1869
|
if (inlineTransaction && transactionData) {
|
|
1868
1870
|
if (!this.transactions.includes(inlineTransaction)) {
|
|
@@ -1916,6 +1918,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1916
1918
|
}, {
|
|
1917
1919
|
key: "paymentRequest",
|
|
1918
1920
|
value: function paymentRequest(parameters) {
|
|
1921
|
+
var _this3 = this;
|
|
1919
1922
|
var container = parameters.container,
|
|
1920
1923
|
styles = parameters.styles,
|
|
1921
1924
|
onElementsMount = parameters.onElementsMount,
|
|
@@ -1942,10 +1945,10 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1942
1945
|
transaction: transaction,
|
|
1943
1946
|
styles: styles,
|
|
1944
1947
|
onClickApplePayButton: function onClickApplePayButton() {
|
|
1945
|
-
return
|
|
1948
|
+
return _this3.startApplePay();
|
|
1946
1949
|
},
|
|
1947
1950
|
onClickGooglePayButton: function onClickGooglePayButton() {
|
|
1948
|
-
return
|
|
1951
|
+
return _this3.startGooglePay();
|
|
1949
1952
|
}
|
|
1950
1953
|
}).then(function (mountedElements) {
|
|
1951
1954
|
if (onElementsMount) {
|
|
@@ -1984,81 +1987,88 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1984
1987
|
}, {
|
|
1985
1988
|
key: "startGooglePay",
|
|
1986
1989
|
value: function startGooglePay() {
|
|
1987
|
-
var
|
|
1990
|
+
var _this4 = this;
|
|
1988
1991
|
var paymentMethod = 'google pay';
|
|
1989
1992
|
var transaction = this.activeTransaction();
|
|
1990
|
-
if (
|
|
1991
|
-
|
|
1992
|
-
return;
|
|
1993
|
-
}
|
|
1994
|
-
if (this.isCharging) {
|
|
1995
|
-
return;
|
|
1996
|
-
}
|
|
1997
|
-
this.isCharging = true;
|
|
1998
|
-
var analyticsPayload = {
|
|
1999
|
-
channel: CHANNELS.GOOGLE_PAY,
|
|
2000
|
-
currency: transaction.response.currency,
|
|
2001
|
-
amount: getChannelAmount(transaction.response, CHANNELS.GOOGLE_PAY)
|
|
2002
|
-
};
|
|
2003
|
-
transaction.logAttempt(paymentMethod);
|
|
2004
|
-
this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2005
|
-
paymentMethod: paymentMethod
|
|
2006
|
-
}));
|
|
2007
|
-
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response.domain === TRANSACTION_DOMAIN.TEST));
|
|
2008
|
-
client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
|
|
2009
|
-
toggleGooglePayLoadingState(_this3.paymentRequestContainer, true);
|
|
2010
|
-
return chargeGooglePay({
|
|
2011
|
-
transactionId: transaction.id,
|
|
2012
|
-
paymentData: paymentData
|
|
2013
|
-
});
|
|
2014
|
-
}).then(function (response) {
|
|
2015
|
-
toggleGooglePayLoadingState(_this3.paymentRequestContainer, false);
|
|
2016
|
-
_this3.isCharging = false;
|
|
2017
|
-
transaction.logAPIResponse(response, paymentMethod);
|
|
2018
|
-
if (response.status === TRANSACTION_STATUS.SUCCESS) {
|
|
2019
|
-
transaction.onSuccess(response);
|
|
2020
|
-
_this3.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2021
|
-
timeSpent: transaction.getTimeSpent()
|
|
2022
|
-
}));
|
|
1993
|
+
if (transaction) {
|
|
1994
|
+
if (this.isCharging) {
|
|
2023
1995
|
return;
|
|
2024
1996
|
}
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
// than leaving the customer holding a token with nowhere to go.
|
|
2028
|
-
var message = response.status === TRANSACTION_STATUS.AUTH ? 'This card requires additional authentication, which is not supported here. Please use another payment method.' : response && response.message || 'Transaction attempt failed';
|
|
2029
|
-
transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
|
|
2030
|
-
message: message
|
|
2031
|
-
}));
|
|
2032
|
-
_this3.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
1997
|
+
this.isCharging = true;
|
|
1998
|
+
var analyticsPayload = {
|
|
2033
1999
|
channel: CHANNELS.GOOGLE_PAY,
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2000
|
+
currency: transaction.response.currency,
|
|
2001
|
+
amount: getChannelAmount(transaction.response, CHANNELS.GOOGLE_PAY)
|
|
2002
|
+
};
|
|
2003
|
+
try {
|
|
2004
|
+
transaction.logAttempt(paymentMethod);
|
|
2005
|
+
this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2006
|
+
paymentMethod: paymentMethod
|
|
2007
|
+
}));
|
|
2008
|
+
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
|
|
2009
|
+
client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
|
|
2010
|
+
toggleGooglePayLoadingState(_this4.paymentRequestContainer, true);
|
|
2011
|
+
return chargeGooglePay({
|
|
2012
|
+
transactionId: transaction.id,
|
|
2013
|
+
paymentData: paymentData
|
|
2014
|
+
});
|
|
2015
|
+
}).then(function (response) {
|
|
2016
|
+
toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
|
|
2017
|
+
_this4.isCharging = false;
|
|
2018
|
+
transaction.logAPIResponse(response, paymentMethod);
|
|
2019
|
+
if (response.status === TRANSACTION_STATUS.SUCCESS) {
|
|
2020
|
+
var data = response.data,
|
|
2021
|
+
envelope = _objectWithoutProperties(response, _excluded3);
|
|
2022
|
+
transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
|
|
2023
|
+
_this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2024
|
+
timeSpent: transaction.getTimeSpent()
|
|
2025
|
+
}));
|
|
2026
|
+
return;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
// `auth` means a step-up we cannot render here, so say so rather
|
|
2030
|
+
// than leaving the customer holding a token with nowhere to go.
|
|
2031
|
+
var message = response.status === TRANSACTION_STATUS.AUTH ? 'This card requires additional authentication, which is not supported here. Please use another payment method.' : response && response.message || 'Transaction attempt failed';
|
|
2032
|
+
transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
|
|
2033
|
+
message: message
|
|
2034
|
+
}));
|
|
2035
|
+
_this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2036
|
+
channel: CHANNELS.GOOGLE_PAY,
|
|
2037
|
+
message: message
|
|
2038
|
+
});
|
|
2039
|
+
}).catch(function (error) {
|
|
2040
|
+
toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
|
|
2041
|
+
_this4.isCharging = false;
|
|
2042
|
+
if (error && error.statusCode === GOOGLE_PAY_STATUS_CODE.CANCELED) {
|
|
2043
|
+
transaction.onCancel();
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
var statusCode = error && error.statusCode;
|
|
2047
|
+
if (statusCode === GOOGLE_PAY_STATUS_CODE.DEVELOPER_ERROR || statusCode === GOOGLE_PAY_STATUS_CODE.MERCHANT_ACCOUNT_ERROR) {
|
|
2048
|
+
logWarning("Google Pay: ".concat(statusCode, ". Google rejected the merchant or the origin serving the button. Check that the merchant ID and domain saved in Dashboard > Developers > Google Pay match this page."));
|
|
2049
|
+
}
|
|
2050
|
+
var message = error && (error.statusMessage || error.message) || 'Could not complete the Google Pay payment';
|
|
2051
|
+
transaction.onSetupError({
|
|
2052
|
+
status: false,
|
|
2053
|
+
message: message
|
|
2054
|
+
});
|
|
2055
|
+
_this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2056
|
+
channel: CHANNELS.GOOGLE_PAY,
|
|
2057
|
+
message: message
|
|
2058
|
+
});
|
|
2059
|
+
});
|
|
2060
|
+
} catch (error) {
|
|
2061
|
+
this.isCharging = false;
|
|
2062
|
+
transaction.onSetupError(error);
|
|
2046
2063
|
}
|
|
2047
|
-
|
|
2048
|
-
transaction
|
|
2049
|
-
|
|
2050
|
-
message: message
|
|
2051
|
-
});
|
|
2052
|
-
_this3.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2053
|
-
channel: CHANNELS.GOOGLE_PAY,
|
|
2054
|
-
message: message
|
|
2055
|
-
});
|
|
2056
|
-
});
|
|
2064
|
+
} else {
|
|
2065
|
+
handleError('Could not initiate google pay transaction');
|
|
2066
|
+
}
|
|
2057
2067
|
}
|
|
2058
2068
|
}, {
|
|
2059
2069
|
key: "startApplePay",
|
|
2060
2070
|
value: function startApplePay() {
|
|
2061
|
-
var
|
|
2071
|
+
var _this5 = this;
|
|
2062
2072
|
var paymentMethod = 'apple pay';
|
|
2063
2073
|
var transaction = this.activeTransaction();
|
|
2064
2074
|
if (transaction) {
|
|
@@ -2092,18 +2102,19 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2092
2102
|
});
|
|
2093
2103
|
validateSession.then(function (response) {
|
|
2094
2104
|
if (response.status !== TRANSACTION_STATUS.SUCCESS) {
|
|
2095
|
-
|
|
2105
|
+
_this5.isCharging = false;
|
|
2096
2106
|
transaction.onSetupError(response);
|
|
2097
2107
|
} else {
|
|
2098
2108
|
applePaySession.completeMerchantValidation(response.data);
|
|
2099
2109
|
}
|
|
2100
2110
|
transaction.logValidationResponse(response.message);
|
|
2101
2111
|
}).catch(function (error) {
|
|
2112
|
+
_this5.isCharging = false;
|
|
2102
2113
|
transaction.onSetupError(error);
|
|
2103
2114
|
});
|
|
2104
2115
|
};
|
|
2105
2116
|
applePaySession.oncancel = function () {
|
|
2106
|
-
|
|
2117
|
+
_this5.isCharging = false;
|
|
2107
2118
|
transaction.onCancel();
|
|
2108
2119
|
};
|
|
2109
2120
|
applePaySession.onpaymentauthorized = function (_ref3) {
|
|
@@ -2114,26 +2125,26 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2114
2125
|
});
|
|
2115
2126
|
charge.then(function (response) {
|
|
2116
2127
|
transaction.logAPIResponse(response, paymentMethod);
|
|
2117
|
-
|
|
2128
|
+
_this5.isCharging = false;
|
|
2118
2129
|
if (response.status === TRANSACTION_STATUS.SUCCESS) {
|
|
2119
2130
|
applePaySession.completePayment(applePaySession.STATUS_SUCCESS);
|
|
2120
2131
|
transaction.onSuccess(response);
|
|
2121
|
-
|
|
2132
|
+
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2122
2133
|
timeSpent: transaction.getTimeSpent()
|
|
2123
2134
|
}));
|
|
2124
2135
|
} else {
|
|
2125
2136
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2126
2137
|
transaction.onSetupError(response);
|
|
2127
|
-
|
|
2138
|
+
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2128
2139
|
channel: CHANNELS.APPLE_PAY,
|
|
2129
2140
|
message: response && response.message || 'Transaction attempt failed'
|
|
2130
2141
|
});
|
|
2131
2142
|
}
|
|
2132
2143
|
}).catch(function (error) {
|
|
2133
|
-
|
|
2144
|
+
_this5.isCharging = false;
|
|
2134
2145
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2135
2146
|
transaction.onSetupError(error);
|
|
2136
|
-
|
|
2147
|
+
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2137
2148
|
channel: CHANNELS.APPLE_PAY,
|
|
2138
2149
|
message: error && error.message || 'Error occurred'
|
|
2139
2150
|
});
|
|
@@ -2291,7 +2302,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2291
2302
|
}, {
|
|
2292
2303
|
key: "animateCheckoutIn",
|
|
2293
2304
|
value: function animateCheckoutIn$1() {
|
|
2294
|
-
var
|
|
2305
|
+
var _this6 = this;
|
|
2295
2306
|
if (!this.isOpen) {
|
|
2296
2307
|
var checkoutIframe = this.checkoutIframe,
|
|
2297
2308
|
backgroundIframe = this.backgroundIframe;
|
|
@@ -2299,7 +2310,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2299
2310
|
checkoutIframe: checkoutIframe,
|
|
2300
2311
|
backgroundIframe: backgroundIframe
|
|
2301
2312
|
}).then(function () {
|
|
2302
|
-
|
|
2313
|
+
_this6.checkoutIframe.contentWindow.postMessage('render', '*');
|
|
2303
2314
|
});
|
|
2304
2315
|
this.isOpen = true;
|
|
2305
2316
|
}
|
|
@@ -2322,7 +2333,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2322
2333
|
}, {
|
|
2323
2334
|
key: "close",
|
|
2324
2335
|
value: function close() {
|
|
2325
|
-
var
|
|
2336
|
+
var _this7 = this;
|
|
2326
2337
|
if (!this.isOpen) {
|
|
2327
2338
|
return;
|
|
2328
2339
|
}
|
|
@@ -2332,7 +2343,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2332
2343
|
checkoutIframe: checkoutIframe,
|
|
2333
2344
|
backgroundIframe: backgroundIframe
|
|
2334
2345
|
}).then(function () {
|
|
2335
|
-
|
|
2346
|
+
_this7.checkoutIframe.contentWindow.postMessage('close', '*');
|
|
2336
2347
|
});
|
|
2337
2348
|
this.isOpen = false;
|
|
2338
2349
|
}
|
package/lib/inline.js
CHANGED
|
@@ -947,7 +947,6 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
947
947
|
}));
|
|
948
948
|
var buttonContainer = document.createElement('div');
|
|
949
949
|
buttonContainer.id = 'google-pay-button-container';
|
|
950
|
-
container.appendChild(buttonContainer);
|
|
951
950
|
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
|
|
952
951
|
var button = client.createButton(_objectSpread2(_objectSpread2({
|
|
953
952
|
buttonColor: styles.theme === PAYMENT_REQUEST_BUTTON_THEME.LIGHT ? 'white' : 'black',
|
|
@@ -958,6 +957,7 @@ function mountGooglePayButton(container, _ref3) {
|
|
|
958
957
|
onClick: onClick,
|
|
959
958
|
allowedPaymentMethods: [buildCardPaymentMethod(googlePayConfig, getSupportedAuthMethods(googlePayConfig))]
|
|
960
959
|
}));
|
|
960
|
+
container.appendChild(buttonContainer);
|
|
961
961
|
var buttonWrapper = document.createElement('div');
|
|
962
962
|
buttonWrapper.id = 'google-pay-button';
|
|
963
963
|
buttonWrapper.appendChild(button);
|
|
@@ -1749,7 +1749,8 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1749
1749
|
}();
|
|
1750
1750
|
|
|
1751
1751
|
var _excluded = ["preload", "inlineTransaction", "transactionData"],
|
|
1752
|
-
_excluded2 = ["container", "styles", "onElementsMount"]
|
|
1752
|
+
_excluded2 = ["container", "styles", "onElementsMount"],
|
|
1753
|
+
_excluded3 = ["data"];
|
|
1753
1754
|
var inlineInstance;
|
|
1754
1755
|
function findResumableTransaction(transactions, parameters) {
|
|
1755
1756
|
if (!transactions.length) {
|
|
@@ -1863,8 +1864,9 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1863
1864
|
transactionData = _ref.transactionData,
|
|
1864
1865
|
options = _objectWithoutProperties(_ref, _excluded);
|
|
1865
1866
|
var hasPaymentRequestButtons = this.hasMountedPaymentRequestButtons();
|
|
1866
|
-
|
|
1867
|
-
|
|
1867
|
+
var activeTransaction = this.activeTransaction();
|
|
1868
|
+
if (activeTransaction && !hasPaymentRequestButtons && activeTransaction !== inlineTransaction) {
|
|
1869
|
+
activeTransaction.cancel();
|
|
1868
1870
|
}
|
|
1869
1871
|
if (inlineTransaction && transactionData) {
|
|
1870
1872
|
if (!this.transactions.includes(inlineTransaction)) {
|
|
@@ -1918,6 +1920,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1918
1920
|
}, {
|
|
1919
1921
|
key: "paymentRequest",
|
|
1920
1922
|
value: function paymentRequest(parameters) {
|
|
1923
|
+
var _this3 = this;
|
|
1921
1924
|
var container = parameters.container,
|
|
1922
1925
|
styles = parameters.styles,
|
|
1923
1926
|
onElementsMount = parameters.onElementsMount,
|
|
@@ -1944,10 +1947,10 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1944
1947
|
transaction: transaction,
|
|
1945
1948
|
styles: styles,
|
|
1946
1949
|
onClickApplePayButton: function onClickApplePayButton() {
|
|
1947
|
-
return
|
|
1950
|
+
return _this3.startApplePay();
|
|
1948
1951
|
},
|
|
1949
1952
|
onClickGooglePayButton: function onClickGooglePayButton() {
|
|
1950
|
-
return
|
|
1953
|
+
return _this3.startGooglePay();
|
|
1951
1954
|
}
|
|
1952
1955
|
}).then(function (mountedElements) {
|
|
1953
1956
|
if (onElementsMount) {
|
|
@@ -1986,81 +1989,88 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1986
1989
|
}, {
|
|
1987
1990
|
key: "startGooglePay",
|
|
1988
1991
|
value: function startGooglePay() {
|
|
1989
|
-
var
|
|
1992
|
+
var _this4 = this;
|
|
1990
1993
|
var paymentMethod = 'google pay';
|
|
1991
1994
|
var transaction = this.activeTransaction();
|
|
1992
|
-
if (
|
|
1993
|
-
|
|
1994
|
-
return;
|
|
1995
|
-
}
|
|
1996
|
-
if (this.isCharging) {
|
|
1997
|
-
return;
|
|
1998
|
-
}
|
|
1999
|
-
this.isCharging = true;
|
|
2000
|
-
var analyticsPayload = {
|
|
2001
|
-
channel: CHANNELS.GOOGLE_PAY,
|
|
2002
|
-
currency: transaction.response.currency,
|
|
2003
|
-
amount: getChannelAmount(transaction.response, CHANNELS.GOOGLE_PAY)
|
|
2004
|
-
};
|
|
2005
|
-
transaction.logAttempt(paymentMethod);
|
|
2006
|
-
this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2007
|
-
paymentMethod: paymentMethod
|
|
2008
|
-
}));
|
|
2009
|
-
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response.domain === TRANSACTION_DOMAIN.TEST));
|
|
2010
|
-
client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
|
|
2011
|
-
toggleGooglePayLoadingState(_this3.paymentRequestContainer, true);
|
|
2012
|
-
return chargeGooglePay({
|
|
2013
|
-
transactionId: transaction.id,
|
|
2014
|
-
paymentData: paymentData
|
|
2015
|
-
});
|
|
2016
|
-
}).then(function (response) {
|
|
2017
|
-
toggleGooglePayLoadingState(_this3.paymentRequestContainer, false);
|
|
2018
|
-
_this3.isCharging = false;
|
|
2019
|
-
transaction.logAPIResponse(response, paymentMethod);
|
|
2020
|
-
if (response.status === TRANSACTION_STATUS.SUCCESS) {
|
|
2021
|
-
transaction.onSuccess(response);
|
|
2022
|
-
_this3.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2023
|
-
timeSpent: transaction.getTimeSpent()
|
|
2024
|
-
}));
|
|
1995
|
+
if (transaction) {
|
|
1996
|
+
if (this.isCharging) {
|
|
2025
1997
|
return;
|
|
2026
1998
|
}
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
// than leaving the customer holding a token with nowhere to go.
|
|
2030
|
-
var message = response.status === TRANSACTION_STATUS.AUTH ? 'This card requires additional authentication, which is not supported here. Please use another payment method.' : response && response.message || 'Transaction attempt failed';
|
|
2031
|
-
transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
|
|
2032
|
-
message: message
|
|
2033
|
-
}));
|
|
2034
|
-
_this3.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
1999
|
+
this.isCharging = true;
|
|
2000
|
+
var analyticsPayload = {
|
|
2035
2001
|
channel: CHANNELS.GOOGLE_PAY,
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2002
|
+
currency: transaction.response.currency,
|
|
2003
|
+
amount: getChannelAmount(transaction.response, CHANNELS.GOOGLE_PAY)
|
|
2004
|
+
};
|
|
2005
|
+
try {
|
|
2006
|
+
transaction.logAttempt(paymentMethod);
|
|
2007
|
+
this.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ATTEMPT, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2008
|
+
paymentMethod: paymentMethod
|
|
2009
|
+
}));
|
|
2010
|
+
var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
|
|
2011
|
+
client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
|
|
2012
|
+
toggleGooglePayLoadingState(_this4.paymentRequestContainer, true);
|
|
2013
|
+
return chargeGooglePay({
|
|
2014
|
+
transactionId: transaction.id,
|
|
2015
|
+
paymentData: paymentData
|
|
2016
|
+
});
|
|
2017
|
+
}).then(function (response) {
|
|
2018
|
+
toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
|
|
2019
|
+
_this4.isCharging = false;
|
|
2020
|
+
transaction.logAPIResponse(response, paymentMethod);
|
|
2021
|
+
if (response.status === TRANSACTION_STATUS.SUCCESS) {
|
|
2022
|
+
var data = response.data,
|
|
2023
|
+
envelope = _objectWithoutProperties(response, _excluded3);
|
|
2024
|
+
transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
|
|
2025
|
+
_this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2026
|
+
timeSpent: transaction.getTimeSpent()
|
|
2027
|
+
}));
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
// `auth` means a step-up we cannot render here, so say so rather
|
|
2032
|
+
// than leaving the customer holding a token with nowhere to go.
|
|
2033
|
+
var message = response.status === TRANSACTION_STATUS.AUTH ? 'This card requires additional authentication, which is not supported here. Please use another payment method.' : response && response.message || 'Transaction attempt failed';
|
|
2034
|
+
transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
|
|
2035
|
+
message: message
|
|
2036
|
+
}));
|
|
2037
|
+
_this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2038
|
+
channel: CHANNELS.GOOGLE_PAY,
|
|
2039
|
+
message: message
|
|
2040
|
+
});
|
|
2041
|
+
}).catch(function (error) {
|
|
2042
|
+
toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
|
|
2043
|
+
_this4.isCharging = false;
|
|
2044
|
+
if (error && error.statusCode === GOOGLE_PAY_STATUS_CODE.CANCELED) {
|
|
2045
|
+
transaction.onCancel();
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2048
|
+
var statusCode = error && error.statusCode;
|
|
2049
|
+
if (statusCode === GOOGLE_PAY_STATUS_CODE.DEVELOPER_ERROR || statusCode === GOOGLE_PAY_STATUS_CODE.MERCHANT_ACCOUNT_ERROR) {
|
|
2050
|
+
logWarning("Google Pay: ".concat(statusCode, ". Google rejected the merchant or the origin serving the button. Check that the merchant ID and domain saved in Dashboard > Developers > Google Pay match this page."));
|
|
2051
|
+
}
|
|
2052
|
+
var message = error && (error.statusMessage || error.message) || 'Could not complete the Google Pay payment';
|
|
2053
|
+
transaction.onSetupError({
|
|
2054
|
+
status: false,
|
|
2055
|
+
message: message
|
|
2056
|
+
});
|
|
2057
|
+
_this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2058
|
+
channel: CHANNELS.GOOGLE_PAY,
|
|
2059
|
+
message: message
|
|
2060
|
+
});
|
|
2061
|
+
});
|
|
2062
|
+
} catch (error) {
|
|
2063
|
+
this.isCharging = false;
|
|
2064
|
+
transaction.onSetupError(error);
|
|
2048
2065
|
}
|
|
2049
|
-
|
|
2050
|
-
transaction
|
|
2051
|
-
|
|
2052
|
-
message: message
|
|
2053
|
-
});
|
|
2054
|
-
_this3.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2055
|
-
channel: CHANNELS.GOOGLE_PAY,
|
|
2056
|
-
message: message
|
|
2057
|
-
});
|
|
2058
|
-
});
|
|
2066
|
+
} else {
|
|
2067
|
+
handleError('Could not initiate google pay transaction');
|
|
2068
|
+
}
|
|
2059
2069
|
}
|
|
2060
2070
|
}, {
|
|
2061
2071
|
key: "startApplePay",
|
|
2062
2072
|
value: function startApplePay() {
|
|
2063
|
-
var
|
|
2073
|
+
var _this5 = this;
|
|
2064
2074
|
var paymentMethod = 'apple pay';
|
|
2065
2075
|
var transaction = this.activeTransaction();
|
|
2066
2076
|
if (transaction) {
|
|
@@ -2094,18 +2104,19 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2094
2104
|
});
|
|
2095
2105
|
validateSession.then(function (response) {
|
|
2096
2106
|
if (response.status !== TRANSACTION_STATUS.SUCCESS) {
|
|
2097
|
-
|
|
2107
|
+
_this5.isCharging = false;
|
|
2098
2108
|
transaction.onSetupError(response);
|
|
2099
2109
|
} else {
|
|
2100
2110
|
applePaySession.completeMerchantValidation(response.data);
|
|
2101
2111
|
}
|
|
2102
2112
|
transaction.logValidationResponse(response.message);
|
|
2103
2113
|
}).catch(function (error) {
|
|
2114
|
+
_this5.isCharging = false;
|
|
2104
2115
|
transaction.onSetupError(error);
|
|
2105
2116
|
});
|
|
2106
2117
|
};
|
|
2107
2118
|
applePaySession.oncancel = function () {
|
|
2108
|
-
|
|
2119
|
+
_this5.isCharging = false;
|
|
2109
2120
|
transaction.onCancel();
|
|
2110
2121
|
};
|
|
2111
2122
|
applePaySession.onpaymentauthorized = function (_ref3) {
|
|
@@ -2116,26 +2127,26 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2116
2127
|
});
|
|
2117
2128
|
charge.then(function (response) {
|
|
2118
2129
|
transaction.logAPIResponse(response, paymentMethod);
|
|
2119
|
-
|
|
2130
|
+
_this5.isCharging = false;
|
|
2120
2131
|
if (response.status === TRANSACTION_STATUS.SUCCESS) {
|
|
2121
2132
|
applePaySession.completePayment(applePaySession.STATUS_SUCCESS);
|
|
2122
2133
|
transaction.onSuccess(response);
|
|
2123
|
-
|
|
2134
|
+
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
|
|
2124
2135
|
timeSpent: transaction.getTimeSpent()
|
|
2125
2136
|
}));
|
|
2126
2137
|
} else {
|
|
2127
2138
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2128
2139
|
transaction.onSetupError(response);
|
|
2129
|
-
|
|
2140
|
+
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2130
2141
|
channel: CHANNELS.APPLE_PAY,
|
|
2131
2142
|
message: response && response.message || 'Transaction attempt failed'
|
|
2132
2143
|
});
|
|
2133
2144
|
}
|
|
2134
2145
|
}).catch(function (error) {
|
|
2135
|
-
|
|
2146
|
+
_this5.isCharging = false;
|
|
2136
2147
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2137
2148
|
transaction.onSetupError(error);
|
|
2138
|
-
|
|
2149
|
+
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2139
2150
|
channel: CHANNELS.APPLE_PAY,
|
|
2140
2151
|
message: error && error.message || 'Error occurred'
|
|
2141
2152
|
});
|
|
@@ -2293,7 +2304,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2293
2304
|
}, {
|
|
2294
2305
|
key: "animateCheckoutIn",
|
|
2295
2306
|
value: function animateCheckoutIn$1() {
|
|
2296
|
-
var
|
|
2307
|
+
var _this6 = this;
|
|
2297
2308
|
if (!this.isOpen) {
|
|
2298
2309
|
var checkoutIframe = this.checkoutIframe,
|
|
2299
2310
|
backgroundIframe = this.backgroundIframe;
|
|
@@ -2301,7 +2312,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2301
2312
|
checkoutIframe: checkoutIframe,
|
|
2302
2313
|
backgroundIframe: backgroundIframe
|
|
2303
2314
|
}).then(function () {
|
|
2304
|
-
|
|
2315
|
+
_this6.checkoutIframe.contentWindow.postMessage('render', '*');
|
|
2305
2316
|
});
|
|
2306
2317
|
this.isOpen = true;
|
|
2307
2318
|
}
|
|
@@ -2324,7 +2335,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2324
2335
|
}, {
|
|
2325
2336
|
key: "close",
|
|
2326
2337
|
value: function close() {
|
|
2327
|
-
var
|
|
2338
|
+
var _this7 = this;
|
|
2328
2339
|
if (!this.isOpen) {
|
|
2329
2340
|
return;
|
|
2330
2341
|
}
|
|
@@ -2334,7 +2345,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2334
2345
|
checkoutIframe: checkoutIframe,
|
|
2335
2346
|
backgroundIframe: backgroundIframe
|
|
2336
2347
|
}).then(function () {
|
|
2337
|
-
|
|
2348
|
+
_this7.checkoutIframe.contentWindow.postMessage('close', '*');
|
|
2338
2349
|
});
|
|
2339
2350
|
this.isOpen = false;
|
|
2340
2351
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paystack/inline-js",
|
|
3
|
-
"version": "2.25.0-dev.
|
|
3
|
+
"version": "2.25.0-dev.7",
|
|
4
4
|
"description": "Client-side library to load the Paystack checkout form",
|
|
5
5
|
"packageManager": "pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800",
|
|
6
6
|
"main": "lib/inline.js",
|