Function: fn_order_placement_routines

Does cs-cart have a function for use in paymentprocessor that finalize order, emty chart… like “fn_order_placement_routines” but for execute in background, no redirect etc…?



My psp does not in some cases redirect user back to shop then the function “fn_order_placement_routines” won't be executed by the user.

But someone has to know??

fn_fninalize_payment(), but if you don't have a response, you are probably missing information that is needed.

Hi, My code look something like this… I want to finalize order in 'mode = notify' and send xml-replay



if (defined('PAYMENT_NOTIFICATION')) {
if ($mode == 'notify') {
// Notify/callback from PSP (no user)
if ( $n_result[1] == 1 ) { // Successful payment
$pp_response['order_status'] = 'P';
$pp_response['transaction_id'] = $n_transactionid[1];
$pp_response['reason_text'] = $processor_msg['result'][$n_result[1]];
fn_finish_payment($_REQUEST['order_id'], $pp_response, true);
$sendresponse = xmlresponse(1,"OK|Completed.");
} else { // Failed payment
$pp_response['order_status'] = ($n_result[1] == 4) ? 'I' : 'F'; // I=Cancel F=Fail
$pp_response['reason_text'] = $processor_msg['result'][$n_result[1]];
$pp_response['errorcode'] = $n_reason[1];
$pp_response['errorName'] = $processor_msg['reason'][$n_reason[1]];
fn_finish_payment($_REQUEST['order_id'], $pp_response, false);
$sendresponse = xmlresponse(1,"OK|Cancel");
}

// Here I want to 'finalize' order AND send XML-reply
echo $sendresponse; // This is XML
//fn_order_placement_routines($_REQUEST['order_id']) // this one allso redirects
exit; // we don't want meta refresh in xml-replay

} elseif ($mode == 'return') {
// User return after completed payment
// Make pp_resonse
fn_finish_payment($_REQUEST['order_id'], $pp_response, false);
} else {
// User return after NOT completed payment.
// Make pp_resonse
fn_finish_payment($_REQUEST['order_id'], $pp_response, false);
}
fn_order_placement_routines($_REQUEST['order_id']) // I want to execute and finalize order..
} else {
// ---
}

Sorry, no time to review custom code snippets.

[quote name='tbirnseth' timestamp='1336243616' post='135915']

Sorry, no time to review custom code snippets.

[/quote]



Ok, but do you know how to emty cart etc… from paymentprocessor (callback from PSP, no user)



something like…


// Empty cart
if ($clear_cart == true && $_error == false) {
$_SESSION['cart'] = array(
'user_data' => !empty($_SESSION['cart']['user_data']) ? $_SESSION['cart']['user_data'] : array(),
'profile_id' => !empty($_SESSION['cart']['profile_id']) ? $_SESSION['cart']['profile_id'] : 0,
'user_id' => !empty($_SESSION['cart']['user_id']) ? $_SESSION['cart']['user_id'] : 0,
);
$_SESSION['shipping_rates'] = array();
unset($_SESSION['shipping_hash']);

db_query('DELETE FROM ?:user_session_products WHERE session_id = ?s AND type = ?s', Session::get_id(), 'C');
}

If things were done properly, there should be NO cart after an order is placed. It moves from cart to order when placed.

[quote name=‘tbirnseth’ timestamp=‘1337274098’ post=‘136633’]

If things were done properly, there should be NO cart after an order is placed. It moves from cart to order when placed.

[/quote]



When the customer comes back from the PSP via redirect_ok_ulr and executes “fn_order_placement_routines” then it works fine. If customer chooses bankpayments on PSP paymentpage the customer is redirected from PSP to bank’s paymentpage, and some of the banks does not send the customer back to the store/PSP after successful payment :-(



If the payment is successful my PSP always send background/callback and execute “fn_finish_payment” and this works great… It’s not possible to make “fn_order_placement_routines” here because that function requires correct session cookie.



When the customer later come to make the new order the old session in “cscart_sessions” are still active and he can not make new orders due to duplicate order number at PSP :-(

Bump.