Merchant Account Services

Integrate the Authorize.Net Payment Gateway with PHP

Integrate the Authorize.Net payment gateway seamlessly into your ecommerce website

Published: November 21st, 2023

Author: Jim Conners

Rating: 10.0

Pages: 1|2|3|4|5|6|7|8|9|10

Introduction

Authorize.Net® is unquestionably the most popular payment gateway in use today. In fact, it is synonymous with ecommerce and is often confused as a payment processor. Its vast popularity with shopping carts, it is integrated with every major and minor shopping cart available, make it a natural choice for merchants wishing to begin processing sales online.

But what if you are implementing a custom shopping cart solution? You will need to integrate Authorize.Net's payment gateway into your application yourself. Fortunately this task is less daunting then it sounds. Below we will explore every aspect of processing a transaction in detail and write code that will allow us to seamlessly integrate the Authorize.Net payment gateway into our application.

Goals

As with any project you undertake, a clear set of goals should be outlined. The goals we have set forth for our project is to write PHP code that:

  • will integrate with the Authorize.Net API seamlessly

    We do not want our customers to leave our website or think they are leaving our website at any time. We want a clean, seamless transaction process that presents our business in a professional manner.

  • is easy to use

    We do not want to spend a lot of time integrating the gateway into our website. That time would be better spent promoting the website so we can make money.

  • is reusable

    Web developers and aggressive entrepeneurs will open more then one ecommerce store. We definitely do not want to reinvent the wheel when it comes to integrating a payment gateway so we will want to make sure the codee we write can be easily transported from integration to integration.

Getting Started

Before we get to the technical nitty gritty of integrating the Authorize.Net payment gateway into an ecommerce application, we have to make sure we have everything we need. Some technical requirements will need to be met if we wish for the code we will write to function properly. We should acquire some useful tools and documentation that will help us understand the inner workings of the Authorize.Net API. We also need to make sure we, as developers, have the technical know-how to handle a task of this magnitude.

Technical Requirements

Before we write a line of code we will need to make sure our server meets the minimum technical specifications for our code to work. You can easily check if your server is properly configured by using PHP's phpinfo() function.

  • PHP 5

    The code that we will be using in this article will be object-oriented. To ensure it is compatible with future applications it is written in PHP 5. This also offers much greater support for object-oriented programming (OOP) then PHP 4 and since we will want our code to be easily reusable, writing it in an object oriented syntax makes good sense.

    To download PHP 5 go to the PHP download page. For a detailed overview of what has changed from PHP 4 to PHP 5, see the What's New in PHP 5 from Zend.

  • CURL

    CURL is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, TFTP, HTTP, HTTPS, TELNET, DICT, FILE and LDAP. CURL supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of other useful tricks.

    PHP supports CURL through the libcurl library. The libcurl library is not enabled by default and also requires the libcurl library to be installed on the server. Libcurl version 7.10.5 or higher is required to work with PHP 5. You can download libcurl from the developer's website. When recompiling PHP to work with libcurl you must be sure to compile PHP '--with-curl'. You can read more about binding PHP with CURL on the PHP website.

  • OpenSSL

    The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a full-strength general purpose cryptography library. The project is managed by a worldwide community of volunteers that use the Internet to communicate, plan, and develop the OpenSSL toolkit and its related documentation.

    OpenSSL version 0.9.6 or higher is required to work with PHP 5. You can download OpenSSL from the developer's website. When recompiling PHP to work with OpenSSL you must be sure to compile PHP '--with-openssl'.

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next