Skip to content

Commit

Permalink
Added a check if domain is registered to Sdk Config builder
Browse files Browse the repository at this point in the history
  • Loading branch information
L3RAZ committed Sep 19, 2024
1 parent b817871 commit 7a5b62b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ps_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class Ps_checkout extends PaymentModule
'PS_CHECKOUT_DISPLAY_LOGO_PRODUCT' => '1',
'PS_CHECKOUT_DISPLAY_LOGO_CART' => '1',
'PS_CHECKOUT_HOSTED_FIELDS_CONTINGENCIES' => 'SCA_WHEN_REQUIRED',
'PS_CHECKOUT_DOMAIN_REGISTERED_SANDBOX' => false,
'PS_CHECKOUT_DOMAIN_REGISTERED_LIVE' => false,
];

public $confirmUninstall;
Expand Down
8 changes: 8 additions & 0 deletions src/PayPal/PayPalConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace PrestaShop\Module\PrestashopCheckout\PayPal;

use Crypto\MAC;
use PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration;
use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException;
use PrestaShop\Module\PrestashopCheckout\Repository\PayPalCodeRepository;
Expand Down Expand Up @@ -52,6 +53,8 @@ class PayPalConfiguration

const PS_CHECKOUT_GOOGLE_PAY = 'PS_CHECKOUT_GOOGLE_PAY';
const PS_CHECKOUT_APPLE_PAY = 'PS_CHECKOUT_APPLE_PAY';
const PS_CHECKOUT_DOMAIN_REGISTERED_SANDBOX = 'PS_CHECKOUT_DOMAIN_REGISTERED_SANDBOX';
const PS_CHECKOUT_DOMAIN_REGISTERED_LIVE = 'PS_CHECKOUT_DOMAIN_REGISTERED_LIVE';

/**
* @var PrestaShopConfiguration
Expand Down Expand Up @@ -454,4 +457,9 @@ public function isApplePayEligible()
{
return (bool) $this->configuration->get(static::PS_CHECKOUT_APPLE_PAY);
}

public function isApplePayDomainRegistered()
{
return (bool) $this->configuration->get($this->getPaymentMode() === Mode::SANDBOX ? static::PS_CHECKOUT_DOMAIN_REGISTERED_SANDBOX : static::PS_CHECKOUT_DOMAIN_REGISTERED_LIVE);
}
}
1 change: 1 addition & 0 deletions src/PayPal/Sdk/PayPalSdkConfigurationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ private function shouldIncludeApplePayComponent()

return $fundingSource && $fundingSource['active']
&& $this->configuration->isApplePayEligible()
&& $this->configuration->isApplePayDomainRegistered()
&& in_array($country, $this->fundingSourceEligibilityConstraint->getCountries('apple_pay'), true)
&& in_array($context->currency->iso_code, $this->fundingSourceEligibilityConstraint->getCurrencies('apple_pay'), true);
}
Expand Down

0 comments on commit 7a5b62b

Please sign in to comment.