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,31 @@
<?php
// stPluginHelper::addConfigValue('stPaymentType', 'stSantaderPlugin', array('name' => 'stSantander', 'description' => 'Płatność eRaty Santander Consumer Bank'));
if (floatval(phpversion()) >= 7.1)
{
stPaymentTypeConfiguration::register('eRaty Santander Consumer Bank', stSantanderRatyPaymentType::class, [
'show_payment_info' => [
'product' => true,
'shopping_cart' => true,
],
'payment_info.width' => 950,
'payment_info.height' => 760,
'installment_payment' => true,
]);
}
if (SF_APP == 'frontend')
{
stPluginHelper::addEnableModule('stSantanderRatyFrontend', 'frontend');
stPluginHelper::addRouting('stSantanderRatyFrontend', '/eraty-santander/:action/*', 'stSantanderRatyFrontend', 'list', 'frontend');
$dispatcher->connect('stUserDataActions.validateAddBasketUser', array('stSantanderListener', 'validateAddBasketUser'));
stSocketView::addComponent('stPayment_show_stSantander_info', 'stSantanderRatyFrontend', 'calculateInBasket');
stSecurity::addCSPException('*.eraty.pl');
stSecurity::addCSPException('static.hotjar.com');
}
elseif (SF_APP == 'backend')
{
stPluginHelper::addEnableModule('stSantanderRatyBackend', 'backend');
stPluginHelper::addRouting('stSantanderRatyBackend', '/eraty-santander/:action/*', 'stSantanderRatyBackend', 'config', 'backend');
}

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,
];
}
}

View File

@@ -0,0 +1,36 @@
<?php
class stSantanderRatyBackendActions extends autoStSantanderRatyBackendActions
{
public function validateConfig()
{
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$data = $this->getRequestParameter('config');
if (isset($data['shop_number']) && empty($data['shop_number']))
{
$this->getRequest()->setError('config{shop_number}', 'Proszę uzupełnić pole.');
}
}
return !$this->getRequest()->hasErrors();
}
protected function saveConfig()
{
$result = parent::saveConfig();
if ($this->config->get('enabled'))
{
stPaymentType::get(stSantanderRatyPaymentType::class)->getConfiguration()->enable();
}
else
{
stPaymentType::get(stSantanderRatyPaymentType::class)->getConfiguration()->disable();
}
return $result;
}
}

View File

@@ -0,0 +1,7 @@
<?php
class stSantanderRatyBackendComponents extends autoStSantanderRatyBackendComponents
{
}
?>

View File

@@ -0,0 +1,21 @@
generator:
param:
model_class: false
title: "eRaty Santander Consumer Bank"
route: "@stSantanderRatyBackend"
icon: "stSantanderRatyPlugin"
documenation:
pl: "https://www.sote.pl/docs/santander_consumer_bank"
en: "https://www.soteshop.com/docs/santander_consumer_bank"
config:
display:
"NONE": [enabled, autoredirect, shop_number, highlighted_for_product]
fields:
enabled: {name: "Włącz", type: checkbox_tag, i18n: stPayment}
autoredirect: {name: "Automatyczne przekierowanie", type: checkbox_tag, help: "Przekierowuje automatycznie na stronę płatności po złożeniu zamówienia", i18n: stPayment}
highlighted_for_product: {name: "Wyróżnij płatność na karcie produktu", type: checkbox_tag}
shop_number: {name: "Numer sklepu", required: true}
actions:
_save: -

View File

@@ -0,0 +1,4 @@
fields:
config{shop_number}:
required:
msg: Proszę uzupełnić pole.

View File

@@ -0,0 +1,45 @@
<?php
class stSantanderRatyFrontendActions extends stActions
{
public function executeAccepted()
{
$this->smarty = new stSmarty('stSantanderRatyFrontend');
$this->smarty->assign('id_wniosku', $this->getRequestParameter('id_wniosku'));
}
public function executeCanceled()
{
$this->smarty = new stSmarty('stSantanderRatyFrontend');
}
public function executePay()
{
$smarty = new stSmarty('stSantanderRatyFrontend');
$paymentType = stPaymentType::get($this->getRequestParameter('type'));
$order = OrderPeer::retrieveByIdAndHashCode($this->getRequestParameter('order_id'), $this->getRequestParameter('order_hash'));
$totalQuantity = count($order->getOrderProducts());
if ($order->getOrderDelivery()->getCostBrutto(true) > 0)
{
$totalQuantity += 1;
}
$smarty->assign('order', $order);
$smarty->assign('order_total_amount', $order->getTotalAmountWithDelivery(true, true));
$smarty->assign('order_total_quantity', $totalQuantity);
$smarty->assign('payment_type', $order->getOrderPayment()->getPaymentType());
$smarty->assign('shop_number', stConfig::getInstance('stSantanderRatyBackend')->get('shop_number'));
$smarty->assign('order_delivery', $order->getOrderDelivery()->getName());
$smarty->assign('client', array(
'name' => $order->getOrderUserDataBilling()->getName(),
'surname' => $order->getOrderUserDataBilling()->getSurname(),
'email' => $order->getOptClientEmail(),
));
$smarty->assign('url_accepted', $paymentType->getReturnUrl($order).'?id=');
$smarty->assign('url_canceled', $paymentType->getReturnUrl($order).'?canceled=1&id=');
$this->smarty = $smarty;
}
}

