The main problem of the workflow with the integration of Paypal + ASP.NET web applications

I am setting up a payment gateway for my software product, which users can buy on the Internet and use. I use the Paypal website payment standard to get started.

There, the main problem bothers me. Workflow for my user: Log in to my product website (free trial license) β†’ Pay for license renewal

Now suppose that the user - xyz@abc.com registered on my site and logs in. Then I will show him the buy now (paypal's) button. He clicks on it, redirects to paypal, pays, redirects back to my site. In the background, I configured the PayPal IPN function and received a notification about this transaction and its details. Now - how do I associate this purchase with my user? How do I know that xyz@abc.com made a payment.

Note. I do not use the autoreturn + PDT method because of its main drawback - if the user closes the browser after payment, but before returning to the autorun page, my logic after payment never starts. Using IPN guarantees the logic of postal payments, but how to connect the payment with the name of the user on my site who initiated and completed the payment?

0
source share
2 answers

For your user payment, you create a unique identifier that you send for payment and get it back to IPN.

PayPal code: " invoice "

Here are the codes: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables

Look at table 4.

invoice β†’ Passthrough variable, which you can use to identify the account number for this purchase.

Here is the code for IPN https://www.paypal.com/us/cgi-bin/webscr?cmd=p/pdn/ipn-codesamples-pop-outside

on if (strResponse == "VERIFIED") {... you can get an invoice ... just by reading Request.Form [" invoice "]

Ps You can use both PDT and IPN, and you can combine the results with them.

+2
source

You need to configure ASP.NET profiles to register subscribers . This allows you to store additional data for each user in the database after they have been verified through IPN. Before sending data to PayPal, you can create a GUID to associate an order with a registered user.

If you are using an ASP.NET website project template, you have profiles out of the box. If you are using an ASP.NET Web Application project template, you can use Web Profile Builder to configure profiles:

http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx

Here is another cool way to do this:

http://leedumond.com/blog/asp-net-profiles-in-web-application-projects/

To associate a payment with a username on your site, the life cycle will be as follows:

1) Use PayPal Subscriptions to process the initial free period :-)

2) The user subscribes to your site and goes to the PayPal site.

3) IPN class handshake using PayPal and capturing the values ​​returned by PayPal

4). The IPN class updates your application database and generates an email to the subscriber with a return URL to register with your site.

5). The IPN class generates email (backup) for the seller with the subscription data.

6) The subscriber creates a user account on your site and sets up any additional information about the members that you want to save in your profile

protected void Createuserwizard1_CreatingUser(object sender, EventArgs e) { WebProfile p = WebProfile.GetProfile(CreateUserWizard1.UserName, true); p.Initialize(CreateUserWizard1.UserName, true); p.subscriberID = ViewState["SubscriberID"].ToString(); p.subscriberExpireDate = ViewState["ExpireDate"].ToString(); p.Save(); } 

Some Gotchas:

Do Not Use PayPal Return URL

Do not mix IPN and PDT . IPN is all you need

Remember the Save () method when creating the profile: -S

+1
source

Source: https://habr.com/ru/post/921624/


All Articles