Who Me Too'd this topic

Authorize.Net API questions and help with your payment integration.

Posts: 2
Registered: ‎08-06-2013
Assistance with SIM (VB.NET) Sample Code for payment form



I am attempting to use authorize.net sample code for SIM (VB.NET) and am having some difficulty. Here is the code I'm currently using:


HTML (may be slightly altered because of this forms HTML checker):


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="wellsfargo.aspx.vb" Inherits="TDEA.wellsfargo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<form id="form1" runat="server" method='post' action='https://secure.authorize.net/gateway/transact.dll'>

login id
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
amount<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />



<input id="HiddenValue" type="hidden" value="Initial Value" runat="server" />
<input type='hidden' runat="server" name='x_login' id='x_login' />
<input type='hidden' runat="server" name='x_amount' id='x_amount' />
<input type='hidden' runat="server" name='x_description' id='x_description' />
<input type='hidden' runat="server" name='x_invoice_num' id='x_invoice_num' />
<input type='hidden' runat="server" name='x_fp_sequence' id='x_fp_sequence' />
<input type='hidden' runat="server" name='x_fp_timestamp' id='x_fp_timestamp' />
<input type='hidden' runat="server" name='x_fp_hash' id='x_fp_hash' />
<input type='hidden' runat="server" name='x_test_request' id='x_test_request' />
<%--<input id="x_relay_response" type="hidden" runat="server" name="x_relay_response" value='TRUE' />--%>
<%--<input type="hidden" runat="server" name="x_relay_url" id='x_relay_url' />--%>
<input type='hidden' runat="server" name='x_show_form' value='PAYMENT_FORM' />







Imports System.Security.Cryptography
Public Class wellsfargo
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' start by setting the static values
Dim transactionKey = "REMOVEDFORSECURITY"
Dim amount = ".99"
Dim description = "TDEA Sample Transaction"
' The is the label on the 'submit' button
Dim label = "Submit Payment"
Dim testMode = "false"

' If an amount or description were posted to this page, the defaults are overidden
If Request.Form("amount") <> "" Then
amount = Request.Form("amount")
End If
If Request.Form("description") <> "" Then
description = Request.Form("description")
End If

' also check to see if the amount or description were sent using the GET method
If Request.QueryString("amount") <> "" Then
amount = Request.QueryString("amount")
End If
If Request.QueryString("description") <> "" Then
description = Request.QueryString("description")
End If

' an invoice is generated using the date and time
Dim invoice = DateTime.Now.ToString("yyyyMMddHHmmss")

' a sequence number is randomly generated
Dim random As New Random
Dim sequence = random.Next(0, 1000)

' a time stamp is generated (using a function from simlib.asp)
Dim timeStamp = CInt((DateTime.UtcNow - New DateTime(1970, 1, 1)).TotalSeconds)

'generate a fingerprint
Dim fingerprint = HMAC_MD5(transactionKey, loginID & "^" & sequence & "^" & timeStamp & "^" & amount & "^")

'Print the Amount and Description to the page by placing them in the Spans
'amountSpan.InnerHtml = amount
'descriptionSpan.InnerHtml = description

'Update the fields in the actual form
x_login.Value = loginID
x_amount.Value = amount
x_description.Value = description
'buttonLabel.Value = label
x_test_request.Value = testMode
x_invoice_num.Value = invoice
x_fp_sequence.Value = sequence
x_fp_timestamp.Value = timeStamp
x_fp_hash.Value = fingerprint
End Sub
Function HMAC_MD5(ByVal Key, ByVal Value)
' The first two lines take the input values and convert them from strings to Byte arrays
Dim HMACkey() As Byte = (New ASCIIEncoding()).GetBytes(Key)
Dim HMACdata() As Byte = (New ASCIIEncoding()).GetBytes(Value)

' create a HMACMD5 object with the key set
Dim myhmacMD5 As New HMACMD5(HMACkey)

' calculate the hash (returns a byte array)
Dim HMAChash() As Byte = myhmacMD5.ComputeHash(HMACdata)

' loop through the byte array and add append each piece to a string to obtain a hash string
Dim fingerprint = ""
For i = 0 To HMAChash.Length - 1
fingerprint &= HMAChash(i).ToString("x").PadLeft(2, "0")

Return fingerprint
End Function

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

End Sub
End Class


Once the page goes to the gateway at https://secure.authorize.net, I receive the following:


The following errors have occurred.

(33) Credit card number is required.
(33) Expiration date is required.


Ultimately, what I want to do is just come up with the value for "amount" & another unique value on my website, send the user off to the payment form on authorize.net then send the aforementioned unique value back to my website along with a confirm/deny that the payment went though. I suppose my post is actually 2 questions...


1. Is SIM what I should be using to accomplish what I want to?

2. What am I doing wrong that I'm getting the error I'm getting/Is it on the code side or within my account settings?


TIA, Mike

Who Me Too'd this topic