Authorize.net Integration eCommerce Payment Gateway ( Direct Post Method New! )

https://developer.authorize.net/integration/fifteenminutes/csharp

These steps assume that your web server is on the public internet and can be accessed via a domain name or IP address.
Step 1:Sign up for a Test Account.
Sign up for a test account to obtain an API Login ID and Transaction Key. These keys will authenticate requests to the payment gateway.

Step 2: Download the Authorize.Net C# SDK and include it in your project
Download the SDK


Create a new ASP.NET MVC application and add a reference to the AuthorizeNET.dll from the SDK

Step 3: Modify web.config.
Add the AuthorizeNET.Helpers namespace to the web.config, under system.web/pages:

...
Step 4: Create a checkout form that posts directly to Authorize.Net
Add the following code to the Home/Index View - this will create a form which will submit a test transaction to Authorize.Net (with hardcoded values). This code uses the SDKs CheckoutFormBuilder to create the form for you - just include your API login and Transaction Key:

In this code, the CheckoutFormBuilder is creating the form that will post to AuthorizeNET, setting the "TestMode" to true. We're sending along an additional piece of information here as well: an order id. This isn't required by the API, but let's you identify the order when we get the response.

Step 5: Create an Action to handle the response from Authorize.Net.
This example uses ASP.NET MVC - if you're using ASP.NET WebForms, you can put this code on PageLoad().

In the above code we passed in the URL "http://YOURSERVER.com/home/sim", so we need to create an Action called "Sim" in our application's HomeController. The form POST from Authorize.Net will include all the transaction information including an MD5 hash which we can use to validate the post's origin.

Open up the HomeController and paste the code below:

[HttpPost] public ActionResult Sim(FormCollection post) { var response = new AuthorizeNET.SIMResponse(post); //first order of business - validate that it was Auth.net that posted this using the //MD5 hash that was passed back to us var isValid = response.Validate("YOUR_API_LOGIN_ID", "YOUR_API_LOGIN_ID"); //if it's not valid - just send them to the home page. Don't throw - that's how //hackers figure out what's wrong :) if (!isValid) return Redirect("/"); //the URL to redirect to- this MUST be absolute var returnUrl = "http://YOUR_SERVER.com/?m="+response.Message; return Content(AuthorizeNET.Helpers.CheckoutFormBuilders.Redirecter(returnUrl)); }This uses SDK classes to parse the response and validate it's origin using the MD5 hash.

An important thing to understand at this point is that Authorize.Net will take whatever content we respond with and it will display it on their server, to our user. So if we simply returned the string "Thank You!" - that's what would be displayed to the user. This response, however, is sent from the Authorize.Net server - not our own - and you can see this if you look at the URL in the address bar upon completion of the transaction. Since that's not what we want, we send a response that causes the user to be redirected to a url on our sever.

It's important to keep in mind that this whole process is "out of session" - which means your user session no longer exists in this response context. The user, in this case, is the Authorize.Net server in that it's notifying our server of a transaction - it has no notion of your current user's session - so our next task is to return the information from Authorize.Net to the current user - and we do this by redirecting away from Authorize.Net using some javascript. In the last line, we're using the SDK to generate this javascript.

For the simplicity of this example, we're redirecting back to the home page of our application so we can see the result.

There are a few considerations here that you will need to manage as a developer - specifically how you manage the order data, and how you display the response from Authorize.Net to the user.

Step 6: Add some code to handle the redirect from Authorize.Net
Add some code to receive the message in the HomeController, Index action. The sample application provides a more complete way of handling the response from Authorize.Net - here we just show the response. To do that, add some code to the Index action to pull the message from the URL:

public ActionResult Index () { ViewData["message"] = Request.QueryString["m"] ?? ""; return View (); }Step 7: Test your HTML form and verify the transaction.

Visit the new payment experience you've just built. Complete the payment form.

Select "Visa" and enter the test credit card number 4111111111111111, any expiration date (MMYY) in the future (such as "1120"), and hit "Submit".

Verify payment transaction success on your transaction report.

Learn More
To accept real payments, you'll need a merchant account. Learn more or apply for a merchant account

Comments

Anonymous said…
There are many other payment softwares and in all this method of payment was quite secured.
Shopping Cart Software Solutions
Unknown said…
Wow, Excellent post. This article is really very interesting and effective. I think its must be helpful for us. thanks for sharing your informative.
mentalist
Unknown said…
This comment has been removed by the author.
Unknown said…
Yasmin hat eine Effizienzrate von beinahe 100% bei der Schwangerschaftsverhütung und ist eines der beliebtesten Empfängnis verhütenden Kombinationspräparate.

yasmin Kaufen
Unknown said…
Phenq PhenQ is a all-natural dietary supplement for fat burning that combines the best qualities of many other supplements into a single pill.
Unknown said…
Foldable WheelchairDependable Website Management is a concierge website management service for businesses who will accept nothing but the best.





Hero said…
1xbet yeni adresi 1xbet Türkiye, online bahis şirketi hakkında giriş ve inceleme bilgileri. Onebahis firması için 2020 güncel yeni giriş adresi, ödemeler ve üyelik işlemleri için detaylı bilgiler, 1xbahis sayfamızda yer almakta.
Aslam said…

meal kits Making cooking a little easier. It's hard, it takes time and who's got the time after a long day of work, looking after kids and being on your feet all day ? I bet you don't and neither do I.. making cheap and tasty modern day meal kits the new normal among all the changes going on in our world today.
Hero said…
Making cooking a little easier. It's hard, it takes time and who's got the time after a long day of work, looking after kids and being on your feet all day ? I bet you don't and neither do I.. making cheap and tasty modern day meal kits the new normal among all the changes going on in our world today. meal kits
Receap said…

BUY SPOTIFY PLAYS REAL PLAYS TO BOOST YOUR MUSIC.
We will promote your tracks and give you very good promotion Buy spotify plays
Haider said…
finance GET UNIQUE INVESTMENT IDEAS FROM AN EXPERIENCED FUND MANAGER TARGETING 5X - 10X+ RETURNS.
Aslam said…
best new diet pill Authentic Option LLC offers collection of natural herbal products for skincare, hair care, and weight loss. We specialize in thermal weight loss, electrostimulation for muscle toning, cellulite removal, under-eye bags treatment and skincare products. We have an amazing range of beard growing products.
Rafid said…
Addictions facts Addiction stands as the top public health problem in America outstanding all other major diseases including stroke, heart diseases and even cancer. The population of addicts is far larger than the patients suffering from the three mentioned diseases in America with sufferers ranging in millions.
Rafid said…
British shorthair for sale We have been branded as the best cattery for breeding healthy kittens and puppies ready for a home.
James said…
legit online casinos that pay real money Compare the best legit online casinos that pay real money including the best crypto casinos, best mobile casinos and the best online casinos in 2021
Aslam said…
motherhood CO.MOM is a fun new online magazine and social network community created by moms for moms. Read interesting articles, get advice from our agony aunt, aunt\y anne, learn how to earn an income online with our guru debbie or you can even seek medical advice from our resident physician dr samantha and relax while checking out the latest horoscopes from our trained mystic. Theres even a thriving forum community where moms of the world can get together and enjoy good conversation along with lots of other fun ways to kill some time with a cuppa when taking a break from being super mom at co.mom.

Popular posts from this blog

Get Organised with OneNote

Windows Server 2016 Enable file downloads in Internet Explorer