Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Blogs | Beginners
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Nevron Chart
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » VB.NET » Payment Gateway Integration using VB.NET with Authorized.NET

Payment Gateway Integration using VB.NET with Authorized.NET


This article shows payment gateway integration using Vb.net and Msxml.XMLHttpRequest object.

Author Rank:
Total page views :  55606
Total downloads :  1224
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
CcProcessing.zip
 
Become a Sponsor

To understand how credit card processes have a look at following steps:

Step 1:  The merchant submits a credit card transaction to the Authorize.Net Payment Gateway on behalf of a customer via secure connection from a Web site, at retail, from a MOTO center or a wireless device.

Step 2:  Authorize.Net receives the secure transaction information and passes it via a secure connection to the Merchant Bank's Processor.

Step 3:  The Merchant Bank's Processor submits the transaction to the Credit Card Interchange (a network of financial entities that communicate to manage the processing, clearing, and settlement of credit card transactions). 

Step 4:  The Credit Card Interchange routes the transaction to the customer's Credit Card Issuer. 

Step 5:  The Credit Card Issuer approves or declines the transaction based on the customer's available funds and passes the transaction results, and if approved, the appropriate funds, back through the Credit Card Interchange. 

Step 6:  The Credit Card Interchange relays the transaction results to the Merchant Bank's Processor. 

Step 7:  The Merchant Bank's Processor relays the transaction results to Authorize.Net. 

For more details please visit to http://www.authorize.net/resources/howitworksdiagram/

Following code can be integrated at the final step, when you are done with the shopping and submitting your order, in the zip file you will find some of the default values are assigned to the form fields, you can assign your own values as per the requirement, and go through the documentation as mentioned in the above url.

Make sure that you have added reference of MsXML to the project and you or your client have merchant ID with authorized.net. You can change code as per the login info of merchant ID.

While submitting a form you submit values for the following fields

   1. x_Description 
   2. x_Amount 
   3. x_Card_Num 
   4. x_Exp_Date 
   5. x_First_Name 
   6. x_Last_Name 
   7. x_Address 
   8. x_City 
   9. x_State
   10. x_ZIP
   11. x_Phone
   12. x_Fax 
   13. x_Email

Using XMLHttpRequest object post the data to the respective URL as below:

