Search code examples
phpauthorize.net

Authorize.net correct way to implement AIM method in php?


This should be a fairly simple question. Essentially, I believe there's a good chance I'm simply brainfarting.

I'm trying to implement a transaction with Authorize.net using the AIM method and I was unsure if I should have a page where the user adds all of their information and card, etc, and have that post to another page that does the cURL and response, etc., or if that's bad practice and I should have it all on one page.

That's basically the simple question, but I can NOT find any implementation docs or decent examples. The only one I can find has all of the info hard coded into the page and does the cURL and response stuff on the same page, which doesn't answer my question!


Solution

  • You can do it on the same page, meaning the form, and the cURL call both on checkout.php. Check for the $_POST variable being set, if it isn't show the form, the destination will be checkout.php (make sure you use HTTPS). If $_POST is set, then make your call to authorize.net via cURL, parse the response, and show the customer a success or fail message.