Skip to content

Commit

Permalink
bug #52 [Hot-fix] Handle store with no PayPal payment method defined …
Browse files Browse the repository at this point in the history
…(Zales0123)

This PR was merged into the 1.0-dev branch.

Discussion
----------

Without it, it's impossible to use product, cart and payment page.

Commits
-------

b0f1b9d Handle store with no PayPal payment method defined
  • Loading branch information
Zales0123 authored Aug 14, 2020
2 parents d8fe821 + b0f1b9d commit d6b7f76
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions src/Controller/PayPalButtonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ public function renderProductPageButtonsAction(Request $request): Response
/** @var ChannelInterface $channel */
$channel = $this->channelContext->getChannel();

return new Response($this->twig->render('@SyliusPayPalPlugin/payFromProductPage.html.twig', [
'clientId' => $this->payPalConfigurationProvider->getClientId($channel),
'completeUrl' => $this->router->generate('sylius_shop_checkout_complete'),
'createPayPalOrderFromProductUrl' => $this->router->generate('sylius_paypal_plugin_create_paypal_order_from_product', ['productId' => $productId]),
'processPayPalOrderUrl' => $this->router->generate('sylius_paypal_plugin_process_paypal_order'),
]));
try {
return new Response($this->twig->render('@SyliusPayPalPlugin/payFromProductPage.html.twig', [
'clientId' => $this->payPalConfigurationProvider->getClientId($channel),
'completeUrl' => $this->router->generate('sylius_shop_checkout_complete'),
'createPayPalOrderFromProductUrl' => $this->router->generate('sylius_paypal_plugin_create_paypal_order_from_product', ['productId' => $productId]),
'processPayPalOrderUrl' => $this->router->generate('sylius_paypal_plugin_process_paypal_order'),
]));
} catch (\InvalidArgumentException $exception) {
return new Response('');
}
}

public function renderCartPageButtonsAction(Request $request): Response
Expand All @@ -64,14 +68,18 @@ public function renderCartPageButtonsAction(Request $request): Response
/** @var ChannelInterface $channel */
$channel = $this->channelContext->getChannel();

return new Response($this->twig->render('@SyliusPayPalPlugin/payFromCartPage.html.twig', [
'clientId' => $this->payPalConfigurationProvider->getClientId($channel),
'completeUrl' => $this->router->generate('sylius_shop_checkout_complete'),
'createPayPalOrderFromCartUrl' => $this->router->generate('sylius_paypal_plugin_create_paypal_order_from_cart', ['id' => $orderId]),
'orderId' => $orderId,
'partnerAttributionId' => $this->payPalConfigurationProvider->getPartnerAttributionId($channel),
'processPayPalOrderUrl' => $this->router->generate('sylius_paypal_plugin_process_paypal_order'),
]));
try {
return new Response($this->twig->render('@SyliusPayPalPlugin/payFromCartPage.html.twig', [
'clientId' => $this->payPalConfigurationProvider->getClientId($channel),
'completeUrl' => $this->router->generate('sylius_shop_checkout_complete'),
'createPayPalOrderFromCartUrl' => $this->router->generate('sylius_paypal_plugin_create_paypal_order_from_cart', ['id' => $orderId]),
'orderId' => $orderId,
'partnerAttributionId' => $this->payPalConfigurationProvider->getPartnerAttributionId($channel),
'processPayPalOrderUrl' => $this->router->generate('sylius_paypal_plugin_process_paypal_order'),
]));
} catch (\InvalidArgumentException $exception) {
return new Response('');
}
}

public function renderPaymentPageButtonsAction(Request $request): Response
Expand All @@ -80,11 +88,15 @@ public function renderPaymentPageButtonsAction(Request $request): Response
/** @var ChannelInterface $channel */
$channel = $this->channelContext->getChannel();

return new Response($this->twig->render('@SyliusPayPalPlugin/payFromPaymentPage.html.twig', [
'clientId' => $this->payPalConfigurationProvider->getClientId($channel),
'completePayPalOrderFromPaymentPageUrl' => $this->router->generate('sylius_paypal_plugin_complete_paypal_order_from_payment_page', ['id' => $orderId]),
'createPayPalOrderFromPaymentPageUrl' => $this->router->generate('sylius_paypal_plugin_create_paypal_order_from_payment_page', ['id' => $orderId]),
'partnerAttributionId' => $this->payPalConfigurationProvider->getPartnerAttributionId($channel),
]));
try {
return new Response($this->twig->render('@SyliusPayPalPlugin/payFromPaymentPage.html.twig', [
'clientId' => $this->payPalConfigurationProvider->getClientId($channel),
'completePayPalOrderFromPaymentPageUrl' => $this->router->generate('sylius_paypal_plugin_complete_paypal_order_from_payment_page', ['id' => $orderId]),
'createPayPalOrderFromPaymentPageUrl' => $this->router->generate('sylius_paypal_plugin_create_paypal_order_from_payment_page', ['id' => $orderId]),
'partnerAttributionId' => $this->payPalConfigurationProvider->getPartnerAttributionId($channel),
]));
} catch (\InvalidArgumentException $exception) {
return new Response('');
}
}
}

0 comments on commit d6b7f76

Please sign in to comment.