2014-04-29 188 views
0

其餘api工作正常,但它不顯示金額爲了總結 「在訂單總結量沒有顯示,但描述顯示? 「我使用下面的代碼通過量和說明」貝寶REST API不顯示付款金額在貝寶沙盒或活網站

require DIR . '/../bootstrap.php'; 
use PayPal\Api\Address; 
use PayPal\Api\Amount; 
use PayPal\Api\Payer; 
use PayPal\Api\Payment; 
use PayPal\Api\FundingInstrument; 
use PayPal\Api\RedirectUrls; 
use PayPal\Api\Transaction; 


$charge = trim($_POST['amount']); 
$currency = trim($_POST['currency']); 
$desc = trim($_POST['desc']); 
$get_url=trim($_SESSION['get_url']); 


$payer = new Payer(); 
$payer->setPayment_method("paypal"); 

$amount = new Amount(); 
$amount->setCurrency($currency); 
$amount->setTotal($charge); 

$transaction = new Transaction(); 
$transaction->setAmount($amount); 
$transaction->setDescription($desc); 





} 

"In order summery its showing description but amount is not showing." 
Please help me to sort out this problem" 
Thank for you help. 

Sunil 

回答

5

創建和至少一個項目添加到ITEMLIST您的交易。 下面是一個例子:

$payer = new Payer();       
$payer->setPaymentMethod("paypal");    

$amount = new Amount();       
$amount->setCurrency($paymentCurrency);   
$amount->setTotal($paymentAmount);    

$item = new Item();        
$item->setQuantity(1);       
$item->setName($paymentDescription);   
$item->setPrice($paymentAmount);    
$item->setCurrency($paymentCurrency);   

$itemList = new ItemList();      
$itemList->setItems(array($item));    

$transaction = new Transaction();    
$transaction->setAmount($amount);    
$transaction->setItemList($itemList);   

$redirectUrls = new RedirectUrls();    
$redirectUrls->setReturnUrl($returnUrl);  
$redirectUrls->setCancelUrl($cancelUrl);  

$payment = new Payment();      

$payment->setIntent("sale");     
$payment->setPayer($payer);      
$payment->setRedirectUrls($redirectUrls);  
$payment->setTransactions(array($transaction)); 
+1

感謝您的回覆,但仍然沒有修復,當我在我的頁面,其顯示空白頁面添加這兩個項目和ITEMLIST。 $ item = new Item(); $ item-> setQuantity(1); $ item-> setName($ paymentDescription); $ item-> setPrice($ paymentAmount); $ item-> setCurrency($ paymentCurrency); $ itemList = new ItemList(); $ itemList-> setItems(array($ item)); –