PayPal确认从iOs付款

时间:2015-01-06 17:07:15

标签: php curl paypal

我正在使用以下代码

    $header = array(
                    'Accept' => 'application/json',
                    'Authorization' => 'Bearer ' . $accessToken );

    $url = 'https://api.sandbox.paypal.com/v1/payments/payment/' . $data['PaymentId'];

    //cURL starts
    $crl = curl_init();
    curl_setopt($crl, CURLOPT_URL, $url);
    curl_setopt($crl, CURLOPT_HTTPHEADER,$header);
    curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($crl, CURLOPT_HTTPGET,true);
    $reply = curl_exec($crl);

   //error handling for cURL
    if ($reply === false) {
       print_r('Curl error: ' . curl_error($crl));
    }
    curl_close($crl);
    //cURL ends

    //decoding the json data
    $decoded_data = json_decode($reply, true);

尽管标题等看起来不错,但响应为空。我需要向PayPal卷曲,检查在应用上付款是否成功。

1 个答案:

答案 0 :(得分:0)

$ header应该是这样的:

$header = array('Accept:application/json', 'Authorization: Bearer ' . $accessToken);

请注意,此处未使用=>,只需直接添加标题项