cancel
Showing results for 
Search instead for 
Did you mean: 

Another darn Error 13 posting

I have ready every single posting here with the term Error 13. Happy I was testing my AIM solution and it was awesome. Then my client learns that the price of a PCI compliant server is ten times what he has been paying so here we go. My SIM solution is simple and should work but I have not gotten past the Error 13.  I even tried using the sample code pasted right into my app. The param_dump.asp page shows no aberations unless it is the hash, which I cannot be sure is correct but since I am using the exact same sample HMAC_MD5 method, it should be good.

 

I've also copied the address https://test.authorize.net/gateway/transact.dll and pasted it directly into my code.

 

I have verified my API Login and Transaction Key.  Also I set a new key in the merchant interface and tried that key (three times I changed these).

 

Embarrassed I won't tell you how many hours I have into this one problem but secretly I will be happy if you or I find some stupid mistake I am making.

 

<%@ Page Title="" Language="C#" MasterPageFile="~/MyMasterPage.master" AutoEventWireup="true" CodeFile="CheckTest.aspx.cs" Inherits="CheckTest" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <form id="simForm" runat="server" method="post" action="https://test.authorize.net/gateway/transact.dll">
        <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 type="hidden" name="x_show_form" value="PAYMENT_FORM" />
        <input type="submit" runat="server" id="buttonLabel" />
    </form>
</asp:Content>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;

public partial class CheckTest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // start by setting the static values
        string loginID = "76zggAY2M";
        string transactionKey = "My API Transaction Key";
        string amount = "19.99";
        string description = "Sample Transaction";
        string label = "Submit Payment"; // The is the label on the 'submit' button
        string testMode = "false";

        string invoice = DateTime.Now.ToString("yyyyMMddhhmmss");

        Random random = new Random();
        string sequence = (random.Next(0, 1000)).ToString();

        string timeStamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();

        string fingerprint = HMAC_MD5(transactionKey, loginID + "^" + sequence + "^" + timeStamp + "^" + amount + "^");


        //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;
    }
    // This is a wrapper for the VB.NET's built-in HMACMD5 functionality
    // This function takes the data and key as strings and returns the hash as a hexadecimal value
    string HMAC_MD5(string key, string value)
    {
        // The first two lines take the input values and convert them from strings to Byte arrays
        byte[] HMACkey = (new System.Text.ASCIIEncoding()).GetBytes(key);
        byte[] HMACdata = (new System.Text.ASCIIEncoding()).GetBytes(value);

        // create a HMACMD5 object with the key set
        HMACMD5 myhmacMD5 = new HMACMD5(HMACkey);

        //calculate the hash (returns a byte array)
        byte[] HMAChash = myhmacMD5.ComputeHash(HMACdata);

        //loop through the byte array and add append each piece to a string to obtain a hash string
        string fingerprint = "";
        for (int i = 0; i < HMAChash.Length; i++)
        {
            fingerprint += HMAChash[i].ToString("x").PadLeft(2, '0');
        }

        return fingerprint;
    }
}

 

Learn more about the Authorize.Net Data Validation URL Tool.

