How to Integrate Authorize.net Payment Gateway in PHP

We will let you know about integrating Authorize.net payment gateway using PHP. I will use official PHP library for Authorize.net that will have necessary method which are using in this tutorial and online transaction in your website. Authorize.net return the string response, So we don’t need to create payment notification page and any other post payment request.You can get more information from Authorize.net API Document.

Authorize.net is simple and secure payment gateway that why every e-commerce platform use it.This PHP payment integration tutorial describe you step by step Authorize.net gateway integration.

I will use AuthorizeNet PHP SDK.

authorize-payment-gateway

You can check other recommended tutorial of Payment Gateway,

How to integrate Authorize.net Payment Gateway With PHP

We will create sandbox account for test payment using Authorize.net Payment Gateway and then change test to live env .We will download PHP SDK of Authorize.net Payment Gateway and integrate with payment form.

Prerequisite for Authorize.net Payment Gateway for PHP

  • PHP 5.6+
  • cURL PHP Extension
  • JSON PHP Extension
  • An Authorize.Net account
  • TLS 1.2 capable versions of libcurl and OpenSSL (or its equivalent)

Step 1: Create sandbox account

We will create sandbox account with Authorize.net to create and test the payment gateway.You can create sandbox account using signup form, after successfully registered account, you will get API login ID and Transaction ID in welcome mail of Authorize.net.You can also get that information from your API page

Step 2: Download PHP SDK of Authorize.net

We will download Authorize.net Payment Gateway and paste into project root folder like d:/xampp/htdocs/authorize_payment_gateway/ or Sample php project and paste into project root folder like d:/xampp/htdocs/authorize_payment_gateway/.

Now open constants/constants.php file and add login_id and transaction_key that you have with your Authorize.net sandbox account.

Create Payment Form

We will create payment form that will have some required fields like cc information and user information, I am using bootstrap to create UI.

I have created only amount text box, you need to add cc input into this form.I have added cc_response.php file that will handle payment request and process payment and display payment response.

Create method to payment using Creditcard

I am taking sample of credit card to get amount and payment using authorize.net gateway.

Authorize.net Test Credit Card Numbers

There are following test credit card numbers provided by Authorize.net and will only work with the sandbox account. The credit card test expiration date after today’s date. If the card code is required, please use any 3-digit combination for Visa, Mastercard, Discover, Diners Club, EnRoute, and JCB; use a 4-digit combination for American Express.

Test Card Brand Number
American Express  370000000000002
Discover 6011000000000012
JCB 3088000000000017
Diners Club/ Carte Blanche 38000000000006
Visa 4007000000027
  4012888818888
  4111111111111111
Mastercard 5424000000000015
  2223000010309703
  2223000010309711

I hope, Its help you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.