Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to integrate PayPal Adaptive Payments into my localhost project. Until now I have managed to perform the paying process. However I need to receive a success response once the payment has been completed in order to update my database.

I have come across the returnURL property, however this is not secure for my implementation since the user can just terminate the session before redirecting the the returnURL and thus the database woould not get updated.

I have also come across the ipnNotificationUrl however I did not manage to make it work. If this is the right way to achieve this goal what needs to be configured in the coding itself, the Web.config, the PayPal sandbox account, or any other configuration.

What is the best practice to achieve this goal?
Posted
Updated 4-Apr-13 3:59am
v2

I have found a possible work around to avoid using the
C#
ipnNotificationURL
.

The lightbox feature. Take a look at the following link Introducing Adaptive Payments While using the lightbox feature, the
C#
returnURL 
seems to be always called.

The returnURL was constructed as follows:
C#
public const string PayPal_URL_Return = YourReturnURL + "/${payKey}";


The
C#
${payKey}
is automatically filled in by PayPal itself Using such information one may call the PaymentDetails using the PayPal Adpative Payments, and use the transaction details accordingly.

For information regarding the PayPal Adaptive Payments visit AdaptivePaymentsSampleApp. The file adaptivepaymentshandler.ashx.cs contains nearly all the necessary details, together with the Web.config file.
 
Share this answer
 
Rutvik Dave is there another way without using IPN since I have to work locally for the moment?
 
Share this answer
 
IPN is the correct way to go. Once the payment is processed Paypal will generate IPN whether it is success or fail. You can specify a url to your web application (not localhost, because paypal cannot access your localhost url. you need to host your application somewhere to test this). and paypal will call that url once the payment is processed. There is a IPN testing tools in the developer sandbox. you can generate as many IPNs you want until everything is working fine. but you need to host your application or implement some kind of dynamic DNS provider to your machine (so that people outside your network can access your url).

Few tips on receiving IPN.


- Check if the request host is Paypal.com before even start processing (this is very easy to check from server variables of the request).

- IPN will have a lot of information regarding your payment, it always a good idea to store everything in your database (this will come handy in case of dispute).

- Mark the order processed only after receiving IPN, until then mark it 'Pending'.

- Receiving IPN doesn't mean that the payment is successful, check the status in the response.
 
Share this answer
 
Never, ever, accept code from a insecure website to handle anything to do with real money.
You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties.

Only get such code from Paypal - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900