Witam, wszystkich, dwie godziny i moduł był gotowy - pozytywnie przeszedł wszystkie testy i porawnie działa na naszej stronie.
www.plotersky.pl Wrzucam go, aby nikt się więcej nie męczył. Pozdrawiam.
Moduł: dla PS 1.4 - 1.5.3 transferuj.pl z prowicja.
www.plotersky.pl/download/transferuj.zip Code: transferuj.php
<?php
if (!defined('_CAN_LOAD_FILES_'))
exit;
class transferuj extends PaymentModule {
private $_html = '';
function __construct()
{
$this->name = 'transferuj';
$this->tab = 'payments_gateways';
$this->version = '2.0';
$this->author = 'Transferuj.pl';
$this->currencies = true;
$this->currencies_mode = 'radio';
parent::__construct();
$this->displayName = $this->l('Transferuj.pl');
$this->description = $this->l('Obsługa płatności Transferuj.pl');
if (!sizeof(Currency::checkPaymentCurrencies($this->id)))
$this->warning = $this->l('Nie ustawiono waluty dla tego modułu');
}
function getContent(){
if (Tools::isSubmit('submit'))
{
Configuration::updateValue('TRANSFERUJ_SID', Tools::getValue('sprzedawcaID'));
Configuration::updateValue('TRANSFERUJ_TIP', Tools::getValue('ip_serw'));
Configuration::updateValue('TRANSFERUJ_COD', Tools::getValue('kod_potw'));
Configuration::updateValue('TRANSFERUJ_SHOW_CHANNELS', Tools::getValue('t_kanaly'));
Configuration::updateValue('TRANSFERUJ_CHANNELS_ONLINE', Tools::getValue('t_online'));
Configuration::updateValue('TRANSFERUJ_SHOW_REG', Tools::getValue('t_reg'));
Configuration::updateValue('PROWICJA', Tools::getValue('prowicja'));
}
$this->_displayForm();
return $this->_html;
}
function _displayForm(){
$this->_html .='<h2>Transferuj.pl</h2>'.$this->l('Poniżej znajdują się parametry integracji systemu płatności Transferuj.pl.');
$this->_html .= '
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<fieldset>
<legend><img src="../img/admin/contact.gif" />'.$this->l('Główne ustawienia').'</legend>
<table id="form" cellspacing="5" cellpadding="5" border="0">
<tr><td>
<label>'.$this->l('ID Sprzedawcy').'
<small style="color:red">'.$this->l('Obowiązkowe').'</small></label>
</td><td>
<input type="text" name="sprzedawcaID" value="'.Configuration::get('TRANSFERUJ_SID').'" />
</td></tr>
<tr><td>
<label>'.$this->l('Kod potwierdzający').'
<small>'.$this->l('Taki sam jak w Panelu sprzedawcy').'</small></label>
</td><td>
<input type="text" name="kod_potw" value="'.Configuration::get('TRANSFERUJ_COD').'" maxlength="16" />
</td></tr>
<tr><td>
<label>'.$this->l('IP serwera').'
<small style="color:red">'.$this->l('Obowiązkowe').'</small></label>
</td><td>
<input type="text" name="ip_serw" value="'.Configuration::get('TRANSFERUJ_TIP').'" />
</td></tr>
<tr><td>
<label>'.$this->l('prowicja').'
<small>'.$this->l('prowicja').'</small></label>
</td><td>
<input type="text" name="prowicja" value="'.Configuration::get('PROWICJA').'" />
</td></tr>
<tr><td>
<label>'.$this->l('Pokaż kanały płatności').'
</label>
</td><td><select name="t_kanaly">
<option value="1" '.(Configuration::get('TRANSFERUJ_SHOW_CHANNELS')==1?'selected':'').'> Tak </option>
<option value="0" '.(Configuration::get('TRANSFERUJ_SHOW_CHANNELS')==0?'selected':'').'> Nie </option>
</select></td></tr>
<tr><td>
<label>'.$this->l('Pokaż tylko kanały online').'
</label>
</td><td><select name="t_online">
<option value="1" '.(Configuration::get('TRANSFERUJ_CHANNELS_ONLINE')==1?'selected':'').'> Tak </option>
<option value="0" '.(Configuration::get('TRANSFERUJ_CHANNELS_ONLINE')==0?'selected':'').'> Nie </option>
</select></td></tr>
<tr><td>
<label>'.$this->l('Wyświetlaj informację z regulaminem Transferuj.pl').'
</label>
</td><td><select name="t_reg">
<option value="1" '.(Configuration::get('TRANSFERUJ_SHOW_REG')==1?'selected':'').'> Tak </option>
<option value="0" '.(Configuration::get('TRANSFERUJ_SHOW_REG')==0?'selected':'').'> Nie </option>
</select></td></tr>
</table>
<input type="submit" name="submit" value="'.$this->l('Zapisz Ustawienia').'" class="button" />
</fieldset>
</form>';
}
function install()
{
if (!parent::install() OR !$this->registerHook('payment') OR !$this->registerHook('paymentReturn'))
return false;
Configuration::updateValue('TRANSFERUJ_TIP', '195.149.229.109');
Configuration::updateValue('TRANSFERUJ_SHOW_CHANNELS', '1');
Configuration::updateValue('TRANSFERUJ_CHANNELS_ONLINE', '0');
Configuration::updateValue('TRANSFERUJ_SHOW_REG', '1');
Configuration::updateValue('PROWICJA', '3%');
if (Validate::isInt(Configuration::get('TRANSFERUJ_NEW_ORDER')) XOR (Validate::isLoadedObject($order_state_new = new OrderState(Configuration::get('TRANSFERUJ_NEW_ORDER')))))
{
$order_state_new = new OrderState();
$order_state_new->name[Language::getIdByIso("pl")] = "Oczekiwanie na płatność Transferuj";
$order_state_new->name[Language::getIdByIso("en")] = "Awaiting Transferuj payment";
$order_state_new->send_email = false;
$order_state_new->invoice = false;
$order_state_new->unremovable = false;
$order_state_new->color = "lightblue";
if (!$order_state_new->add())
return false;
//@copy('logo.gif', '../../img/os/'.$order_state_new->id.'.gif');
if(!Configuration::updateValue('TRANSFERUJ_NEW_ORDER', $order_state_new->id))
return false;
}
return true;
}
function uninstall()
{
return (parent::uninstall());
}
function hookPayment($params)
{
if (!$this->active)
return;
global $smarty, $cookie;
$smarty->assign('this_path', $this->_path);
$smarty->assign('buttonText', $this->l('Płać z Transferuj.pl'));
return $this->display(__FILE__, 'transferuj.tpl');
}
function hookPaymentReturn($params){
if (!$this->active)
return;
return $this->display(__FILE__, 'confirmation.tpl');
}
function preparePayment()
{
global $smarty, $cart, $cookie;
$kraj_iso = LanguageCore::getIsoById($cookie->id_lang);
$currency = $this->getCurrency((int)$cart->id_currency);
if ($cart->id_currency != $currency->id)
{
$cart->id_currency = (int)$currency->id;
$cookie->id_currency = (int)$cart->id_currency;
$cart->update();
Tools::redirect('modules/'.$this->name.'/payment.php');
}
$address = new Address(intval($cart->id_address_invoice));
$customer = new Customer(intval($cart->id_customer));
if(Configuration::get('PROWICJA') != '3'){
$val = str_replace(',', '.', Configuration::get('PROWICJA'));
$prowicja = $cart->getOrderTotal(true, Cart::BOTH)/100*$val;
$kwota = round($cart->getOrderTotal(true, Cart::BOTH)+$prowicja,2);
$kwota = number_format($kwota, 2, '.', '')+$prowicja; // floatval nie jest potrzebne
}
else
{
$kwota = number_format($cart->getOrderTotal(true, Cart::BOTH)+$prowicja, 2, '.', ''); // floatval nie jest potrzebne
}
$channels = '';
$reg = '';
$sid = Configuration::get('TRANSFERUJ_SID');
if(Configuration::get('TRANSFERUJ_SHOW_CHANNELS') == 1 && function_exists('curl_exec'))
{
$api_url = "
https://secure.transferuj.pl/channels-".$sid.Configuration::get('TRANSFERUJ_CHANNELS_ONLINE').".js";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $api_url);
$curl_res = (curl_exec($ch));
@curl_close($ch);
preg_match_all("/\['(.*?)','(.*?)'/s", $curl_res, $res);
$channels = '<p>Wybierz swój kanał płatności:</p>
<table><tr>';
for($i=0;$i<count($res[1]);$i++)
{
$cell = "<td style='padding:4px'><input type='radio' id='tr_".$res[1][$i]."' name='kanal' value='".$res[1][$i]."' /><label for='tr_".$res[1][$i]."'> ".$res[2][$i]."</label></td>";
if($i % 2 == 1)
$channels .= $cell."</tr><tr>";
else
$channels .= $cell;
}
$channels .= '</tr></table>';
}
if(Configuration::get('TRANSFERUJ_SHOW_REG') == 1)
{
$reg = '
<input id="t_accept" type="checkbox" checked="checked" value="1" name="akceptuje_regulamin">
<label for="t_accept">
Akceptuję <a target="_blank" href="
https://secure.transferuj.pl/regulamin.pdf">regulamin[/url] serwisu Transferuj.pl
</label>';
}
$crc = base64_encode($cart->id);
$smarty->assign(array(
'kwota'=>$kwota,
'mail'=>$customer->email,
'nazwisko'=>$customer->lastname,
'imie'=>$customer->firstname,
'telefon'=>$address->phone,
'adres'=>$address->address1." ".$address->address2,
'miasto'=>$address->city,
'kod'=>$address->postcode,
'BackUrl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__,
'goBackUrl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'order-confirmation.php?key='.$customer->secure_key.'&id_cart='.intval($cart->id).'&id_module='.intval($this->id),
'goBackUrlError' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'history.php',
'notify' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/transferuj/validation.php',
'jezyk' => $kraj_iso,
'crc' => $crc,
'kraj'=>$address->country,
'sid'=> $sid,
'seckey'=> $customer->secure_key,
'chan'=> $channels,
'reg'=> $reg,
'prowicja'=> $prowicja
));
}
}
?>
Code: checkout.tpl
{capture name=path}<a href="{$link->getPageLink('order.php', true)}">{l s='Twoje zakupy' mod='transferuj'}[/url]<span class="navigation-pipe">{$navigationPipe}</span>{l s='Płać z Transferuj.pl' mod='transferuj'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}
<h2>{l s='Podsumowanie zamówienia' mod='transferuj'}</h2>
{assign var='current_step' value='payment'}
{include file="$tpl_dir./order-steps.tpl"}
<center><img src="transferuj-full-color-449x162.png" alt="{l s='Płać z Transferuj.pl' mod='transferuj'}" style="margin-bottom: 5px" /></center>
<p>
{l s='Poniżej znajduje się podsumowanie Twojego zamówienia.' mod='transferuj'}
</p>
<p style="margin-top:10px;">
<table width="60%" border="0" style="font-size:14px">
<tr>
<td>Podsumowanie zakupów :</td>
<td align="right"><strong>{convertPriceWithCurrency price =$cart->getOrderTotal(true) currency=$currency}</strong></td>
</tr>
<tr>
<td> </td>
<td align="right"> </td>
</tr>
<tr>
<td>Prowizja Transferuj.pl ( 3% ) : </td>
<td align="right"><strong>{convertPriceWithCurrency price =$prowicja currency=$currency}</strong></td>
</tr>
<tr>
<td> </td>
<td align="right"> </td>
</tr>
<tr>
<td>{l s='Całkowita kwota do zapłaty' mod='transferuj'}:</td>
<td align="right" style="text-decoration:underline" ><strong>{convertPriceWithCurrency price =$kwota currency=$currency}</strong></td>
</tr>
</table>
</p>
<p>
<form action="{$this_path_ssl}validation.php" method="post" id="transferujForm" name="transferujForm">
<input type="hidden" name="confirm" value={$seckey} />
<input type="hidden" name="id" value="{$sid}" />
<input type="hidden" name="kwota" value="{$kwota}" />
<input type="hidden" name="prowicja" value="{$prowicja}" />
<input type="hidden" name="email" value="{$mail}" />
<input type="hidden" name="nazwisko" value="{$nazwisko}" />
<input type="hidden" name="imie" value="{$imie}" />
<input type="hidden" name="adres" value="{$adres}" />
<input type="hidden" name="miasto" value="{$miasto}" />
<input type="hidden" name="kraj" value="{$kraj}" />
<input type="hidden" name="kod" value="{$kod}" />
<input type="hidden" name="jezyk" value="{$jezyk}" />
<input type="hidden" name="cart" value="{$crc}" />
<input type="hidden" name="telefon" value="{$telefon}" />
<input type="hidden" name="pow_url" value="{$goBackUrl}" />
<input type="hidden" name="pow_url_blad" value="{$goBackUrlError}" />
<input type="hidden" name="wyn_url" value="{$notify}" />
{$chan}
{$reg}
</p>
<p>
{l s='Potwierdź zamówienie klikając \'Potwierdzam zamówienie\'' mod='transferuj'}.</p>
<p class="cart_navigation">
<a href="{$link->getPageLink('order.php', true)}?step=3" class="button_large">{l s='Inne metody płatności' mod='transferuj'}[/url]
<a href="#" class="exclusive_large" onclick="$('#transferujForm').submit();return false;">{l s='Potwierdzam zamówienie' mod='transferuj'}[/url]
</p>