Hello,
I'm using MV-4.7.2 and have a problem in my shipping cost.
The total amount is showing correctly in checkout page including shipping cost, but when customer hits the pay button and redirect to external 3rd party payment gateway, the amount which is showing up there is total amount minus shipping cost.
Have i done anything wrong? or maybe its a bug in my 3rd party payment add-on?
The payment add-on which i'm using is a local and only inside the country gateway which has only 2 files: a .php and a .tpl and it has a record for inserting in database. that's all.
Can anyone help me?
HERE IS THE PHP FILE CONTENTS:
@session_start();
use Tygh\Http;
use Tygh\Registry;if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }
define(‘MAX_THE_GATEWAY_PRODUCTS’, 100);
// Return from THE_GATEWAY website
if (defined(‘PAYMENT_NOTIFICATION’))
{
if ($mode == ‘notify’ && !empty($_REQUEST[‘order_id’]))
{
if (fn_check_payment_script(‘THE_GATEWAY_FILE.php’, $_REQUEST[‘order_id’], $processor_data))
{
$pp_response = array();
$order_info = fn_get_order_info($_REQUEST[‘order_id’]);
if (empty($processor_data))
{
$processor_data = fn_get_processor_data($order_info[‘payment_id’]);
}
$THE_GATEWAY_STATUSES = $processor_data[‘processor_params’][‘statuses’];
$THE_GATEWAY_API = $processor_data[‘processor_params’][‘api’];
$OrderID = $_REQUEST[‘order_id’];
$current_location = Registry::get(‘config.current_location’);
$RedirectURL = “$current_location/$index_script?dispatch=orders.details&order_id=$OrderID”;
$transId = isset($_POST[‘transId’])?$_POST[‘transId’]:‘’;
$factorNumber = isset($_POST[‘factorNumber’])?$_POST[‘factorNumber’]:‘’;
$pp_response[‘transaction_id’] = $transId;
$result = FALSE;
if (isset($_POST[‘status’]) && $_POST[‘status’] == 1)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://THE_GATEWAY_URL/payment/verify’);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(‘api’ => $THE_GATEWAY_API, ‘transId’ => $transId)));
$response = curl_exec($ch);
$error = curl_errno($ch);
curl_close($ch);
$result = $error ? FALSE : json_decode($response);
}
if ($result && isset($result->status) && $result->status == 1)
{
$pp_response[‘order_status’] = $THE_GATEWAY_STATUSES[‘completed’];
$pp_response[‘reason_text’] = ‘successful payment’.$transId;
fn_clear_cart($_SESSION[‘cart’]);
}
else
{
$pp_response[‘order_status’] = $THE_GATEWAY_STATUSES[‘denied’];
$pp_response[‘reason_text’] = ‘Invalid payment message’.(isset($result->errorMessage) ? $result->errorMessage : $_POST[‘message’]);
}
if ($pp_response[‘order_status’] == $THE_GATEWAY_STATUSES[‘pending’])
{
fn_change_order_status($_REQUEST[‘order_id’], $pp_response[‘order_status’]);
}
else
{
fn_finish_payment($_REQUEST[‘order_id’], $pp_response);
}
header(‘location: index.php?dispatch=orders.details&order_id=’.$REQUEST[‘order_id’]);
}
}
}
else
{
$THE_GATEWAY_API = $processor_data[‘processor_params’][‘api’];
$THE_GATEWAY_currency = $processor_data[‘processor_params’][‘currency’];
$THE_GATEWAY_shipping = fn_order_shipping_cost($order_info);
$THE_GATEWAY_total = fn_format_price($order_info[‘total’] - $THE_GATEWAY_shipping, $THE_GATEWAY_currency);
$THE_GATEWAY_shipping = fn_format_price($THE_GATEWAY_shipping, $THE_GATEWAY_currency);
$THE_GATEWAY_order_id = $processor_data[‘processor_params’][‘order_prefix’].(($order_info[‘repaid’]) ? ($order_id .'‘. $order_info[‘repaid’]) : $order_id);
$return_url = fn_url(“payment_notification.return?payment=THE_PAYMENT_GATEWAY&order_id=$order_id”, AREA, ‘current’);
$cancel_url = fn_url(“payment_notification.cancel?payment=THE_PAYMENT_GATEWAY&order_id=$order_id”, AREA, ‘current’);
$notify_url = fn_url(“payment_notification.notify?payment=THE_PAYMENT_GATEWAY&order_id=$order_id”, AREA, ‘current’);
$callBackUrl = urlencode($notify_url.’&custom=‘.$order_id.’&invoice=‘.$THE_GATEWAY_order_id);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,‘https://THE_GATEWAY_URL/payment/send’);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(‘api’ => $THE_GATEWAY_API, ‘amount’ => $THE_GATEWAY_total, ‘redirect’ => $callBackUrl, ‘factorNumber’ => time())));
$response = curl_exec($ch);
$error = curl_errno($ch);
curl_close($ch);
$result = $error ? FALSE : json_decode($response);
if ($result && isset($result->status) && $result->status == 1)
{
fn_create_payment_form(‘https://THE_GATEWAY_URL/payment/gateway/’.$result->transId, array(), ‘THE_PAYMENT_GATEWAY Server’, false);
}
else
{
echo ‘’.(isset($result->errorMessage) ? $result->errorMessage : $error).’
';
}
}
exit;
All the best,
diako