Php 贝宝自适应支付

Php 贝宝自适应支付,php,curl,paypal,paypal-adaptive-payments,Php,Curl,Paypal,Paypal Adaptive Payments,我最近一直在尝试使用PHP向PayPal发出API请求,以支付多个帐户,但到目前为止我没有运气 ` ?>` 这是我创建的一个类文件,它非常粗糙,但不起作用。这里还有一些代码。 `加载->库(“贝宝”); $pp=新贝宝() ?> ` 我得到了这个答复。 responseEnvelope.timestamp=2014-04-22T06%3A15%3A49.821-07%3A00&responseEnvelope.ack=Failure&responseEnvelope.correlationId=

我最近一直在尝试使用PHP向PayPal发出API请求,以支付多个帐户,但到目前为止我没有运气

` ?>`

这是我创建的一个类文件,它非常粗糙,但不起作用。这里还有一些代码。 `加载->库(“贝宝”); $pp=新贝宝()

?> ` 我得到了这个答复。 responseEnvelope.timestamp=2014-04-22T06%3A15%3A49.821-07%3A00&responseEnvelope.ack=Failure&responseEnvelope.correlationId=b3d05fe547e22&responseEnvelope.build=10680030&error(0)。errorId=580001&error(0)。域=平台与错误(0)。子域=应用程序与错误(0)。严重性=错误(0)。类别=应用程序与错误(0).message=无效+请求%3A+%7B0%7D


有人知道为什么这可能是

根据您的错误是
参数无效:无法识别参数
@ohgod为什么这很奇怪,因为我从PayPal Dashboard复制并粘贴了详细信息需要查看您发送的完整原始请求。也就是说,我建议你看看我的电脑。这将使这一切变得更快、更容易。@AndrewAngell我解决了这个问题,我要求格式为NV格式,我将格式更改为JSON格式,它马上就可以工作了。
class PayPal
{
    public $_headers = array();
    public $_config = array();
    public $_data = array();

    public function __construct()
    {
        if (!in_array('curl', get_loaded_extensions()))
        {
            trigger_error("CURL extension is not installed or enabled", E_USER_ERROR);
        }
    }

    public function update_headers(array $credentails)
    {
        $this->_headers = $credentails;
        return $this;
    }

    public function update_config(array $config)
    {
        $this->_config = $config;
        return $this;
    }

    public function pay($data, $call)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->get_url());
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $this->_headers);
        return curl_exec($ch);
    }

    public function split_pay()
    {
        // create the pay request
        $this->_data = array(
            "actionType" =>"PAY",
            "currencyCode" => "USD",
            "receiverList" => array(
                "receiver" => array(
                    array(
                        "amount"=> "1.00",
                        "email"=>"******@gmail.com"
                    ),
                    array(
                        "amount"=> "2.00",
                        "email"=>"*********.co.uk"
                    ),
                ),
            ),
            "returnUrl" => "http://test.local/payments/confirm",
            "cancelUrl" => "http://test.local/payments/cancel",
            "requestEnvelope" => array(
                "errorLanguage" => "en_US",
                "detailLevel" => "ReturnAll",
            ),
        );

        return $this->pay($this->_data, "PAY");
    }

    private function get_url()
    {
        if (empty($this->_config))
        {
            trigger_error("You have not setup the config", E_USER_ERROR);    
        }

        return $this->_config['url'];
    }

    public function call_headers()
    {
        if (empty($this->_headers))
        {
            trigger_error("You have not set any headers", E_USER_ERROR);    
        }

        print_r($this->_headers);
    }
}
        //Bring me the money!
        //Headers for paypal
        $headers = array(
            "X-PAYPAL-SECURITY-USERID: ********",
            "X-PAYPAL-SECURITY-PASSWORD: *********",
            "X-PAYPAL-SECURITY-SIGNATURE: **********",
            "X-PAYPAL-REQUEST-DATA-FORMAT: NV",
            "X-PAYPAL-RESPONSE-DATA-FORMAT: NV",
            "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T"
        );

        $config = array(
            'url' => 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay',
            'username' => '********',
            'password' => '********',
            'signature' => '********',
            'app_id' => 'APP-80W284485P519543T',
        );

        $pp->update_headers($headers)->update_config($config);
        print_r($pp->split_pay());