@paystack/inline-js 2.27.0-dev.3 → 2.27.0-dev.5

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
@@ -833,17 +833,19 @@ var PaystackPop = (function () {
833
833
  var buildCardPaymentMethod = function buildCardPaymentMethod(googlePayConfig, authMethods) {
834
834
  return {
835
835
  type: 'CARD',
836
- parameters: {
836
+ parameters: _objectSpread2({
837
837
  allowedAuthMethods: authMethods,
838
838
  allowedCardNetworks: googlePayConfig.allowed_card_networks,
839
839
  billingAddressRequired: true,
840
840
  billingAddressParameters: googlePayConfig.billing_address_parameters,
841
841
  assuranceDetailsRequired: true
842
- }
842
+ }, googlePayConfig.allowed_issuer_country_codes && googlePayConfig.allowed_issuer_country_codes.length && {
843
+ allowedIssuerCountryCodes: googlePayConfig.allowed_issuer_country_codes
844
+ })
843
845
  };
844
846
  };
845
847
  var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
846
- var merchantInfo = googlePayConfig.merchant_info || {};
848
+ var merchantInfo = googlePayConfig.registered_merchant_info || {};
847
849
  return {
848
850
  merchantId: merchantInfo.merchantId,
849
851
  merchantName: merchantInfo.merchantName,
@@ -851,7 +853,7 @@ var PaystackPop = (function () {
851
853
  };
852
854
  };
853
855
  var warnOnOriginMismatch = function warnOnOriginMismatch(googlePayConfig) {
854
- var registeredOrigin = googlePayConfig.merchant_info && googlePayConfig.merchant_info.merchantOrigin;
856
+ var registeredOrigin = googlePayConfig.registered_merchant_info && googlePayConfig.registered_merchant_info.merchantOrigin;
855
857
  var hostname = window.location.hostname;
856
858
  if (registeredOrigin && registeredOrigin !== hostname) {
857
859
  logWarning("Google Pay: the registered merchantOrigin (\"".concat(registeredOrigin, "\") does not match this page (\"").concat(hostname, "\"). Google may reject the payment sheet. Update the domain in Dashboard > Developers > Google Pay."));
@@ -925,6 +927,11 @@ var PaystackPop = (function () {
925
927
  if (!channels.includes(CHANNELS.GOOGLE_PAY)) {
926
928
  return Promise.resolve(null);
927
929
  }
930
+ var googlePayConfig = getGooglePayConfig(transaction);
931
+ if (googlePayConfig && !googlePayConfig.registered_merchant_info) {
932
+ logWarning('Google Pay: this business has no Google Pay merchant profile, so no Google Pay button is shown. Add one in Dashboard > Developers > Google Pay.');
933
+ return Promise.resolve(null);
934
+ }
928
935
  var loadSdk = hasGooglePaySDKLoaded() ? Promise.resolve(true) : loadScript(GOOGLE_PAY_SDK_SOURCE).then(function () {
929
936
  return hasGooglePaySDKLoaded();
930
937
  });
@@ -939,6 +946,16 @@ var PaystackPop = (function () {
939
946
  };
940
947
 
941
948
  var _excluded$2 = ["height", "width", "borderRadius", "buttonRadius"];
949
+
950
+ // Outside production, checkout calls the legacy API on a VPN-only host, so the
951
+ // checkout frame needs Local Network Access delegated from the merchant page.
952
+ function getCheckoutIframeAllow() {
953
+ var features = ['payment', 'clipboard-read', 'clipboard-write'];
954
+ if (config.environment !== ENVIRONMENT.PRODUCTION) {
955
+ features.push('local-network-access');
956
+ }
957
+ return features.join('; ');
958
+ }
942
959
  function createIframe(id) {
943
960
  var iframe = document.createElement('iframe');
944
961
  iframe.setAttribute('frameBorder', '0');
@@ -955,7 +972,7 @@ var PaystackPop = (function () {
955
972
  iframe.style.cssText = checkoutCSS;
956
973
  iframe.style.colorScheme = 'light';
957
974
  iframe.setAttribute('allowpaymentrequest', 'true');
958
- iframe.setAttribute('allow', 'payment; clipboard-read; clipboard-write');
975
+ iframe.setAttribute('allow', getCheckoutIframeAllow());
959
976
  document.body.appendChild(iframe);
960
977
  return iframe;
961
978
  }
@@ -977,7 +994,7 @@ var PaystackPop = (function () {
977
994
  iframe.id = id;
978
995
  iframe.name = id;
979
996
  iframe.setAttribute('allowpaymentrequest', 'true');
980
- iframe.setAttribute('allow', 'payment; clipboard-read; clipboard-write');
997
+ iframe.setAttribute('allow', getCheckoutIframeAllow());
981
998
  return iframe;
982
999
  }
983
1000
  function getApplePayButton(container) {
package/es/inline.js CHANGED
@@ -830,17 +830,19 @@ var buildBaseRequest = function buildBaseRequest(googlePayConfig) {
830
830
  var buildCardPaymentMethod = function buildCardPaymentMethod(googlePayConfig, authMethods) {
831
831
  return {
832
832
  type: 'CARD',
833
- parameters: {
833
+ parameters: _objectSpread2({
834
834
  allowedAuthMethods: authMethods,
835
835
  allowedCardNetworks: googlePayConfig.allowed_card_networks,
836
836
  billingAddressRequired: true,
837
837
  billingAddressParameters: googlePayConfig.billing_address_parameters,
838
838
  assuranceDetailsRequired: true
839
- }
839
+ }, googlePayConfig.allowed_issuer_country_codes && googlePayConfig.allowed_issuer_country_codes.length && {
840
+ allowedIssuerCountryCodes: googlePayConfig.allowed_issuer_country_codes
841
+ })
840
842
  };
841
843
  };
842
844
  var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
843
- var merchantInfo = googlePayConfig.merchant_info || {};
845
+ var merchantInfo = googlePayConfig.registered_merchant_info || {};
844
846
  return {
845
847
  merchantId: merchantInfo.merchantId,
846
848
  merchantName: merchantInfo.merchantName,
@@ -848,7 +850,7 @@ var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
848
850
  };
849
851
  };
850
852
  var warnOnOriginMismatch = function warnOnOriginMismatch(googlePayConfig) {
851
- var registeredOrigin = googlePayConfig.merchant_info && googlePayConfig.merchant_info.merchantOrigin;
853
+ var registeredOrigin = googlePayConfig.registered_merchant_info && googlePayConfig.registered_merchant_info.merchantOrigin;
852
854
  var hostname = window.location.hostname;
853
855
  if (registeredOrigin && registeredOrigin !== hostname) {
854
856
  logWarning("Google Pay: the registered merchantOrigin (\"".concat(registeredOrigin, "\") does not match this page (\"").concat(hostname, "\"). Google may reject the payment sheet. Update the domain in Dashboard > Developers > Google Pay."));
@@ -922,6 +924,11 @@ var loadGooglePay = function loadGooglePay(transaction) {
922
924
  if (!channels.includes(CHANNELS.GOOGLE_PAY)) {
923
925
  return Promise.resolve(null);
924
926
  }
927
+ var googlePayConfig = getGooglePayConfig(transaction);
928
+ if (googlePayConfig && !googlePayConfig.registered_merchant_info) {
929
+ logWarning('Google Pay: this business has no Google Pay merchant profile, so no Google Pay button is shown. Add one in Dashboard > Developers > Google Pay.');
930
+ return Promise.resolve(null);
931
+ }
925
932
  var loadSdk = hasGooglePaySDKLoaded() ? Promise.resolve(true) : loadScript(GOOGLE_PAY_SDK_SOURCE).then(function () {
926
933
  return hasGooglePaySDKLoaded();
927
934
  });
@@ -936,6 +943,16 @@ var loadGooglePay = function loadGooglePay(transaction) {
936
943
  };
937
944
 
938
945
  var _excluded$2 = ["height", "width", "borderRadius", "buttonRadius"];
946
+
947
+ // Outside production, checkout calls the legacy API on a VPN-only host, so the
948
+ // checkout frame needs Local Network Access delegated from the merchant page.
949
+ function getCheckoutIframeAllow() {
950
+ var features = ['payment', 'clipboard-read', 'clipboard-write'];
951
+ if (config.environment !== ENVIRONMENT.PRODUCTION) {
952
+ features.push('local-network-access');
953
+ }
954
+ return features.join('; ');
955
+ }
939
956
  function createIframe(id) {
940
957
  var iframe = document.createElement('iframe');
941
958
  iframe.setAttribute('frameBorder', '0');
@@ -952,7 +969,7 @@ function mountCheckoutIframe(id) {
952
969
  iframe.style.cssText = checkoutCSS;
953
970
  iframe.style.colorScheme = 'light';
954
971
  iframe.setAttribute('allowpaymentrequest', 'true');
955
- iframe.setAttribute('allow', 'payment; clipboard-read; clipboard-write');
972
+ iframe.setAttribute('allow', getCheckoutIframeAllow());
956
973
  document.body.appendChild(iframe);
957
974
  return iframe;
958
975
  }
@@ -974,7 +991,7 @@ function mountEmbedCheckoutIframe(id, src) {
974
991
  iframe.id = id;
975
992
  iframe.name = id;
976
993
  iframe.setAttribute('allowpaymentrequest', 'true');
977
- iframe.setAttribute('allow', 'payment; clipboard-read; clipboard-write');
994
+ iframe.setAttribute('allow', getCheckoutIframeAllow());
978
995
  return iframe;
979
996
  }
980
997
  function getApplePayButton(container) {
package/lib/inline.js CHANGED
@@ -832,17 +832,19 @@ var buildBaseRequest = function buildBaseRequest(googlePayConfig) {
832
832
  var buildCardPaymentMethod = function buildCardPaymentMethod(googlePayConfig, authMethods) {
833
833
  return {
834
834
  type: 'CARD',
835
- parameters: {
835
+ parameters: _objectSpread2({
836
836
  allowedAuthMethods: authMethods,
837
837
  allowedCardNetworks: googlePayConfig.allowed_card_networks,
838
838
  billingAddressRequired: true,
839
839
  billingAddressParameters: googlePayConfig.billing_address_parameters,
840
840
  assuranceDetailsRequired: true
841
- }
841
+ }, googlePayConfig.allowed_issuer_country_codes && googlePayConfig.allowed_issuer_country_codes.length && {
842
+ allowedIssuerCountryCodes: googlePayConfig.allowed_issuer_country_codes
843
+ })
842
844
  };
843
845
  };
844
846
  var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
845
- var merchantInfo = googlePayConfig.merchant_info || {};
847
+ var merchantInfo = googlePayConfig.registered_merchant_info || {};
846
848
  return {
847
849
  merchantId: merchantInfo.merchantId,
848
850
  merchantName: merchantInfo.merchantName,
@@ -850,7 +852,7 @@ var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
850
852
  };
851
853
  };
852
854
  var warnOnOriginMismatch = function warnOnOriginMismatch(googlePayConfig) {
853
- var registeredOrigin = googlePayConfig.merchant_info && googlePayConfig.merchant_info.merchantOrigin;
855
+ var registeredOrigin = googlePayConfig.registered_merchant_info && googlePayConfig.registered_merchant_info.merchantOrigin;
854
856
  var hostname = window.location.hostname;
855
857
  if (registeredOrigin && registeredOrigin !== hostname) {
856
858
  logWarning("Google Pay: the registered merchantOrigin (\"".concat(registeredOrigin, "\") does not match this page (\"").concat(hostname, "\"). Google may reject the payment sheet. Update the domain in Dashboard > Developers > Google Pay."));
@@ -924,6 +926,11 @@ var loadGooglePay = function loadGooglePay(transaction) {
924
926
  if (!channels.includes(CHANNELS.GOOGLE_PAY)) {
925
927
  return Promise.resolve(null);
926
928
  }
929
+ var googlePayConfig = getGooglePayConfig(transaction);
930
+ if (googlePayConfig && !googlePayConfig.registered_merchant_info) {
931
+ logWarning('Google Pay: this business has no Google Pay merchant profile, so no Google Pay button is shown. Add one in Dashboard > Developers > Google Pay.');
932
+ return Promise.resolve(null);
933
+ }
927
934
  var loadSdk = hasGooglePaySDKLoaded() ? Promise.resolve(true) : loadScript(GOOGLE_PAY_SDK_SOURCE).then(function () {
928
935
  return hasGooglePaySDKLoaded();
929
936
  });
@@ -938,6 +945,16 @@ var loadGooglePay = function loadGooglePay(transaction) {
938
945
  };
939
946
 
940
947
  var _excluded$2 = ["height", "width", "borderRadius", "buttonRadius"];
948
+
949
+ // Outside production, checkout calls the legacy API on a VPN-only host, so the
950
+ // checkout frame needs Local Network Access delegated from the merchant page.
951
+ function getCheckoutIframeAllow() {
952
+ var features = ['payment', 'clipboard-read', 'clipboard-write'];
953
+ if (config.environment !== ENVIRONMENT.PRODUCTION) {
954
+ features.push('local-network-access');
955
+ }
956
+ return features.join('; ');
957
+ }
941
958
  function createIframe(id) {
942
959
  var iframe = document.createElement('iframe');
943
960
  iframe.setAttribute('frameBorder', '0');
@@ -954,7 +971,7 @@ function mountCheckoutIframe(id) {
954
971
  iframe.style.cssText = checkoutCSS;
955
972
  iframe.style.colorScheme = 'light';
956
973
  iframe.setAttribute('allowpaymentrequest', 'true');
957
- iframe.setAttribute('allow', 'payment; clipboard-read; clipboard-write');
974
+ iframe.setAttribute('allow', getCheckoutIframeAllow());
958
975
  document.body.appendChild(iframe);
959
976
  return iframe;
960
977
  }
@@ -976,7 +993,7 @@ function mountEmbedCheckoutIframe(id, src) {
976
993
  iframe.id = id;
977
994
  iframe.name = id;
978
995
  iframe.setAttribute('allowpaymentrequest', 'true');
979
- iframe.setAttribute('allow', 'payment; clipboard-read; clipboard-write');
996
+ iframe.setAttribute('allow', getCheckoutIframeAllow());
980
997
  return iframe;
981
998
  }
982
999
  function getApplePayButton(container) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/inline-js",
3
- "version": "2.27.0-dev.3",
3
+ "version": "2.27.0-dev.5",
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",