first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
class stSantander
{
public function checkPaymentConfiguration()
{
return true;
}
public static function getCalculateRateUrl($total_amount)
{
$config = stConfig::getInstance('stSantanderRatyBackend');
return 'https://wniosek.eraty.pl/symulator/oblicz/numerSklepu/'.$config->get('shop_number').'/typProduktu/0/wartoscTowarow/'.$total_amount;
}
public static function getFormUrl()
{
return 'https://wniosek.eraty.pl/formularz/';
}
public static function isActive()
{
if (!PaymentTypePeer::isActive('stSantander')) return false;
$eraty = new stSantander();
if (!$eraty->checkPaymentConfiguration()) return false;
return true;
}
}

View File

@@ -0,0 +1,26 @@
<?php
class stSantanderListener
{
public static function validateAddBasketUser(sfEvent $event, $ok)
{
if (stSantander::isActive())
{
$action = $event->getSubject();
if ($action->getRequest()->getMethod() == sfRequest::POST)
{
$delivery = stDeliveryFrontend::getInstance($action->getUser()->getBasket())->getDefaultDelivery();
if ($delivery && $delivery->getDefaultPayment()->getPaymentTypeApi()->isType(stSantanderRatyPaymentType::class) && $action->getUser()->getBasket()->getTotalAmount(true, true) < 100)
{
$action->setFlash('warning', $action->getContext()->getI18N()->__('Zakup na raty dostępny jest od 100 zł wartości produktu lub całego
zamówienia', null, 'stSantanderRatyFrontend'));
$ok = false;
}
}
}
return $ok;
}
}

View File

@@ -0,0 +1,50 @@
<?php
class stSantanderRatyPaymentType extends stPaymentTypeAbstract
{
public function process(Order $order): ?string
{
return $this->generateUrl($order, '@stSantanderRatyFrontend', ['action' => 'pay']);
}
public function return(Order $order, sfWebRequest $request): ?bool
{
if (!$request->hasParameter('canceled'))
{
$payment = $order->getOrderPayment();
$payment->setConfigurationParameter('santander_application_id', $request->getParameter('id'));
$payment->save();
}
return null;
}
public function statusNotification(Order $order, sfWebRequest $request): bool
{
return false;
}
public function getPaymentInformationUrl(string $amount): ?string
{
return 'https://wniosek.eraty.pl/symulator/oblicz/numerSklepu/'.$this->getConfiguration()->getParameter('shop_number').'/typProduktu/0/wartoscTowarow/'.$amount;
}
public function checkPaymentConfiguration(?PaymentType $paymentType = null, ?string $amount = null): bool
{
return parent::checkPaymentConfiguration() && (SF_APP != 'frontend' || $this->getCurrency()->getShortcut() == 'PLN' && (null === $amount || $amount >= 100));
}
public function getHighlightedPaymentsForProduct(): array
{
if (empty($this->getConfiguration()->getParameter('highlighted_for_product')))
{
return [];
}
$highlighted = new stPaymentHighlighted($this);
return [
$this->getConfiguration()->getId() => $highlighted,
];
}
}