How to authenticate Paypal Success page in ASP.NET - c#

I have a PayPal transaction successful page that I need to store customer data on.
How can I authenticate this page on page load so that it only displays when users come back from a successful PayPal transaction? (you can't just type it in manually in the browser)

I think you can send some custom data parameter to PayPal which PayPal sends as a parameter to your success page. You have to check for the correct value of that parameter in your Page_load event.

Related

DNN PayPal settings checking receiver_email

On one of the pages of my DNN website I've set up a BuyNow button inside a HTML/Text module. The button does a POST on submit to the PayPal Sandbox URL. I've also set up a REST based service which PayPal is going to post the IPN information to.
In this service I'm sending a POST with the cmd_notify parameter and get back the information associated to the transaction.
At this point I would like to check whether the receiver_email parameter which PayPal sends coincides with my seller email adress from inside the Sandbox account. However I don't want to hardcode the value for the latter. I've noticed that DNN has a "Payment Settings" section under Admin->Advanced Settings.
[TL;DR]
How can I programatically access the PayPal email address info stored at Admin->Advanced Settings->Payment Settings from back-end webservice C# code? Is this possible?
This is stored in the HostSettings table as a setting key named "ProcessorUserId":
select * from hostsettings where settingname='ProcessorUserId'
Programmatically, if you're inside DNN you can access it through:
DotNetNuke.Common.Globals.HostSettings(KEY)
that is:
string pid= DotNetNuke.Common.Globals.HostSettings("ProcessorUserId");
Hope it helps,
al.

paypal integration in asp.net with c#

I am trying to integrate paypal gateway in my aspx page having shopping cart. I succeed to commit transaction using express checkout method generated by paypal integration wizard but what I am being unable to do is sending product quantity and details to paypal page.
And how can I redirect to my own review page where shipping and billing address is present after log in into the paypal?
how can i redirect to my own review page where shipping and billing address
First you need to send a unique number id for the order that is connected to your database with the information that you like to show after the purchase.
Then you send the "return" parametre with the full url with the unique id of your order that your customer will return and you need to show the final informations.
eg:
<input type="hidden" name="return" value="https://www.urls.con/orderinfos.aspx?TID=112999182">
of cource for better protection is good to encode some how your order id. All of that exist on the paypal sdk manual.
Also return url are the "notify_url" to be notify even if the user not return, and "cancel_return" in case of cancel the payment
You can also search for PDT for the return, and IPN for the notify for more advanced information.

Why HttpContext.Current.Session is changing evertime I visit the same page ASP.Net

Here's the scenario
I have a page lets say login.aspx having a button called login, on click event of that button when I check for the SessionID its shows a specific value for example "A"
Now I am making a call to some external page and that page then calls this page again.
for instance once I click login button I call a twitter app and when user authorizes it, I am redirected back to the same page, but now when I am accessing the SessionID its a new ID.
I have no idea why this is happening, I just want to have the same SessionID
Are you adding any data to the session? You need to do so for the session ID to "stick".
You don't have multiple web servers, do you?
If so, and if you're not using a shared session state provider, you'd tend to see this kind of behaviour.
Edit.
OK, next question...
Is the URL that the Twitter authorisation is returning to using exactly the same domain name?
For example, if your application is running on http://127.0.0.1:1234/ and the return URL is http://localhost:1234/ ?
Edit2: Yes?
When you are redirected back from the Twitter app on 127.0.0.1, the ASP.NET session cookie isn't being passed back to the web server because the domain is different.
You need the domain that the app is running under to match the Twitter callback URL.
Reconfigure the Twitter callback URL to localhost:1234 and I think you should be OK.

Preventing Session Timeouts in asp.net mvc

i have a form where user enter some information. The problem is when they submit the form, due to session timeout, the page redirected to login page. After login they return to the same page but the form is empty and all information is lost which is very annoying for the user.
What is the best solution? I don't want to refresh the page. Should I send ajax request after every 5 minutes.
NOTE: The current Session Timeout is 40 minutes and it is stored in database.
If sliding expiration is enabled you could indeed poll the server at regular intervals to ensure that the session doesn't expire.
Pass the formcollection to the logon page to pass back to the form after redirecting.
EDIT: You can modify the action that the form posts to so that instead of sending unauthorized users to the logon action strait away you can have it first check if the user is authenticated then if not save the data somewhere (sql table or a cookie should be fine) and send the user to the logon action or continue to handle the data as normal. Have a parameter passed to the form action that indicates if and where to retrieve the saved data.

How can I redirect a user back to signout page when timed out? Asp.net MVC

I have site that users lots of ajax(jquery). Now if the user times out for whatever reason(walked about for 30mins or something). On there next action I want them to be returned to the login page.
I setup everything in the webconfig(returnUrl and timeout) and if they try to go to a page they have no premission to go to they get sent to the login page.
However I have the authorize tags on the methods in my controllers that are used for ajax requests. So if a user timesout they are no longer authenticated but they might be on that needed authentication since they logged in and walked away.
Now they could go and try to save something at this point that would do an ajax request. The authorize tag will stop them from doing this since they will fail authorization and the return url will kick in.
However eventhough the return url seems to be sent back to them they are not redirected to the signin page. So I am guessing since all this stuff is ajax thats why it is not working properly. So is there away I can fix this?
You need to check the Ajax error for a 403 response
Run a client-side function every 30 seconds using setTimeout, which should ask the server via AJAX if the session has been timed out. If it has, the client-side code could toss out any login cookie and redirect to the login page.
You can either code hard-code the login url into the client-side code, or have the server handler return the value from the web.config if it needs to timeout.
This still leaves the possibility that the user could try something in the 0-30 seconds between when the user actually times out and the client side code does its request to check. To prevent this as well, have the server send back the amount of time left in the session, that way your client-side code can make the decision to either check back again sooner, or do the client-side redirect before the server-side drop-dead time.

Categories

Resources