XMLReq.open("POST", "
https://secure.authorize.net/gateway/transact.dll?" & PostData & "", False)
XMLReq.send()

I have also trapped the response code to know the status of transaction.

Response Code:


   1 = This transaction has been approved.
   2 = This transaction has been declined.
   3 = There has been an error processing this transaction.

The entire code snippet as below which is called on submit of button from the form.

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

        'First enter our loginID'

        Dim PostData As String

        'test account for Authorize.Net

        PostData = "x_Login=test"

        PostData = PostData & "&x_Version=3.1"

        'since we are testing

        PostData = PostData & "&x_Test_Request=TRUE"

        'we want comma delimited

        PostData = PostData & "&x_ADC_Delim_Data=TRUE"

        'do not want to redirect

        PostData = PostData & "&x_ADC_URL=FALSE"

        'Now add the form fields       

        PostData = PostData & "&x_Card_Num=" & Request.Form("x_Card_Num") & ""

        PostData = PostData & "&x_Exp_Date=" & Request.Form("x_Exp_Date") & ""

        PostData = PostData & "&x_Description=" & Request.Form("x_Description") & ""

        PostData = PostData & "&x_Amount=" & Request.Form("x_Amount") & ""

        PostData = PostData & "&x_First_Name=" & Request.Form("x_First_Name") & ""

        PostData = PostData & "&x_Last_Name=" & Request.Form("x_Last_Name") & ""

        PostData = PostData & "&x_company=" & Request.Form("x_company") & ""

        PostData = PostData & "&x_Address=" & Request.Form("x_Address") & ""

        PostData = PostData & "&x_City=" & Request.Form("x_City") & ""

        PostData = PostData & "&x_State=" & Request.Form("x_State") & ""

        PostData = PostData & "&x_ZIP=" & Request.Form("x_ZIP") & ""

        PostData = PostData & "&x_Phone=" & Request.Form("x_Phone") & ""

        PostData = PostData & "&x_Fax=" & Request.Form("x_Fax") & ""

        PostData = PostData & "&x_Email=" & Request.Form("x_Email") & ""

 

        Dim XMLReq As New MSXML.XMLHTTPRequest

        Dim strURL As String

        Dim tempstr As String

        Dim strStatus As Integer

        Dim strRetval As String

        Dim strArrayVal As Array

        Dim x_response_code As String

        Dim x_Description As String

        Dim x_Amount As String

 

        XMLReq = New MSXML.XMLHTTPRequest

        PostData = PostData & "&x_Password=jvette1"

        XMLReq.open("POST", "https://secure.authorize.net/gateway/transact.dll?" & PostData & "", False)

        XMLReq.send()

        strStatus = XMLReq.status

        strRetval = XMLReq.responseText

        strArrayVal = Split(strRetval, ",", -1)

        'Response Code:

        '1 = This transaction has been approved.

        '2 = This transaction has been declined.

        '3 = There has been an error processing this transaction.

        Dim x_response_subcode As String

        Dim x_response_reason_code As String

        Dim x_response_reason_text As String

        Dim x_auth_code As String

        Dim x_avs_code As String

        Dim x_trans_id As String

        Dim x_invoice_num As String

        Dim x_country As String

        Dim x_method As String

        Dim x_type As String

        Dim x_cust_id As String

        Dim x_company As String

        Dim x_First_Name As String

        Dim x_Last_Name As String

        Dim x_Address As String

        Dim x_City As String

        Dim x_State As String

        Dim x_ZIP As String

        Dim x_Phone As String

        Dim x_Fax As String

        Dim x_Email As String

 

        x_response_code = strArrayVal(0)

        x_response_subcode = strArrayVal(1)

        x_response_reason_code = strArrayVal(2)

        x_response_reason_text = strArrayVal(3)

        '6 digit approval code

        x_auth_code = strArrayVal(4)

        x_avs_code = strArrayVal(5)

        'transaction id

        x_trans_id = strArrayVal(6)

        x_invoice_num = strArrayVal(7)

        x_Description = strArrayVal(8)

        x_Amount = strArrayVal(9)

        x_method = strArrayVal(10)

        x_type = strArrayVal(11)

        x_cust_id = strArrayVal(12)

        x_First_Name = strArrayVal(13)

        x_Last_Name = strArrayVal(14)

        x_company = strArrayVal(15)

        x_Address = strArrayVal(16)

        x_City = strArrayVal(17)

        x_State = strArrayVal(18)

        x_ZIP = strArrayVal(19)

        x_country = strArrayVal(20)

        x_Phone = strArrayVal(21)

        x_Fax = strArrayVal(22)

        x_Email = strArrayVal(23)

        'Check the ErrorCode to make sure that the component was able to talk

        'to the authorization network

        If (strStatus <> 200) Then

            Response.Write("An error has occured during processing your request.  " & "Please try again later." &
            strStatus)

        Else

            If x_response_code.Equals("1") Then

                Response.Write("Thank you for your purchase.(Transaction has been approved)")

            ElseIf x_response_code.Equals("2") Then

                Response.Write("Transaction has been declined")

            Else

                Response.Write("There has been error while processing this transaction." & "Please try again later."
                & x_response_code)

            End If

        End If

End Sub


Login to add your contents and source code to this article
 About the author
 
Munir Shaikh
Munir is MCP in Microsoft .NET Framework 3.5, Windows Communication Foundation
Appl ication Developmen, software Developer/ project lead with 9 Yrs development experience who works on IT projects mainly for Microsoft and some open source technologies. Most of these projects have been intranet based web applications / sites with SQL/Oracle as back-end. Currently he  is focusing more on Silverlight, WCF & WPF development. He had worked on payment gateway implementation. He is experienced in Insurance, Supply Chain management, Trading, Real-Estate & currently Legacy modernization domain.
Apart from this he has implemented on CMMi L3 for organization and has good understanding of process. He has also involved in consulting activities like Architecture Review, Project Plan, HLD, LLD, Risk Management etc....
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
SQL and .NET performance profiling in one place
Investigate SQL and .NET code side-by-side with ANTS Performance Profiler 6, so you can see which is causing the problem without switching tools.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
60 FREE UI Controls from DevExpress
Register for your FREE copy on over 60 free presentation controls from DevExpress - Absolutely Free-of-Charge without any royalties or distribution costs. Visit Devexpress.com/60 today. Free controls include advanced lists box, dropdown calendar, rich text edit, spin edit, tab control and so much more!

DevExpress engineers feature rich presentation controls and reporting tools for WinForms, ASP.NET, WPF, and Silverlight. Our technologies help you build your best, see complex software with greater clarity and deliver compelling business solutions for Windows and the web in the shortest possible time.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Visualize your workspace with new multiple monitor support, powerful Web development, new SharePoint support with tons of templates and Web parts, and more accurate targeting of any version of the .NET Framework. Get set to unleash your creativity.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Developer-Ready ASP.NET 2.0 Web Hosting with 3 MONTHS FREE
Now supporting .NET 3.0 Framework with Windows Workflow Foundation, Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF), windows CardSpace (WCS)! Providing more flexibility for Developers with Web Services Support and a User/Permission Manger. Also supporting MS SQL 2005/2000 with Real-Time Backups, FREE Automated Attach .MDF Tool, FREE SQL Restore and Shrink SQL DB Tools, and SQL
Read the Top 10 Books for Microsoft Developers, 15 Days FREE
Read the Top 10 Books for Microsoft Developers, 15 Days FREE
Try Safari Books Online - 15 Days FREE + 15% Off for 1 Year
Try Safari Books Online - 15 Days FREE + 15% Off for 1 Year
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Become a Sponsor
 Comments
