Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php PayPal API-错误400-传入的JSON请求未映射到API请求_Php_Paypal - Fatal编程技术网

Php PayPal API-错误400-传入的JSON请求未映射到API请求

Php PayPal API-错误400-传入的JSON请求未映射到API请求,php,paypal,Php,Paypal,下面是start.php: <?php require "../vendor/autoload.php"; define('SITE_URL', 'http://Mundwaechter.de'); $paypal = new \PayPal\Rest\ApiContext( new \PayPal\Auth\OAuthTokenCredential('HIDDEN','HIDDEN') ); $paypal->setConfig(['mode

下面是start.php:

<?php

require "../vendor/autoload.php";

define('SITE_URL', 'http://Mundwaechter.de');



$paypal = new \PayPal\Rest\ApiContext(
        new \PayPal\Auth\OAuthTokenCredential('HIDDEN','HIDDEN')
      );

$paypal->setConfig(['mode' => 'sandbox',
                 'http.ConnectionTimeOut' => 30,
                 'log.LogEnabled' => true,
                 'log.FileName' => 'logPaypal.txt',
                 'log.LogLevel' => 'FINE',
                 'validation.level' => 'log'
                ]);
它说JSON不正确,所以这里是JSON输出代码:

就是这样,我总是得到错误


谢谢科技

你在?@ramilar上读到信息了吗?这个链接现在没有指向任何东西(或者锚已经过期)。我也有同样的错误,我看不出我做错了什么。。。你解决问题了吗?
session_start();


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

require "../app/start.php";

Include "../php/MySQL.php";
Include "../php/Functions.php";


$first_name = $_SESSION['register_first_name'];
$last_name = $_SESSION['register_last_name'];
$email = $_SESSION['register_email'];

$first_name = strtolower($first_name);
$last_name = strtolower($last_name);
$email = strtolower($email);

$first_name = ucfirst($first_name);
$last_name = ucfirst($last_name);
$email = ucfirst($email);

$password = $_SESSION['register_password'];

$password_md5 = md5($register_password);

$code = $_POST['register_code'];


$praxis = getPraxisFromCode($code, $db);



if(hasAccount($email, $db) == true){
    echo "Hat schon einen Account";
} else {
    echo "Hat noch keinen Account";
    deleteCode($code, $db);
    createAccount($first_name, $last_name, $email, $password_md5, $praxis, $db);
}

mysql_close($db);

echo "<br>A";
$payer = new Payer();
$payer->setPaymentMethod('paypal');
echo "<br>B";
$item = new Item();
$item->setName("Mundwaechter")
    ->setCurrency('EUR')
    ->setQuantity('1')
    ->setPrice('15.00');
echo "<br>C";
$itemList = new ItemList();
$itemList->setItems([$item]);
echo "<br>D";
$details = new Details();
$details->setShipping('0.00')
        ->setTax('0.00')
        ->setSubtotal('15.00');
echo "<br>E";
$amount = new Amount();
$amount->setCurrency('EUR')
        ->setTotal('15.00')
        ->setDetails($details);
echo "<br>F";
$transaction = new Transaction();
$transaction->setAmount($amount)
            ->setItemList($itemList)
            ->setDescription('1 Mundwaechter Lizenz fuer eine Person')
            ->setInvoiceNumber(uniqid());
echo "<br>G";
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("http://Mundwaechter.de/transaction_complete.php")
             ->setCancelUrl("http://Mundwaechter.de/transaction_failure.php");
echo "<br>H";
$payment = new Payment();
$payment->setIntent('sale')
        ->setPayer($payer)
        ->setRedirectUrls($redirectUrls)
        ->setTransactions($transaction);
echo "<br>I";



try{
    $payment->create($paypal);
} catch (Exception $ex) {
            //ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $paypal, $ex);
            //var_dump($items);
            echo "<pre>" . $payment;
            echo $ex->getData();
            echo $product->shipping;
            echo $amount->getTotal;
            exit(1);
        }



/*
catch(PayPal\Exception\PayPalConnectionException $err){
    echo($err->getData());

}
*/
echo "<br>J";
$approvalUrl = $payment->getApprovalLink();
echo "<br>K";
header("Location: {".$approvalUrl."}");

echo "<br><hr><br>WORKING!";

?>
{"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":"602bfb6c4c828"}
{
    "intent": "sale",
    "payer": {
        "payment_method": "paypal"
    },
    "redirect_urls": {
        "return_url": "http://Mundwaechter.de/transaction_complete.php",
        "cancel_url": "http://Mundwaechter.de/transaction_failure.php"
    },
    "transactions": {
        "amount": {
            "currency": "EUR",
            "total": "15.00",
            "details": {
                "shipping": "0.00",
                "tax": "0.00",
                "subtotal": "15.00"
            }
        },
        "item_list": {
            "items": [
                {
                    "name": "Mundwaechter",
                    "currency": "EUR",
                    "quantity": "1",
                    "price": "15.00"
                }
            ]
        },
        "description": "1 Mundwaechter Lizenz fuer eine Person",
        "invoice_number": "56d18699a1eb3"
    }
}