我在沙盒模式下使用以下代码:
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$amount = new Amount();
$amount->setCurrency('USD')
->setTotal(10);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setDescription('Bezahl einfach eh')
->setInvoiceNumber(uniqid());
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl('http://www.bla.com?pay=yes')
->setCancelUrl('http://www.bla.com?pay=no');
$payment = new Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions([$transaction]);
但它在结帐预览中没有显示10美元,所以我添加了:
$payer = new Payer();
$payer->setPaymentMethod('paypal');
// added ==>
$item1 = new Item();
$item1->setName('One week premium member')
->setCurrency('USD')
->setPrice(10);
$itemList = new ItemList();
$itemList->setItems(array($item1));
$details = new Details();
$details->setSubtotal(10);
// <== added
$amount = new Amount();
$amount->setCurrency('USD')
->setTotal(10);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setItemList($itemList) // <== added
->setDescription('Bezahl einfach eh')
->setInvoiceNumber(uniqid());
但现在我得到了以下错误:
exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.' in
等
我该怎么做?
忽略:我需要在问题上添加一些文字才能发布..顺便说一句,对不起我的坏英语