Changing Order Status

hello,,,,,

I am implementing a new payment processor i followed the documentation tutorial and created my payment script and i updated payment_processors table. The payment processor connects successfully to the Gateway with the correct data and i receive the feedback from the Gateway as url (containing mode payment and status ) like this (myurl&mode=successpayment=payment&status=approved) for example

and it worked ,,,,,

i want to know if this (myurl&mode=successpayment=payment&status=approved) is correct or Not if not what is the best possible way

Now the only status that occurs in admin panel is incomplete even when the transaction is approved by the Gateway !! how to update it ??

any help please???

Hello

During background communication or after return payment if you know that the payment will be successful, change the order status.

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

if (fn_change_order_status($order_id, $pp_response['order_status'], '', true)) {
define('ORDER_NOTIFICATION_SENT', true);

} // end if

Best regards

Robert

Hello

During background communication or after return payment if you know that the payment will be successful, change the order status.

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

if (fn_change_order_status($order_id, $pp_response['order_status'], '', true)) {
define('ORDER_NOTIFICATION_SENT', true);

} // end if

Best regards

Robert

hello,,

i tried it but still not working all my orders all with incomplete status even when the payment is successful

Hello

During background communication or after return payment if you know that the payment will be successful, change the order status.

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

if (fn_change_order_status($order_id, $pp_response['order_status'], '', true)) {
define('ORDER_NOTIFICATION_SENT', true);

} // end if

Best regards

Robert

i want to change the status after i receive the feedback from the gateway if the payment was successful i want to change the status to paid Successfully and notify the customer otherwise update the status to declined and also notify the customer about the status

Hello

Please show your code from file payment processor (file from directory /app/your_addon/payments)

Best regards

Robert

Hello

Please show your code from file payment processor (file from directory /app/your_addon/payments)

Best regards

Robert

/***************************************************************************
* *
* (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev *
* *
* This is commercial software, only users who have purchased a valid *
* license and accept to the terms of the License Agreement can install *
* and use this program. *
* *
****************************************************************************
* PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. *
****************************************************************************/

if (!defined('BOOTSTRAP')) { die('Access denied'); }

use Tygh\Tygh;

