PayPal API REST problem - 404 json

jkallup

Erfahrenes Mitglied
Hallo Coders,

ich habe ein Problem, das ich nicht lösen kann.
Mittels PayPal API REST versuche ich via SandBox ein Webauftritt zu gestallten.
Der request scheint durchzugehen, aber Response hat Fehler 400

Code:
{
    "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": "74c7fcb3e3cd7"
}

könnte da einer mal drüber schauen und mir Rückmeldungen geben
Danke.

Code:
require "bootstrap.php";
require "common.php";

use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\ExecutePayment;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;

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

$item1 = new Item();
$item1
->setName("Release: 2016-07-24")
->setCurrency("EUR")
->setQuantity(1)
->setSku("2016001")
->setPrice(5.00);

$itemlist = new ItemList();
$itemlist->setItems($item1);

$details = new Details();
$details
->setShipping(1.2)
->setTax(0.0)
->setSubtotal(6.20);

$amount = new Amount();
$amount
->setCurrency("EUR")
->setTotal(6.21)
->setDetails($details);

$transaction = new Transaction();
$transaction
->setAmount($amount)
->setItemList($itemlist)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());

$baseurl = getBaseUrl();
$redirecturls = new RedirectUrls();
$redirecturls
->setReturnUrl("$baseurl/ExecutePayment.php?success=true")
->setCancelUrl("$baseurl/ExecutePayment.php?success=false");

$payment = new Payment();
$payment
->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirecturls)
->setTransactions(array($transaction));

$request = clone $payment;

try {
$payment->create($apiContext);
$payment->setIntent("authorize");

$exepay = new PaymentExecution();
$result = $payment->execute($exepay,$apiContext);

$payment->create();
$payment->links();

} catch (Exception $ex) {
ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.",
"Payment", null, $request, $ex); exit(1);
}