REMOTE_ADDR:76.106.203.120
REQUEST_METHOD:post
HTTP_REFERER:"My Web Clients Domain /Checkout.aspx?ProductID=134
Field Name Field Value
ctl00$ContentPlaceHolder1$x_test_requestfalse
ctl00$ContentPlaceHolder1$x_descriptionSample Transaction
ctl00$ContentPlaceHolder1$buttonLabelBuy Now
ctl00$ContentPlaceHolder1$x_amount20.1600
ctl00$ContentPlaceHolder1$shippingSelectionfedex, $5.66, FEDEXGROUND, 2 day(s),
ctl00$ContentPlaceHolder1$x_fp_sequence51
ctl00$ContentPlaceHolder1$x_invoice_num20101218032407
ctl00$ContentPlaceHolder1$x_login"my API Login ID copied directly from the merchant interface"
x_relay_responsetrue
__VIEWSTATEENCRYPTED
__VIEWSTATEOL5D2NS91HYStQDwJdnmArBgm5DJ0VDbA8xWP8STufiHBgab1lp/agiRmukie9ZDJzcXLYMkCO75+AK1dTOOasnt3/olzWusovACNkN9jsLwOfDOOwK7tt1481WKB1Wy/CgwV/ItKAm1U3F4LVx8F6bYZ5dwddwsgEPMonQxweBxIPnpKNFMrEXxY+lcBpHIgUkqYlRHFWcJ7W3OrnnZQZXkVNEVwaoZ2mITWTHv7IUORXYUH9XDI1zGHZJVnTr4CJh6UXlF9VjLZch/qXUO8A0Z6mV1SYSNozuFIs+x05hffVmKznYN3wwkXDjueQg+cfCY1BU7kPuCNo2NvJcl5gz+Xg3GAE4taYmpSrMuWmbdl7nbYl9DFTk427jYTKBazTI7a2jUMLNJhW4pgEP7NxrZztS3alO8yQvr+UvqLUc6la9TMRvQ/mDqAWCEC4dvTuW//01h3zg65iPvgOrmbxfo8nSbEUh+fJYgc++0EjXGjpOzt6E1cJOb3IHYn2uUCXEtkBZTvGPRiw0iUSdYbtfyoElQhl/MaAyvATck9ODPAKLGf7J5AySr0lSUsxK+TgB9St7gNH/LBAlBV2r9hYkaXuCgX+nF3aC8gj5qTCZ8I+puofMyE//d1tC++sTOL4qCUpwalx01s3wi4H6lnqx+lDep1IrSimhxRWGsoFUFbsI579FtqO2W3Edzhjwh6ZBtuj19fhXRf+EsXPgv/YSdIRw0dgrdIn6Tip/aCLs=
x_relay_url"My Web Clients Domain" /OrderPlaced.aspx
ctl00$ContentPlaceHolder1$HiddenValueInitial Value
__EVENTVALIDATIONpTz2854KasTE2bGpi4mAOqRQ3P8+qQCEAC0gX1IEWr0Qe4zZwolgF4y2k4QRjwzWQRccvD5mBouh23LbYq8VplaTmVI5tiaKCvpSIKHjeCHSGmzWUDW9Dd2tPizsYr+v
x_show_formPAYMENT_FORM
ctl00$ContentPlaceHolder1$x_fp_hash5c2d47df23f9b97483bac3c43dbc0657
ctl00$ContentPlaceHolder1$x_fp_timestamp

1292711047

 

pathfinder
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

It getting Error 13 because it can't find the loginID because it's doesn't work inside a master page.

This will work

<input name="x_login" type="hidden" id="x_login" value="76zggAY2M" />


This will not work.
<input name="ctl00$ContentPlaceHolder1$x_login" type="hidden" id="ctl00_ContentPlaceHolder1_x_login" value="76zggAY2M" />

 

 

 

View solution in original post

RaynorC1emen7
Expert
3 REPLIES 3

It getting Error 13 because it can't find the loginID because it's doesn't work inside a master page.

This will work

<input name="x_login" type="hidden" id="x_login" value="76zggAY2M" />


This will not work.
<input name="ctl00$ContentPlaceHolder1$x_login" type="hidden" id="ctl00_ContentPlaceHolder1_x_login" value="76zggAY2M" />

 

 

 

RaynorC1emen7
Expert

Whoops, of-course.  I can work with that.  Thanks for your patient answer.

The way to handle this in ASP.NET Master Pages is to override Render and replace the Ctl00$...$.

 

    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
        Dim Html As New StringWriter()
        Dim Render As New HtmlTextWriter(Html)
        MyBase.Render(Render)
        writer.Write(Html.ToString().Replace("name=""ctl00$MainContent$", "name=""").Replace("id=""ctl00_MainContent_", "id="""))
    End Sub

petefratus1
Member