Skip to content

Commit

Permalink
Fix EU payments
Browse files Browse the repository at this point in the history
This probably broke after SDK update - redirect information is stored
inside redirect property, and not in performRedirect property.

Closes #69
  • Loading branch information
getdatakick committed Jun 20, 2023
1 parent ca1fa42 commit 9ee80db
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions controllers/front/eupayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ public function __construct()
public function initContent()
{
if (!Module::isEnabled('stripe')) {
Tools::redirect('index.php?controller=order&step=3');
Tools::redirect($this->getCheckoutUrl());
}
$cart = $this->context->cart;
if (!$cart->id_customer || !$cart->id_address_delivery || !$cart->id_address_invoice || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=3');
Tools::redirect($this->getCheckoutUrl());
}

$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=3');
Tools::redirect($this->getCheckoutUrl());
}

parent::initContent();
Expand Down Expand Up @@ -445,10 +445,20 @@ protected function initAlipay()
* @return void
* @throws PrestaShopException
*/
protected function performRedirect(\Stripe\Source $source): void
protected function performRedirect(\Stripe\Source $source)
{
if (isset($source->performRedirect->url)) {
Tools::redirect($source->performRedirect->url);
}
$url = isset($source->redirect->url)
? $source->redirect->url
: $this->getCheckoutUrl();
Tools::redirect($url);
}

/**
* @return string
* @throws PrestaShopException
*/
protected function getCheckoutUrl()
{
return Context::getContext()->link->getPageLink('order', null, null, 'step=3');
}
}

0 comments on commit 9ee80db

Please sign in to comment.