New payment gateway addon incredible error

420 views Asked by At

i'm making some tests to develop a custom payment gateway addon in cscart

The development has been very simple and intuitive, but there is a thing i am going crazy for 1 week. After the transaction as been completed the user is redirected to index.php?dispatch=checkout.complete&order_id=20036 but the green popup notification dosn't appear as on the other payments....

The code looks like normal.. i look on all other payments script and all is regular

the final function in /core/fn.cart.php fn_order_placement_routines valorize correctly the $_SESSION var with the notification data fn_set_notification('N',.....

this is the code

if (!defined('AREA') ) { die('Access denied'); }
if (defined('PAYMENT_NOTIFICATION')) {
if ($mode == 'notify' && !empty($_REQUEST['order_id'])) {
  if (fn_check_payment_script('gateway.php', $_REQUEST['order_id'], $processor_data)) {
   $order_id = $_REQUEST['order_id'];
   $order_info = fn_get_order_info($order_id);
   $pp_response = array(
    'reason_text' => '',
    'order_status' => 'F'
   );
   if (empty($processor_data)) {
    $processor_data = fn_get_processor_data($order_info['payment_id']);
   }
   $returnvalue = $_POST['PROCESSING_RESULT'];
   if ($returnvalue && strstr($returnvalue,"ACK")) {
    $pp_response['order_status'] = "E";
    $pp_response['reason_text'] .= "Status: OK";
   }else {
    $pp_response['order_status'] = "N";
    $pp_response["reason_text"] = fn_get_lang_var('text_transaction_cancelled');
   }
   if (isSet($_REQUEST['IDENTIFICATION_UNIQUEID'])) {
    $pp_response['transaction_id'] = $_REQUEST['IDENTIFICATION_UNIQUEID'];
   }
[b]   fn_finish_payment($_REQUEST['order_id'], $pp_response, false);
   fn_order_placement_routines($_REQUEST['order_id'], true);[/b]
  }
}
} else {
    if ($mode == 'place_order') {
    //call the gateway, assign response url etc
    // $current_location."/".$index_script."?dispatch=payment_notification.notify&payment=gateway.php&order_id=".$order_id;
    }
}

the fn_order_place_routine should be show by default the green or red popup based on the status of the order.... nothing.. dosn't appear

thanks in advance

1

There are 1 answers

0
bimib On

As I can see you are using custom order status for sucessfull transaction:

$pp_response['order_status'] = "E";

So, to display notification the 'inventory' option for this status should be set as 'Decreased'. In this case the E status will be included in the result of the fn_get_order_paid_statuses() function and the following code in the fn_order_placement_routines function will work:

if (in_array($status, fn_get_order_paid_statuses())) {
    if ($action == 'repay') {
        fn_set_notification('N', __('congratulations'), __('text_order_repayed_successfully'));
    } else {
        fn_set_notification('N', __('order_placed'), __('text_order_placed_successfully'));
    }
}

Best regards.