贝宝手机验证一直提示错误_快速提示:贝宝IPN始终返回“无效”的解决方案

贝宝手机验证一直提示错误

Paypal logo

When developing with PayPal’s IPN simulator, you might run into the situation where it keeps returning “Invalid” when verifying the message, regardless of the encoding you set or all conditions matching and being valid.

使用贝宝(PayPal)的IPN模拟器进行开发时,您可能会遇到这样的情况,即在验证消息时,它始终返回“无效” ,而不管您设置编码所有匹配且有效的条件

The Paypal developers team is notorious for ignoring all inquiries, and the docs are famously hard to read, so debugging these issues is incredibly hard and can cost you hours upon billable hours. I’ve even gone as far as set up a live server for testing the IPN simulator, for fear Ngrok was at fault when testing locally, and even added a certificate to the endpoint to get HTTPS going – no dice. In the end, the solution was – as is usually the case – simple but obscure.

贝宝(Paypal)开发人员团队因忽略所有查询而臭名昭著,并且众所周知,文档难以阅读,因此调试这些问题异常困难,并且在收费时间上可能要花费您数小时。 我什至已经设置了一个用于测试IPN模拟器的实时服务器,以免Ngrok在本地测试时出错,甚至还向端点添加了证书以使HTTPS正常运行-没问题。 最后,通常情况下,解决方案是简单但晦涩的。

The symptom (the failure) is caused by the date field, if it contains a timezone identifier. All this, however, is caused by the fact that PHP has two different URL encoding / decoding functions: raw and non-raw.

如果症状(失败)是由日期字段引起的,则该日期字段包含时区标识符。 但是,所有这些都是由于PHP具有两种不同的URL编码/解码功能:原始和非原始的。

Here’s an example.

这是一个例子。

Say we have a date in the IPN simulator going like this:

假设我们在IPN模拟器中有一个日期,如下所示:

Fri Aug 19 2016 09:25:00 GMT+0100 (GMT Daylight Time)

This arrives at the listener’s end (in your PHP code) as this:

这样到达侦听器的末端(在您PHP代码中),如下所示:

Fri%20Aug%2019%202016%2009%3A25%3A00%20GMT+0100%20%28GMT%20Daylight%20Time%29

The substring GMT+0100 is problematic, because the PHP function urldecode interprets the + as a space, so it gets decoded into:

子字符串GMT+0100有问题,因为PHP函数urldecode+解释为空格,因此将其解码为:

Fri Aug 19 2016 09:25:00 GMT 0100 (GMT Daylight Time)

Notice the + was lost, turned into a space character.

注意+丢失了,变成了空格字符。

When this gets re-encoded for sending back to Paypal for verification, the verification fails because it’s no longer the same value in the field – the + is missing. It’s a very, very tiny detail, and incredibly hard to spot when hand-inspecting the field values, but it’s there. This is enough, as per Paypal docs, to make the verification return “INVALID”.

当对此进行重新编码以发送回Paypal进行验证时,验证将失败,因为该字段中的值不再相同-缺少+ 。 这是一个非常非常小的细节,在手动检查字段值时很难发现,但是它就在那里。 根据Paypal文档,这足以使验证返回“ INVALID”。

There are two solutions to this problem:

有两个解决此问题的方法:

  1. Use rawurlencode and rawurldecode instead of their non-raw counterparts. These encode the + symbol, too, instead of turning it into a space character, and it all works then.

    使用rawurlencoderawurldecode而不是它们的非原始对应物。 它们也对+符号进行编码,而不是将其转换为空格字符,然后一切正常。

  2. Use a Paypal IPN Listener client which has this built in. I recently submitted a patch to this one, and it works like a charm.

    使用PayPal IPN监听器的客户端已内置此。我最近提交了一个补丁来这一个 ,它就像一个魅力。

Hope this little hint saved someone from lots of frustrating googling!

希望这个小提示可以使某人摆脱许多令人沮丧的谷歌搜索!

翻译自: https://www.sitepoint.com/quick-tip-solution-to-paypal-ipn-always-returning-invalid/

贝宝手机验证一直提示错误

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值