first commit
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
class stCashBillFrontendActions extends stActions {
|
||||
|
||||
public function executeReturnSuccess() {
|
||||
$this->smarty = new stSmarty($this->getModuleName());
|
||||
}
|
||||
|
||||
public function executeReturnFail() {
|
||||
$this->smarty = new stSmarty($this->getModuleName());
|
||||
$this->contactPage = WebpagePeer::retrieveByState('CONTACT');
|
||||
}
|
||||
|
||||
public function executeNewPaymentFail() {
|
||||
$this->smarty = new stSmarty($this->getModuleName());
|
||||
$this->contactPage = WebpagePeer::retrieveByState('CONTACT');
|
||||
}
|
||||
|
||||
public function executeReportStatus() {
|
||||
$this->setLayout(false);
|
||||
|
||||
$cmd = $this->getRequest()->getParameter('cmd');
|
||||
$args = $this->getRequest()->getParameter('args');
|
||||
$sign = $this->getRequest()->getParameter('sign');
|
||||
|
||||
$stCashBill = new stCashBill();
|
||||
|
||||
$shopSign = md5($cmd.$args.$stCashBill->getSecretKey());
|
||||
|
||||
if ($shopSign == $sign) {
|
||||
try {
|
||||
$client = new stCashBillSoapClient($stCashBill->getSoapUri());
|
||||
$response = $client->getPayment(array('id' => $args));
|
||||
} catch (SoapFault $e) {
|
||||
$response = null;
|
||||
}
|
||||
|
||||
if ($response !== null) {
|
||||
$data = unserialize($response->return->additionalData);
|
||||
|
||||
if (false === $data) {
|
||||
$stPayment = new stPayment();
|
||||
if ($response->return->status == 'PositiveFinish')
|
||||
$stPayment->confirmPayment($response->return->additionalData);
|
||||
elseif ($response->return->status == 'NegativeFinish')
|
||||
$stPayment->cancelPayment($response->return->additionalData);
|
||||
} elseif ($response->return->status == 'PositiveFinish') {
|
||||
$payment = PaymentPeer::retrieveByIdAndHash($data['id'], $data['hash']);
|
||||
|
||||
if ($payment)
|
||||
{
|
||||
$payment->setStatus(true);
|
||||
$payment->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
file_put_contents(sfConfig::get('sf_root_dir').'/log/cashbill.txt', '['.date('d-m-Y H:i:s').'] No Payment instance for:'.var_export($response->return, true)."\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function executeNewPayment() {
|
||||
$url = '@stCashBillPluginNewPaymentFail';
|
||||
if ($this->getRequest()->hasParameter('id') && $this->getRequest()->hasParameter('hash')) {
|
||||
$id = $this->getRequest()->getParameter('id');
|
||||
$hash = $this->getRequest()->getParameter('hash');
|
||||
$order = OrderPeer::retrieveByIdAndHashCode($id, $hash);
|
||||
|
||||
$channelId = $this->getRequest()->getParameter('channelId', null);
|
||||
|
||||
if (is_object($order)) {
|
||||
$stCashBill = new stCashBill();
|
||||
$stWebRequest = new stWebRequest();
|
||||
$user = $order->getOrderUserDataBilling();
|
||||
$payment = $order->getOrderPayment();
|
||||
|
||||
try {
|
||||
$client = new stCashBillSoapClient($stCashBill->getSoapUri());
|
||||
$parameters = array(
|
||||
'title' => $this->getContext()->getI18n()->__('Zamówienie numer:').' '.$order->getNumber(),
|
||||
'amount' => array(
|
||||
'value' => $stCashBill->parseAmount(stPayment::getUnpayedAmountByOrder($order)),
|
||||
'currencyCode' => stPaymentType::getCurrency($order->getId())->getShortcut(),
|
||||
),
|
||||
'languageCode' => stPaymentType::getLanguage(array('PL', 'EN')),
|
||||
'returnUrl' => 'http://'.$stWebRequest->getHost().'/cashbill/returnSuccess',
|
||||
'negativeReturnUrl' => 'http://'.$stWebRequest->getHost().'/cashbill/returnFail',
|
||||
'personalData' => array(
|
||||
'firstName' => $user->getName(),
|
||||
'surname' => $user->getSurname(),
|
||||
'email' => $order->getGuardUser()->getUsername(),
|
||||
),
|
||||
'additionalData' => serialize(array('id' => $payment->getId(), 'hash' => $payment->getHash())),
|
||||
'referer' => 'SOTE',
|
||||
);
|
||||
|
||||
if ($channelId !== null)
|
||||
$parameters['paymentChannel'] = $channelId;
|
||||
|
||||
$response = $client->newPayment($parameters);
|
||||
|
||||
if(is_object($response))
|
||||
$url = $response->return->redirectUrl;
|
||||
} catch (SoapFault $e) {
|
||||
file_put_contents(sfConfig::get('sf_root_dir').'/log/cashbill.txt', '['.date('d-m-Y H:i:s').'] Order number '.$order->getNumber().':'.var_export($e->getMessage(), true)."\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->redirect($url);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
class stCashBillFrontendComponents extends sfComponents {
|
||||
|
||||
public function executeShowPayment() {
|
||||
$this->smarty = new stSmarty('stCashBillFrontend');
|
||||
|
||||
$this->stCashBill = new stCashBill();
|
||||
$this->order = OrderPeer::retrieveByPK($this->getRequestParameter('id'));
|
||||
|
||||
if (in_array($this->stCashBill->getShowVariant(), array('text', 'image'))) {
|
||||
$this->channels = $this->stCashBill->getPaymentChannels();
|
||||
} else
|
||||
$this->channels = array();
|
||||
|
||||
if ($this->getContext()->getModuleName() == 'stPayment' && $this->getContext()->getActionName() == 'pay')
|
||||
$this->redirect = true;
|
||||
else
|
||||
$this->redirect = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
st_theme_use_stylesheet('stPayment.css');
|
||||
st_theme_use_stylesheet('stCashBillPlugin.css');
|
||||
$smarty->assign('check_configuration', $stCashBill->checkPaymentConfiguration());
|
||||
if ($stCashBill->checkPaymentConfiguration()) {
|
||||
$smarty->assign('form_start', form_tag('@stCashBillPluginNewPayment?id='.$order->getId().'&hash='.$order->getHashCode(), array('class' => 'st_form', 'id' => 'st_cashbill_form_new_payment')));
|
||||
$smarty->assign('pay_submit', submit_tag(__('Zapłać')));
|
||||
$smarty->assign('channels', $channels);
|
||||
$smarty->assign('redirect', $redirect);
|
||||
$smarty->assign('show_variant', $stCashBill->getShowVariant());
|
||||
}
|
||||
$smarty->assign('description', stPaymentType::getSummaryDescriptionByOrderIdAndHash($order->getId()));
|
||||
$smarty->display('cashbill_show_payment.html');
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
st_theme_use_stylesheet('stPayment.css');
|
||||
$smarty->assign('contactLink', is_object($contactPage) ? url_for('stWebpageFrontend/index?url='.$contactPage->getFriendlyUrl()) : null);
|
||||
$smarty->display('cashbill_new_payment_fail.html');
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
st_theme_use_stylesheet('stPayment.css');
|
||||
$smarty->assign('contactLink', is_object($contactPage) ? url_for('stWebpageFrontend/index?url='.$contactPage->getFriendlyUrl()) : null);
|
||||
$smarty->display('cashbill_return_fail.html');
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
st_theme_use_stylesheet('stPayment.css');
|
||||
$smarty->display('cashbill_return_success.html');
|
||||
@@ -0,0 +1,8 @@
|
||||
<div id="stPayment_return" class="box roundies">
|
||||
<div class="title">
|
||||
<h2>{__ text="Płatność"}</h2>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>{__ text="Błąd podczas tworzenia nowej płatności."}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div id="stPayment_return" class="box roundies">
|
||||
<div class="title">
|
||||
<h2>{__ text="Płatność"}</h2>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>{__ text="Płatność nie została zrealizowana."}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div id="stPayment_return" class="box roundies">
|
||||
<div class="title">
|
||||
<h2>{__ text="Płatność"}</h2>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>{__ text="Dziękujemy za dokonanie płatności."}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,84 @@
|
||||
{use_stylesheet src="stUser.css"}
|
||||
<div id="privacy_overlay" style="height: auto">
|
||||
<div class="privacy_overlay_content" style="text-align: center; height: auto">
|
||||
<h2>CashBill</h2>
|
||||
<p>{__ text="Za chwilę nastąpi przekierowanie na stronę płatności. Proszę czekać."}</p>
|
||||
<p><img src="/images/frontend/theme/responsive/preloader.gif"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="st_box_payment">
|
||||
<img id="st_home" src="/images/frontend/theme/default2/stCashBillPlugin/logo.png" alt=""/><br />
|
||||
<span>
|
||||
{$description}
|
||||
</span>
|
||||
{if $check_configuration}
|
||||
<div id="cashbill_list">
|
||||
{$form_start}
|
||||
{if $show_variant == 'text'}
|
||||
{assign var='i' value=0}
|
||||
{foreach from=$channels item=channel}
|
||||
{assign var='i' value=$i+1}
|
||||
<div class="line">
|
||||
<input type="radio" name="channelId" id="check_{$i}" value="{$channel->id}" class="radiobutton"/>
|
||||
<label class="name" for="check_{$i}">{$channel->name}</label>
|
||||
</div>
|
||||
{/foreach}
|
||||
{elseif $show_variant == 'image'}
|
||||
{assign var='i' value=0}
|
||||
{foreach from=$channels item=channel}
|
||||
{assign var='i' value=$i+1}
|
||||
<div class="item box_form img_list">
|
||||
<label for="check_{$i}">
|
||||
<img src="{$channel->logoUrl}" />
|
||||
<h5 class="name">{$channel->name}</h5>
|
||||
<input type="radio" name="channelId" id="check_{$i}" value="{$channel->id}" class="radiobutton"/>
|
||||
</label>
|
||||
</div>
|
||||
{/foreach}
|
||||
{elseif $show_variant == 'none' && $redirect}
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$(document).ready(function () {
|
||||
$("#st_cashbill_form_new_payment").submit(function() {
|
||||
var form = $(this);
|
||||
|
||||
if (form.data('submited')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
form.data('submited', true);
|
||||
|
||||
$('#privacy_overlay').overlay({
|
||||
mask: {
|
||||
color: '#000',
|
||||
loadSpeed: 'fast',
|
||||
opacity: 0.5
|
||||
},
|
||||
close: '.close',
|
||||
closeOnClick: false,
|
||||
closeOnEsc: false,
|
||||
top: "20%",
|
||||
speed: 'fast',
|
||||
load: true,
|
||||
oneInstance: true
|
||||
});
|
||||
}).submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
{/if}
|
||||
<div class="clear"></div>
|
||||
<div class="buttons right">
|
||||
<button type="submit" class="important roundies">
|
||||
<span class="arrow_right">{__ text="Zapłać"}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</form>
|
||||
</div>
|
||||
{else}
|
||||
<br />{__ text="Płatność została błędnie skonfigurowana."}
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
{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="CashBill"}
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<p>
|
||||
{__ text="Błąd podczas tworzenia nowej płatności."}<br/>
|
||||
{__ text="Skontaktuj się z nami." langCatalogue="stPayment"}
|
||||
</p>
|
||||
{if $contactLink}
|
||||
<a href="{$contactLink}" class="btn btn-primary">{__ text="Kontakt" langCatalogue="stPayment"}</a>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
{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="CashBill"}
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<p>
|
||||
{__ text="Płatność nie została zrealizowana."}<br/>
|
||||
{__ text="Skontaktuj się z nami." langCatalogue="stPayment"}
|
||||
</p>
|
||||
{if $contactLink}
|
||||
<a href="{$contactLink}" class="btn btn-primary">{__ text="Kontakt" langCatalogue="stPayment"}</a>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
{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="CashBill"}
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<p>{__ text="Dziękujemy za dokonanie płatności."}</p>
|
||||
<a href="/" class="btn btn-primary">{__ text="Wróć do zakupów" langCatalogue="stPayment"}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,79 @@
|
||||
<div class="modal fade modal-vertical-centered" id="order-process-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<h3 class="text-center">{__ text="CashBill"}</h3>
|
||||
<p class="text-center">{__ text="Za chwilę nastąpi przekierowanie na stronę płatności. Proszę czekać."}</p>
|
||||
<div class="preloader"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default center-block"{if $show_variant == 'image'} id="payment-list"{elseif $show_variant == 'text'} id="payment-list-text"{/if}>
|
||||
<div class="panel-heading">
|
||||
{__ text="CashBill"}
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
{if $check_configuration}
|
||||
<img src="/images/frontend/theme/default2/stCashBillPlugin/logo.png" alt="{__ text="CashBill"}"/><br />
|
||||
<span>
|
||||
{$description}
|
||||
</span>
|
||||
{$form_start}
|
||||
{$hidden_order_id}
|
||||
{if $show_variant == 'text'}
|
||||
{assign var='i' value=0}
|
||||
<div class="row" data-equalizer>
|
||||
{foreach from=$channels item=channel}
|
||||
{assign var='i' value=$i+1}
|
||||
<div class="col-sm-6 col-md-4 col-lg-3" data-equalizer-watch>
|
||||
<label for="check_{$i}" class="btn btn-default">
|
||||
<input type="radio" name="channelId" id="check_{$i}" value="{$channel->id}"/>
|
||||
{$channel->name}
|
||||
</label>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
{elseif $show_variant == 'image'}
|
||||
{assign var='i' value=0}
|
||||
<div class="row" data-equalizer>
|
||||
{foreach from=$channels item=channel}
|
||||
{assign var='i' value=$i+1}
|
||||
<div class="col-xs-6 col-sm-3 col-md-2" data-equalizer-watch>
|
||||
<label for="check_{$i}" class="text-center btn btn-default">
|
||||
<img class="img-responsive" src="{$channel->logoUrl}" alt="{$channel->name}"/>
|
||||
<input type="radio" name="channelId" id="check_{$i}" value="{$channel->id}"/>
|
||||
</label>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
{elseif $show_variant == 'none' && $redirect}
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$(document).ready(function () {
|
||||
$("#st_cashbill_form_new_payment").submit(function() {
|
||||
var form = $(this);
|
||||
|
||||
if (form.data('submited')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
form.data('submited', true);
|
||||
|
||||
$('#order-process-modal').modal({ show: true });
|
||||
}).submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
{/if}
|
||||
<button type="submit" class="btn btn-primary pull-right">
|
||||
{__ text="Zapłać"}
|
||||
</button>
|
||||
</form>
|
||||
{else}
|
||||
{__ text="Płatność została błędnie skonfigurowana."}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user