0

好吧,我已经搜索了这个和更多的论坛,没有适合我的解决方案。

我有这个代码:

$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Authorization: Bearer ' . $this->auth['access_token']
    ));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array(
        'intent' => 'sale',
        'redirect_urls' => array(
            'return_url' => 'http://andershagbard.wep.dk/goingpro/',
            'cancel_url' => 'http://andershagbard.wep.dk/goingpro/'
        ),
        'payer' => array (
            'payment_method' => 'paypal'
        ),
        'transactions' => array(
            'amount' => array(
                'total' => '5.00',
                'currency' => 'USD'
            ),
            'description' => 'This is the payment transaction description.'
        )
    )));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $result = curl_exec($ch);

它返回

(
[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] => 27f7487f9c07f
4

0 回答 0