Assign Payment Processor To Order Status

we installed new payment gateway myfatoorah,
its work perfect with us , but we need to change the order status once order is completed from "complete" to another order status we will create call "Paid" and after order deliver we will assign it as complete to calculate to total paid correctly .

i change the the 'C' Letters to 'E' letter the new status. also nothing change.

{__("COMPLETED")}:
{foreach from=$statuses item="s" key="k"}
{$s}
{/foreach}
also i change
$myfatoorah_settings['general']['callback_url'] = fn_url('myfatoorah_callback', 'C'); to 'E'
and the order status come with complete no the new status.

Please return 'C' parameter to the fn_url function since it is not related with order status. It means store-front (customer) area

As for initial question, it is required to examine php script of this payment gateway. From the provided code I can see, that you should just change status in the payment method settings without changing the code

Please return 'C' parameter to the fn_url function since it is not related with order status. It means store-front (customer) area

As for initial question, it is required to examine php script of this payment gateway. From the provided code I can see, that you should just change status in the payment method settings without changing the code

thank you eCom lab you are really best company

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.

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';
$gateway_url = 'https://test.myfatoorah.com/pg/PayGatewayServiceV2.asmx';
$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");
}
)

The following line of code changes order status

fn_change_order_status($order_id, $myfatoorah_settings['myfatoorah_statuses']['COMPLETED'], '', false);

As you can see, it uses status from settings for successful orders. The only thing I do not like, the script does not check response from payment gateway and always set status defined in the settings

The following line of code changes order status

fn_change_order_status($order_id, $myfatoorah_settings['myfatoorah_statuses']['COMPLETED'], '', false);

As you can see, it uses status from settings for successful orders. The only thing I do not like, the script does not check response from payment gateway and always set status defined in the settings

yes eCom lab your are right , and thank a lot for your guileless

You are welcome!

The following line of code changes order status

fn_change_order_status($order_id, $myfatoorah_settings['myfatoorah_statuses']['COMPLETED'], '', false);

As you can see, it uses status from settings for successful orders. The only thing I do not like, the script does not check response from payment gateway and always set status defined in the settings

That is a poorly written payment script. It should always check the response from the request and act accordingly.

When we write payment methods, we generally let the user choose in their payment method settings what the order status should be based on the response, not just hard-wired to one value for all responses.

Standard type of responses to handle are Fail, Declined, Approved, Pending. These are general and need to be tailored to the payment method. Generally Fail is an inability to process the transaction (like connection failure, bad account, sometimes bad card data like CVV or Postal Codes, etc.); Declined is for insufficient funds, AVS failures or other card/customer related issues; Approved can be a successful Capture or a successful Auth,.depending on payment provider capabilities; and Pending is usually related to those types of payment methods that require further approval (like credit accounts, etc.) where the actual approval status will be determined manually or come asynchonously at a later time (after customer has placed the order)..

That is a poorly written payment script. It should always check the response from the request and act accordingly.

When we write payment methods, we generally let the user choose in their payment method settings what the order status should be based on the response, not just hard-wired to one value for all responses.

Standard type of responses to handle are Fail, Declined, Approved, Pending. These are general and need to be tailored to the payment method. Generally Fail is an inability to process the transaction (like connection failure, bad account, sometimes bad card data like CVV or Postal Codes, etc.); Declined is for insufficient funds, AVS failures or other card/customer related issues; Approved can be a successful Capture or a successful Auth,.depending on payment provider capabilities; and Pending is usually related to those types of payment methods that require further approval (like credit accounts, etc.) where the actual approval status will be determined manually or come asynchonously at a later time (after customer has placed the order)..

thank you EZ , we face many issue from this payment and we contact the company to edit it ,

also there problem with that payment, if customer choose this payment methods and the payment page opens and customer close the page without enter any data , cs-cart create incomplete order. is that normal .

When we write payment methods, we generally let the user choose in their payment method settings what the order status should be based on the response, not just hard-wired to one value for all responses.

Standard type of responses to handle are Fail, Declined, Approved, Pending. These are general and need to be tailored to the payment method. Generally Fail is an inability to process the transaction (like connection failure, bad account, sometimes bad card data like CVV or Postal Codes, etc.); Declined is for insufficient funds, AVS failures or other card/customer related issues; Approved can be a successful Capture or a successful Auth,.depending on payment provider capabilities; and Pending is usually related to those types of payment methods that require further approval (like credit accounts, etc.) where the actual approval status will be determined manually or come asynchonously at a later time (after customer has placed the order)..

I agree with you. But we integrated payment systems which do not have callbacks at all. You can only specify success and failed URLs to which customer is redirected after payment. If MyFatoorah works in this way, we do not recommend to use it

I agree with you. But we integrated payment system which do not have callbacks at all. You can only specify success and failed URLs to which customer is redirected after payment. If MyFatoorah works in this way, we do not recommend to use it

in general thank you all for your great help, you are really the best companies ever

You are welcome! :)

If the payment process can't be completed, it will most likely generate an incompleted order. However, this too is controlled by the payment method. All orders start out as incompleted and have to have their status changed based on what happens in the payment method.

If the payment process can't be completed, it will most likely generate an incompleted order. However, this too is controlled by the payment method. All orders start out as incompleted and have to have their status changed based on what happens in the payment method.

yes EZ that's what happen with us . overall we understand that with this payment methods.

and we was familiar with it.

special thank to you EZ for your help