Problem developing new Payment Module

Hi there folks,



I’m trying to develop a Payment Module for my enterprise payment system but I’m having some issues with that.



This is the file struct of my Paymente Module:


  • skins/computer_shop/customer/views/orders/components/payments/multibanco.tpl
  • payments/multibanco.php
  • payments/multibanco/ifmb.php



    And these are the files content by the struct order:



    File: multibanco.tpl

{* $Id: multibanco.tpl 6645 2008-12-22 20:21:37Z zeke $ *}



File: multibanco.php

```php
if (defined('PAYMENT_NOTIFICATION')) {

$pp_response = array();

$pp_response['order_status'] = 'P';
fn_finish_payment($_REQUEST['order_id'],$pp_response);

fn_order_placement_routines($_REQUEST['order_id'],array(),true,'save');

}else{

$entidade=$processor_data['params']['entidade'];
$subentidade=$processor_data['params']['subentidade'];
$order_total=$order_info['total'];
$current_location = Registry::get('config.current_location');
$link_script = $current_location . "/payments/multibanco/ifmb.php";
$url_return = $current_location . "/$index_script";

echo <<










EOT;
}
?> ```



File: ifmb.php

```php function format_number($number)
{
$verifySepDecimal = number_format(99,2);

$valorTmp = $number;

$sepDecimal = substr($verifySepDecimal, 2, 1);

$hasSepDecimal = True;

$i=(strlen($valorTmp)-1);

for($i;$i!=0;$i-=1)
{
if(substr($valorTmp,$i,1)=="." || substr($valorTmp,$i,1)==","){
$hasSepDecimal = True;
$valorTmp = trim(substr($valorTmp,0,$i))."@".trim(substr($valorTmp,1+$i));
break;
}
}

if($hasSepDecimal!=True){
$valorTmp=number_format($valorTmp,2);

$i=(strlen($valorTmp)-1);

for($i;$i!=1;$i--)
{
if(substr($valorTmp,$i,1)=="." || substr($valorTmp,$i,1)==","){
$hasSepDecimal = True;
$valorTmp = trim(substr($valorTmp,0,$i))."@".trim(substr($valorTmp,1+$i));
break;
}
}
}

for($i=1;$i!=(strlen($valorTmp)-1);$i++)
{
if(substr($valorTmp,$i,1)=="." || substr($valorTmp,$i,1)=="," || substr($valorTmp,$i,1)==" "){
$valorTmp = trim(substr($valorTmp,0,$i)).trim(substr($valorTmp,1+$i));
break;
}
}

if (strlen(strstr($valorTmp,'@'))>0){
$valorTmp = trim(substr($valorTmp,0,strpos($valorTmp,'@'))).trim($sepDecimal).trim(substr($valorTmp,strpos($valorTmp,'@')+1));
}

return $valorTmp;
}
//FIM TRATAMENTO DEFINIÇÕES REGIONAIS


//INICIO REF MULTIBANCO

function GenerateMbRef($ent_id, $subent_id, $order_id, $order_value)
{


$order_id ="0000".$order_id;

$order_value = format_number($order_value);

//Apenas sao considerados os 4 caracteres mais a direita do order_id
$order_id = substr($order_id, (strlen($order_id) - 4), strlen($order_id));


if ($order_value < 1){
echo "Lamentamos mas é impossível gerar uma referência MB para valores inferiores a 1 Euro";
return;
}
if ($order_value >= 1000000){
echo "AVISO: Pagamento fraccionado por exceder o valor limite para pagamentos no sistema Multibanco
";
}
while ($order_value >= 1000000){
GenerateMbRef($order_id++, 999999.99);
$order_value -= 999999.99;
}


//cálculo dos check digits


$chk_str = sprintf('%05u%03u%04u%08u', $ent_id, $subent_id, $order_id, round($order_value*100));

$chk_array = array(3, 30, 9, 90, 27, 76, 81, 34, 49, 5, 50, 15, 53, 45, 62, 38, 89, 17, 73, 51);

for ($i = 0; $i < 20; $i++)
{
$chk_int = substr($chk_str, 19-$i, 1);
$chk_val += ($chk_int%10)*$chk_array[$i];
}

$chk_val %= 97;

$chk_digits = sprintf('%02u', 98-$chk_val);

return $subent_id." ".substr($chk_str, 8, 3)." ".substr($chk_str, 11, 1).$chk_digits;

}

$ent= $_POST['ENTIDADE'];
$subent = $_POST['SUBENTIDADE'];
$order_id = $_POST['ID'];
$order_total = $_POST['VALOR'];
$url_return = $_POST['RETURN'];

$ref = GenerateMbRef($ent, $subent, $order_id, $order_total);
?>







IFMB - Sistema Pagamentos Por Multibanco







































Pagamento por Multibanco ou Homebanking
Entidade:
Referência:
Valor:
O talão emitido pela caixa automática faz prova de pagamento. Conserve-o.


>



/>










```

When I checkout order and go to the payment page in order to get the values to pay the product everything is ok.

The problem is when I click the button in the [B]ifmb.php[/B] page in order to return to the order page I get the two green box that is visible at the image that i will show:

[IMG]http://dl.dropbox.com/u/1725058/cscart_issue.jpg[/IMG]

How can I remove the Green Box that say "[B][I][U]Transaction was canceled by the customer[/U][/I][/B]"?!

Kind Regards,
Manuel Rocha

No one can help me?



I think this should be easy for you guys.

[quote name=‘rei007’]No one can help me?



I think this should be easy for you guys.[/QUOTE]



Are you pushing a status at all? Are you reading the status from your Payment Processor correctly?

[quote name=‘gidarren’]Are you pushing a status at all? Are you reading the status from your Payment Processor correctly?[/QUOTE]



How do I see it with the code I present?