Jump to content

Payment module issue (SMARTY syntax)


Recommended Posts

Hello everyone
I am having an issue with Dotpay payment module. It sends to server a shop name as payment description. I was trying to make it in such syntax: cart id, firstname, lastname, city, email of client but i am not into SMARTY so there was no effect but only such errors in Apache errorlog:
PHP Parse error:  syntax error, unexpected ''description'' (T_CONSTANT_ENCAPSED_STRING), expecting ')'

Below you can se i made one change in script:

$params = array(
                    'id' => Configuration::get('DP_ID'),
                    'amount' => (float)$cart->getOrderTotal(true, Cart::BOTH),
                    'currency' => $currency["iso_code"],
  //                'description' => Configuration::get('PS_SHOP_NAME'), // <--- original
   
                    'url' => $this->context->link->getModuleLink('dotpay', 'payment', array('control' => $cart->id), Configuration::get('DP_SSL', false)),                        
                    'type' => 0,                        
                    'urlc' => $this->context->link->getModuleLink('dotpay', 'callback', array('ajax' => '1'), Configuration::get('DP_SSL', false)),
                    'control' => $cart->id,
                    'firstname' => $customer->firstname,
                    'lastname' => $customer->lastname,                        
                    'email' => $customer->email,
                    'street' => $address->address1,
                    'city' => $address->city,
                    'postcode'=> $address->postcode,
                    'api_version' => 'legacy'
        'description' = $params['id'].$params['firstname'].$params['lastname'].$params['city'].$params['email'] <--- changed


            );

I would appreciate any help.

 

Link to comment
Share on other sites

Whole payment processing script:

<?php
/**
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author    Piotr Karecki <[email protected]>
*  @copyright Dotpay
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*
*/

class dotpaypaymentModuleFrontController extends ModuleFrontController
{   
    public function initContent()
    {
        $this->display_column_left = false;	
        parent::initContent();
        $control=(int)Tools::getValue('control');
        $cart = $this->context->cart;              
        if (!empty($control))
            $cart = new Cart($control);
        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');
        $customer = new Customer($cart->id_customer);
        if (!Validate::isLoadedObject($customer))
                Tools::redirect('index.php?controller=order&step=1');
        $address = new Address($cart->id_address_invoice);
        $params = null;
        $template = "payment_return";
        if ($cart->OrderExists() == true) 
            Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.Order::getOrderByCartId($cart->id).'&key='.$customer->secure_key);                    
        elseif (Tools::getValue("status") == "OK")
            $form_url = $this->context->link->getModuleLink('dotpay', 'payment', array('control' => $cart->id, 'status' => 'OK'), Configuration::get('DP_SSL', false));
        else 
        {
            // 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'] == 'dotpay')
            {
                $authorized = true;
                break;
            }
            if (!$authorized)
                die('This payment method is not available.');         
            $template = "payment";
            $form_url = "https://ssl.dotpay.pl/";
            $currency = Currency::getCurrency($cart->id_currency);
            if (Configuration::get('DP_TEST')==1) $form_url.="test_payment/";
            $params = array(
                    'id' => Configuration::get('DP_ID'),
                    'amount' => (float)$cart->getOrderTotal(true, Cart::BOTH),
                    'currency' => $currency["iso_code"],
  //                'description' => Configuration::get('PS_SHOP_NAME'), //
		    
                    'url' => $this->context->link->getModuleLink('dotpay', 'payment', array('control' => $cart->id), Configuration::get('DP_SSL', false)),                        
                    'type' => 0,                        
                    'urlc' => $this->context->link->getModuleLink('dotpay', 'callback', array('ajax' => '1'), Configuration::get('DP_SSL', false)),
                    'control' => $cart->id,
                    'firstname' => $customer->firstname,
                    'lastname' => $customer->lastname,                        
                    'email' => $customer->email,
                    'street' => $address->address1,
                    'city' => $address->city,
                    'postcode'=> $address->postcode,
                    'api_version' => 'legacy',
'description' = $params['id'].$params['firstname'].$params['lastname'].$params['city'].$params['email']

            );
            $chk = $params['id'].$params['amount'].$params['currency'].$params['description'].$params['control'].Configuration::get('DP_PIN');
            $chk = rawurlencode($chk);
            if(Configuration::get('DP_CHK'))
                $params['chk']=hash('md5', $chk);
        }
        $this->context->smarty->assign(array(
            'params' => $params,
            'module_dir' => $this->module->getPathUri(),
            'form_url' => $form_url,
            ));
        $this->setTemplate($template.".tpl");
    }
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...