PayPal 自适应付款后不执行任何操作

Posted

技术标签:

【中文标题】PayPal 自适应付款后不执行任何操作【英文标题】:No action is performed after PayPal Adaptive Payment 【发布时间】:2020-06-13 12:20:56 【问题描述】:

我正在为 Paypal 自适应付款尝试此 (Method),第一部分运行良好,但在完成第二部分后没有任何反应,也没有查看错误。我知道这已经发布,但我查看了所有其他答案,但都是徒劳的。 我试图寻找其他选项来执行此功能,但它主要在“Ruby”或其他框架上可用,但我在 PHP

中需要它

这是 php 代码

class PaypalTest
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;

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,
    );

    $this->envelope = array(
        "errorLanguage" => "en_US",
        "detailLevel" => "ReturnAll"
    );


function getPaymentOptions($paykey)
    $packet = array(
        "requestEnvelope" => $this->envelope,
        "paykey" => $paykey
    );

    return $this->_paypalSend($packet,"getPaymentOptions");

function setPaymentOptions()


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_HTTPHEADER, $this->headers);
    $response = json_decode(curl_exec($ch),true);
    return $response;


function splitPay()

// create the pay request
    $createPacket = array(
        "actionType" =>"PAY",
        "currencyCode" => "USD",
        "receiverList" => array(
            "receiver" => array(
                array(
                    "amount"=> "200.00",
                    "email"=>"sb-3oe0y636987@personal.example.com"
                )
            )
        ),
        "returnUrl" => "http://test.local/payments/confirm",
        "cancelUrl" => "http://test.local/payments/cancel",
        "requestEnvelope" => $this->envelope
    );

    $response = $this->_paypalSend($createPacket,"Pay");
    print_r($response);
    $payKey = $response['payKey'];
    $detailPacket = array(
        "requestEnvelope" => $this->envelope,
        "payKey" => $payKey,
        "receiverOptions" => array(
            array(
                "receiver" => array("email"=>"sb-3oe0y636987@personal.example.com"),
                "invoiceData" => array(
                    "item" => array(
                        array(
                            "name" => "Product 1",
                            "price" => "100.00",
                            "identifier" => "p1"
                        ),
                        array(
                            "name" => "Product 2",
                            "price" => "100.00",
                            "identifier" => "p1"
                        )
                    )
                )
            )
        )
    );

    $response = $this->_paypalSend($detailPacket,"setPaymentOptions");
    echo $response;
    print_r($response);
    $dets = $this->getPaymentOptions($payKey);
    print_r($dets);



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

【问题讨论】:

您是否有用于自适应支付的实时应用 ID?这个问题可能没有实际意义,因为自适应支付非常老旧,不再支持新的集成。即使您确实让它在沙箱中工作,您也无法对此做任何事情。 还有其他类似的解决方案吗? 【参考方案1】:

新的集成不再支持自适应支付,因此不应使用。

改为切换到受支持的集成,例如 PayPal Checkout。

(还有更专业的PayPal Commerce Platform,仅适用于经过批准的 PayPal 合作伙伴。)

【讨论】:

但它返回“payKey”是什么意思? 对于多个收款人的分期付款? EC Parallel Payments 不需要实时 APP ID,因此目前可能可用,但也已弃用,将来可能不支持。 developer.paypal.com/docs/archive/express-checkout/…

以上是关于PayPal 自适应付款后不执行任何操作的主要内容,如果未能解决你的问题,请参考以下文章

PayPal 自适应付款退款问题

Paypal 自适应支付和 IPN

Python 中的 PayPal 自适应付款转换货币请求(已弃用的 API)

Paypal 自适应链式支付

如何验证我的收款人以进行 paypal 自适应付款

模式窗口中的PayPal自适应付款?