PayPal IPN 唯一标识符 [英] PayPal IPN unique identifier

查看:32
本文介绍了PayPal IPN 唯一标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直认为与 IPN 消息一起发送的 txn_id 是唯一的.PayPal 指南似乎支持这个想法 - https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro

I always assumed that txn_id sent with IPN message is unique. PayPal guidelines seem to support this idea - https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro

避免重复的 IPN 消息.检查您是否尚未处理由 IPN 消息中返回的事务 ID 标识的事务.您可能需要将 IPN 消息返回的事务 ID 存储在文件或数据库中,以便您可以检查重复项.如果PayPal发送的交易ID重复,请勿再次处理.

Avoid duplicate IPN messages. Check that you have not already processed the transaction identified by the transaction ID returned in the IPN message. You may need to store transaction IDs returned by IPN messages in a file or database so that you can check for duplicates. If the transaction ID sent by PayPal is a duplicate, you should not process it again.

但是我发现 PayPal 的电子支票付款 IPN 使用相同的交易 ID 发送了两次.一次在初始付款时 payment_status 为待处理",几天后电子支票实际处理时 payment_status 为已完成".

However I found that PayPal's eCheck payment IPN is sent twice with the same transaction ID. Once during initial payment with payment_status as "Pending" and again after couple days when eCheck is actually processes with payment_status as "Completed".

我想存储两个交易,但仍想避免存储重复项.IPN 中有另一个字段 ipn_track_id 并且它对于两个交易都是不同的,但我找不到它的文档,除了这个模糊的描述:

I want to store both transactions, but still would like to avoid storing duplicates. There is another field in IPN called ipn_track_id and it's different for both transactions, but I can't find documentation for it, except this vague description:

内部;仅供 MTS 和 DTS 使用

Internal; only for use by MTS and DTS

还有其他人在使用 ipn_track_id 来唯一标识 IPN 消息吗?

Anyone else is using ipn_track_id to uniquely identify IPN messages?

推荐答案

ipn_track_id 不应使用;主要是因为这仅供内部使用,而且对于每个 IPN 消息都是唯一的.
txn_id 对于每个交易都是唯一的,而不是每个 IPN 消息.

ipn_track_id shouldn't be used; mainly because this is for internal use only as stated, and because it's unique for every IPN message.
The txn_id is unique for each transaction, not each IPN message.

这是什么意思;一个事务可以有多个 IPN 消息.例如,eCheck,默认情况下它将进入待处理"状态,并在电子支票清除后完成".
但您也可能会看到撤销、取消的撤销、打开的案例和针对相同 txn_id 的退款.

What this means is; one transaction can have multiple IPN messages. eCheck, for example, where it will go in a 'Pending' state by default, and 'Complete' once the eCheck has cleared.
But you may also see reversals, canceled reversals, cases opened and refunds against the same txn_id.

伪代码:

If not empty txn_id and txn_type = web_accept and payment_status = Completed  
    // New payment received; completed. May have been a transaction which was pending earlier.
    Update database set payment_status = Completed and txn_id = $_POST['txn_id']  

If not empty txn_id and txn_type = web_accept and payment_status = Pending  
    // New payment received; completed  
    Update database set payment_status = Pending and payment_reason = $_POST['pending_reason'] and txn_id = $_POST['txn_id']

您可以在 https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables#id08CTB0S055Z

基本上;PayPal 将生成唯一的卖家交易 ID.此交易 ID 在完成"之前可能会经历多个阶段,因此您需要能够处理这些异常.

Basically; PayPal will generate a unique seller transaction ID. This tranaction ID may go through various stages before it's 'Completed', so you'll need to be able to handle these exceptions.

关于PayPal在文档中的说明:如果在交付过程中遇到错误,PayPal可能会重新发送单个IPN消息.例如,每当 PayPal POST 向其发送 IPN 数据时,您的脚本都需要返回正确的 HTTP/1.1 200 OK HTTP 状态响应.
如果您不返回 HTTP/1.1 200 OK 响应,PayPal 将重新尝试发送相同数据,每条 IPN 消息最多 16 次.

As for PayPal's note in the documentation: PayPal may resend individual IPN mesages if it encounters errors during delivery. For example, it's required for your script to return a proper HTTP/1.1 200 OK HTTP status response whenever PayPal POST's the IPN data to it.
If you don't return a HTTP/1.1 200 OK response, PayPal will reattempt sending the same data up to 16 times per indiviudal IPN message.

注意:卖家的交易 ID 与买家的交易 ID 不同,因为它们是两种不同的操作(一个借方,一个贷方).

Note: A seller's transaction ID is different from a buyer's transction ID, since they're two different actions (one debit, one credit).

这篇关于PayPal IPN 唯一标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