Paypal返回“INVALID”,尽管订阅成功付款

问题描述 投票:0回答:1

我正在使用Paypal沙箱尝试订阅功能,并且付款已成功处理。但是,在尝试验证响应时,Paypal会返回INVALID响应。

这是我要发送的数据 -

Array
(
    [cmd] => _notify-validate
    [txn_type] => subscr_signup
    [subscr_id] => I-3R009NJ6JYS9
    [last_name] => buyer
    [residence_country] => GB
    [mc_currency] => USD
    [item_name] => Sellacious_Git
    [business] => [email protected]
    [amount3] => 52.50
    [recurring] => 1
    [payer_status] => verified
    [payer_email] => [email protected]
    [first_name] => test
    [receiver_email] => [email protected]
    [payer_id] => LCLETGLHU5H7A
    [reattempt] => 1
    [item_number] => 123
    [subscr_date] => 06:35:57 Sep 15, 2018 PDT
    [charset] => windows-1252
    [period3] => 1 D
    [mc_amount3] => 52.50
    [auth] => AyB1VOVssxLlLE177ha.etTVC3E8ZWDZOAEu.e9Wezio0ciVvog4UXvI6ODZq-ZxS2tearHH1MAiO.U7E0k.IBg
    [form_charset] => UTF-8
)

这是我得到的回应 -

(
    [code] => 200
    [headers] => Array
        (
            [Date] => Sat, 15 Sep 2018 14:05:29 GMT
            [Server] => Apache
            [X-Frame-Options] => SAMEORIGIN
            [Set-Cookie] => Apache=10.72.108.11.1537020329139856; path=/; expires=Mon, 07-Sep-48 14:05:29 GMT
            [Vary] => Accept-Encoding,User-Agent
            [Connection] => close
            [Transfer-Encoding] => chunked
            [Content-Type] => text/html; charset=UTF-8
        )

    [body] => INVALID
)

我试图通过的网址是 -

https://ipnpb.sandbox.paypal.com/cgi-bin/webscr

我还在个人资料> PayPal按钮语言编码的Paypal卖家设置中将字符编码设置为UTF-8。

请帮忙。

paypal paypal-sandbox sandbox paypal-subscriptions
1个回答
0
投票

我已经实现了如下,这是正常的:

只需更改以下代码中的电子邮件地址并尝试,它应该可以正常工

function paymentIpnlistener(){
     // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';
    foreach ($_POST as $key => $value) {
        $value = urlencode(stripslashes($value));
        $req .= "&$key=$value";
    }
    // post back to PayPal system to validate
    $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
    // If testing on Sandbox use: 
    $header .= "Host: www.sandbox.paypal.com:443\r\n";
    //$header .= "Host: ipnpb.paypal.com:443\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    if (strpos('ssl://www.sandbox.paypal.com', 'sandbox') !== FALSE && function_exists('openssl_open')) {
    $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
  }
    else{
    // The old "normal" way of validating an IPN.
     $fp = fsockopen('ssl://www.sandbox.paypal.com', 80, $errno, $errstr, 30);
    }
    // If testing on Sandbox use:
    //$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
    //$fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30);
    // assign posted variables to local variables
    $item_name          = $_POST['item_name'];
    $item_number        = $_POST['item_number'];
    $payment_status     = $_POST['payment_status'];
    $payment_amount     = $_POST['mc_gross'];
    $payment_currency   = $_POST['mc_currency'];
    $txn_id             = $_POST['txn_id'];
    $receiver_email     = $_POST['receiver_email'];
    $payer_email        = $_POST['payer_email'];
    if (!$fp) {
     // HTTP ERROR
    } else {
        fputs ($fp, $header . $req);
        while (!feof($fp)) {
            $res = fgets ($fp, 1024);
            if (strcmp ($res, "VERIFIED") == 0) {
                // check the payment_status is Completed
                // check that txn_id has not been previously processed
                // check that receiver_email is your Primary PayPal email
                // check that payment_amount/payment_currency are correct
                // process payment

                $mail_From = "// add here your working email address";
                $mail_To = "// add here your working email address";
                $mail_Subject = "VERIFIED IPN";
                $mail_Body = $req;
                foreach ($_POST as $key => $value){
                    $emailtext .= $key . " = " .$value ."\n\n";
                }

                mail($mail_To, $mail_Subject, $emailtext . "\n\n" . $mail_Body, $mail_From);

            }
            else if (strcmp ($res, "INVALID") == 0) {
                // log for manual investigation

                $mail_From = "From: // add here your working email address";
                $mail_To = "// add here your working email address";
                $mail_Subject = "INVALID IPN";
                $mail_Body = $req;

                foreach ($_POST as $key => $value){
                    $emailtext .= $key . " = " .$value ."\n\n";
                }

                mail($mail_To, $mail_Subject, $emailtext . "\n\n" . $mail_Body, $mail_From);

            }
        }   // while end
     fclose ($fp);
    }   
}

请使用上面的功能我希望它能解决你的问题,我已经用PHP实现了。如果需要任何帮助,请告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.