vendredi 20 mai 2016

PayPal does not show order summary-Omnipay

Order_summary_image

I have a function for Paypal redirection for that I pass some values in params..

It only pass the Description field doesn't shows the amount to be paid,and rest of my order summaries..

Here is my function

public function postPayment() 
{   
    $hot_id     = \Session::get('hot_id');
    $user_id    = \Session::get('uid');
    $check_in   = \Session::get('check_in');
    $check_out  = \Session::get('check_out');
    $mem_count  = \Session::get('mem_count');
    $rm_no      = \Session::get('rm_no');

    $check_in   = strtotime($check_in);
    $check_in   = date('Y-m-d',$check_in);

    $check_out  = strtotime($check_out);
    $check_out  = date('Y-m-d',$check_out);

    $datediff   = strtotime($check_out) - strtotime($check_in);
    $diff       = floor($datediff/(86400));

    $room_prize = \DB::select("SELECT `room_prize` FROM `abserve_hotel_rooms` WHERE `room_id` = ".$_POST['room_id']);
    $arr = array();
        foreach ($room_prize as $key => $value) {
            $arr[]= (get_object_vars($value));
        }
        $room_prize = array();
        foreach ($arr as $key => $value) {
            $room_prize[]=($value['room_prize']);
        }
    if($rm_no == 1)
    {
        $room_prize = (int) $room_prize[0] * (int) $diff;
    }
    else
    {
        $room_prize = (int) $room_prize[0] * (int) $diff * (int) $rm_no;
    }

    $room_prize = number_format((float)$room_prize, 2, '.', '');
    $room_id    = $_POST['room_id'];

    $today      = new DateTime();
    $created_at = $today->format('Y-m-d');

    $values = array('user_id' => $user_id,'hotel_id' => $hot_id,'room_id'=>$room_id,'room_prize'=>$room_prize,'check_in'=>$check_in,'check_out'=>$check_out,'created_at'=>$created_at);

    \DB::table('abserve_orders')->insert($values);

    $order_id = DB::select("SELECT `id` FROM `abserve_orders` WHERE `room_id` = ".$_POST['room_id']." AND `user_id` = ".$user_id);
    $arr = array();
        foreach ($order_id as $key => $value) {
            $arr[]= (get_object_vars($value));
        }
        $order_id = array();
        foreach ($arr as $key => $value) {
            $order_id[]=($value['id']);
        }
        $order_id = $order_id[0];

        $params = array(
                'cancelUrl'     => url().'/cancel_order',
                'returnUrl'     => url().'/payment_success', 
                'name'          => 'new order',
                'description'   => 'description1', 
                'amount'        => $room_prize,
                'currency'      => 'USD',
                'hot_id'        => $hot_id,
                'room_id'       => $room_id,
                'user_id'       => $user_id,
                'check_in'      => $check_in,
                'check_out'     => $check_out,
                'order_id'      => $order_id,
                'nights'        => $diff,
        );
        // print_r($params);exit;
        \Session::put('params', $params);
        \Session::save();  

        $gateway = Omnipay::create('PayPal_Express');

        $gateway->setUsername('googley555_api1.yahoo.com');
        $gateway->setPassword('3EQ6S6PB68A52JKZ');
        $gateway->setSignature('AFcWxV21C7fd0v3bYYYRCpSSRl31AHaEiWOLAf5jQQ3-A9hLlhypSz9h');
        $gateway->setTestMode(true);

    $response = $gateway->purchase($params)->send();

        if ($response->isSuccessful()) {

            // payment was successful: update database
            print_r($response);

    } elseif ($response->isRedirect()) {

            // redirect to offsite payment gateway
            $response->redirect();

    } else {

          // payment failed: display message to customer
          echo $response->getMessage();

    }
}

I don't know what are missing in it..

Someone please help me..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire