Skip to loginSkip to content

Our API

Learn about Authorize.net APIs and Products

API documentation

Integrate with our APIs with easy to read documentation.

API reference

Easy no-setup way to test our APIs – Out of the box samples with editable body - Send requests to our sandbox and see responses.

Sample code on [GitHub]

Sample codes published on GitHub for each REST API in popular languages

SDKs on [GitHub]

SDKs source code published on GitHub in popular languages

API change log

Track changes to our APIs over the years

System change log

Track changes to our System over the years

Upgrade guide

Ready to upgrade your API integration? Here’s how :

Getting started

Time to make your first API call.

Get started

Step-by-step guide to make your first API call.

Common setup questions

Commonly-encountered problems and solutions.

How payments work

Curious about payments?

Testing guide

Complete your integration journey – guides with sandbox testing instructions and processor specific testing trigger data.

Go-Live checklist

A Handy checklist for to go-live

Support

Reach out to our award-winning customer support team, or contact sales directly.

Get support

Reach out to our award-winning customer support team, or contact sales directly.

News and announcements

Find what we’re building and what our customers are saying here.

Forums

Come discuss with our curated Developer Community

Authorize.net on GitHub

Easy access to Github

Authorize.net on Stack Overflow

StackOverflow posts

Developer blog

Read about how we build products & leverage technology at Authorize.net

Response (error) codes

A handy guide to all the error codes

FAQs

Frequently asked questions relating to Authorize.net REST APIs and developer center.

Knowledge base

Sandbox

Affiliate

Support

  • Payment Card Payment Tutorial
    • Authentication
    • Transaction Type
    • Amount
    • Payment
    • Order Information
    • Billing Address
    • Shipping Address
    • Completed Request
    • Connecting to Authorize.net
    • Parsing the Response

Payment Card Payment Tutorial

If you are new to the Authorize.net API, we suggest that you begin with this tutorial. Because Authorize.net is a payment gateway, our most commonly used API method is the request to process a payment transaction using a payment card. This method is sometimes called an authorize-and-capture transaction because it requests both authorization and capture of the payment transaction in a single request. We recommend that you begin with this method, even if you do not expect to use it directly in your final product. Many components of this method are used throughout the API and the communication for all methods uses the same process of sending a request and parsing the response.

Instead of showing you every possible way of constructing the transaction request, this guide summarizes the most commonly used components and builds a sample request. To see every data field that is available, or to review the order of these elements, you can use our API Reference Guide.

The minimum data required for transaction requests are authentication, payment information, and payment amount. For best practices, most transactions will also include information such as a billing address, order details, and customer details.

Authentication

For this example, authentication is performed using an API login ID and transaction key.

Sample Authentication Structure

Transaction Type

The first value to specify for any transaction request is what type of transaction to process. When you use the payment card payment type, you can choose between either authorize-only (authOnlyTransaction) or authorize-and-capture (authCaptureTransaction). The default if no transaction type is specified is an authorize-and-capture transaction type, however, the recommended best practice is to always explicitly identify the transaction type.

Sample Transaction Type Declaration

Amount

The payment amount is the only paramter that is absolutely required other than the payment details. The payment amount should be specified using standard decimal notation. The currency type is not defined in this field.

Sample Amount Structure

Payment

The payment object includes the required details for the method of payment. This can be payment card details, bank account information, or tokenized payment information from a service such as Apple Pay.

A traditional payment card is, by far, the most commonly used payment type for processing a transaction. Payment cards can be used for any API call that takes the payment type object as an input.

When charging a payment card, you will need at least the card number and expiration date. For improved security, we strongly recommended that you also collect and validate the Card Code. When testing in the sandbox environment, you can use test-card numbers. For more information about testing, see our Testing Guide.

Payment Card Form Fields

Field Name Description Format Required
cardNumberThe 13-16-digit payment card number.16-digit, Numeric.Yes
expirationDateThe payment card's expiration date (month and year).MMYYYes
cardCodeThe 3 or 4 digit card code.3-4 digit, numericNo

Payment Card Payment Structure

