Payment Gateway

hello ,,

https://docs.cs-cart...ssor_addon.html

I followed the tutorial and i wrote the code and it send form data contain all order details to issuing bank URL but now i want to add virtual link to receive the data and send feedback ? i dont know how to do so ?? i created php file temporary to receive and send feedback to my payment gateway but i dont know how to redirect it back with response data to my payment gateway

any help please?

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);

    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_check_payment_script('alpha_bank.php', $order_id)) {
    fn_finish_payment($order_id, $pp_response);
    fn_order_placement_routines('route', $order_id);
}

}
else {

    $payment_url = 'http://localhost/pay-now/login-2.html';


$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_create_payment_form($payment_url, json_encode($post_data), ‘bejaii’, false);
}
exit;


Hello,

You can handle the feedback inside of your payment processor.

If your payment gateway allows you to specify the feedback URL in the payment request, do it as follows:

https://your-store.example.com/index.php?dispatch=payment_notification.feedback&payment=bejaii&order_id={$order_id}

After that you'll be able to handle feedback in the following section of your processor:

if (defined('PAYMENT_NOTIFICATION')) {
    if ($mode === 'feedback') {
        // handle feedback here
    }
}

Please check my answer on your question in another thread