Can You help Me by dharmesh On March 23, 2006

Can you help me in integrating with World pay payment gateway.i am developing a website using C#.net (1.1)as code behind and Sqlserver(2000) as a database.how i can send a request from my aspx page to world pay.

thanks

Dharmesh

Reply | Email | Delete | Modify | 
Re: Can You help Me by Syed On June 4, 2007
hi dharmesh, I had successfully implemented the worldpay Payment in my Application...



This is the Sample ,

<INPUT TYPE="hidden" NAME="instId" VALUE="value" ID="your_instId" runat="server"> <INPUT TYPE="hidden" NAME="currency" VALUE="GBP" ID="currency" runat="server"> <INPUT TYPE="hidden" NAME="futurePayType" VALUE="regular" ID="futurePayType" runat="server"> <INPUT TYPE="hidden" NAME="option" VALUE="1" ID="option"> <INPUT TYPE="hidden" NAME="startDelayMult" VALUE="3" ID="startDelayMult"> <INPUT TYPE="hidden" NAME="startDelayUnit" VALUE="2" ID="startDelayUnit"> <INPUT TYPE="hidden" NAME="noOfPayments" VALUE="11" ID="noOfPayments" runat="server"> <INPUT TYPE="hidden" NAME="intervalMult" VALUE="1" ID="intervalMult" runat="server"> <INPUT TYPE="hidden" NAME="intervalUnit" VALUE="3" ID="intervalUnit"> <INPUT TYPE="hidden" NAME="normalAmount" VALUE="17.99" ID="normalAmount" runat="server"> <INPUT TYPE="hidden" NAME="initialAmount" VALUE="10.00" ID="initialAmount" runat="server"> <INPUT TYPE="hidden" NAME="desc" VALUE="Test Item" ID="desc"> <INPUT TYPE="hidden" NAME="cartId" VALUE="Test Item" ID="cartId"> <INPUT TYPE="hidden" NAME="testMode" VALUE="100" ID="testMode" runat="server"> <INPUT TYPE="hidden" NAME="amount" VALUE="1" ID="amount" runat="server"> <INPUT TYPE="hidden" NAME="lang" VALUE="en" ID="lang" runat="server"> <INPUT TYPE="hidden" NAME="fixContact" ID="fixContact"> <INPUT TYPE="hidden" NAME="subst" VALUE="yes" ID="subst"> <INPUT TYPE="hidden" NAME="C_return" VALUE="welcome back" ID="C_return"> <INPUT TYPE="hidden" NAME="M_var1" VALUE="fred" ID="M_var1"> <INPUT TYPE="hidden" NAME="MC_log" VALUE="2379" ID="MC_log"> <INPUT TYPE="hidden" NAME="name" VALUE='name' ID="name"> <INPUT TYPE="hidden" NAME="address" VALUE='address' ID="address"> <INPUT TYPE="hidden" NAME="postcode" VALUE='postcode' ID="hidden9"> <INPUT TYPE="hidden" NAME="country" VALUE="GB" ID="country" runat="server"> <INPUT TYPE="hidden" NAME="tel" VALUE='tel' ID="tel"> <INPUT TYPE="hidden" NAME="fax" VALUE='fax' ID="fax"> <INPUT TYPE="hidden" NAME="email" value='email' ID="email">

Submit the form to "https://select.worldpay.com/wcc/purchase";

Hope it will be useful to U....(u can reach me at syedibrahimsmn@aol.com)
If u hav any doubt ,u may contact through this Email

Syed.....
Reply | Email | Delete | Modify | 
SIM or AIM by jeeva On June 30, 2006

hello,

iam also trying to do a page which connects to a payment gateway(SIM)-Authorize.net

code u 've given is for AIM or SIM?

when iam trying to execute ur code i get the following error :=

No overload for method 'open' takes '3' arguments
No overload for method 'send' takes '0' arguments

Hope u can help me out.
 

Reply | Email | Delete | Modify | 
Re: SIM or AIM by Munir On July 3, 2006

Hi,

Please go through Authorized.net documentation in depth