Order Information

The order information is not required, but is stored along with the transaction at Authorize.net. Including the order information enables you to more easily identify transactions for your account and makes the data available to other applications that integrate with the same Authorize.net account, for example, reporting or analytics applications. In some cases, the invoice number may also be passed to the card-issuing bank during a payment card authorization.

The two basic fields for order information consist of an invoice number and an order description.

Sample Order Object

Line Item Details

For even more precision in your reporting, you can also provide a further breakdown of data into line item details, which include individual item prices, descriptions, and quantities.

Sample Line Items

Customer Details

The customer details include your own unique identifier for the customer along with the email address to be used for communication such as email receipts.

Sample Customer

Billing Address

The billing address is strongly recommended for the purposes of address verification when processing a payment card. The address is not validated for all payment types and not every field is validated even for payment cards, but it is a best practice to capture the full address.

Sample Billing Address

Shipping Address

The shipping address does not apply in all scenarios, but is still a common element for most payment transactions. This address is not validated against the payment method, but it can be validated as a real, shippable address by using the Advanced Fraud Detection Suite.

Sample Shipping Address

Completed Request

As mentioned at the beginning of this section, this is only one sample request and does not cover every possible field. To review the full API specification, you will want to review the API Reference. That being said, all of the above fields can be grouped into a single transaction request object that can be communicated with the Authorize.net API.

Sample Create Transaction Request

Connecting to Authorize.net

After building the XML object for an API request, submit it to the Authorize.net payment gateway as a standard HTTPS POST to an Authorize.net API endpoint. The exact process for doing this will depend upon the development language that you use.

API Endpoints

It is necessary to use the API endpoint that matches the environment of the account that you are testing with. If you attempt to use the credentials for a sandbox account on the production endpoint (or vice versa) you will recieve an error indicating that the authentication has failed.

Production: https://api.authorize.net/xml/v1/request.api

Sandbox: https://apitest.authorize.net/xml/v1/request.api

Parsing the Response

When you have successfully POSTed the transaction to the Authorize.net API, the immediate response will include the result of the API request, as well as the result of the transaction (if it was processed). It is important to understand how to read this response and determine if the payment was approved.

Complete Response

As you can see below, the complete response includes multiple response fields which indicate the status of separate elements of the original API request. For a complete breakdown of each of these elements, you can see the API Reference. This tutorial shows how to parse the most critical elements.

Sample Transaction Response

API Request Status

The messages element is included in every Authorize.net API response. The contents of this message indicate whether the API request was understood and successfully parsed by Authorize.net. The resultCode element will be either Ok or Error. The message code and text can be referenced for more specific detail about an error, if one was encountered.

Importantly, this does not identify whether a transaction was approved or declined by the issuing bank. It only indicates that the transaction was processed by Authorize.net

Response Messages

Response Code

If the API request was successfully processed (resultCode = Ok), there will also be a response code to indicate the result of submitting the transaction request to the banking network. In a standard payment card transaction, there are only four possible response codes.

1 - Approved

2 - Declined

3 - Error

4 - Held for Review

In order to determine that a payment card was approved by the cardholder's bank, you must receive both a message code of Ok and a response code of 1.

Reasponse Reason Codes

Response reason codes contain more detailed information about the transaction. For information about specific response reason codes, see our Reason Response Code Tool.

Next Steps

When you have successfully processed a payment, you can move on to other functionality, using the Authorize.net API.

Some of the more popular next steps include:

Reducing PCI Scope with Accept.JS and Accept Hosted

Integrating Customer Profiles to streamline customer payments

Managing Subscriptions for automated scheduled payments Monitoring Account Activity with webhooks

Expand Payment Options by adding support for alternative payments

Review Transaction History using reporting API methods

Authorize.Net

Visa

Cybersource.com

Privacy

Ad prefernces

Cookie policy

Terms and conditions

© 2019-2022. Authorize.net. All rights reserved. All brand names and logos are the property of their respective owners, are used for identification purposes only, and do not imply product endorsement or affiliation with Authorize.net.

Open in a new window