if (defined('PAYMENT_NOTIFICATION')) {
$pp_response = array();
$pp_response['order_status'] = 'F';
$pp_response['reason_text'] = __('text_transaction_declined');
$order_id = !empty($_REQUEST['order_id']) ? (int)$_REQUEST['order_id'] : 0;

if ($mode == 'success' && !empty($_REQUEST['order_id'])) {

$order_info = fn_get_order_info($order_id);
echo "successfull1";
if (empty($processor_data)) {
$processor_data = fn_get_processor_data($order_info['payment_id']);
}

$post_data = array();
$post_data_values = array(
'mid',
'orderid',
'status',
'orderAmount',
'currency',
'paymentTotal',
'riskScore',
'payMethod',
'txId',
'paymentRef'

);

foreach ($post_data_values as $post_data_value) {
if (isset($_REQUEST[$post_data_value])) {
$post_data[] = $_REQUEST[$post_data_value];
}
}



if($_REQUEST['status'] == 'CAPTURED') {
$pp_response['order_status'] = 'P';
$pp_response['reason_text'] = __('transaction_approved');
$pp_response['transaction_id'] = $_REQUEST['paymentRef'];
// if (fn_change_order_status($order_id, $pp_response['order_status'], '', true)) {
//define('ORDER_NOTIFICATION_SENT', true);

//}
$payment_id= $order_info['payment_id'];
$transaction_id= $pp_response['transaction_id'];
$status= $pp_response['order_status'];
fn_change_order_status($order_id, $pp_response['order_status'], '', $force_notification);


db_query("INSERT INTO `cscart_order_transactions`(payment_id``, `transaction_id`, `status`,'extras') VALUES ($payment_id, $transaction_id,$status,'mmmm')");




}

if (fn_check_payment_script('myprocessor.php', $order_id)) {
fn_finish_payment($order_id, $pp_response);

fn_order_placement_routines('route', $order_id);

}

}
else {

$payment_url = 'x';


$amount = fn_format_price($order_info['total'], $processor_data['processor_params']['currency']);
$confirm_url = fn_url("payment_notification.success?payment=bejaii&order_id=$order_id", AREA, 'current');
$cancel_url = fn_url("payment_notification.fail?payment=bejaii&order_id=$order_id", AREA, 'current');

/** @var \Tygh\Location\Manager $location_manager */
$location_manager = Tygh::$app['location'];

$post_data = [
// 'mid' => $processor_data['processor_params']['merchant_id'],
// 'lang' => $processor_data['processor_params']['language'],
'orderid' => time() . $order_id,
//'orderDesc' => '#' . $order_id,
'orderAmount' => $amount,
// 'currency' => $processor_data['processor_params']['currency'],
//'payerEmail' => $order_info['email'],
//'payerPhone' => $location_manager->getLocationField($order_info, 'phone', '', BILLING_ADDRESS_PREFIX),
//'trType' => '1',
'confirmUrl' => $confirm_url,
// 'cancelUrl' => $cancel_url,
// 'billState' => $location_manager->getLocationField($order_info, 'state', '', BILLING_ADDRESS_PREFIX),
// 'billZip' => $location_manager->getLocationField($order_info, 'zipcode', '', BILLING_ADDRESS_PREFIX),
// 'billCity' => $location_manager->getLocationField($order_info, 'city', '', BILLING_ADDRESS_PREFIX),
// 'billAddress' => $location_manager->getLocationField($order_info, 'address', '', BILLING_ADDRESS_PREFIX),
// 'shipCountry' => $location_manager->getLocationField($order_info, 'country', '', SHIPPING_ADDRESS_PREFIX),
// 'shipState' => $location_manager->getLocationField($order_info, 'state', '', SHIPPING_ADDRESS_PREFIX),
// 'shipZip' => $location_manager->getLocationField($order_info, 'zipcode', '', SHIPPING_ADDRESS_PREFIX),
// 'shipCity' => $location_manager->getLocationField($order_info, 'city', '', SHIPPING_ADDRESS_PREFIX),
// 'shipAddress' => $location_manager->getLocationField($order_info, 'address', '', SHIPPING_ADDRESS_PREFIX),
];
//fn_print_r(json_encode($post_data));
//fn_print_r($post_data);


fn_create_payment_form($payment_url, $post_data, 'xx', true);
}
exit;


/***************************************************************************
* *
* (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev *
* *
* This is commercial software, only users who have purchased a valid *
* license and accept to the terms of the License Agreement can install *
* and use this program. *
* *
****************************************************************************
* PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. *
****************************************************************************/

if (!defined('BOOTSTRAP')) { die('Access denied'); }

use Tygh\Tygh;

if (defined('PAYMENT_NOTIFICATION')) {
$pp_response = array();
$pp_response['order_status'] = 'F';
$pp_response['reason_text'] = __('text_transaction_declined');
$order_id = !empty($_REQUEST['order_id']) ? (int)$_REQUEST['order_id'] : 0;

if ($mode == 'success' && !empty($_REQUEST['order_id'])) {

$order_info = fn_get_order_info($order_id);
echo "successfull1";
if (empty($processor_data)) {
$processor_data = fn_get_processor_data($order_info['payment_id']);
}

$post_data = array();
$post_data_values = array(
'mid',
'orderid',
'status',
'orderAmount',
'currency',
'paymentTotal',
'riskScore',
'payMethod',
'txId',
'paymentRef'

);

foreach ($post_data_values as $post_data_value) {
if (isset($_REQUEST[$post_data_value])) {
$post_data[] = $_REQUEST[$post_data_value];
}
}



if($_REQUEST['status'] == 'CAPTURED') {
$pp_response['order_status'] = 'P';
$pp_response['reason_text'] = __('transaction_approved');
$pp_response['transaction_id'] = $_REQUEST['paymentRef'];
// if (fn_change_order_status($order_id, $pp_response['order_status'], '', true)) {
//define('ORDER_NOTIFICATION_SENT', true);

//}
$payment_id= $order_info['payment_id'];
$transaction_id= $pp_response['transaction_id'];
$status= $pp_response['order_status'];
fn_change_order_status($order_id, $pp_response['order_status'], '', $force_notification);


db_query("INSERT INTO `cscart_order_transactions`(payment_id``, `transaction_id`, `status`,'extras') VALUES ($payment_id, $transaction_id,$status,'mmmm')");




}

if (fn_check_payment_script('myprocessor.php', $order_id)) {
fn_finish_payment($order_id, $pp_response);

fn_order_placement_routines('route', $order_id);

}

}
else {

$payment_url = 'x';


$amount = fn_format_price($order_info['total'], $processor_data['processor_params']['currency']);
$confirm_url = fn_url("payment_notification.success?payment=bejaii&order_id=$order_id", AREA, 'current');
$cancel_url = fn_url("payment_notification.fail?payment=bejaii&order_id=$order_id", AREA, 'current');

/** @var \Tygh\Location\Manager $location_manager */
$location_manager = Tygh::$app['location'];

$post_data = [
// 'mid' => $processor_data['processor_params']['merchant_id'],
// 'lang' => $processor_data['processor_params']['language'],
'orderid' => time() . $order_id,
//'orderDesc' => '#' . $order_id,
'orderAmount' => $amount,
// 'currency' => $processor_data['processor_params']['currency'],
//'payerEmail' => $order_info['email'],
//'payerPhone' => $location_manager->getLocationField($order_info, 'phone', '', BILLING_ADDRESS_PREFIX),
//'trType' => '1',
'confirmUrl' => $confirm_url,
// 'cancelUrl' => $cancel_url,
// 'billState' => $location_manager->getLocationField($order_info, 'state', '', BILLING_ADDRESS_PREFIX),
// 'billZip' => $location_manager->getLocationField($order_info, 'zipcode', '', BILLING_ADDRESS_PREFIX),
// 'billCity' => $location_manager->getLocationField($order_info, 'city', '', BILLING_ADDRESS_PREFIX),
// 'billAddress' => $location_manager->getLocationField($order_info, 'address', '', BILLING_ADDRESS_PREFIX),
// 'shipCountry' => $location_manager->getLocationField($order_info, 'country', '', SHIPPING_ADDRESS_PREFIX),
// 'shipState' => $location_manager->getLocationField($order_info, 'state', '', SHIPPING_ADDRESS_PREFIX),
// 'shipZip' => $location_manager->getLocationField($order_info, 'zipcode', '', SHIPPING_ADDRESS_PREFIX),
// 'shipCity' => $location_manager->getLocationField($order_info, 'city', '', SHIPPING_ADDRESS_PREFIX),
// 'shipAddress' => $location_manager->getLocationField($order_info, 'address', '', SHIPPING_ADDRESS_PREFIX),
];
//fn_print_r(json_encode($post_data));
//fn_print_r($post_data);


fn_create_payment_form($payment_url, $post_data, 'xx', true);
}
exit;

my payment processor is @ app/payment/myprocessor.php

Hello

Did you print $_REQUEST?

$_REQUEST['status'] is equal 'CAPTURED'

(and you should uncomment fn_change_order_status)

Best regards

Robert

Hello

Did you print $_REQUEST?

$_REQUEST['status'] is equal 'CAPTURED'

(and you should uncomment fn_change_order_status)

Best regards

Robert

yes it prints (CAPTURED) as received from the gateway .. i did uncomment it but still no working order status appears in complete

yes it prints (CAPTURED) as received from the gateway .. i did uncomment it but still no working order status appears in complete

and in cs-cart orders table the status appears with letter N

Please add

fn_print_die($pp_response);

before fn_change_order_status call and check if this array is populated correctly