本文介绍了将Paypal IPN与在localhost上运行的网站一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Paypal即时付款通知(Paypal IPN)集成到我的ASP.NET网站中.该网站处于开发模式,并且可以在localhost上运行.

I want to integrate Paypal Instant Payment Notifications (Paypal IPN) into my ASP.NET website. The website is in development mode and it runs on localhost.

按照本教程操作( https://developer.paypal .com/docs/classic/ipn/integration-guide/IPNTesting/#local ),我创建了一个脚本来模拟IPN通知.此IPN通知会命中我网站的IPN处理程序.

Following this tutorial (https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNTesting/#local) I created a script that simulates a IPN notification. This IPN notification hits the IPN handler of my website.

但是,当我的IPN处理程序将信息重新发布回Paypal沙箱时,Paypal总是返回INVALID.我想这是预料之中的,因为Paypal没有发送原始IPN消息.

However, when my IPN handler reposts the information back to Paypal sandbox, Paypal always returns INVALID. I guess this is expected because Paypal did not send the original IPN message.

但是,我想测试Paypal验证IPN消息时将运行的代码.目前,我无能为力. Paypal文档说,我应该将验证消息时运行的代码放入消息无效时运行的块中.

However, I want to test the code that will run when IPN message is verified by Paypal. Currently I have no way to do it. Paypal docs say that I should put the code that runs when message is verified into the block that runs when message is invalid.

那是

if(response == "VERIFIED")
{
    //put any code here in the else if block below
}
else if(response == "INVALID")
{

}

这种技术对我来说似乎很不干净且不完整.部署到实时服务器时,我将不得不更改代码.

This technique appears very unclean and incomplete to me. I will have to change my code when I deploy to live server.

是否有更好的方法可以使用localhost测试IPN?

推荐答案

为此提供了一个很棒的工具: https://ngrok .com/.

There is a great tool for this: https://ngrok.com/.

Ngrok允许将经过检查的隧道安全地连接到本地主机".基本上,您部署ngrok,然后类似"48210d19.ngrok.com"的URL将指向您的本地主机.您使用该URL来测试IPN.

Ngrok allows "secure intospected tunnels into localhost". Basically you deploy ngrok, and then a URL like '48210d19.ngrok.com' will point to your localhost. You use that URL for testing your IPNs.

这篇关于将Paypal IPN与在localhost上运行的网站一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 23:01