View File

@@ -0,0 +1,57 @@
<?php
class stSantanderRatyFrontendComponents extends sfComponents
{
public function executeShowPayment()
{
$smarty = new stSmarty('stSantanderRatyFrontend');
$order = stPaymentType::getOrderInSummary();
$totalQuantity = count($order->getOrderProducts());
if ($order->getOrderDelivery()->getCostBrutto(true) > 0)
{
$totalQuantity += 1;
}
$smarty->assign('order', $order);
$smarty->assign('order_total_amount', $order->getTotalAmountWithDelivery(true, true));
$smarty->assign('order_total_quantity', $totalQuantity);
$smarty->assign('shop_number', stConfig::getInstance('stSantanderRatyBackend')->get('shop_number'));
$smarty->assign('order_delivery', $order->getOrderDelivery()->getName());
$smarty->assign('client', array(
'name' => $order->getOrderUserDataBilling()->getName(),
'surname' => $order->getOrderUserDataBilling()->getSurname(),
'email' => $order->getOptClientEmail(),
));
$smarty->assign('url_accepted', $this->getController()->genUrl('@stSantanderRatyFrontend?action=accepted', true).'?id=');
$smarty->assign('url_canceled', $this->getController()->genUrl('@stSantanderRatyFrontend?action=canceled', true).'?id=');
return $smarty;
}
public function executeCalculate()
{
$config = stConfig::getInstance(sfContext::getInstance(), 'stSantanderRatyBackend');
if ($this->amount < 100 || !$config->get('shop_number')){
return sfView::NONE;
}
$smarty = new stSmarty('stSantanderRatyFrontend');
$smarty->assign('url', stSantander::getCalculateRateUrl($this->amount));
$smarty->assign('is_ajax', isset($this->is_ajax) ? $this->is_ajax: false);
$smarty->assign('small', isset($this->small) ? $this->small: false);
return $smarty;
}
public function executeCalculateInBasket()
{
sfLoader::loadHelpers(array('Helper', 'stPartial'));
echo st_get_component('stSantanderRatyFrontend', 'calculate', array('amount' => $this->getUser()->getBasket()->getTotalAmount(true, true), 'small' => true));
return sfView::NONE;
}
}

View File

@@ -0,0 +1,3 @@
<?php
$smarty->display('pay.html');

View File

@@ -0,0 +1,24 @@
{set layout="one_column"}
<div id="payment">
<div class="title">
<h1>{__ text="Płatność"}</h1>
</div>
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="eRaty Santader Consumer Bank"}
</div>
<div class="panel-body text-center">
<p style="margin-bottom: 20px;"><img src="/plugins/stSantanderRatyPlugin/images/eraty.png"></p>
<b>Dziękujemy za złożenie wniosku. </b>
<br><br>
Numer wniosku kredytowego/decyzja to: <b>{$id_wniosku}</b>.
<br><br>
<b>W przypadku pozytywnej wstępnej weryfikacji oczekuj na kontakt telefoniczny z
konsultantem Santander Consumer Bank</b>
<br><br>
Podczas rozmowy telefonicznej sporządzi razem z Tobą umowę ratalną.
<br>
Przygotuj: dowód osobisty oraz drugi dokument tożsamości.
</div>
</div>
</div>

View File

@@ -0,0 +1,30 @@
<a id="eraty-santander-calculate-trigger" class="btn btn-default btn-eraty{if !$small} btn-eraty-lg{/if}" href="{$url}">
{__ text="Oblicz"}
</a>
{if $small}
<img src="/plugins/stSantanderRatyPlugin/images/eraty_btn_sm.png" alt="" style="margin-left: 5px">
{else}
<img src="/plugins/stSantanderRatyPlugin/images/eraty_btn.png" alt="" style="margin-left: 5px">
{/if}
{literal}
<script type="text/javascript">
jQuery(function() {
$('#eraty-santander-calculate-trigger').click(function(){
var width = 640;
var height = 500;
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 4;
console.log(top);
window.open($(this).attr('href'),
'Policz_rate',
'width='+width+',height='+height+',directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,left='+left+',top='+top);
return false;
});
});
</script>
{/literal}

View File

