cancel
Showing results for 
Search instead for 
Did you mean: 

Getting started with PHP API

Hello,

 

I am looking for a some direction on how to get started. I have written an HTML form which already submits to a PHP where I insert the data into a mySQL database. I am looking for an easy way to integrate Authorize.net user profile creation/update and credit card verification. I would also like to run the connection inside an html iFrame as I do not want to be responsible for storing and transmitting credit card info. I must not be looking in the right area of the development site because everything I find seems to leave out alot of information. Any help would be appreciated. 

 

Dan

grepler
Member
6 REPLIES 6

Hi @grepler,

 

We'd be happy to walk you through this. You might want to start with our Getting Started page, which will walk you through getting the PHP SDK installed. Then, you'll want to look through our sample code on GitHub to see examples of calling a hosted payment form or the hosted profile management forms.

 

Then, for any specific questions or problems you run into along the way, feel free to ask here!

Aaron
All Star

Thanks Aaron,

 

How do I get the sample code to work within an iframe in my existing form? The instructions on the Dev site are not very intuitive. There is a huge chunk of data missing. Any help is appreciated. 

 

 

Hi @grepler,

 

The SDK will handle the calls to get a form token through PHP. The actual construction of a web site to display the form is left up to you.

 

The basics are that you'll have a form in your page so the browser will post the token back to us. Quoting from the documentation:

"Whatever method is used, the form is called by passing the received token to our system in an HTTP form POST. The only form field that must be included in that form is an input field named "token". Insert the complete token that you've received back from getHostedPaymentPageRequest as the value of that field."

 

If you want to display things in an iframe, there's lots of tutorials around the web for you to do that. But, the basics would be to create an iframe in your page, and then have the form post done from that iframe.

OK Thanks Aaron. I'll read through this doc. At first glance it looks like what I am looking for. But I will have to let you know after testing. 

 

Dan

Hi Aaron, Thanks so much for your help so far. I am to the point where I am getting a token. Ihave populated a variable with the token, the instructions say that in order to get the form page on authorize.net I need to send the token back? I tried using curl in my cone to do this but I'm still getting a missing token error. Does this look right to you?

 

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://test.authorize.net/payment/payment');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $token);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
echo $ch;
curl_close($ch);

Hi @grepler,

 

You can't do it in curl, because you need the browser to send the token back. To get the form to be loaded from our site directly in the browser, the request has to itself come from the browser.

 

So, you create an HTML form in your page with a single hidden input field named token like so:

<form method="post" action="https://test.authorize.net/payment/payment">
    <input type="hidden" name="token" value="HOSTED_FORM_TOKEN"/>
</form>

Then, either add a button to submit the form, or submit it using scripting.