Payment Engine API

The Payment Engine is a cloud based EMV middleware that point of sale developers can use to simplify their integration with various EMV capable payment terminals such as the Verifone MX series and the Castles MP200.

Endpoint URL

The base url for the production API is:

 <span class="hljs-symbol">https:</span>/<span class="hljs-regexp">/swipebox.io/api</span><span class="hljs-regexp">/v2/</span>

The hostname "swipebox.io" can be swapped out for any of the other gateway hostnames (see the High Availability Guide. During development, "sandbox.swipebox.io" should be used. For more information on the development sandbox see the Sandbox Guide.

The "v2" refers the API version and can replaced with an endpoint key. The API limits the number of API calls allowed per minute and per day based on this key. Using "v2" is fine for development and smaller merchants, but could result in API rate limit errors for high traffic merchants. Larger merchants and developers should register their own software endpoint key in the Dev Portal. For more details, see the API Rate Limits section below.

There are other features available with developer registered endpoints including, restricting use of the end point by IP address and listing contact information for support. The endpoint keys are independent of the merchant API keys. An endpoint can be used with any merchant account.

API Index

Device Management

Payment Requests

API Rate Limits

To prevent abuse, the API implements per minute and daily rate limits. The limits are counted per endpoint key and IP address. When using the default endpoint url, the limits are 45/minute and 5000/day. When the limit is exceeded, the API will return HTTP error code 429:

   HTTP/<span class="hljs-number">1.1</span> <span class="hljs-number">429</span> API Rate <span class="hljs-keyword">Limit</span> Exceed 

The body of the response will be:

 {"<span class="hljs-attribute">error</span>":<span class="hljs-value"><span class="hljs-string">"API Rate Limit Exceed"</span></span>,"<span class="hljs-attribute">errorcode</span>":<span class="hljs-value"><span class="hljs-number">155</span></span>}

Developers can utilize the "X-Rate-Limit" HTTP header to manage their API rate limit usage:

   <span class="hljs-keyword">X</span>-Rate-Limi<span class="hljs-variable">t:</span> <span class="hljs-string">"8 of 45/min; 8 of 5000/day"</span>

Higher limits are immediately available by self registering an endpoint in the Dev Portal. Further increases to the limits are granted on a case by case basis. Contact the integration support team for further information. To test the API Rate Limit feature, use the API endpoint "https://sandbox.swipebox.io/api/RATELIMT/". Your second request will be rate limited.

IP Access Restrictions

By default, API endpoints are available to clients on any IP address. Developers can edit their API endpoint to restrict calls from a set list of IP addresses. To test the IP access restriction, you can use the url "https://sandbox.swipebox.io/api/IPACCESS/". When access is blocked HTTP error code 401 will be returned:

   HTTP/<span class="hljs-number">1.1</span> <span class="hljs-number">401</span> <span class="hljs-keyword">Access</span> Denied 

The body of the response will be:

 {"<span class="hljs-attribute">error</span>":<span class="hljs-value"><span class="hljs-string">"Access Denied"</span></span>,"<span class="hljs-attribute">errorcode</span>":<span class="hljs-value"><span class="hljs-number">156</span></span>}

Authentication

All API calls require an APIkey (sourcekey) and API hash. The API hash is built by hashing a random seed, the API key, and the private API pin.

 <span class="hljs-variable"><span class="hljs-keyword">var</span> seed</span> = random_value();
<span class="hljs-variable"><span class="hljs-keyword">var</span> prehash</span> = apikey + seed + apipin;
<span class="hljs-variable"><span class="hljs-keyword">var</span> apihash</span> = 's2/'+ seed + '/' + sha256(prehash);

The API key and API hash must be sent in a basic auth http header (base64 encode "apikey:apihash"):

 <span class="hljs-constant">Authorization: Basic
  OnMyL2YxYmFmMjE1OGQwNDQwYmI4N2U4OTRjOWU5MmQ4Mzk2L2ZhODgxNWNkYWMxZjY4M2VkNWQyY2Y5NmRhNmMzN2JlODRmNzNhNDA0ODYwNDU3YzNkZDdiNmM0NTc5NjA0YWY</span>=

Common Formats

Lists

All API endpoints that return multi objects use a standard list format:

 {
   <span class="hljs-string">"type"</span>: <span class="hljs-string">"list"</span>,
   <span class="hljs-string">"limit"</span>: <span class="hljs-number">100</span>,
   <span class="hljs-string">"offset"</span>: <span class="hljs-number">0</span>,
   <span class="hljs-string">"data"</span>: [
      <span class="hljs-decorator">{...}</span>,
      <span class="hljs-decorator">{...}</span>,
   ],
   <span class="hljs-string">"total"</span>: <span class="hljs-number">200</span>
 }

To change the number of objects returned in the result set, pass a "limit" variable in the request url (example: /api/customers?limit=1000). To retrieve the next group of objects, pass in "offset" with the item # to start with. "0" is the first item. For example, if there are 21 customers you could pull them in three calls:

 /api/customers?<span class="hljs-variable">limit=</span><span class="hljs-number">10</span>&<span class="hljs-variable">offset=</span><span class="hljs-number">0</span>
... <span class="hljs-number">10</span> customers returned ...
/api/customers?<span class="hljs-variable">limit=</span><span class="hljs-number">10</span>&<span class="hljs-variable">offset=</span><span class="hljs-number">10</span>
... <span class="hljs-number">10</span> customers returned ...
/api/customers?<span class="hljs-variable">limit=</span><span class="hljs-number">10</span>&<span class="hljs-variable">offset=</span><span class="hljs-number">20</span>
... <span class="hljs-number">1</span> customer returned ...

Objects

Single objects will all include a "key" (the primary public key for the object) and a "type" (the object type). For example:

 <span class="hljs-collection">{
  <span class="hljs-string">"key"</span>: <span class="hljs-string">"a8ai3k7i77tw"</span>,
  <span class="hljs-string">"type"</span>: <span class="hljs-string">"customer"</span>,
  <span class="hljs-string">"firstname"</span>: <span class="hljs-string">"John"</span>,
  <span class="hljs-string">"lastname"</span>: <span class="hljs-string">"Doe"</span>,
  ...
 }</span>

Common Errors

Errorcode Message Troubleshooting
0 Valid authentication required Authorization header was missing.
21002 API authentication failed Authentication was not successful. Possible reasons could include: using the wrong PIN, using a sourcekey from sandbox in production mode, or that the authentication header was malformed.
 

For inquiries contact us at (720) 277-0648