first commit
This commit is contained in:
384
apps/frontend/modules/stPayment/actions/actions.class.php
Normal file
384
apps/frontend/modules/stPayment/actions/actions.class.php
Normal file
@@ -0,0 +1,384 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stPayment
|
||||
*
|
||||
* Ten plik należy do aplikacji stPayment opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stPayment
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: actions.class.php 10 2009-08-24 09:32:18Z michal $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>,
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa stPaymentActions
|
||||
*
|
||||
* @package stPayment
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stPaymentActions extends stActions
|
||||
{
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var Order
|
||||
*/
|
||||
protected $order;
|
||||
/**
|
||||
* Przekierowanie na strone główną sklepu jeżeli nie została wybrana żadna akcja
|
||||
*/
|
||||
public function executeIndex()
|
||||
{
|
||||
$this->redirect('@homepage');
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualizowanie dostawy za pomocą Ajax
|
||||
*/
|
||||
public function executeAjaxPaymentTypeUpdate()
|
||||
{
|
||||
$paymnetTypeId = $this->getRequestParameter('id');
|
||||
stPayment::getInstance($this->getContext())->set($paymnetTypeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Akcja obsługująca żądanie ręcznego przekierowania do serwisu płatności
|
||||
*
|
||||
* @return mixed
|
||||
* @throws PropelException
|
||||
* @throws stNotificationException
|
||||
* @throws sfStopException
|
||||
*/
|
||||
public function executePay()
|
||||
{
|
||||
$this->order = OrderPeer::retrieveByIdAndHashCode($this->getRequestParameter('id'), $this->getRequestParameter('hash_code'));
|
||||
|
||||
$currency = stCurrency::getInstance($this->getContext());
|
||||
|
||||
$currency->setByIso($this->order->getOrderCurrency()->getShortcut());
|
||||
|
||||
if ($this->order->getIsPayed())
|
||||
{
|
||||
return $this->redirect('@stOrderSummary?id=' . $this->order->getId() . '&hash_code=' . $this->order->getHashCode());
|
||||
}
|
||||
|
||||
$paymentType = $this->order->getOrderPayment()->getPaymentType();
|
||||
|
||||
if ($paymentType && $paymentType->getApiInstance() instanceof stPaymentTypeInterface)
|
||||
{
|
||||
$url = $this->processPayment($paymentType->getApiInstance(), $this->order);
|
||||
|
||||
return $this->redirect($url);
|
||||
}
|
||||
|
||||
$this->smarty = new stSmarty($this->getModuleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Akcja obsługująca żądanie z automatycznym przekierowaniem do serwisu płatności
|
||||
*
|
||||
* @return sfView::NONE
|
||||
* @throws stPaymentTypeConfigurationException
|
||||
* @throws PropelException
|
||||
* @throws stNotificationException
|
||||
*/
|
||||
public function executeProcessPayment()
|
||||
{
|
||||
$type = $this->getRequestParameter('type');
|
||||
$orderId = $this->getRequestParameter('order_id');
|
||||
$orderHash = $this->getRequestParameter('order_hash');
|
||||
|
||||
$paymentType = stPaymentType::get($type);
|
||||
$order = OrderPeer::retrieveByIdAndHashCode($orderId, $orderHash);
|
||||
|
||||
return $this->renderJSON([
|
||||
'redirect' => $this->processPayment($paymentType, $order)
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Akcja obsługująca żądania błędów podczas przetwarzania płatności
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @throws sfViewException
|
||||
* @throws stPaymentTypeConfigurationException
|
||||
*/
|
||||
public function executeFailure()
|
||||
{
|
||||
$type = $this->getRequestParameter('type');
|
||||
|
||||
$smarty = new stSmarty($this->getModuleName());
|
||||
$webpage = WebpagePeer::retrieveByState('CONTACT');
|
||||
|
||||
if ($webpage)
|
||||
{
|
||||
sfLoader::loadHelpers(array('Helper', 'stUrl'));
|
||||
$smarty->assign('contact_url', st_url_for('stWebpageFrontend/index?url=' . $webpage->getFriendlyUrl()));
|
||||
}
|
||||
|
||||
$paymentType = stPaymentType::get($type);
|
||||
|
||||
$smarty->assign('title', $paymentType->getConfiguration()->getName());
|
||||
$smarty->assign('logo', $paymentType->getLogoPath());
|
||||
$smarty->assign('message', $this->getContext()->getI18N()->__('Wystąpił błąd podczas przetwarzania płatności.'));
|
||||
|
||||
$this->smarty = $smarty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Akcja obsługująca żądania powrotu klienta do sklepu
|
||||
*
|
||||
* @return void
|
||||
* @throws stPaymentTypeConfigurationException
|
||||
* @throws PropelException
|
||||
* @throws sfException
|
||||
* @throws stNotificationException
|
||||
*/
|
||||
public function executeReturn()
|
||||
{
|
||||
$type = $this->getRequestParameter('type');
|
||||
$orderId = $this->getRequestParameter('order_id');
|
||||
$orderHash = $this->getRequestParameter('order_hash');
|
||||
|
||||
$paymentType = stPaymentType::get($type);
|
||||
$logger = $paymentType->getLogger();
|
||||
$order = OrderPeer::retrieveByIdAndHashCode($orderId, $orderHash);
|
||||
|
||||
if (null === $order)
|
||||
{
|
||||
$logger->fatal('Wystąpił nieoczekiwany wyjątek po powrocie klienta do sklepu: `Zamówienie o id **%%id%%** nie istnieje...`', [
|
||||
'%%id%%' => $orderId,
|
||||
]);
|
||||
|
||||
throw new sfException(sprintf('Zamówienie o id **%%id%% nie istnieje...', $orderId));
|
||||
}
|
||||
|
||||
$ok = $paymentType->return($order, $this->getRequest());
|
||||
|
||||
if (false === $ok)
|
||||
{
|
||||
$payment = $order->getOrderPayment();
|
||||
$payment->setCancel(true);
|
||||
$payment->save();
|
||||
|
||||
$logger->info('Płatność dla zamówienia **[%%number%%](%%link%%)** została anulowana na życzenie klienta', [
|
||||
'%%number%%' => $order->getNumber(),
|
||||
'%%link%%' => $this->generateBackendUrl('@stOrder?action=edit&id='.$order->getId()),
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$logger->info('Klient zakończył opłacanie zamówienia **[%%number%%](%%link%%)** i powrócił do sklepu', [
|
||||
'%%number%%' => $order->getNumber(),
|
||||
'%%link%%' => $this->generateBackendUrl('@stOrder?action=edit&id='.$order->getId()),
|
||||
]);
|
||||
|
||||
if (true === $ok)
|
||||
{
|
||||
$this->processPayment($paymentType, $order);
|
||||
}
|
||||
}
|
||||
|
||||
$smarty = new stSmarty($this->getModuleName());
|
||||
$smarty->assign('title', $paymentType->getConfiguration()->getName());
|
||||
$smarty->assign('logo', $paymentType->getLogoPath());
|
||||
$smarty->assign('canceled', false === $ok);
|
||||
|
||||
$this->smarty = $smarty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Akcja obsługująca żądania zmiany statusu płatności
|
||||
*
|
||||
* @return string
|
||||
* @throws stPaymentTypeConfigurationException
|
||||
* @throws PropelException
|
||||
* @throws stNotificationException
|
||||
*/
|
||||
public function executeStatusNotification()
|
||||
{
|
||||
$type = $this->getRequestParameter('type');
|
||||
$orderId = $this->getRequestParameter('order_id');
|
||||
$orderHash = $this->getRequestParameter('order_hash');
|
||||
$securityToken = $this->getRequestParameter('security_token');
|
||||
|
||||
$paymentType = stPaymentType::get($type);
|
||||
$logger = $paymentType->getLogger();
|
||||
$order = OrderPeer::retrieveByIdAndHashCode($orderId, $orderHash);
|
||||
|
||||
$logger->info('Przetwarzanie powiadomienia o statusie płatności');
|
||||
|
||||
if (null === $order)
|
||||
{
|
||||
$paymentType->getLogger()->fatal('Wystąpił nieoczekiwany wyjątek: `Zamówienie o id **%%id%%** nie istnieje...`', [
|
||||
'%%id%%' => $orderId,
|
||||
]);
|
||||
|
||||
return sfView::HEADER_ONLY;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ($securityToken != stPaymentTypeAbstract::generateSecurityToken($order))
|
||||
{
|
||||
$paymentType->getLogger()->error('Nieprawidłowy token bezpieczeństwa');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->processStatusNotification($paymentType, $order);
|
||||
}
|
||||
}
|
||||
catch (stPaymentTypeException $e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return sfView::HEADER_ONLY;
|
||||
}
|
||||
|
||||
public function executePaymentInformation()
|
||||
{
|
||||
$type = $this->getRequestParameter('type');
|
||||
$amount = $this->getRequestParameter('amount');
|
||||
$currencyAmount = $this->getRequestParameter('currency_amount');
|
||||
$paymentType = stPaymentType::get($type);
|
||||
$smarty = new stSmarty($paymentType->getConfiguration()->getFrontendModule());
|
||||
|
||||
$parameters = $paymentType->getPaymentInformation(stPrice::round($amount), stPrice::round($currencyAmount));
|
||||
|
||||
foreach ($parameters as $name => $value)
|
||||
{
|
||||
$smarty->assign($name, $value);
|
||||
}
|
||||
|
||||
return $this->renderText($smarty->fetch('payment_information.html'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Akcja obsługująca żądanie zwracające listę kanałów płatności
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @throws sfError404Exception
|
||||
*/
|
||||
public function executeSelectChannel()
|
||||
{
|
||||
$id = $this->getRequestParameter('id');
|
||||
/**
|
||||
* @var stBasket $basket
|
||||
*/
|
||||
$basket = $this->getUser()->getBasket();
|
||||
$amount = $basket->getTotalAmount(true) + stDeliveryFrontend::getInstance($basket)->getTotalDeliveryCost(true);
|
||||
|
||||
$payment = PaymentTypePeer::retrieveByPK($id);
|
||||
|
||||
if (null === $payment)
|
||||
{
|
||||
return $this->forward404();
|
||||
}
|
||||
|
||||
$api = $payment->getApiInstance();
|
||||
|
||||
if ($api instanceof stPaymentTypeInterface)
|
||||
{
|
||||
$smarty = new stSmarty($api->getConfiguration()->getFrontendModule());
|
||||
|
||||
if ($smarty->themeTemplateExists('payment_select_channel.html'))
|
||||
{
|
||||
$smarty->register_function('parent', [$this, 'getSelectChannelTemplate']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$smarty = new stSmarty('stPayment');
|
||||
}
|
||||
|
||||
$smarty->assign('amount', $amount);
|
||||
$smarty->assign('payment', $payment);
|
||||
$smarty->assign('payment_channels', $payment->getChannels($amount));
|
||||
|
||||
$this->smarty = $smarty;
|
||||
}
|
||||
|
||||
public function getSelectChannelTemplate(?array $params, Smarty $currentSmarty)
|
||||
{
|
||||
$smarty = new stSmarty($this->getModuleName());
|
||||
$smarty->_tpl_vars = !empty($params) ? array_merge($currentSmarty->get_template_vars(), $params) : $currentSmarty->get_template_vars();
|
||||
return $smarty->fetch('payment_select_channel.html');
|
||||
}
|
||||
|
||||
/**
|
||||
* Metoda przetwarzania płatnośc przed przejściem do serwisu
|
||||
*
|
||||
* @param stPaymentTypeInterface $paymentType
|
||||
* @param Order $order
|
||||
* @return string
|
||||
* @throws PropelException
|
||||
* @throws stNotificationException
|
||||
*/
|
||||
protected function processPayment(stPaymentTypeInterface $paymentType, Order $order): string
|
||||
{
|
||||
try
|
||||
{
|
||||
$paymentType->getLogger()->info('Przetwarzanie płatności dla zamówienia **[%%number%%](%%link%%)**', [
|
||||
'%%number%%' => $order->getNumber(),
|
||||
'%%link%%' => $this->generateBackendUrl('@stOrder?action=edit&id='.$order->getId()),
|
||||
]);
|
||||
|
||||
$url = $paymentType->process($order);
|
||||
|
||||
$payment = $order->getOrderPayment();
|
||||
$payment->setInProgress(true);
|
||||
$payment->save();
|
||||
|
||||
$paymentType->getLogger()->info('Przetwarzanie płatności dla zamówienia **[%%number%%](%%link%%)** zakończone pomyślnie, przekierowuję klienta do serwisu płatności <%%url%%>', [
|
||||
'%%number%%' => $order->getNumber(),
|
||||
'%%link%%' => $this->generateBackendUrl('@stOrder?action=edit&id='.$order->getId()),
|
||||
'%%url%%' => $url,
|
||||
]);
|
||||
|
||||
return $url;
|
||||
}
|
||||
catch (stPaymentTypeException $e)
|
||||
{
|
||||
$paymentType->getLogger()->exception($e);
|
||||
}
|
||||
|
||||
return $paymentType->getFailureUrl($order);
|
||||
}
|
||||
|
||||
protected function processStatusNotification(stPaymentTypeInterface $paymentType, Order $order): bool
|
||||
{
|
||||
if ($paymentType->statusNotification($order, $this->getRequest()))
|
||||
{
|
||||
$payment = $order->getOrderPayment();
|
||||
$payment->setStatus(true);
|
||||
$payment->save();
|
||||
|
||||
$paymentType->getLogger()->info('Zamówienie **[%%number%%](%%link%%)** zostało opłacone', [
|
||||
'%%number%%' => $order->getNumber(),
|
||||
'%%link%%' => $this->generateBackendUrl('@stOrder?action=edit&id='.$order->getId()),
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function generateBackendUrl($internalUrl)
|
||||
{
|
||||
$this->getRequest()->setScriptNameByApp('backend');
|
||||
$result = $this->getController()->genUrl($internalUrl);
|
||||
$this->getRequest()->setScriptNameByApp('frontend');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
225
apps/frontend/modules/stPayment/actions/components.class.php
Normal file
225
apps/frontend/modules/stPayment/actions/components.class.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stPayment
|
||||
*
|
||||
* Ten plik należy do aplikacji stPayment opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stPayment
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: components.class.php 13721 2011-06-20 14:13:12Z michal $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>,
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa stPaymentComponents
|
||||
*
|
||||
* @package stPayment
|
||||
* @subpackage actions
|
||||
* @property Order $order
|
||||
* @property Product $product
|
||||
*/
|
||||
class stPaymentComponents extends sfComponents
|
||||
{
|
||||
public function executePaymentInfoButton()
|
||||
{
|
||||
if (!$this->payment_type instanceof stPaymentTypeInterface)
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$smarty = new stSmarty('stPayment');
|
||||
$smarty->assign('amount', $this->amount);
|
||||
$smarty->assign('payment_type', $this->payment_type);
|
||||
$smarty->assign('init', $this->getUser()->getParameter('payment_info_button.init', false, 'soteshop/stPayment'));
|
||||
$smarty->assign('type', $this->payment_type->getConfiguration()->getId());
|
||||
$smarty->assign('title', isset($this->title) ? $this->title : null);
|
||||
$smarty->assign('button_label', isset($this->button_label) ? $this->button_label : $this->payment_type->getPaymentInformationTitle());
|
||||
|
||||
$this->getUser()->setParameter('payment_info_button.init', true, 'soteshop/stPayment');
|
||||
|
||||
return $smarty;
|
||||
}
|
||||
/**
|
||||
* Wyświetlenie listy płatności
|
||||
*/
|
||||
public function executeSelectPaymentType()
|
||||
{
|
||||
$this->smarty = new stSmarty('stPayment');
|
||||
$c = new Criteria();
|
||||
$c->add(PaymentTypePeer::ACTIVE, 1);
|
||||
$this->paymentTypes = PaymentTypePeer::doSelect($c);
|
||||
|
||||
$paymentTypes = $this->paymentTypes;
|
||||
foreach ($paymentTypes as $key => $paymentType)
|
||||
{
|
||||
if(class_exists($paymentType->getModuleName()))
|
||||
{
|
||||
$moduleName = $paymentType->getModuleName();
|
||||
$obj = new $moduleName;
|
||||
if(method_exists($obj, 'checkPaymentConfiguration'))
|
||||
{
|
||||
if (!$obj->checkPaymentConfiguration())
|
||||
{
|
||||
unset($this->paymentTypes[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->hasPaymentType = false;
|
||||
if (count($this->paymentTypes) > 0)
|
||||
{
|
||||
$this->hasPaymentType = true;
|
||||
}
|
||||
|
||||
$this->checked = 0;
|
||||
|
||||
$paymentType = stPayment::getInstance($this->getContext());
|
||||
if(is_object($paymentType->get())) $this->checked = $paymentType->get()->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pokazanie płatności w podsumowaniu zamówienia
|
||||
* @deprecated 8.0.9.0
|
||||
*/
|
||||
public function executeShowPayment()
|
||||
{
|
||||
$this->smarty = new stSmarty('stPayment');
|
||||
|
||||
$this->paymentType = null;
|
||||
$this->paymentTypeName = null;
|
||||
|
||||
if (!isset($this->order))
|
||||
{
|
||||
$this->order = OrderPeer::retrieveByIdAndHashCode($this->getRequestParameter('id'), $this->getRequestParameter('hash_code'));
|
||||
}
|
||||
|
||||
if (null === $this->order)
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$payment = $this->order->getOrderPayment();
|
||||
|
||||
if (!$payment)
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$this->paymentType = $payment->getPaymentType()->getModuleName();
|
||||
$this->paymentTypeName = $payment->getPaymentType()->getName();
|
||||
|
||||
if(!$this->getController()->componentExists($this->paymentType.'Frontend', 'showPayment'))
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
}
|
||||
|
||||
public function executeProcessPayment()
|
||||
{
|
||||
if (!$this->order->showPayment())
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$paymentType = $this->order->getOrderPayment()->getPaymentType();
|
||||
$api = $paymentType->getApiInstance();
|
||||
|
||||
if ($api && $api instanceof stPaymentTypeInterface && $api->isAutoRedirectEnabled())
|
||||
{
|
||||
$action = $this->getController()->genUrl('@stPayment?action=processPayment&order_id='.$this->order->getId().'&order_hash='.$this->order->getHashCode().'&type='.$api->getConfiguration()->getId());
|
||||
}
|
||||
elseif(!$this->getController()->actionExists($paymentType->getModuleName().'Frontend', 'processPayment'))
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = $this->getController()->genUrl($paymentType->getModuleName().'Frontend/processPayment?id='.$this->order->getId().'&hash='.$this->order->getHashCode());
|
||||
}
|
||||
|
||||
$this->smarty = new stSmarty('stPayment');
|
||||
$this->smarty->assign('api', $paymentType->getApiInstance());
|
||||
$this->smarty->assign('action', $action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pokazywanie informacji na karcie produktu
|
||||
*/
|
||||
public function executeShowInfoInProduct()
|
||||
{
|
||||
if ($this->product && !$this->product->isPriceVisible())
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
$config = stConfig::getInstance('stProduct');
|
||||
|
||||
if ($config->get('show_available_payments'))
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addJoin(PaymentTypePeer::ID, DeliveryHasPaymentTypePeer::PAYMENT_TYPE_ID);
|
||||
$c->addJoin(DeliveryHasPaymentTypePeer::DELIVERY_ID, DeliveryPeer::ID);
|
||||
$c->add(DeliveryPeer::ACTIVE, true);
|
||||
$c->add(PaymentTypePeer::ACTIVE, true);
|
||||
$c->addGroupByColumn(PaymentTypePeer::ID);
|
||||
$payments = PaymentTypePeer::doSelectWithI18n($c);
|
||||
}
|
||||
else
|
||||
{
|
||||
$payments = [];
|
||||
}
|
||||
|
||||
$this->smarty = new stSmarty('stPayment');
|
||||
$this->smarty->assign('payments', $payments);
|
||||
$this->smarty->assign('highlighted', $this->getHighlighted($payments, $this->product));
|
||||
$this->smarty->assign('payments_label', $i18n->__('Płatności'));
|
||||
$this->smarty->assign('lukas', stLukas::isActive());
|
||||
$this->smarty->assign('amount', stPrice::round($this->product->getPriceBrutto(true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca listę wyróżnionych płatności
|
||||
*
|
||||
* @param PaymentType[] $paymentTypes
|
||||
* @param Product $product
|
||||
* @return array
|
||||
* @todo Dostosowanie stPrzelewy24 do stPaymentTypeInterface
|
||||
*/
|
||||
protected function getHighlighted(array $paymentTypes, Product $product): array
|
||||
{
|
||||
$results = [];
|
||||
$amount = $product->getPriceBrutto(true);
|
||||
|
||||
$api = new stPrzelewy24();
|
||||
|
||||
if ($api->checkPaymentConfiguration() && $api->getChannels())
|
||||
{
|
||||
$types = $api->getBasketPaymentTypes();
|
||||
|
||||
foreach ($api->getHighlightedPaymentsForProduct() as $type => $params)
|
||||
{
|
||||
if (isset($types[$type]))
|
||||
{
|
||||
$results[$type] = $params;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($paymentTypes as $paymentType)
|
||||
{
|
||||
if ($paymentType->getApiInstance() && method_exists($paymentType->getApiInstance(), 'getHighlightedPaymentsForProduct') && $paymentType->checkPaymentConfiguration($amount))
|
||||
{
|
||||
$results = array_merge($results, call_user_func([$paymentType->getApiInstance(), 'getHighlightedPaymentsForProduct'], $this->getContext()->getI18N(), $amount));
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user