简体   繁体   English

贝宝IPN问题

[英]Paypal IPN Problem

I am developing a site where users can buy features using paypal. 我正在开发一个网站,用户可以在其中使用Paypal购买功能。 If user's paypal email is different from the email stored in our site how can i get notified about the user's payment via IPN? 如果用户的贝宝电子邮件与存储在我们网站中的电子邮件不同,如何通过IPN通知用户付款?

You tagged your question with C#, so I'm assuming you're developing an ASP.NET site. 您用C#标记了问题,所以我假设您正在开发一个ASP.NET网站。 And in the absence of more specific information, I'm going to assume you're using the default SqlMembershipProvider for your site. 并且在没有更多具体信息的情况下,我将假设您为您的站点使用默认的SqlMembershipProvider。

So, to identify your user, you should probably use the ProviderUserKey property of the MembershipUser object. 因此,要标识您的用户,您可能应该使用MembershipUser对象的ProviderUserKey属性。 Use the following code to get the ProviderUserKey for your currently logged-in user: 使用以下代码获取您当前登录用户的ProviderUserKey:

MembershipUser currentUser = Membership.GetUser();
string userId = currentUser.ProviderUserKey.ToString();

Once you have a String containing the ProviderUserKey, you can pass it to PayPal using the custom HTML variable in your form: 获得包含ProviderUserKey的字符串后,可以使用表单中的自定义HTML变量将其传递给PayPal:

<input type="hidden" name="custom" value="<%=userId%>"/>

When PayPal send the IPN message, it will send back the value that you set for the custom HTML variable. 当贝宝发送IPN消息时,它将发回您为自定义HTML变量设置的值。 You can get the value from Response.Form and get the corresponding user: 您可以从Response.Form获取值并获取相应的用户:

object userId = Request.Form["custom"];
MembershipUser user = Membership.GetUser(userId);

Hope this helps! 希望这可以帮助!

You need to use the email of the user (the one which he/she used for your website) as an identifier. 您需要使用用户的电子邮件(他/她用于您网站的电子邮件)作为标识符。

When the user pays you, your website needs to send this email to Paypal as a "custom" field, and Paypal will send it back to you, among other IPN notification parameters. 当用户付款时,您的网站需要将此电子邮件作为“自定义”字段发送给Paypal,Paypal会将其发送回给您,以及其他IPN通知参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM