PayPal自适应付款证书错误

时间:2013-12-03 21:05:50

标签: php curl paypal paypal-adaptive-payments

我正在尝试实施PayPal自适应付款,但是一旦我尝试使用cURL发布,我就会收到NULL响应并且curl_error()会出现以下错误:

  

0NSS:找不到客户端证书(未指定昵称)

以下是使用沙箱的完整PHP代码, am 。某些敏感信息已加星标( * )。

<?php

class PayPal {

public $API_USER      = "*********.gmail.com";
public $API_PASSWORD  = "********************";
public $API_SIGNATURE = "******************************";
public $API_APP_ID    = "APP-80W284485P519543T";

public $apiUrl = "https://svcs.sandbox.paypal.com/AdaptivePayments/";
public $paypalUrl = "https://sandbox.paypal.com/webscr?cmd=ap-payment&paykey=";

public $headers = array();

function __construct() {
    $this->headers = array(
            "X-PAYPAL-SECURITY-USERID : " . $this->API_USER,
            "X-PAYPAL-SECURITY-PASSWORD : " . $this->API_PASSWORD,
            "X-PAYPAL-SECURITY-SIGNATURE : " . $this->API_SIGNATURE,
            "X-PAYPAL-REQUEST-DATA-FORMAT : JSON",
            "X-PAYPAL-RESPONSE-DATA-FORMAT : JSON",
            "X-PAYPAL-APPLICATION-ID : " . $this->API_APP_ID
    );
}

function paypalSend($data, $call) {
    $ch = curl_init();

    $curl_params = array(
        CURLOPT_URL => $this->apiUrl . $call,
        CURLOPT_RETURNTRANSFER => TRUE,
        CURLOPT_SSL_VERIFYPEER => FALSE,
        CURLOPT_SSL_VERIFYHOST => FALSE,
        CURLOPT_HTTPHEADER => $this->headers,
        CURLOPT_POSTFIELDS => json_encode($data)
    );

    curl_setopt_array($ch, $curl_params);
    $result = curl_exec($ch);

    echo(curl_errno($ch));
    echo(curl_error($ch));

    curl_close($ch);

    return json_decode($result, TRUE);
}

function getPayKey() {
    $createPacket = array(
        "actionType" => "PAY",
        "currencyCode" => "USD",
        "receiverList" => array(
            "receiver" => array(
                array(
                "amount" => "5.00",
                "email" => "*********@gmail.com"
                )
            )
        ),
        "returnUrl" => "http://example.com/success",
        "cancelUrl" => "http://example.com/failure",
        "requestEnvelope" => array(
            "errorLanguage" => "en_US",
            "detailLevel" => "ReturnAll"
        )
    );

    // paypal Send
    $response = $this->paypalSend($createPacket, "Pay");
    var_dump($response);
}
}

$pp = new Paypal();
$pp->getPayKey();

?>

0 个答案:

没有答案