Reply | Email | Delete | Modify | 
can u help me in integrating Paypal by ashish On February 23, 2007
hi munir can u help me out in integrating paypal payment gateway in my shopping application. ashish jain
Reply | Email | Delete | Modify | 
can u help me in integrating Paypal by ashish On February 23, 2007
hi munir can u help me out in integrating paypal payment gateway in my shopping application. ashish jain
Reply | Email | Delete | Modify | 
Re: can u help me in integrating Paypal by Munir On March 5, 2007

Hi ashish,

Please find following paypal URL need to redirect while processing your shopping cart information
string url =
"https://www.paypal.com/cart/add=1&business=email&item_number=number&item_name=name&amount=amount&cy_code=currency_code&return=return_url&cancel_return=cancel_return";

where following variables you need to send with the successURL and canCellURL
string email = // PayPal business name (email address)

string number = //Item number which you are shopping
string name = // Name of item purchasing
double amount = // total amount to be deducted from the transaction
string currency_code = //Currency Code like USD for $, Euros:  €.
string return_url = //URL to which user will redirect after successful transaction
string cancel_return = // In case transaction is failed it should go to which page

Note: the information should be send as URLENCODE to avoid space etc.


Enjoy !

Smart & Simple Coding
Regards,
>>Munnamax

Reply | Email | Delete | Modify | 
can u help x_auth_code by phani On April 4, 2007
After Refund process i recive x_auth_code value is empty wat it means
Reply | Email | Delete | Modify | 
Re: can u help x_auth_code by Munir On April 5, 2007

Hi,

In the transaction response string from Authorize.Net, this value is the six-digit authorization code returned by the card issuing bank, and indicates that the transaction was approved.

Typically, the only time the x_auth_code field is used is in the event that the merchant previously submitted an Authorization Only (AUTH_ONLY) transaction via a processing system or payment gateway other than Authorize.Net, and wanted to capture the transaction using Authorize.Net. To do this, the transaction method (x_method) must be submitted with the value of “CAPTURE_ONLY,” and the authorization code (x_auth_code) issued for the original AUTH_ONLY must be submitted in the transaction request string to Authorize.Net.

Refer http://developer.authorize.net/guides/ for further implementation details

Regards,
>>Munnamax

Reply | Email | Delete | Modify | 
Where can i find MsXML by Guhananth On May 3, 2007
Where can i find MsXML to add reference?How to get merchant ID?If trasaction fails ,will the amount be refunded to bank account?
Reply | Email | Delete | Modify | 
Where can i find MsXML by Guhananth On May 3, 2007
Where can i find MsXML to add reference?How to get merchant ID?If trasaction fails ,will the amount be refunded to bank account?
Reply | Email | Delete | Modify | 
Where can i find MsXML by ajay On August 21, 2007
Where can i find MsXML pls help me .Its urgent
Reply | Email | Delete | Modify | 
Where can i find MsXML by ajay On August 21, 2007
Where can i find MsXML pls help me .Its urgent
Reply | Email | Delete | Modify | 
Re: Where can i find MsXML by Munir On August 21, 2007
Hi,
It must be there in the attached zip file in the bin directory
Or you can add reference to your project as
Right click project >> Properties >> Select Com Tab and choose Microsoft XML Version 2.6 or whatever is suitable to you.

Regards,
>>Munnamax
Reply | Email | Delete | Modify | 
authroize.net by veena On February 4, 2008
XMLReq = New MSXML.XMLHTTPRequest 'PostData = PostData & "&x_Password=jvette1" ' XMLReq.open("POST", "https://secure.authorize.net/gateway/transact.dll?" & PostData & "", False) XMLReq.open("POST", "https://test.authorize.net/gateway/transact.dll?" & PostData & "", True) XMLReq.send() strStatus = XMLReq.status this is my code but here i am getting an error "Unspecified error" here i have commented the password so i am getting the error. and also iam getting the email ie it is working but why this unspecified error please help me out
Reply | Email | Delete | Modify | 
Access is denied MSXML by jetro On March 19, 2008
I've added the Microsoft XML from component reference but still this error shown. Please help me to solve my problem. Thanks. ******************************************* Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Access is denied: 'msxml'. *******************************************
Reply | Email | Delete | Modify | 
Integration of DHL by suryaprakash On September 19, 2008
Hi Munir, I want to integrate DHL to my Site. Can you help me with code , and also tell me how to get dummy Id and password for dhl and the testing environment. Thanx in advance.:)
Reply | Email | Delete | Modify | 
I want integrate online payment gateway for gaming site, Can you help me by Amol On July 16, 2010
I want integrate online payment gateway for gaming site
Specially for mirada gaming service
http://www.mirada.tv/
Thanks & Regards
Amol D Ghatkar
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2010.8.14
 © 2010  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.