How to get the API key

Every Swipe Checkout API call requires the API Key and the Merchant ID as parameters that need to be passed. When developing on behalf of a customer (merchant), you will need to obtain the API Key and Merchant ID from them. This information is available from within the Merchant Console under Settings.

Example code for API integration

Sample C# Code

Here's an example of how to use C# code to integrate with Swipe APIs using ASP or

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace ConsoleApplication1
public class Program
public static void Main(string[] args)
var url = "";
var params="merchant_id=207448428C7F78&apikey=2cf03c3f93104e6f56c4cd5f2b4d13b8&td_item=your_product& td_description=brief_description_of_product&td_amount=9.95&td_default_quantity=10&td_user_data=some_da";
Console.WriteLine("GET Response: " + Get(url,params));
Console.WriteLine("POST Response: " + Post(url,params));
public static string Get(string url,string params)
WebRequest request = System.Net.HttpWebRequest.Create(url + "?" + params);
var response = request.GetResponse();
return (new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd());
public static string Post(string url,string params)
ASCIIEncoding encoding = new ASCIIEncoding();
WebRequest httpWReq = System.Net.HttpWebRequest.Create(url);
byte[] data = encoding.GetBytes(params);
httpWReq.Method = "POST";
httpWReq.ContentType = "application/x-www-form-urlencoded";
httpWReq.ContentLength = data.Length;
using (Stream newStream = httpWReq.GetRequestStream())
newStream.Write(data, 0, data.Length);
WebResponse response = httpWReq.GetResponse();
return (new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd());

Sample PHP Code

Swipe API calls can be programatically sent parameters using the 'POST' or 'GET' methods. Form data with the correct parameters, (eg td_item, td_description) can be posted directly to the api calls. Below are some handy functions for dealing with API's:

Posting to an API url.

$url = "";

$body = "merchant_id=afc9b037&td_item=your_product&td_description=brief_description_of_product&td_amount=9.95&td_default_quantity=10&td_user_data=some_data";

unction post_to_url($url, $body){
$ch = curl_init ($url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec ($ch);
curl_close ($ch);
return $html;
function fetch_url ($url){
$ch = curl_init();
$html = curl_exec($ch);
return $html;

Json response as follows:


Product IDs

Swipe Checkout has a mini e-commerce solution that can fit the needs of smaller merchants. In that case, identifier_ids can be replaced with product_ids which are IDs of the products a merchant can create from within the Merchant Tools section of the merchant dashboard.

How to create a TransactionIdentifier API call

On the payment page the cardholder must be able to clearly identify what they are paying for and how much their credit card will be charged. Before you can send transactions to be processed by Swipe, you need to use either a Product ID or an Identifier ID. Product IDs are generated when a merchant adds a product under Merchant Tools. For merchants who are using their own shopping cart, they need to have their developers create TransactionIdentifier API Call to generate identifier_ids for the transaction. A transaction identifier is a temporary record held in the Swipe system that identifies transactions sent to the payments page for a particular item being sold. Identifiers are set up for sale items using this API. You pass the item details and the API will return the item identifier. When a user clicks to buy an item, the corresponding identifier is sent to the payments page, where the item details are displayed. The advantage of the using this API is that an identifier can be setup for any item on your website, even if it is unknown to Swipe.

The API takes the following parameters:

merchant_idAlphanumericThis is the merchant id
td_itemAlphaThe item to set up the identifier for (e.g. Super Duper Hand Bag)
td_descriptionThis is the optional decription of the product
td_amountNumericThis is the total amount of the item including any taxes, shipping costs or any other applicable charges
td_default_quantityNumericOptional quantity of the item. Default is 1
td_user_dataAlphanumericAny additional, arbitrary data you would like to pass to the Swipe Checkout page. After the transaction is processed this field is also sent back as part of the parameters included in the callback URL.

See the example below:

Example create TransactionIdentifier API call:

If the API call was successful, it will return this response in JSON format:


The 'identifier' is the ID of the transaction identifier now setup in the Swipe system. When this ID is passed to the payment page via the 'identifier_id' parameter, the item details will be displayed.

Example of Payments URL with the indentifier_id passed in:

The payment page will load the item by the identifier ID. Because the item_quantity has not been given a value, the quantity will default to the item default value, or 1 item_quantity is not specified.

Using the product page to process transactions

In most cases your client will be using the Swipe hosted payment page solution to process their e-commerce transactions for which there are two options:

1.The transaction is initiated by a cardholder clicking on the Buy Now button generated by Swipe Checkout using the Buy Now buttons section under Merchant Tools.

2.The transaction is initiated by a shopping cart instance from a website.

Option 1 does not require any developer input and requires no API call.

Option 2 requires you to integrate with 2 APIs to process the transaction. You will need to use the TransactionIdentifier API and the Payments Page API call.

Making a payment page API call

Swipe Checkout processes online transactions through the payments page. When a user clicks "Buy Now" or a webpage link, they are redirected to the payments page to complete the transaction. To know which item or product to show details for, the payment page must be passed either a product ID (the ID of a product that already exists inside Merchant Tools) or an identifier ID (created using the create TransactionIdentifier API). The details for a product can then be loaded by Swipe Checkout and displayed on the payment page.

Under no circumstances can you pass cardholder information to this page. Before you can use this API call, you must either have a product ID or an identifier ID.

The payment page takes either the product ID or identifier ID to process a transaction.

Example of Payments URL with the product_id passed in:

The payments page will load the product by the product ID, as long as the product is active under Merchant Tools. For processing multiple products, simply add more instances of product_ids to the URL like so:

Payment Page API usage for shopping carts

In the event of a shopping cart containing multiple items at point of checkout, you will need to calculate the total amount to be charged to the customer’s credit card. The next step is to create TransactionIdentifier API call and generate an identifier_id for the cart’s contents. Next, pass this identifier_id to the payments page API and the payment page will display the total amount to be charged.