How to Integrate Payment Gateway in PHP

We will let you know about integrating payment gateway using PHP. I will use official PHP library for that will have necessary method which are using in this tutorial and online transaction in your website. 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 API Document. is simple and secure payment gateway that why every e-commerce platform use it.This PHP payment integration tutorial describe you step by step gateway integration.

I will use AuthorizeNet PHP SDK.


You can check other recommended tutorial of Payment Gateway,

How to integrate Payment Gateway With PHP

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

Prerequisite for 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 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 can also get that information from your API page

Step 2: Download PHP SDK of

We will download 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 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 gateway. Test Credit Card Numbers

There are following test credit card numbers provided by 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
Mastercard 5424000000000015

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.