@paystack/inline-js 2.26.0-dev.2 → 2.26.0-dev.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/inline.js CHANGED
@@ -2029,6 +2029,13 @@ var PaystackPop = (function () {
2029
2029
  paymentMethod: paymentMethod
2030
2030
  }));
2031
2031
  var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
2032
+ var notifyMerchant = function notifyMerchant(notify) {
2033
+ try {
2034
+ notify();
2035
+ } catch (error) {
2036
+ logWarning("Google Pay: a merchant callback threw. ".concat(error && error.message || error));
2037
+ }
2038
+ };
2032
2039
  client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
2033
2040
  toggleGooglePayLoadingState(_this4.paymentRequestContainer, true);
2034
2041
  return chargeGooglePay({
@@ -2042,11 +2049,9 @@ var PaystackPop = (function () {
2042
2049
  if (response.status === TRANSACTION_STATUS.SUCCESS) {
2043
2050
  var data = response.data,
2044
2051
  envelope = _objectWithoutProperties(response, _excluded3);
2045
- try {
2046
- transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
2047
- } catch (error) {
2048
- logWarning("Google Pay: the onSuccess callback threw. ".concat(error && error.message || error));
2049
- }
2052
+ notifyMerchant(function () {
2053
+ return transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
2054
+ });
2050
2055
  _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
2051
2056
  timeSpent: transaction.getTimeSpent()
2052
2057
  }));
@@ -2056,9 +2061,11 @@ var PaystackPop = (function () {
2056
2061
  // `auth` means a step-up we cannot render here, so say so rather
2057
2062
  // than leaving the customer holding a token with nowhere to go.
2058
2063
  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';
2059
- transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
2060
- message: message
2061
- }));
2064
+ notifyMerchant(function () {
2065
+ return transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
2066
+ message: message
2067
+ }));
2068
+ });
2062
2069
  _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2063
2070
  channel: CHANNELS.GOOGLE_PAY,
2064
2071
  message: message
@@ -2067,7 +2074,9 @@ var PaystackPop = (function () {
2067
2074
  toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
2068
2075
  _this4.isCharging = false;
2069
2076
  if (error && error.statusCode === GOOGLE_PAY_STATUS_CODE.CANCELED) {
2070
- transaction.onCancel();
2077
+ notifyMerchant(function () {
2078
+ return transaction.onCancel();
2079
+ });
2071
2080
  return;
2072
2081
  }
2073
2082
  var statusCode = error && error.statusCode;
@@ -2075,9 +2084,11 @@ var PaystackPop = (function () {
2075
2084
  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."));
2076
2085
  }
2077
2086
  var message = error && (error.statusMessage || error.message) || 'Could not complete the Google Pay payment';
2078
- transaction.onSetupError({
2079
- status: false,
2080
- message: message
2087
+ notifyMerchant(function () {
2088
+ return transaction.onSetupError({
2089
+ status: false,
2090
+ message: message
2091
+ });
2081
2092
  });
2082
2093
  _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2083
2094
  channel: CHANNELS.GOOGLE_PAY,
@@ -2085,9 +2096,12 @@ var PaystackPop = (function () {
2085
2096
  });
2086
2097
  }).catch(function (error) {
2087
2098
  _this4.isCharging = false;
2088
- transaction.onSetupError({
2089
- status: false,
2090
- message: error && error.message || 'Could not complete the Google Pay payment'
2099
+ logWarning("Google Pay: the charge handler failed. ".concat(error && error.message || error));
2100
+ notifyMerchant(function () {
2101
+ return transaction.onSetupError({
2102
+ status: false,
2103
+ message: 'Could not complete the Google Pay payment'
2104
+ });
2091
2105
  });
2092
2106
  });
2093
2107
  } catch (error) {
package/es/inline.js CHANGED
@@ -2026,6 +2026,13 @@ var Inline = /*#__PURE__*/function () {
2026
2026
  paymentMethod: paymentMethod
2027
2027
  }));
2028
2028
  var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
2029
+ var notifyMerchant = function notifyMerchant(notify) {
2030
+ try {
2031
+ notify();
2032
+ } catch (error) {
2033
+ logWarning("Google Pay: a merchant callback threw. ".concat(error && error.message || error));
2034
+ }
2035
+ };
2029
2036
  client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
2030
2037
  toggleGooglePayLoadingState(_this4.paymentRequestContainer, true);
2031
2038
  return chargeGooglePay({
@@ -2039,11 +2046,9 @@ var Inline = /*#__PURE__*/function () {
2039
2046
  if (response.status === TRANSACTION_STATUS.SUCCESS) {
2040
2047
  var data = response.data,
2041
2048
  envelope = _objectWithoutProperties(response, _excluded3);
2042
- try {
2043
- transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
2044
- } catch (error) {
2045
- logWarning("Google Pay: the onSuccess callback threw. ".concat(error && error.message || error));
2046
- }
2049
+ notifyMerchant(function () {
2050
+ return transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
2051
+ });
2047
2052
  _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
2048
2053
  timeSpent: transaction.getTimeSpent()
2049
2054
  }));
@@ -2053,9 +2058,11 @@ var Inline = /*#__PURE__*/function () {
2053
2058
  // `auth` means a step-up we cannot render here, so say so rather
2054
2059
  // than leaving the customer holding a token with nowhere to go.
2055
2060
  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';
2056
- transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
2057
- message: message
2058
- }));
2061
+ notifyMerchant(function () {
2062
+ return transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
2063
+ message: message
2064
+ }));
2065
+ });
2059
2066
  _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2060
