[insert_php]
global $wpdb;
global $woocommerce;
if(isset($_GET[“vpc_TxnResponseCode”]) && isset($_GET[“vpc_MerchTxnRef”]))
{
$order_id = $_GET[“vpc_MerchTxnRef”];
echo $status;
if($order_id != ”){
$order = new WC_Order($order_id);
$amount = $_GET[‘vpc_Amount’];
$status = $_GET[“vpc_TxnResponseCode”];
if( ‘0’ == $status){
$order->add_order_note(‘Commercial payment successful
Unnique Id from Commercial IPG: ‘.$_GET[“vpc_TransactionNo”]);
$order->add_order_note(‘Your order placed successfully’);
$woocommerce->cart->empty_cart();
$mailer = $woocommerce->mailer();
$admin_email = get_option( ‘admin_email’, ” );
$message = $mailer->wrap_message(__( ‘Order confirmed’,’woocommerce’),sprintf(__(‘Order ‘.$_GET[“vpc_TransactionNo”].’ has been confirmed’, ‘woocommerce’ ), $order->get_order_number(), $posted[‘reason_code’]));
$mailer->send( $admin_email, sprintf( __( ‘Payment for order %s confirmed’, ‘woocommerce’ ), $order->get_order_number() ), $message );
$message = $mailer->wrap_message(__( ‘Order confirmed’,’woocommerce’),sprintf(__(‘Order ‘.$_GET[“vpc_TransactionNo”].’ has been confirmed’, ‘woocommerce’ ), $order->get_order_number(), $posted[‘reason_code’]));
$mailer->send( $order->billing_email, sprintf( __( ‘Payment for order %s confirmed’, ‘woocommerce’ ), $order->get_order_number() ), $message );
$order->payment_complete();
echo ‘
Commercial payment successful
Unnique Id from Commercial IPG: ‘.$_GET[“vpc_TransactionNo”] ;
echo ‘
Your order receipt will be send to your inbox’;
}else{
global $wpdb;
$order->update_status(‘failed’);
$order->add_order_note(‘Failed – Code’.$_POST[‘pgErrorCode’]);
$order->add_order_note(‘failed’);
echo(‘
Payment process is failed !’) ;
}
}
}else {
echo(‘
Payment process is failed !’) ;
}
[/insert_php]