使用Paypal php sdk在PHP上出现MALFORMED_REQUEST错误?

i am reciving this error and i am not sure why, my code look fine with all properly made, can someone help me with it ?

using the paypal sdk php v1 The full error is stdClass Object ( [name] => MALFORMED_REQUEST [message] => Incoming JSON request does not map to API request [information_link] => https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST [debug_id] => 47013277923b )

$precio = 1;
$total = ($cantidad / 100) *2;
$cantidad =1;


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

$item = new item();
$item->setName("Servicio")
     ->setCurrency('USD')
     ->setQuantity($cantidad)
     ->setPrice($precio);

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

$detalles = new Details();
$detalles->setShipping(0)
->setSubtotal($precio);

$amount = new Amount();
$amount->setCurrency("USD")
->setTotal($total)
->setDetails($detalles);

$transicion = new Transaction();
$transicion->setAmount($cantidad) 
->setItemList($lista)
->setDescription("Pago ")
->setInvoiceNumber(uniqid());


$redirect = new RedirectUrls();
$redirect->setReturnUrl(URL_SITIO."/pago?exito=true")
->setCancelUrl(URL_SITIO."/pago?exito=false");

$pago = new Payment();
$pago->setIntent("sale")
->setIntent($compra)
->setRedirectUrls($redirect)
->setTransactions(array($transicion));

try {
    //code...
    $pago->create($apiContext);
}catch (PayPal\Exception\PayPalConnectionException $pce) {
    //throw $th;
    echo '<pre>';print_r(json_decode($pce->getData()));exit;

}

$aprobado = $pago->getApprovalLink();
header("Location: {$aprobado}");
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问