php - 当我使用 Sandbox 时,PayPal payment_status 总是挂起

标签 php paypal paypal-sandbox paypal-ipn

我正在使用 PayPal IPN 功能,但是当我使用 Sandbox 进行测试时,我一直收到 _POST[payment_status] = Pending。因此,我无法测试完整的购买以确保整个过程正常运行。

这是我的代码:

// Set the request paramaeter
$req = 'cmd=_notify-validate';

// Run through the posted array
foreach ($_POST as $key => $value)
{
    // If magic quotes is enabled strip slashes
    if (get_magic_quotes_gpc())
    {
        $_POST[$key] = stripslashes($value);
        $value = stripslashes($value);
    }
    $value = urlencode($value);
    // Add the value to the request parameter
    $req .= "&$key=$value";
}

$ch = curl_init();    // Starts the curl handler
curl_setopt($ch, CURLOPT_URL,$paypal[$testing]); // Sets the paypal address for curl
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Returns result to a variable instead of echoing
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // Sets a time limit for curl in seconds (do not set too low)
curl_setopt($ch, CURLOPT_POST, 1); // Set curl to send data using post
curl_setopt($ch, CURLOPT_POSTFIELDS, $req); // Add the request parameters to the post
$result = curl_exec($ch); // run the curl process (and return the result to $result
curl_close($ch);

if (strcmp ($result, "VERIFIED") == 0) // It may seem strange but this function returns 0 if the result matches the string So you MUST check it is 0 and not just do strcmp ($result, "VERIFIED") (the if will fail as it will equate the result as false)
{
// It worked
// do my stuff
}else{

    foreach($_POST as $key=>$value){
        $post_str .="_POST[$key] = $value<br>";
    }

    $sub = "Paypal error";
    $mes = "$post_str";
    mailer($sub, $mes, $from, $to);

}

这是我在电子邮件中收到的错误消息:

_POST[mc_gross] = 120.00
_POST[protection_eligibility] = Ineligible
_POST[address_status] = confirmed
_POST[payer_id] = QDZDYY4JWGFVG
_POST[tax] = 0.00
_POST[address_street] = 1 Maire-Victorin
_POST[payment_date] = 12:25:03 Apr 11, 2013 PDT
_POST[payment_status] = Pending
_POST[charset] = windows-1252
_POST[address_zip] = M5A 1E1
_POST[first_name] = gppl
_POST[address_country_code] = CA
_POST[address_name] = gppl Simard's Test Store
_POST[notify_version] = 3.7
_POST[custom] = 
_POST[payer_status] = verified
_POST[address_country] = Canada
_POST[address_city] = Toronto
_POST[quantity] = 1
_POST[verify_sign] = An5ns1Kso7MWUdW4ErQKJJJ4qi4-AjAXF3KMNcb6G83Jslw18dw.Ti32
_POST[payer_email] = 78h23d8712h3d@x.com
_POST[txn_id] = 2KU491796R824634N
_POST[payment_type] = instant
_POST[payer_business_name] = gppl x's Test Store
_POST[last_name] = Simard
_POST[address_state] = Ontario
_POST[receiver_email] = x@x.x
_POST[pending_reason] = unilateral
_POST[txn_type] = web_accept
_POST[item_name] = 926537
_POST[mc_currency] = CAD
_POST[item_number] = 
_POST[residence_country] = CA
_POST[test_ipn] = 1
_POST[handling_amount] = 0.00
_POST[transaction_subject] = 926537
_POST[payment_gross] = 
_POST[shipping] = 0.00
_POST[ipn_track_id] = c7dcef0b1c333

这个错误真的让我抓狂。 大家知道,我已经将付款审核设置为关闭

最佳答案

如果您使用的是沙箱,请打开 developer.paypal.com->Dashboard->Accounts->facilitator@yourhost.com->Profile->Settings。将“付款审核”设置为“关闭”

关于php - 当我使用 Sandbox 时,PayPal payment_status 总是挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15957451/

相关文章:

php - 如何判断 URL 是否指向图像?

php - Firebase 云消息传递 PHP 集成发送推送通知

php - 如何使用 checkout.js 在 paypal 快速结帐中成功全额付款后获取 IPN 状态

python - Paypal 批量付款 - Python - 访问被拒绝

paypal - PapPal 中 payment_status 为 pending 怎么办?

php - 将字符串拆分为数组并附加上一个值

php - sql php函数中的插入查询

c# - 购物车商品总金额与 SetExpressCheckout PayPal Api 上的订单金额不匹配

c# - 根据用户的送货地址设置运费 Paypal REST API

Paypal 订阅免费试用无效