2016-05-20 63 views
1

Order_summary_image貝寶不顯示訂單彙總,Omnipay

我對貝寶重定向一個函數傳遞我params中的一些值..

只通過Description字段不顯示金額付,我的訂單彙總的休息..

這裏是我的功能

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

    } 
} 

我不知道什麼是它缺少做..

有人請幫助我..

回答

0

不能任意參數,如hot_id,ROOM_ID等,以貝寶(或omnipay)通過,因爲它不知道他們做什麼。 PayPal僅用於採取某些參數,而PayPal不採取的參數則被Omnipay忽略。

您可能必須提供所有這些額外參數作爲PayPal明白的描述參數的一部分。

理想情況下,應將這些應用程序以某種有用的格式顯示給用戶,然後將用戶重定向到PayPal結帳頁面。