接受PayPal付款且回复无效

时间:2013-11-14 20:07:49

标签: php curl paypal

好吧,我已经搜索了这个以及更多的论坛,对我来说没有解决方案。

我有这段代码:

$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

0 个答案:

没有答案