Skip to content

Commit

Permalink
Added Environment for Google Pay
Browse files Browse the repository at this point in the history
  • Loading branch information
L3RAZ committed Jul 15, 2024
1 parent 72e2fb8 commit f1d7cee
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions ps_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@ public function hookActionFrontControllerSetMedia()
$this->name . 'HostedFieldsEnabled' => $isCardAvailable && $payPalConfiguration->isHostedFieldsEnabled() && in_array($payPalConfiguration->getCardHostedFieldsStatus(), ['SUBSCRIBED', 'LIMITED'], true),
$this->name . 'HostedFieldsSelected' => false !== $psCheckoutCart && $psCheckoutCart->isHostedFields(),
$this->name . 'HostedFieldsContingencies' => $payPalConfiguration->getHostedFieldsContingencies(),
$this->name . 'PayPalEnvironment' => $payPalConfiguration->getPaymentMode(),
$this->name . 'ExpressCheckoutSelected' => false !== $psCheckoutCart && $psCheckoutCart->isExpressCheckout(),
$this->name . 'ExpressCheckoutProductEnabled' => $expressCheckoutConfiguration->isProductPageEnabled() && $payPalConfiguration->isPayPalPaymentsReceivable(),
$this->name . 'ExpressCheckoutCartEnabled' => $expressCheckoutConfiguration->isOrderPageEnabled() && $payPalConfiguration->isPayPalPaymentsReceivable(),
Expand Down Expand Up @@ -1115,21 +1116,34 @@ public function hookActionFrontControllerSetMedia()
],
]);

/** @var \PrestaShop\Module\PrestashopCheckout\Environment\Env $env */
$env = $this->getService(\PrestaShop\Module\PrestashopCheckout\Environment\Env::class);

$foSdkUrl = $env->getEnv('CHECKOUT_FO_SDK_URL');
if (substr($foSdkUrl, -3) !== '.js') {
$foSdkVersion = $env->getEnv('CHECKOUT_FO_SDK_VERSION');
if (empty($foSdkVersion)) {
/** @var \PrestaShop\Module\PrestashopCheckout\Version\Version $version */
$version = $this->getService('ps_checkout.module.version');
$majorModuleVersion = explode('.', $version->getSemVersion())[0];
$foSdkVersion = "$majorModuleVersion.X.X";
}

$foSdkUrl = $foSdkUrl . $foSdkVersion . '/sdk/ps_checkout-fo-sdk.js';
}

if (method_exists($this->context->controller, 'registerJavascript')) {
$this->context->controller->registerJavascript(
$this->name . 'Front',
$this->getPathUri() . 'views/js/front.js?version=' . $version->getSemVersion(),
$foSdkUrl,
[
'position' => 'bottom',
'priority' => 201,
'server' => 'remote',
]
);
} else {
$this->context->controller->addJS(
$this->getPathUri() . 'views/js/front.js?version=' . $version->getSemVersion(),
false
);
$this->context->controller->addJS($foSdkUrl, false);
}
}

Expand Down

0 comments on commit f1d7cee

Please sign in to comment.