[英]Paypal adaptive payments IPN callback: how to return the complete unaltered ipn message
I'm working on a marketplace (buyers and sellers) and the middleman gets a cut of every purchase. 我在一个市场上(买方和卖方)工作,中间人每次购买都会得到一部分。 I want to enable the buyer to buy the item right after the buy button being redirected to Paypal.
我想让买家在将购买按钮重定向到Paypal之后立即购买商品。 This is good and working.
这很好并且可以正常工作。
response = ADAPTIVE_GATEWAY.setup_purchase(
:return_url => 'return_url',
:cancel_url => 'cancel_url',
:ipn_notification_url => 'ipn_notification_url',
:receiver_list => recipients,
)
# ADAPTIVE_GATEWAY.set_payment_options(...)
redirect_to (ADAPTIVE_GATEWAY.redirect_url_for(response['payKey']))
Next step is to validate the transaction with ipn. 下一步是使用ipn验证交易。 I do receive the paypal callback, but I'm unclear what should be returned?
我确实收到了贝宝回调,但是不清楚应返回什么?
def notify_cb
notify = ActiveMerchant::Billing::Integrations::PaypalAdaptivePayment::Notification.new(request.raw_post)
if notify.acknowledge
update_attributes({
:transaction_id => notify.transaction_id,
:status => notify.status
})
end
render :nothing => true # render nothing?!? RENDER_LINE
end
Most of the examples here on SO render nothing (RENDER_LINE), while on paypal documentation the flow is described as ( https://www.x.com/developers/paypal/documentation-tools/ipn/integration-guide/IPNIntro#protocol_and_arch ): SO上的大多数示例都不会呈现任何内容(RENDER_LINE),而在Paypal文档上,流程描述为( https://www.x.com/developers/paypal/documentation-tools/ipn/integration-guide/IPNIntro#protocol_and_arch ):
The IPN protocol consists of three steps: IPN协议包括三个步骤:
PayPal sends your IPN listener a message that notifies you of the event 贝宝向您的IPN侦听器发送一条消息,通知您该事件
Your listener sends the complete unaltered message back to PayPal; 您的听众会将完整的未更改消息发送回PayPal; the message must contain the same fields in the same order and be encoded in the same way as the original message
邮件必须包含与原始邮件相同的顺序的相同字段,并且必须以与原始邮件相同的方式进行编码
PayPal sends a single word back, which is either VERIFIED if the message originated with PayPal or INVALID if there is any discrepancy with what was originally sent PayPal发回一个单词,如果消息是由PayPal发出的,则为VERIFIED;如果与原始发送的内容有任何差异,则为INVALID
My question would be how to return the complete unaltered message back to PayPal or i'm missing/being wrong with my understanding of the flow? 我的问题是如何将完整的未更改消息返回给PayPal,或者我对流程的了解不正确/错了?
Are you posting back to https://sandbox.paypal.com/ or https://www.sandbox.paypal.com/cgi-bin/webscr (either include “cmd=_notify-validate as part of your POST data, or include via GET)? 您是要发回到https://sandbox.paypal.com/还是https://www.sandbox.paypal.com/cgi-bin/webscr (是否将“ cmd = _notify-validate作为POST数据的一部分,或者通过GET包含)?
The former returns a HTTP 301 because you're basically pointing directly to the homepage, whereas the latter will point directly to the page hosting the IPN validation logic. 前者返回HTTP 301,因为您基本上是直接指向主页,而后者将直接指向承载IPN验证逻辑的页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.