【问题标题】:Paypal IPN Verification from return_url is INVALID but from notify_url is VERIFIED来自 return_url 的 Paypal IPN 验证无效,但来自 notify_url 的验证已验证
【发布时间】:2014-12-26 02:27:19
【问题描述】:

我正在使用 Paypal 订阅,标准网站按钮。所以对于这个问题,payment_type 是 subscr_signup,用于为您的新用户创建用户帐户。我的 HTML 按钮表单的“notify_url”值设置为http://domain.com/billing/ipn,“return”设置为http://domain.com/billing/thankyou,“rm”设置为 2

这样,当有人完成付款时,他/她将被重定向到我们的感谢页面,以及 POST 中的 IPN 数据。我明白了。但是当我用 Paypal 验证它时,我得到了一个无效的响应。现在,奇怪的是,我们也应该将数据发送到我们的 IPN notify_url,对吧?我们做到了,但这一次,向 Paypal 验证它会返回 VERIFIED。

我注意到发送的数据存在一些差异。

返回感谢页面的数据 - 无效(JSON 化)

{
"txn_type": "subscr_signup",
"subscr_id": "I-HHTJ0ANUHKRU",
"last_name": "Ismail",
"residence_country": "CA",
"mc_currency": "USD",
"item_name": "Individual eStudio Plan",
"business": "business@kengkawan.com",
"amount3": "99.00",
"recurring": "1",
"address_street": "1 Maire-Victorin",
"payer_status": "verified",
"payer_email": "customer@kengkawan.com",
"address_status": "confirmed",
"first_name": "Iszuddin",
"receiver_email": "business@kengkawan.com",
"address_country_code": "CA",
"payer_id": "LYRHTKFEH45M8",
"address_city": "Toronto",
"reattempt": "1",
"item_number": "IND",
"address_state": "Ontario",
"subscr_date": "22:52:19 Oct 29, 2014 PDT",
"address_zip": "M5A 1E1",
"charset": "windows-1252",
"period3": "1 Y",
"address_country": "Canada",
"mc_amount3": "99.00",
"address_name": "Iszuddin Ismail",
"auth": "AUjfQ4uRNLr22YfSNPGR1YLm5w81cYyFjf9PEu7mVGSLTp2cFD67opAIXJ-Dtsnw4KEXlF0Y268Ks9VmrwpDRrg",
"form_charset": "UTF-8"
}

NOTIFY_URL 的数据,后端 IPN 数据 - 已验证(JSON 化)

{
"txn_type": "subscr_signup",
"subscr_id": "I-HHTJ0ANUHKRU",
"last_name": "Ismail",
"residence_country": "CA",
"mc_currency": "USD",
"item_name": "Individual eStudio Plan",
"business": "business@kengkawan.com",
"amount3": "99.00",
"recurring": "1",
"address_street": "1 Maire-Victorin",
"verify_sign": "Ajiy6YmBz00sV0oT2S-obuaQ3kehAQO0-T8GJFKpiQnaRzRv7.oJ5Eqy",
"payer_status": "verified",
"test_ipn": "1",
"payer_email": "customer@kengkawan.com",
"address_status": "confirmed",
"first_name": "Iszuddin",
"receiver_email": "business@kengkawan.com",
"address_country_code": "CA",
"payer_id": "LYRHTKFEH45M8",
"address_city": "Toronto",
"reattempt": "1",
"item_number": "IND",
"address_state": "Ontario",
"subscr_date": "22:52:19 Oct 29, 2014 PDT",
"address_zip": "M5A 1E1",
"charset": "windows-1252",
"notify_version": "3.8",
"period3": "1 Y",
"address_country": "Canada",
"mc_amount3": "99.00",
"address_name": "Iszuddin Ismail",
"ipn_track_id": "698ae88a36ef9"
}

由于我确实收到了预期的响应(已验证或无效),我相信我的 Paypal IPN 验证码是正确的。但以防万一,这是我的 HTML 按钮代码。

            <form action="<?php echo $this->url?>" method="post" name="ppform">
         <input type="hidden" name="cmd" value="_xclick-subscriptions">
         <input type="hidden" name="business" value="<?php echo $this->paypal_email; ?>">
         <input type="hidden" name="item_name" value="<?php echo $selected_plan['name'] ?>"> 
         <input type="hidden" name="item_number" value="<?php echo $selected_plan['code'] ?>"> 
         <input type="hidden" name="a3" value="<?php echo $selected_plan['price']; ?>"> <!-- subscription price -->
         <input type="hidden" name="p3" value="1">  <!-- rebill every x value -->
         <input type="hidden" name="t3" value="<?php echo $selected_plan['recurring_period'] ?>">  <!-- interval M=month/W=week/Y=year -->
         <input type="hidden" name="src" value="1"> <!-- Is this recurring 1=yes/0=no -->
         <input type="hidden" name="currency_code" value="<?php echo $selected_plan['currency'] ?>">
         <!-- <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> -->
         <input type="hidden" name="rm" value="2">
         <input type="hidden" name="notify_url" value="<?php echo site_url('billing/ipn') ?>">
         <input type="hidden" name="return" value="<?php echo site_url('billing/thankyou') ?>">

        </form>     

【问题讨论】:

  • 我认为问题不完整/不清楚,您在下面的评论中说您现在使用 PDT,您应该使用此信息更新问题。请注意,您可以并且也许应该同时实现 IPN 和 PDT,如 here 所述。还请指定您使用的编程语言(也许是 PHP?)并为此添加标签,因为它会增加您获得响应的机会。您是否使用沙盒进行测试?
  • 请同时发布一些代码。用于实现 IPN 的示例代码(PHP、.Net、Coldfusion 等)here,用于实现 PDT 的示例代码here

标签: paypal paypal-ipn


【解决方案1】:

return_url 不接收任何付款/IPN 信息。通常它应该只是一个显示“谢谢,再来一次”的静态页面。

您应该使用 notify_url 验证 IPN 消息。您需要发送收到的付款数据完全与收到的方式相同。如果你在一个好的请求上收到 INVALID 错误,你应该仔细检查你收到请求的编码,存储在 php 中并发回。您可以在付款代码中使用PayPal PHP SDK 确定。

请注意,IPN 会发送一堆关于订阅用户注册、付款处理等的消息。

【讨论】:

  • 感谢您的帮助。在一个论坛中,有人建议我使用 PDT 来处理返回流量。所以这就是我所做的。我的系统仍然在后端记录 IPN 数据,接收 subscr_signup 和 subscr_payment 交易类型。但是为了在付款后处理用户,我现在使用 PDT 数据。它需要在 Paypal 帐户中进行一些设置更新。然后,根据我的 GET tx 参数和我的秘密 PDT 令牌,我可以请求交易的完整数据。 developer.paypal.com/docs/classic/products/…
  • return_url 如果使用 PDT 可以接收付款信息(似乎是这种情况)。
猜你喜欢
  • 2011-06-18
  • 2017-02-17
  • 2016-06-26
  • 2014-09-30
  • 2012-03-08
  • 2012-05-16
  • 1970-01-01
  • 2012-01-04
  • 2013-02-14
相关资源
最近更新 更多