Developer forum
E-mail notifications
Call external provider
I'm writing a custom checkout handler that connects to an external payment provider. The connection is requiring either a submitted form using POST or a redirect call using GET. I used base.SubmitForm(url, parameters) inside the StartCheckOut method, but get an error that the thread is being aborted.
How can you integrate and external provider using a custom checkout class? Where do I place the code to connect to the external provider?
Best regards,
Per
Replies
Hi Per
The reason you get a ThreadAbortException is because SubmitForm does a Response.Redirect. This is the standard way .NET handles this. If you catch the exception then simply return string.Empty. You can see how we do it in either the QuickPay3 or Dibs providers available for download here: http://developer.dynamicweb-cms.com/downloads/source-code.aspx
Hope this helps :)
- Jeppe
Have a very strange problem, the request to the external provider crashes when I use SubmitForm, but not when call the same page with the same hardcoded values.
Does SubmitForm for use a special encoding or something?
Best regards,
Per
Because of the way SubmitForm works, the form action url and dictionary keys and values are url encoded. Do you know which values fail?
Hi again!
So the form is actually submitted by GET and not by POST?
/Per
No, it does do a POST, but the CheckoutHandler cannot do that by itself. What actually happens is that all values are passed to a dedicated page which then does the actual POST. And when the values are passed, they are also url encoded.
Here is the error:
"Viewstate verification failed. Reason: The viewstate supplied failed integrity check. "
Is it possible to disable url encoding or use a GET call instead?
Can't see so many ways to do a submit to an external page if you can't use the method SubmitForm.
Best regards,
Per
One way, and presumably the easiest, is to render a template that is submitted using JS after it's been shown.
Something like this:
<form id="myForm" action="http://yourprovider.com" method="POST"> <input type="hidden" name="SomeProviderKey" value="<!--@MyProvider.SomeProviderKeyValue-->" /> </form> <script type="text/javascript"> document.getElementById("myForm").submit(); </script>
var template = new Dynamicweb.Templatev2.Template("pathToTemplateFile"); template.SetTag("MyProvider.SomeProviderKeyValue", "My value"); return template.Output();
You must be logged in to post in the forum