贝宝自适应支付PHP [英] Paypal adaptive payment php

查看:81
本文介绍了贝宝自适应支付PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题.我已按照本教程进行操作-> http://www.youtube.com/watch?v = rzRR1i-F_VA

I have this problem. I've follow this tutorial -> http://www.youtube.com/watch?v=rzRR1i-F_VA

在完成所有设置之后,我在完成身份验证过程中遇到了一些问题.在对身份验证进行了一些研究之后,我对此进行了测试-> https: //developer.paypal.com/webapps/developer/docs/classic/lifecycle/ug_sandbox/

and after setting everything, I have some problem with getting through the authentification process. And After some research on authentification, I've tested this -> https://developer.paypal.com/webapps/developer/docs/classic/lifecycle/ug_sandbox/

在过程中的某个时刻(发出测试请求),我已经在bash控制台中对其进行了测试,并且我的用户名,密码和签名有效.因此,我认为问题出在我正在使用的代码中.

At some point in the process (Making test requests), I've tested it in a bash console, and my userid, password and signature worked. So I figure that the problem was in the code I was using.

所以这是代码:

<?php
class PaypalTest extends CComponent{

public $api_user = "**********************";
public $api_pass = "***********";
public $api_sig = "**************************";
public $app_id = "APP-80W284485P519543T";
public $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/';
public $paypalUrl="https://www.paypal.com/webscr?cmd=_ap-payment&paykey=";
public $headers;

public function __construct(){
    $this->headers = array(
        "X-PAYPAL-SECURITY-USERID: ".$this->api_user,
        "X-PAYPAL-SECURITY-PASSWORD: ".$this->api_pass,
        "X-PAYPAL-SECURITY-SIGNATURE: ".$this->api_sig,
        "X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
        "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
        "X-PAYPAL-APPLICATION-ID: ".$this->app_id,
    );
}

public function getPaymentOptions($paykey){

}
public function setPaymentOptions(){

}
public function _paypalSend($data,$call){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);
    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, json_encode($data));
    curl_setopt($ch, CURLOPT_HEADER, $this->headers);
    $response = json_decode(curl_exec($ch),true);
    return $response;

}
public function splitPay(){

    // create the pay request
    $createPacket = array(
        "actionType" =>"PAY",
        "currencyCode" => "USD",
        "receiverList" => array(
            "receiver" => array(
                array(
                    "amount"=> "1.00",
                    "email"=>"********@hotmail.com"
                ),
                array(
                    "amount"=> "2.00",
                    "email"=>"********@gmail.ca"
                ),
            ),
        ),
        "returnUrl" => "http://test.local/payments/confirm",
        "cancelUrl" => "http://test.local/payments/cancel",
        "requestEnvelope" => array(
            "errorLanguage" => "en_US",
            "detailLevel" => "ReturnAll",
        ),
    );

    $response = $this->_paypalSend($createPacket,"Pay");
}
}

这是电话:

$payment = new PaypalTest();
$payment->splitPay();

非常简单,但是某些方法不起作用.而且我对Curl并不是很熟悉,所以我认为你们可以帮助我

Quite simple, but something is not working. And I'm not really familiar with Curl so I thought you guys could help me

PS:我处于沙盒模式

P.S: I'm in sandbox mode

谢谢

卡尔

推荐答案

将CURLOPT_HEADER更改为CURLOPT_HTTPHEADER

change CURLOPT_HEADER to CURLOPT_HTTPHEADER

这篇关于贝宝自适应支付PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