Problem With A New Payment Method With A Local Bank

hi to everyone.

i'm a new user at this forum and a newbie of cs-cart.

i have create a script for payment with a local bank.

the script work correctly, send payment at the bank server and return the result of transition.

When i catch the result of transition, I change the state of order like processed, but I can't clear the cart.

the server of the bank accept two url for the transition positive result (urlok, urlack) and two for the negtive (urlko ,urlnack).

so, urlok and urlko assign the value of a button to return at the site at the end of transition.

urlack and urlnack execute the background operation without force the user to return to the site at the end of operation.

this is a part of my script.

i think ther is an error when i try to refresh the page whith the new url.

Can anyone help me?

/***************************************************************************

  •                                                                      *
    
  • (c) 2015 Lorenzo Zanin *

  •                                                                      *
    

****************************************************************************/

use Tygh\Session; //ok

use Tygh\Registry;

if (defined(‘PAYMENT_NOTIFICATION’)){

if ($mode == 'notify') {
	fn_order_placement_routines('route', $_REQUEST['order_id']);
}

}elseif(!empty($_GET[‘ORDER_ID’])){

 require './init_payment.php';

$orderid=substr($_GET['ORDER_ID'], -2,2);

$order_info = fn_get_order_info($orderid, true);


fn_payments_set_company_id($orderid);

$pp_response = array();

$pp_response['order_status'] = 'P';

 $pp_response['reason_text']=__('transaction_approved');

 $pp_response['transaction_id'] =$_GET['TRANSACTION_ID'];


fn_finish_payment($orderid, $pp_response);



  echo "";
exit;

}else{

if (!defined('BOOTSTRAP')) { die('Access denied'); }

// info dell'ordine ( sperando che $order_info sia già definita da qualche parte )

// ammontare totale dell'ordine

$totale = str_replace('.', ',', $order_info["total"]);



$numero = rand(0,9999);

// qui c'è l'id dello'ordine va aggiunta una stringa casuale per evitare che la richiesta d'ordine venga eseguita due volte allo stesso modo creo numero random 

$order_id='MAMATEST'.$numero."-".$order_info["order_id"];

// id dell'ordine ( mi serve dopo per estrerre i dati degli articoli che ci sono nell'ordine)

$_order_id = ($order_info['repaid']) ? ($order_id . '_' . $order_info['repaid']) : $order_id;



// indirizzo per invio pagamento

if ($processor_data['processor_params']['mode'] == 'test')

{

	$payment_url = 'https://www.servizipos.it/GT_EgipsyWeb/CheckOutEGIPSy.jsp';

	$totale='0,01';

}else

{

	$payment_url = '';

}	



$mid=$processor_data['processor_params']['merchant_id'];

$divisa='EUR';

$abi='035XX';

$items='2002^prova^1^0,01^EUR';

$key="E5D49168---------------------B02360B6B";

$mac=strtoupper(md5($mid.$order_id.$totale.$divisa.$abi.$items.$key));

//$urlok= fn_url("payment_notification.process?payment=elmama_virtual_pay&order_id={$order_info['order_id']}", AREA, 'current');

$urlnotify=fn_url("payment_notification.notify?payment=elmama_virtual_pay&order_id={$order_info['order_id']}", AREA, 'current');

$url2= fn_payment_url('current','elmama_virtual_pay.php');


$post_data = array(

	 'MERCHANT_ID' => $mid,

	 'ORDER_ID' => $order_id,

	 'IMPORTO' => $totale,

	 'DIVISA' => $divisa,

	 'ABI' => $abi,

	 'ITEMS' => $items,

	 'LINGUA' => 'ita',

	 'URLOK' => 'http://elmama.it/',  // da impostare una volta creata una pagina apposita per pagamento andato a buon fine

	 'URLKO' => 'http://elmama.it/', 

	 'URLACK'=>	$url2, 

	 'URLNACK'=>$url2,

	 'MAC' => $mac



);

//fn_change_order_status($order_info["order_id"], 'O');

fn_create_payment_form($payment_url, $post_data, 'El Mama VirtualPay');

exit;//  --> Ci va?

}

?>

Cart is cleared in the fn_order_placement_routines function. Are you sure you can reach this part of code?

Cart is cleared in the fn_order_placement_routines function. Are you sure you can reach this part of code?

Thanks for the reply and sorry for my english.

The problem is this. the functions fn_order_placement_routines isn't reach.

the script arrived correctly at: fn_finish_payment($orderid, $pp_response);

but i think is the successive line the problem. this line:

echo "";
	exit;

because don't work every line of code I put into the:

if (defined('PAYMENT_NOTIFICATION')){
.....
    .....

}

urlok and urlko should be

domain.com/app/payments/elmama_virtual_pay.php

urlack and urlnack should be

domain.com/index.php?dispatch=payment_notification.notify?payment=elmama_virtual_pay&order_id=XXX

Try to replace:

         'URLOK' => 'http://elmama.it/',  // da impostare una volta creata una pagina apposita per pagamento andato a buon fine
     'URLKO' => 'http://elmama.it/', 

with

         'URLOK' => $urlnotify,  // da impostare una volta creata una pagina apposita per pagamento andato a buon fine
     'URLKO' => $urlnotify, 

Try replacing the line:

echo "";
    exit;

with this one:

fn_redirect('payment_notification.notify?payment=elmama_virtual_pay&order_id=' . $orderid);

Try replacing the line:

echo "";
    exit;

with this one:

fn_redirect('payment_notification.notify?payment=elmama_virtual_pay&order_id=' . $orderid);

The initial code works correctly, just notify URLs are not sent to the payment gateway

hi eComLabs

if i use

 'URLOK' => $urlnotify,  // da impostare una volta creata una pagina apposita per pagamento andato a buon fine

‘URLKO’ => $urlnotify,

the script work correctly!

but to change the state of order i have to force the user to return on my site. with push on button which activates the command urlok and I'd prefer not to. because the user could leave the site of the bank without pressing the button to go back to my site.

Simtech this don't work

fn_redirect('payment_notification.notify?payment=elmama_virtual_pay&order_id=' . $orderid);
I have also tried to use the functions
fn_order_placement_routines('route', orderid);

just after fn_finish_payment($orderid, $pp_response);

but don't work