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

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

问题描述

我一直认为与IPN消息一起发送的txn_id是唯一的.贝宝准则似乎支持这一想法- 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)的eCheck付款IPN发送了两次,并使用了相同的交易ID.在第一次付款期间,将payment_status设置为待处理",然后在几天后再次进行eCheck实际处理时,将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在默认情况下将处于待处理"状态,在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消息.例如,每当贝宝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天全站免登陆