简体   繁体   中英

Paypal IPN Problem

I am developing a site where users can buy features using 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?

You tagged your question with C#, so I'm assuming you're developing an ASP.NET site. And in the absence of more specific information, I'm going to assume you're using the default SqlMembershipProvider for your site.

So, to identify your user, you should probably use the ProviderUserKey property of the MembershipUser object. Use the following code to get the ProviderUserKey for your currently logged-in user:

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:

<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. You can get the value from Response.Form and get the corresponding user:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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