2067
  channel: CHANNELS.GOOGLE_PAY,
2061
2068
  message: message
@@ -2064,7 +2071,9 @@ var Inline = /*#__PURE__*/function () {
2064
2071
  toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
2065
2072
  _this4.isCharging = false;
2066
2073
  if (error && error.statusCode === GOOGLE_PAY_STATUS_CODE.CANCELED) {
2067
- transaction.onCancel();
2074
+ notifyMerchant(function () {
2075
+ return transaction.onCancel();
2076
+ });
2068
2077
  return;
2069
2078
  }
2070
2079
  var statusCode = error && error.statusCode;
@@ -2072,9 +2081,11 @@ var Inline = /*#__PURE__*/function () {
2072
2081
  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."));
2073
2082
  }
2074
2083
  var message = error && (error.statusMessage || error.message) || 'Could not complete the Google Pay payment';
2075
- transaction.onSetupError({
2076
- status: false,
2077
- message: message
2084
+ notifyMerchant(function () {
2085
+ return transaction.onSetupError({
2086
+ status: false,
2087
+ message: message
2088
+ });
2078
2089
  });
2079
2090
  _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2080
2091
  channel: CHANNELS.GOOGLE_PAY,
@@ -2082,9 +2093,12 @@ var Inline = /*#__PURE__*/function () {
2082
2093
  });
2083
2094
  }).catch(function (error) {
2084
2095
  _this4.isCharging = false;
2085
- transaction.onSetupError({
2086
- status: false,
2087
- message: error && error.message || 'Could not complete the Google Pay payment'
2096
+ logWarning("Google Pay: the charge handler failed. ".concat(error && error.message || error));
2097
+ notifyMerchant(function () {
2098
+ return transaction.onSetupError({
2099
+ status: false,
2100
+ message: 'Could not complete the Google Pay payment'
2101
+ });
2088
2102
  });
2089
2103
  });
2090
2104
  } catch (error) {
package/lib/inline.js CHANGED
@@ -2028,6 +2028,13 @@ var Inline = /*#__PURE__*/function () {
2028
2028
  paymentMethod: paymentMethod
2029
2029
  }));
2030
2030
  var client = getGooglePayClient(resolveGooglePayEnvironment(transaction.response));
2031
+ var notifyMerchant = function notifyMerchant(notify) {
2032
+ try {
2033
+ notify();
2034
+ } catch (error) {
2035
+ logWarning("Google Pay: a merchant callback threw. ".concat(error && error.message || error));
2036
+ }
2037
+ };
2031
2038
  client.loadPaymentData(buildPaymentDataRequest(transaction)).then(function (paymentData) {
2032
2039
  toggleGooglePayLoadingState(_this4.paymentRequestContainer, true);
2033
2040
  return chargeGooglePay({
@@ -2041,11 +2048,9 @@ var Inline = /*#__PURE__*/function () {
2041
2048
  if (response.status === TRANSACTION_STATUS.SUCCESS) {
2042
2049
  var data = response.data,
2043
2050
  envelope = _objectWithoutProperties(response, _excluded3);
2044
- try {
2045
- transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
2046
- } catch (error) {
2047
- logWarning("Google Pay: the onSuccess callback threw. ".concat(error && error.message || error));
2048
- }
2051
+ notifyMerchant(function () {
2052
+ return transaction.onSuccess(_objectSpread2(_objectSpread2({}, data), envelope));
2053
+ });
2049
2054
  _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
2050
2055
  timeSpent: transaction.getTimeSpent()
2051
2056
  }));
@@ -2055,9 +2060,11 @@ var Inline = /*#__PURE__*/function () {
2055
2060
  // `auth` means a step-up we cannot render here, so say so rather
2056
2061
  // than leaving the customer holding a token with nowhere to go.
2057
2062
  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';
2058
- transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
2059
- message: message
2060
- }));
2063
+ notifyMerchant(function () {
2064
+ return transaction.onSetupError(_objectSpread2(_objectSpread2({}, response), {}, {
2065
+ message: message
2066
+ }));
2067
+ });
2061
2068
  _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2062
2069
  channel: CHANNELS.GOOGLE_PAY,
2063
2070
  message: message
@@ -2066,7 +2073,9 @@ var Inline = /*#__PURE__*/function () {
2066
2073
  toggleGooglePayLoadingState(_this4.paymentRequestContainer, false);
2067
2074
  _this4.isCharging = false;
2068
2075
  if (error && error.statusCode === GOOGLE_PAY_STATUS_CODE.CANCELED) {
2069
- transaction.onCancel();
2076
+ notifyMerchant(function () {
2077
+ return transaction.onCancel();
2078
+ });
2070
2079
  return;
2071
2080
  }
2072
2081
  var statusCode = error && error.statusCode;
@@ -2074,9 +2083,11 @@ var Inline = /*#__PURE__*/function () {
2074
2083
  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."));
2075
2084
  }
2076
2085
  var message = error && (error.statusMessage || error.message) || 'Could not complete the Google Pay payment';
2077
- transaction.onSetupError({
2078
- status: false,
2079
- message: message
2086
+ notifyMerchant(function () {
2087
+ return transaction.onSetupError({
2088
+ status: false,
2089
+ message: message
2090
+ });
2080
2091
  });
2081
2092
  _this4.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2082
2093
  channel: CHANNELS.GOOGLE_PAY,
@@ -2084,9 +2095,12 @@ var Inline = /*#__PURE__*/function () {
2084
2095
  });
2085
2096
  }).catch(function (error) {
2086
2097
  _this4.isCharging = false;
2087
- transaction.onSetupError({
2088
- status: false,
2089
- message: error && error.message || 'Could not complete the Google Pay payment'
2098
+ logWarning("Google Pay: the charge handler failed. ".concat(error && error.message || error));
2099
+ notifyMerchant(function () {
2100
+ return transaction.onSetupError({
2101
+ status: false,
2102
+ message: 'Could not complete the Google Pay payment'
2103
+ });
2090
2104
  });
2091
2105
  });
2092
2106
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/inline-js",
3
- "version": "2.26.0-dev.2",
3
+ "version": "2.26.0-dev.3",
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",