@@ -0,0 +1,18 @@
{set layout="one_column"}
<div id="payment">
<div class="title">
<h1>{__ text="Płatność"}</h1>
</div>
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="eRaty Santader Consumer Bank"}
</div>
<div class="panel-body text-center">
<p style="margin-bottom: 20px;"><img src="/plugins/stSantanderRatyPlugin/images/eraty.png"></p>
Zrezygnowałeż z otrzymania kredytu ratalnego.
<br>
Skontaktuj się z właścicielem sklepu w celu wyjaśnienia sytuacji oraz pomyślnym
dokończenia transakcji.
</div>
</div>
</div>

View File

@@ -0,0 +1,72 @@
{assign var=delivery value=$order->getOrderDelivery()}
{capture assign="button_label"}
{__ text="Oblicz"} <img src="/plugins/stSantanderRatyPlugin/images/eraty_btn.png" alt="">
{/capture}
<div id="payment">
<div id="eraty-santander-form" class="panel panel-default center-block">
<div class="panel-heading">
{__ text="eRaty Santader Consumer Bank"}
</div>
<div class="panel-body text-center">
<p style="margin-bottom: 20px;"><img src="/plugins/stSantanderRatyPlugin/images/eraty.png"></p>
<p>
{__ text="Przed złożeniem wniosku możesz zapoznać się z procedurą udzielenia kredytu ratalnego oraz obliczyć raty."}
</p>
<div class="row">
<div class="col-lg-6 how-to-buy" style="padding-bottom: 15px">
<a target="_blank" class="btn btn-default btn-eraty" href="https://www.santanderconsumer.pl/raty-jak-kupic">
<span>{__ text="Jak kupić na"}</span>
<img src="/plugins/stSantanderRatyPlugin/images/eraty_btn.png" alt="">
</a>
</div>
<div class="col-lg-6 calculate" style="padding-bottom: 15px">
{st_get_component module="stPayment" component="paymentInfoButton" payment_type=$payment_type->getApiInstance() amount=$order_total_amount button_label=$button_label}
</div>
</div>
<form action=" https://wniosek.eraty.pl/formularz" method="post">
{foreach key=index item=order_product from=$order->getOrderProducts()}
<input name="idTowaru{$index+1}" type="hidden" value="{$order_product->getId()}">
<input name="nazwaTowaru{$index+1}" type="hidden" value="{$order_product->getName()}">
<input name="wartoscTowaru{$index+1}" type="hidden" value="{$order_product->getPriceBrutto(true)}">
<input name="liczbaSztukTowaru{$index+1}" type="hidden" value="{$order_product->getQuantity()}">
<input name="jednostkaTowaru{$index+1}" type="hidden" value="{$order_product->getUom()}">
{/foreach}
{assign var=delivery_cost value=$delivery->getCostBrutto(true)}
{if $delivery_cost > 0}
<input name="idTowaru{$index+2}" type="hidden" value="KosztPrzesylki">
<input name="nazwaTowaru{$index+2}" type="hidden" value="{$delivery->getName()}">
<input name="wartoscTowaru{$index+2}" type="hidden" value="{$delivery_cost}">
<input name="liczbaSztukTowaru{$index+2}" type="hidden" value="1">
<input name="jednostkaTowaru{$index+2}" type="hidden" value="szt.">
{/if}
<input type="hidden" name="wartoscTowarow" value="{$order_total_amount}">
<input type="hidden" name="liczbaSztukTowarow" value="{$order_total_quantity}">
<input type="hidden" name="numerSklepu" value="{$shop_number}">
<input type="hidden" name="typProduktu" value="0">
<input type="hidden" name="sposobDostarczeniaTowaru" value="{$delivery->getName()}">
<input type="hidden" name="nrZamowieniaSklep" value="{$order->getId()}">
<input type="hidden" name="imie" value="{$client.name}">
<input type="hidden" name="nazwisko" value="{$client.surname}">
<input type="hidden" name="email" value="{$client.email}">
<input type="hidden" name="char" value="UTF-8">
<input type="hidden" name="wniosekZapisany" value="{$url_accepted}">
<input type="hidden" name="wniosekAnulowany" value="{$url_canceled}">
<p>
<label><input type="checkbox" required="required"> Zapoznałem się <a target="_blank" href="https://www.santanderconsumer.pl/raty-jak-kupic">z procedurą udzielenia kredytu konsumenckiego na zakup towarów i usług eRaty Santander Consumer Bank</a></label>
</p>
<p>
{__ text='Aby rozpocząć proces składania wniosku ratalnego należy zapoznać się z procedurą udzielenia kredytu, a następnie kliknąć na poniższy przycisk "Kupuję na raty z Santander Consumer Bank"'}
</p>
<div class="text-right">
<button class="btn btn-primary btn-eraty" type="submit">
<span>{__ text='Złóż wniosek'}</span>
<img src="/plugins/stSantanderRatyPlugin/images/eraty_btn_white.png" alt="">
</button>
</div>
</form>
</div>
</div>
</div>

View File

@@ -0,0 +1 @@
<iframe src="{$url}" style="width: 100%; height: 500px; border: none"><div class="preloader"></div></iframe>