Similar to this incident I am trying to create a payment provider that posts to a local form. The local form contains a .Net user control that parses the FormPost data, calls Authorize.Net Customer Information Manager (CIM) CreateCustomerProfileTransaction, and for testing purposes displays the incoming values and CIM call results.
I seem to be getting the following error in the javascript, now:
Uncaught TypeError: Cannot read property 'form' of null
Try and change the Tea Commerce script to the non minified and use the debugger in FireBug to see where the form is wrong. Have a normal starter kit to check against. Maybe you forgot to have a form around the properties the goToPayment generates?
Uncaught TypeError: Cannot read property 'form' of null
It appears that I am missing something in the GenerateForm, or I haven't implemented something else that is required, causing tcs.callBase to return null. Stepping into the callBase function, (~line 810) the createBaseUrl returns a url, then it keeps coming back to 808, before it eventually bombs out back at 720.
Since I can't trace the service call, is there a likely missing object that defines the form, other than the content of GenerateForm?
This looks like a server error is happening. Try and have a breakpoint in the error event around line 825. This should give you the description. Or have a look at your server log and see what error your .NET code has logged for you.
At this point, it doesn't look like a server error. The IIS & .Net logs don't display any errors. I have stepped through it several times, but I seem to be missing where the magic happens. I attached the debug process to the IIS and stepped through the payment provider, there were no errors and values were as expected.
On a whim, I switched to the Authorize.Net payment provider I used earlier to access secure.authorize.net in test mode. It works fine, generates the form data and directs to the appropriate page. From here, I stepped through the GenerateForm & FormPostUrl without error; but when it returned to the javascript rtnData is a form object, where the CIM payment provider resulted in null.
From what I can tell, they are both generating the form data in GenerateForm, then grabbing the FormPostUrl; is there another piece that is generating the form object?
Have you hooked into any of the Tea Commerce events that could maybe cause an error? Try and disable the hooks if you have any.
The form is generated in the Base method - GeneratePaymentForm - it calls the correct payment provider for the key/values to send to the form post url that the payment provider specifies. This is some of the code that generates the form - so you could try and have a look. Maybe you didnt send a value in the submitInput (the parameter for GeneratePaymentForm? This would cause it to wrap the form into some javascript. But if you just switch the payment provider its pretty weird that it doesnt work. Try and just return no values for your payment provider and have the formpost url say - http://test.com and see if you get a form object.
//Genereate formDictionary<string, string> inputFields = paymentProviderInstance.GenerateForm( order, teaCommerceContinueUrl, teaCommerceCancelUrl, teaCommerceCallbackUrl, settings );
StringBuilder sbForm = newStringBuilder();
string rtnStr;
sbForm.AppendFormat( @"<form action=""{0}"" method=""post""{1}>", paymentProviderInstance.FormPostUrl, !string.IsNullOrEmpty( paymentProviderInstance.FormAttributes ) ? " " + paymentProviderInstance.FormAttributes : string.Empty );
foreach ( var kvp in inputFields ) {
sbForm.AppendFormat( @"<input type=""hidden"" id=""{0}"" name=""{0}"" value=""{1}"" />", kvp.Key, kvp.Value );
}
sbForm.Append( submitInput );
sbForm.Append( @"</form>" );
if ( string.IsNullOrEmpty( submitInput ) ) {
//If no button is provided we assume we are returning to a javascript//All qoutes must be escaped for the javascript
sbForm = sbForm.Replace( "\"", "\\\"" );
//The Form html is wrapped in a javascript object
rtnStr = string.Format( @"{{""submitJavascriptFunction"": ""{0}"",""form"":""{1}""}}", paymentProviderInstance.SubmitJavascriptFunction, sbForm.ToString() );
} else {
rtnStr = sbForm.ToString();
}
I found the problem, although I am not sure I understand it. I went back to basics and commented every line in the GenerateForm function except creating and returning inputFields. This worked.
So I uncommented the definitions one by one and found that the culprit was:
Custom Payment Provider w/ Local FormPostUrl
Hi All,
Similar to this incident I am trying to create a payment provider that posts to a local form. The local form contains a .Net user control that parses the FormPost data, calls Authorize.Net Customer Information Manager (CIM) CreateCustomerProfileTransaction, and for testing purposes displays the incoming values and CIM call results.
I seem to be getting the following error in the javascript, now:
I suspect the problem is in the payment provider. I've set the FormPostUrl to the correct page, and used the following for my GenerateForm:
Anyone have any ideas, or an idea on tracking down the cause?
Thanks,
-Chris
Hi Chris
Try and change the Tea Commerce script to the non minified and use the debugger in FireBug to see where the form is wrong. Have a normal starter kit to check against. Maybe you forgot to have a form around the properties the goToPayment generates?
Kind regards
Anders
Hi Anders,
Thanks for the quick response.
The error is at line 720:
It appears that I am missing something in the GenerateForm, or I haven't implemented something else that is required, causing tcs.callBase to return null. Stepping into the callBase function, (~line 810) the createBaseUrl returns a url, then it keeps coming back to 808, before it eventually bombs out back at 720.
Since I can't trace the service call, is there a likely missing object that defines the form, other than the content of GenerateForm?
-Chris
Hi Chris
This looks like a server error is happening. Try and have a breakpoint in the error event around line 825. This should give you the description. Or have a look at your server log and see what error your .NET code has logged for you.
Kind regards
Anders
Hi Anders,
At this point, it doesn't look like a server error. The IIS & .Net logs don't display any errors. I have stepped through it several times, but I seem to be missing where the magic happens. I attached the debug process to the IIS and stepped through the payment provider, there were no errors and values were as expected.
On a whim, I switched to the Authorize.Net payment provider I used earlier to access secure.authorize.net in test mode. It works fine, generates the form data and directs to the appropriate page. From here, I stepped through the GenerateForm & FormPostUrl without error; but when it returned to the javascript rtnData is a form object, where the CIM payment provider resulted in null.
From what I can tell, they are both generating the form data in GenerateForm, then grabbing the FormPostUrl; is there another piece that is generating the form object?
Thanks for any help you can provide
-Chris
Hi Chris
Have you hooked into any of the Tea Commerce events that could maybe cause an error? Try and disable the hooks if you have any.
The form is generated in the Base method - GeneratePaymentForm - it calls the correct payment provider for the key/values to send to the form post url that the payment provider specifies. This is some of the code that generates the form - so you could try and have a look. Maybe you didnt send a value in the submitInput (the parameter for GeneratePaymentForm? This would cause it to wrap the form into some javascript. But if you just switch the payment provider its pretty weird that it doesnt work. Try and just return no values for your payment provider and have the formpost url say - http://test.com and see if you get a form object.
Hi Anders,
I found the problem, although I am not sure I understand it. I went back to basics and commented every line in the GenerateForm function except creating and returning inputFields. This worked.
So I uncommented the definitions one by one and found that the culprit was:
I replaced it with:
and now it works. Like I said, I found it, but I'm not sure I understand it.
Thanks again for all your help.
-Chris
Hi Chris
WHAT! That doesnt make any sense - but, hey, if it works :)
Kind regards
Anders
is working on a reply...