Waiting for Paypal Payment Notification ASP.NET - asp.net

I am implementing an ASP.NET web app where the user will fill an application that spans over multiple steps/Pages, with previous/Next buttons on each page to navigate back and forth to each step.
On the second step/page, I have a paypal payment button, so the user can pay for the services they selected on the first page.
My requirements is to wait for the user to pay with paypal and get the notification that a payment was received then navigate to the next page automatically. The user should not be able to proceed without payment.
The paypal payment button opens a new window with paypal site where the user makes the payment.
I looked at Paypal IPN (Instant Payment Notification), Paypal can send the notification to a service on the back-end in the web app, but how can I forward the user to the next page once this notification is received, since this service is not tied directly to the page that the user has opened on his browser?
The one way I am thinking to do is to store the payment in some table with the userid and a unique code and have a javascript function with setInterval(checkPayment, 5000); so every 5 seconds, it calls a service to check if there was a payment and forward the user.
Is there any better solution ?

Better solution is to NOT involve IPN in your checkout flow. As stated:
Because IPN is not a real-time service, your checkout flow should not wait for the IPN message before it is allowed to complete.
REF: https://developer.paypal.com/docs/classic/products/instant-payment-notification/
Paypal has an extensive API that handles your flow - e.g
Express Checkout
REST

Related

PayPal Sandbox subscription webhook response not getting

I'm trying to get notified via webhooks when a simple payment is made and subscription, however I don't receive any request from paypal on the specified URL. Here is what I've done:
I have 2 sandbox accounts: Facilitator and Buyer
Create an app (sanbox mode) for the facilitator account
Add a webhook URL in that app
Login into sanbox.paypal.com with the sandbox facilitator username and password
Get payment through express checkout and customer also agree for subscription
Received success response from PayPal
Prepare query string to create subscription for that customer and send data through REST Api
Received response from PayPal related to subscription.
When I login to business account or Facilitator account, I can see bot payment and subscription transaction but the webhook page on my server is not called.
Also if I go to Developer Account -> Webhook Notifications and select the app I have this message: You don't have any events for the selected application
NOTE: If I add the URL in the webhook simulator everything works great.
Am I doing something wrong?
Thanks
You can try to add "All events" for your webhook endpoint.
Then check if you received anything after completing your order in Developer Account -> Webhook Notifications.
If you still get nothing there, consider cross checking your clientId + secret that you use while creating your order.

Redirecting to paypal checkout page

Am working with imevent theme template(I bought it) to build an event page.It has two registration options.1 register without paypal 2. register with paypal.The first option sends the registration details to an email. Is there a way i can then redirect to paypal to enable client to pay via credit or debit card. That is after sending registration details to a specified email.?

Silent payment using paypal without redirecting to paypal url

Is there a way I can pass the sellers credentials to the Paypal API and it can make a transaction without taking him to Paypal URL?
TL. DR.
I am trying to build an eCommerce website for a shop with Paypal as the payment medium. The payment for user has been implemented where he is redirected to the Paypal website and he can purchase an item. But under certain conditions he is allowed to cancel his purchase and his payment must be credited back to him.
I need this transaction to happen without navigating to the Paypal URL.The reason is that, the buyer is the one initiating the transaction. So there is no way he can authorize a transfer from sellers to buyers account. The buyer should be able to press the "Cancel Order" button and the payment should be immediately credited back to his paypal account.
I can store the sellers credentials in the server and send it to the API which should be able to authorize him but I was looking for an API which Paypal provides to make this happen.
My requirement is different from the anser provided in this question as here they still show a popup of paypal webpage.

PayPal asynchronous notification

Now information about the successful transaction I get with a redirect the user back to my site from paypal. And then I make additional requests to api paypal.
But if the user cancels the redirect to my site, for some reason, I do not get the information about the transaction.
Is there an asynchronous notification from Paypal for Website Payments Standard or Express Checkout?
Instant Payment Notification (IPN) works for all payment methods through PayPal. The Developer.PayPal.com document you linked is a list of variables for the Express Checkout feature and it is telling you that you can only pass the NOTIFYURL variable successfully in the DoExpressCheckoutPayment API call.
In Payments Standard transactions you'll use the notify_url variable.
You can also just enable IPN within your account to have an IPN post sent to your notification page when any payment completes - regardless of whether or not you define a URL in the button code or API request (the URL you define in the code will always override what is set in your account).

Preventing Spoofing with Paypal

I have a scenario where i need to have a user checkout through PayPal and then once we receive the payment then we create a membership record in our membership site. The PayPal requires a "return" field when you submit the form button that will take the user back to our page once the order has been successfully processed. On that page is where we actually track the sale and fire a chunk of javascript to track the sale.
So my question is this, how can i make sure that the return page comes from PayPal and is not spoofed by a user in the system. I know there is a way to use the notify_url to have PayPal post back to our system, but in this case i have to run a chunk of javascript. Is there an easy way to do this, or would i have to write some looping/timeout function that checks to see if the notify post has come through?
Im using .net to do the posting to paypal
You need to have PayPal call a script on your site in order to prevent spoofing. Anything that goes through the client/browser is open to the user for modification, so only things that come directly to your server from PayPal are secure.

Resources