Reply
Highlighted
Member
Posts: 5
Registered: ‎01-04-2012

Re: Silent Post not Posting: Page Load Event Issue?

Making some progress here, it appears that i can only capture a post back (so far) when i void a transaction.  I wrote a short function to log everything in the form as well as see what my SQL query would look like (two birds):

 

private void WriteToLog()

    {

       

string data = "Started to Write   " + DateTime.Now.ToString() + "\n\r";

data = data +

"*************************************************************************\n\r";

       

int icount = 0;

       

string destPath = System.Web.HttpContext.Current.Server.MapPath("~/bin");

       

File.WriteAllText(destPath + "\\SilentPost.txt", data);

        data =

"";

       

while (icount < Request.Form.Count)

        {

            data = data + Request.Form[icount].ToString() +

"\n\r";

            icount++;

        }

       

File.AppendAllText(destPath + "\\SilentPost.txt", data);

        data =

"Starting SQL Query \n\r *************************************************************************\n\r";

       

File.AppendAllText(destPath + "\\SilentPost.txt", data);

       

string status = "";

       

switch (Request.Form["x_response_code"].ToString())

        {

           

case"1":

                status =

"Approved";

               

break;

           

case"2":

                status =

"Declined";

               

break;

           

case"3":

                status =

"Error";

               

break;

           

case"4":

                status =

"Held for Review";

               

break;

        }

       

StringBuilder OrdersCMD = newStringBuilder();

        OrdersCMD.Append(

"UPDATE orders set ");

        OrdersCMD.Append(

"First_Name = '" + Request.Form["x_first_name"].ToString() + "', Last_Name = '" + Request.Form["x_last_name"].ToString() + "', Address = '" + Request.Form["x_address"].ToString() + "', City = '");

        OrdersCMD.Append(Request.Form[

"x_city"].ToString() + "', State = '" + Request.Form["x_state"].ToString() + "', Zip = '" + Request.Form["x_zip"].ToString() + "', Email = '" + Request.Form["x_email"].ToString() + "', AuthCode = '");

        OrdersCMD.Append(Request.Form[

"x_auth_code"].ToString() + "', TransactionID = '" + Request.Form["x_trans_id"].ToString() + "', Status = '" + status + "' WHERE OrderNumber = '" + Request.Form["x_invoice_num"].ToString() + "'");

       

File.AppendAllText(destPath + "\\SilentPost.txt", OrdersCMD.ToString());

        data =

"End Write\n\r";

        data = data +

"*************************************************************************\n\r";

       

File.AppendAllText(destPath + "\\SilentPost.txt", data);

}

 

To test i hit the page via a browser and the log is created.  I then deleted the log and submitted a transaction via my site with no issues.  I waited 5 minutes (timestamp on the emailed reciept) and got no log file.  Next i void the transaction and my log is created (timestamp shows it created 5 minutes later then transaction). containing only partial data.  Any ideas?

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: Silent Post not Posting: Page Load Event Issue?

What's your log file output look like? I don't know C#, but here's something I found in Google that might work for neatly converting the form data to a string:

http://ruuddottech.blogspot.com/2009/07/php-vardump-method-for-c.html

 

Note that File.WriteAllText overwrites whatever's there already, so if you do multiple calls, you probably want to use a call that appends to the file instead.

Highlighted
Member
Posts: 5
Registered: ‎01-04-2012

Re: Silent Post not Posting: Page Load Event Issue?

@TJPride - I only use the File.WriteAllText on the first call to generate a new log or over write an old one, the rest of the File calls are appends.  At this point I don't care about the format or if it's appending the point is it's never being called.  The example i posted captures data as expected when a VOID takes place so i know the code works but i see NOTHING generated (no logs at all) when a standard transaction happens.  I can only assume authorize.net never calls my page because at the very least i should get a log file with the date in it. (i commit that action before moving on to anything that could fail because there is no data).  Do you know if there is any way to check on the authorize.net side to see if the kick off the post as expected??

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: Silent Post not Posting: Page Load Event Issue?

Doesn't make any sense. Anything that would stop regular transactions from coming through would also stop voids, unless somehow you're specifying a different URL, or perhaps Authorize.net isn't triggering the Page_Load event. Have you tried setting up a PHP page that does nothing but log output to see if this is specific to C#?

Highlighted
Member
Posts: 5
Registered: ‎01-04-2012

Re: Silent Post not Posting: Page Load Event Issue?

I don't know anything about PHP but i did find an ASP sample Authorize provides, i'm going to test it today.

Highlighted
Contributor
Posts: 14
Registered: ‎01-26-2012

Re: Silent Post not Posting: Page Load Event Issue?

Hi John,

 

I am having a similar issue. Could you please explain what you did....if possible with a sample code(thanks a lot)...

 

You now have a Authorize.NET hosted payment form and whose receipt page are you using?

Could you say what are all values you set to work....

 

Appreciate very much for the help..... Got struck....:(

 

Thanks again..