Blue Theme Orange Theme Green Theme Red Theme
 
Team Foundation Server Hosting
Home | Forums | Videos | Photos | Blogs | Beginners | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
DevExpress UI Controls
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 :
Page Views : 67532
Downloads : 1643
Rating :
 Rate it
Level : Advanced
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
CcProcessing.zip
 
 
Discover the top 5 tips for understanding .NET Interop
Become a Sponsor
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

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

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate 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.
Discover the top 5 tips for understanding .NET
Ricky Leeks presents the top 5 tips for understanding .NET Interoperability. Learn more.
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.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Team Foundation Server Hosting
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 | 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 | 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 | Modify 
Re: SIM or AIM by Munir On July 3, 2006

Hi,

Please go through Authorized.net documentation in depth


Reply | Email | 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 | 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 | 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 | 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 | 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 | 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 | 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 | Modify 
Where can i find MsXML by ajay On August 21, 2007
Where can i find MsXML pls help me .Its urgent
Reply | Email | Modify 
Where can i find MsXML by ajay On August 21, 2007
Where can i find MsXML pls help me .Its urgent
Reply | Email | 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 | 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 | 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 | 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 | 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 | Modify 
can u help me by sanket On November 27, 2010
hi i am working as a junior asp.net(c#) developer. and i am totally new to this concept.
i want all info from scratch or developed full application.
so i can refer it and i can develop it by myself.
so please help me for this.
Reply | Email | Modify 
DevExpress Free UI Controls
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.