Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
truecoders committed Mar 10, 2018
0 parents commit 91e1eac
Show file tree
Hide file tree
Showing 18 changed files with 575 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# yadpay
13 changes: 13 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>yadpay</name>
<displayName><![CDATA[Оплата Яд-ом]]></displayName>
<version><![CDATA[0.0.1]]></version>
<description><![CDATA[Оплата Яд-ом (карты и яденьги)]]></description>
<author><![CDATA[TrueCoders]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall>Точно?</confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
13 changes: 13 additions & 0 deletions config_ru.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>yadpay</name>
<displayName><![CDATA[Оплата Яндекс]]></displayName>
<version><![CDATA[0.0.1]]></version>
<description><![CDATA[Этим модулем можно платить с помощью Яндекс.Денег и картами]]></description>
<author><![CDATA[Truecoders]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Точно?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
11 changes: 11 additions & 0 deletions controllers/front/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header("Location: ../");
exit;
24 changes: 24 additions & 0 deletions controllers/front/paying.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

class YadpayPayingModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
$cart = $this->context->cart;

$currency = $this->context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);

foreach($cart as $key => $value)
{
echo "[$key]", $value, "<hr>";
}

echo $total . '<hr>';
echo $this->module->yadWallet . '<hr>';
echo $this->module->yadRedirectUrl . '<hr>';
echo $this->module->yadClientId . '<hr>';
echo $this->module->yadSecret . '<hr>';
echo $customer->secure_key . '<hr>';
}
}
37 changes: 37 additions & 0 deletions controllers/front/payment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

class YadpayPaymentModuleFrontController extends ModuleFrontController
{
public $ssl = true;

/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();

$cart = $this->context->cart;
if (!$this->module->checkCurrency($cart)) {
Tools::redirect('index.php?controller=order');
}

$this->context->smarty->assign(array(
'nbProducts' => $cart->nbProducts(),
'cust_currency' => $cart->id_currency,
'currencies' => $this->module->getCurrency((int)$cart->id_currency),
'total' => $cart->getOrderTotal(true, Cart::BOTH),
'isoCode' => $this->context->language->iso_code,
'checkOrder' => $this->module->yadWallet,
'checkOrder' => $this->module->yadRedirectUrl,
'checkOrder' => $this->module->yadClientId,
'checkOrder' => $this->module->yadSecret,
'checkDescription' => Tools::nl2br($this->module->yadDescription),
'this_path' => $this->module->getPathUri(),
'this_path_check' => $this->module->getPathUri(),
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/'
));

$this->setTemplate('payment_execution.tpl');
}
}
43 changes: 43 additions & 0 deletions controllers/front/validation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

class YadpayValidationModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
$cart = $this->context->cart;

if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}

// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'yadpay') {
$authorized = true;
break;
}
}

if (!$authorized) {
die($this->trans('Оплата не доступна', array(), 'Modules.Yadpay.Shop'));
}

$customer = new Customer($cart->id_customer);

if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}

$currency = $this->context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);

$mailVars = array(
'{YAD_DESCRIPTION}' => Configuration::get('YAD_DESCRIPTION'),
'{yadpay_html}' => str_replace("\n", '<br />', Configuration::get('yadpay_description')));

$this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $this->module->displayName, null, $mailVars, (int)$currency->id, false, $customer->secure_key);

Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
}
}
11 changes: 11 additions & 0 deletions controllers/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header("Location: ../");
exit;
11 changes: 11 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header("Location: ../");
exit;
11 changes: 11 additions & 0 deletions views/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header("Location: ../");
exit;
11 changes: 11 additions & 0 deletions views/templates/front/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header("Location: ../");
exit;
15 changes: 15 additions & 0 deletions views/templates/front/payment_infos.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<section>
<p>{l s='Оплатите заказ ниже' d='Modules.Yadpay.Shop'}
<dl>
<dt>{l s='Сумма' d='Modules.Yadpay.Shop'}</dt>
<dd>{$checkTotal}</dd>
<dt>{l s='Порядок заказа' d='Modules.Yadpay.Shop'}</dt>
<dd>{$checkDescription}</dd>
</dl>
</p>
</section>
<script type="text/javascript">
function goToPayTo(url) {
alert(url);
}
</script>
11 changes: 11 additions & 0 deletions views/templates/hook/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header("Location: ../");
exit;
7 changes: 7 additions & 0 deletions views/templates/hook/info.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="alert alert-info">
<img src="../modules/yadpay/yadpay.jpg" style="float:left; margin-right:15px;" width="86" height="49">
<img src="../modules/yadpay/yadpay.jpg" style="float:left; margin-right:15px;" width="86" height="49">
<p><strong>{l s="Оплата Яд-ом" d='Modules.Yadpay.Admin'}</strong></p>
<p>{l s="При оплате статус сменится на ожидание оплаты" d='Modules.Yadpay.Admin'}</p>
<p>{l s="Нужно будет руками сменить статус заказа" d='Modules.Yadpay.Admin'}</p>
</div>
11 changes: 11 additions & 0 deletions views/templates/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header("Location: ../");
exit;
Binary file added yadpay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 91e1eac

Please sign in to comment.