@paystack/inline-js 2.27.0-dev.2 → 2.27.0-dev.4

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
@@ -598,17 +598,26 @@ var PaystackPop = (function () {
598
598
  };
599
599
  var validateApplePaySession = function validateApplePaySession(_ref2) {
600
600
  var transactionId = _ref2.transactionId,
601
+ accessCode = _ref2.accessCode,
602
+ publicKey = _ref2.publicKey,
601
603
  validationURL = _ref2.validationURL,
602
604
  merchantName = _ref2.merchantName,
603
605
  _ref2$domainName = _ref2.domainName,
604
606
  domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
605
607
  var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
606
- var params = {
607
- transaction: transactionId,
608
+
609
+ // createFormBody would send a missing value as the text "undefined"
610
+ var params = _objectSpread2(_objectSpread2(_objectSpread2({
611
+ transaction: transactionId
612
+ }, accessCode && {
613
+ accessCode: accessCode
614
+ }), publicKey && {
615
+ publicKey: publicKey
616
+ }), {}, {
608
617
  sessionUrl: validationURL,
609
618
  displayName: merchantName,
610
619
  domainName: domainName
611
- };
620
+ });
612
621
  var formBody = createFormBody(params);
613
622
  var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
614
623
  body: formBody
@@ -824,17 +833,19 @@ var PaystackPop = (function () {
824
833
  var buildCardPaymentMethod = function buildCardPaymentMethod(googlePayConfig, authMethods) {
825
834
  return {
826
835
  type: 'CARD',
827
- parameters: {
836
+ parameters: _objectSpread2({
828
837
  allowedAuthMethods: authMethods,
829
838
  allowedCardNetworks: googlePayConfig.allowed_card_networks,
830
839
  billingAddressRequired: true,
831
840
  billingAddressParameters: googlePayConfig.billing_address_parameters,
832
841
  assuranceDetailsRequired: true
833
- }
842
+ }, googlePayConfig.allowed_issuer_country_codes && googlePayConfig.allowed_issuer_country_codes.length && {
843
+ allowedIssuerCountryCodes: googlePayConfig.allowed_issuer_country_codes
844
+ })
834
845
  };
835
846
  };
836
847
  var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
837
- var merchantInfo = googlePayConfig.merchant_info || {};
848
+ var merchantInfo = googlePayConfig.registered_merchant_info || {};
838
849
  return {
839
850
  merchantId: merchantInfo.merchantId,
840
851
  merchantName: merchantInfo.merchantName,
@@ -842,7 +853,7 @@ var PaystackPop = (function () {
842
853
  };
843
854
  };
844
855
  var warnOnOriginMismatch = function warnOnOriginMismatch(googlePayConfig) {
845
- var registeredOrigin = googlePayConfig.merchant_info && googlePayConfig.merchant_info.merchantOrigin;
856
+ var registeredOrigin = googlePayConfig.registered_merchant_info && googlePayConfig.registered_merchant_info.merchantOrigin;
846
857
  var hostname = window.location.hostname;
847
858
  if (registeredOrigin && registeredOrigin !== hostname) {
848
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."));
@@ -916,6 +927,11 @@ var PaystackPop = (function () {
916
927
  if (!channels.includes(CHANNELS.GOOGLE_PAY)) {
917
928
  return Promise.resolve(null);
918
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
+ }
919
935
  var loadSdk = hasGooglePaySDKLoaded() ? Promise.resolve(true) : loadScript(GOOGLE_PAY_SDK_SOURCE).then(function () {
920
936
  return hasGooglePaySDKLoaded();
921
937
  });
@@ -2333,6 +2349,8 @@ var PaystackPop = (function () {
2333
2349
  var validateSession = validateApplePaySession({
2334
2350
  validationURL: validationURL,
2335
2351
  transactionId: transaction.id,
2352
+ accessCode: transaction.accessCode,
2353
+ publicKey: transaction.parameters.key,
2336
2354
  merchantName: transaction.response.merchant_name
2337
2355
  });
2338
2356
  validateSession.then(function (response) {
package/es/inline.js CHANGED
@@ -595,17 +595,26 @@ var generateApplePaymentRequestObject = function generateApplePaymentRequestObje
595
595
  };
596
596
  var validateApplePaySession = function validateApplePaySession(_ref2) {
597
597
  var transactionId = _ref2.transactionId,
598
+ accessCode = _ref2.accessCode,
599
+ publicKey = _ref2.publicKey,
598
600
  validationURL = _ref2.validationURL,
599
601
  merchantName = _ref2.merchantName,
600
602
  _ref2$domainName = _ref2.domainName,
601
603
  domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
602
604
  var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
603
- var params = {
604
- transaction: transactionId,
605
+
606
+ // createFormBody would send a missing value as the text "undefined"
607
+ var params = _objectSpread2(_objectSpread2(_objectSpread2({
608
+ transaction: transactionId
609
+ }, accessCode && {
610
+ accessCode: accessCode
611
+ }), publicKey && {
612
+ publicKey: publicKey
613
+ }), {}, {
605
614
  sessionUrl: validationURL,
606
615
  displayName: merchantName,
607
616
  domainName: domainName
608
- };
617
+ });
609
618
  var formBody = createFormBody(params);
610
619
  var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
611
620
  body: formBody
@@ -821,17 +830,19 @@ var buildBaseRequest = function buildBaseRequest(googlePayConfig) {
821
830
  var buildCardPaymentMethod = function buildCardPaymentMethod(googlePayConfig, authMethods) {
822
831
  return {
823
832
  type: 'CARD',
824
- parameters: {
833
+ parameters: _objectSpread2({
825
834
  allowedAuthMethods: authMethods,
826
835
  allowedCardNetworks: googlePayConfig.allowed_card_networks,
827
836
  billingAddressRequired: true,
828
837
  billingAddressParameters: googlePayConfig.billing_address_parameters,
829
838
  assuranceDetailsRequired: true
830
- }
839
+ }, googlePayConfig.allowed_issuer_country_codes && googlePayConfig.allowed_issuer_country_codes.length && {
840
+ allowedIssuerCountryCodes: googlePayConfig.allowed_issuer_country_codes
841
+ })
831
842
  };
832
843
  };
833
844
  var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
834
- var merchantInfo = googlePayConfig.merchant_info || {};
845
+ var merchantInfo = googlePayConfig.registered_merchant_info || {};
835
846
  return {
836
847
  merchantId: merchantInfo.merchantId,
837
848
  merchantName: merchantInfo.merchantName,
@@ -839,7 +850,7 @@ var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
839
850
  };
840
851
  };
841
852
  var warnOnOriginMismatch = function warnOnOriginMismatch(googlePayConfig) {
842
- var registeredOrigin = googlePayConfig.merchant_info && googlePayConfig.merchant_info.merchantOrigin;
853
+ var registeredOrigin = googlePayConfig.registered_merchant_info && googlePayConfig.registered_merchant_info.merchantOrigin;
843
854
  var hostname = window.location.hostname;
844
855
  if (registeredOrigin && registeredOrigin !== hostname) {
845
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."));
@@ -913,6 +924,11 @@ var loadGooglePay = function loadGooglePay(transaction) {
913
924
  if (!channels.includes(CHANNELS.GOOGLE_PAY)) {
914
925
  return Promise.resolve(null);
915
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
+ }
916
932
  var loadSdk = hasGooglePaySDKLoaded() ? Promise.resolve(true) : loadScript(GOOGLE_PAY_SDK_SOURCE).then(function () {
917
933
  return hasGooglePaySDKLoaded();
918
934
  });
@@ -2330,6 +2346,8 @@ var Inline = /*#__PURE__*/function () {
2330
2346
  var validateSession = validateApplePaySession({
2331
2347
  validationURL: validationURL,
2332
2348
  transactionId: transaction.id,
2349
+ accessCode: transaction.accessCode,
2350
+ publicKey: transaction.parameters.key,
2333
2351
  merchantName: transaction.response.merchant_name
2334
2352
  });
2335
2353
  validateSession.then(function (response) {
package/lib/inline.js CHANGED
@@ -597,17 +597,26 @@ var generateApplePaymentRequestObject = function generateApplePaymentRequestObje
597
597
  };
598
598
  var validateApplePaySession = function validateApplePaySession(_ref2) {
599
599
  var transactionId = _ref2.transactionId,
600
+ accessCode = _ref2.accessCode,
601
+ publicKey = _ref2.publicKey,
600
602
  validationURL = _ref2.validationURL,
601
603
  merchantName = _ref2.merchantName,
602
604
  _ref2$domainName = _ref2.domainName,
603
605
  domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
604
606
  var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
605
- var params = {
606
- transaction: transactionId,
607
+
608
+ // createFormBody would send a missing value as the text "undefined"
609
+ var params = _objectSpread2(_objectSpread2(_objectSpread2({
610
+ transaction: transactionId
611
+ }, accessCode && {
612
+ accessCode: accessCode
613
+ }), publicKey && {
614
+ publicKey: publicKey
615
+ }), {}, {
607
616
  sessionUrl: validationURL,
608
617
  displayName: merchantName,
609
618
  domainName: domainName
610
- };
619
+ });
611
620
  var formBody = createFormBody(params);
612
621
  var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
613
622
  body: formBody
@@ -823,17 +832,19 @@ var buildBaseRequest = function buildBaseRequest(googlePayConfig) {
823
832
  var buildCardPaymentMethod = function buildCardPaymentMethod(googlePayConfig, authMethods) {
824
833
  return {
825
834
  type: 'CARD',
826
- parameters: {
835
+ parameters: _objectSpread2({
827
836
  allowedAuthMethods: authMethods,
828
837
  allowedCardNetworks: googlePayConfig.allowed_card_networks,
829
838
  billingAddressRequired: true,
830
839
  billingAddressParameters: googlePayConfig.billing_address_parameters,
831
840
  assuranceDetailsRequired: true
832
- }
841
+ }, googlePayConfig.allowed_issuer_country_codes && googlePayConfig.allowed_issuer_country_codes.length && {
842
+ allowedIssuerCountryCodes: googlePayConfig.allowed_issuer_country_codes
843
+ })
833
844
  };
834
845
  };
835
846
  var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
836
- var merchantInfo = googlePayConfig.merchant_info || {};
847
+ var merchantInfo = googlePayConfig.registered_merchant_info || {};
837
848
  return {
838
849
  merchantId: merchantInfo.merchantId,
839
850
  merchantName: merchantInfo.merchantName,
@@ -841,7 +852,7 @@ var buildMerchantInfo = function buildMerchantInfo(googlePayConfig) {
841
852
  };
842
853
  };
843
854
  var warnOnOriginMismatch = function warnOnOriginMismatch(googlePayConfig) {
844
- var registeredOrigin = googlePayConfig.merchant_info && googlePayConfig.merchant_info.merchantOrigin;
855
+ var registeredOrigin = googlePayConfig.registered_merchant_info && googlePayConfig.registered_merchant_info.merchantOrigin;
845
856
  var hostname = window.location.hostname;
846
857
  if (registeredOrigin && registeredOrigin !== hostname) {
847
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."));
@@ -915,6 +926,11 @@ var loadGooglePay = function loadGooglePay(transaction) {
915
926
  if (!channels.includes(CHANNELS.GOOGLE_PAY)) {
916
927
  return Promise.resolve(null);
917
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
+ }
918
934
  var loadSdk = hasGooglePaySDKLoaded() ? Promise.resolve(true) : loadScript(GOOGLE_PAY_SDK_SOURCE).then(function () {
919
935
  return hasGooglePaySDKLoaded();
920
936
  });
@@ -2332,6 +2348,8 @@ var Inline = /*#__PURE__*/function () {
2332
2348
  var validateSession = validateApplePaySession({
2333
2349
  validationURL: validationURL,
2334
2350
  transactionId: transaction.id,
2351
+ accessCode: transaction.accessCode,
2352
+ publicKey: transaction.parameters.key,
2335
2353
  merchantName: transaction.response.merchant_name
2336
2354
  });
2337
2355
  validateSession.then(function (response) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/inline-js",
3
- "version": "2.27.0-dev.2",
3
+ "version": "2.27.0-dev.4",
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",