You can have the payment script set the order status based on the responses from the payment processor. The script is either located in the app/payments directory or in app/addons/[PROCESSOR ADDON]/payments directory
You can then evaluate the response and set it to whatever order status you want by setting $pp_response['order_status'] to the status you want (in your example 'E'). The order status should be based on "response" rather than an input form.
thank you EZ i found it in payment Setting as eCom lab Guided me ,
i tried to find you code "$pp_response['order_status']" in payment processor and it didn't exist.,
i will share the script with yours
(
use Tygh\Registry;
use Tygh\Http;
use Tygh\Session;
// app/addons/myfatoorah_payment/payments/myfatoorah_payment_processor.php
// Preventing direct access to the script, because it must be included by the "include" directive. The "BOOTSTRAP" constant is declared during system initialization.
defined('BOOTSTRAP') or die('Access denied');
// Here are two different contexts for running the script.
if (defined('PAYMENT_NOTIFICATION')) {
/**
* Receiving and processing the answer
* from third-party services and payment systems.
*/
if ($mode == 'complete' && !empty($_REQUEST['order_id'])) {
$order_id = $_REQUEST['order_id'];
$cart = &Tygh::$app['session']['cart'];
$order_info = fn_get_order_info($_REQUEST['order_id'], true);
$myfatoorah_settings = fn_myfatoorah_payment_get_myfatoorah_settings();
fn_change_order_status($order_id, $myfatoorah_settings['myfatoorah_statuses']['COMPLETED'], '', false);
fn_finish_payment($_REQUEST['order_id'], $order_info['payment_info'], false);
fn_order_placement_routines('repay', $_REQUEST['order_id'], 'A');
// fn_clear_cart($cart, true, true);
} elseif ($mode == 'cancel') {
fn_order_placement_routines('route', $_REQUEST['order_id']);
}
} else {
$cart = &Tygh::$app['session']['cart'];
$auth = \Tygh::$app['session']['auth'];
try {
/**
* Running the necessary logics for payment acceptance
* after the customer presses the "Submit my order" button.
*/
$merchant_code = Registry::get('addons.myfatoorah_payment.merchant_code');
$merchant_username = Registry::get('addons.myfatoorah_payment.merchant_username');
$merchant_password = Registry::get('addons.myfatoorah_payment.merchant_password');
$gateway_url = Registry::get('addons.myfatoorah_payment.gateway_url');
$payment_type = Registry::get('addons.myfatoorah_payment.payment_type');
$test_mode = Registry::get('addons.myfatoorah_payment.test_mode');
if($test_mode == 'Y'){
$merchant_code = '999999';
$merchant_username = 'testapi@myfatoorah.com';
$merchant_password = 'E55D0';
$payment_type = 'BOTH';
}
$item_mode = Registry::get('addons.myfatoorah_payment.item_mode');
$description_mode = Registry::get('addons.myfatoorah_payment.description_mode');
$slogan = Registry::get('addons.myfatoorah_payment.myfatoorah_slogan');
$lang_settings = Registry::get('settings.Appearance.frontend_default_language');
$currencies_settings = Registry::get('currencies');
$myfatoorah_settings = fn_myfatoorah_payment_get_myfatoorah_settings();
if ($order_info['secondary_currency'] == 'USD' ||
$order_info['secondary_currency'] == 'EUR' ||
$order_info['secondary_currency'] == 'KWD' ||
$order_info['secondary_currency'] == 'GEL'
) {
$order_currency = $order_info['secondary_currency'];
} else {
throw new Exception('Selected currency is not accepted for this payment method');
}
$items = array();
$product_options = array();
foreach ($order_info['products'] as $product) {
if($description_mode == "short_description"){
$product_data = fn_get_product_data($product['product_id'], $auth, CART_LANGUAGE, '', true, true, true, false, false, true, false, true);
}else{
if (!empty($product['product_options'])) {
foreach ($product['product_options'] as $opt) {
array_push($product_options, $opt['option_name'] . ": " . $opt['variant_name']);
}
} else {
$product_options = array();
}
}
if(!empty($product_options)){
$attributes = implode(", ", $product_options);
}else{
$attributes = "";
}
if(!empty($product_data['short_description'])){
$short_description = $product_data['short_description'];
}else{
$short_description = "";
}
array_push($items, $product['subtotal'] . "|" .
$product['amount'] . "|" .
$product['product'] . "|" . $short_description . "|" . $attributes);
}
$order_name = "";
$order_description = "";
$taxes = 0;
foreach ($order_info['taxes'] as $v)
{
foreach ($v['applies']['items']['P'] as $k1 => $v1)
{
$taxes += $v['rate_value'];
}
}
$shipping = 0;
foreach ($order_info['shipping'] as $v)
{
$shipping += $v['rate'];
}
$confirm_link = fn_url("payment_notification.complete?payment=myfatoorah_payment_processor&order_id=" . $order_id.'&id', AREA, 'current');
$cancel_link = fn_url("payment_notification.cancel?payment=myfatoorah_payment_processor&order_id=" . $order_id.'&', AREA, 'current');
$back_link = base64_encode($confirm_link . "|" . $cancel_link);
if (empty($merchant_code)) {
throw new Exception("Merchant ID is Empty");
}
if (empty($order_info['order_id'])) {
throw new Exception("Order ID is Empty");
}
if (empty($order_info['total'])) {
throw new Exception("Order Price is Empty");
}
$data = array(
"merchant_code" => $merchant_code,
"merchant_username" => $merchant_username,
"merchant_password" => $merchant_password,
"payment_type" => $payment_type,
"MerchantUser" => $order_info['email'],
"firstname" => $order_info['firstname'],
"phone" => $order_info['phone'],
"MerchantOrderID" => $order_info['order_id'],
"OrderPrice" => $order_info['total'],
"OrderCurrency" => $order_currency,
"OrderName" => $order_name,
"OrderDescription" => $order_description,
"confirm_link" => $confirm_link,
"cancel_link" => $cancel_link,
"Mlogo" => base64_encode($myfatoorah_settings['main_pair']['detailed']['image_path']),
"Mslogan" => $slogan,
"Language" => (($lang_settings == "ka") ? "GE" : "EN"),
);
$data_hash = implode("|", $data);
$data['Items'] = $items;
$data['shipping'] = $shipping;
$data['taxes'] = $taxes;
$result = fn_myfatoorah_payment_send_request($gateway_url, $data);
$file_contents = htmlspecialchars($result);
$doc = new \DOMDocument();
if ($doc != null) {
$doc->loadXML( html_entity_decode($file_contents) );
$ResponseCode = $doc->getElementsByTagName("ResponseCode");
$ResponseCode = $ResponseCode->item(0)->nodeValue;
$paymentUrl = $doc->getElementsByTagName("paymentURL");
$paymentUrl = $paymentUrl->item(0)->nodeValue;
$referenceID = $doc->getElementsByTagName("referenceID");
$referenceID = $referenceID->item(0)->nodeValue;
$ResponseMessage = $doc->getElementsByTagName("ResponseMessage");
$ResponseMessage = $ResponseMessage->item(0)->nodeValue;
} else {
//Error connecting server
header('Location: '.$merchant_error_url);
}
$responseArray = array(
'result' => 'success',
'redirect' =>$paymentUrl,
'ResponseCode' => $ResponseCode,
'paymentUrl' => $paymentUrl,
'referenceID' => $referenceID);
if ($ResponseCode == '0') {
// tep_session_register('referenceID');
header('Location: '.$paymentUrl);
exit;
} else {
tep_redirect($error_url);
}
exit();
} catch (Exception $exception) {
fn_set_notification('E', __('Error'), $exception->getMessage());
}
fn_print_r("Sending data");
}
)