How to: Form post to remote page using code behind?
-
Hi I have a third party payment system to integrate into my application. The final page in my application displays the order details and allows the user to confirm their order. Upon clicking confirm the order is created and at this point in my code behind file I would like to generate a post to a third party payment form that expects some form post values and the users browser should then be redirected to that page within the same session obviously so that the posted values can be used accordingly. Any help would be greatly appreciated :) Thanks in advance Andy
-
Hi I have a third party payment system to integrate into my application. The final page in my application displays the order details and allows the user to confirm their order. Upon clicking confirm the order is created and at this point in my code behind file I would like to generate a post to a third party payment form that expects some form post values and the users browser should then be redirected to that page within the same session obviously so that the posted values can be used accordingly. Any help would be greatly appreciated :) Thanks in advance Andy
Some API's are easier to work with then you think and while you did not mention which payment API your using, most are similar in how they are used/consumed. You can use the HttpWebRequest class to post values to a site (e.g. PayPal), but the premise is the same. Dim req As HttpWebRequest = CType(WebRequest.Create(API_URL), HttpWebRequest) ' Set values for the request back req.Method = "POST" req.ContentType = "application/x-www-form-urlencoded" If you need to post the values to the page and have the user perform some final steps on the page while keeping the user on your site, this can be a little more tricky. You would need to send the identifier for the cart/user from your site, so once they are redirected back to your site, you can perform the look up and react to the messages sent from the api. You should look into the documentation of the API though. Most times you can handle all of this without the user ever leaving your site - a much better implementation IMO.