我目前正在使用贝宝 php rest api 0.6。我无法设置折扣金额。
我可以看到物品清单、税金和装运金额。但不知道如何配置折扣。$payer = 新付款人(); $payer->setPaymentMethod("paypal");
$item = new Item();
$item->setQuantity("1");
$item->setName("Classic Shirt");
$item->setPrice("100.00");
$item->setCurrency("USD");
$item->setSku("CS00001");
$item2 = new Item();
$item2->setQuantity("1");
$item2->setName("Classic Brown Shirt");
$item2->setPrice("100.00");
$item2->setCurrency("USD");
$item2->setSku("CS00002");
$amount = new Amount();
$amount->setCurrency("USD");
$amountDetails = new Details();
$amountDetails->setSubtotal('200');
$amountDetails->setTax('10');
$amountDetails->setShipping('10');
//$amountDetails->setDiscount('10');
$amount->setDetails($amountDetails);
$amount->setTotal("210.00");
$item_list = new ItemList();
$item_list->setItems(array($item,$item2));
$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription("This is incredibly awesome.");
$transaction->setItem_list($item_list);
$baseUrl = getBaseUrl();
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("$baseUrl/ExecutePayment.php?success=true")
->setCancelUrl("$baseUrl/ExecutePayment.php?success=false");
// ### Payment
// A Payment Resource; create one using
// the above types and intent set to 'sale'
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));