# Composing Requests
# Base Urls
Sandbox
The Sandbox environment is provided for testing. Transaction responses are simulated and do not leave the platform for processing. No billing related items occur within this environment.
Sandbox url:
Production
The Production environment should be used for all LIVE transactional processing.
Production url:
# Versioning
The platform's semi-RESTful API is fully backwards compatible and versioning is not necessary. Changes and feature updates are sent out via the platform prior to release.
Current version:
1.5.1
# Headers
The following headers should be included with your requests:
# Authorization
Calls to the API must include an Authorization header with the request. Either a JWT (JSON Web Token) or an API Key can be used as the value of this header, like so:
Authorization: Bearer { JWTToken }
Authorization: { API Key }
# Api Keys
API keys are used to authenticate your requests to the API. You can create and manage your API keys in the control panel. API keys are tied to a user account.
Their are two types of API keys:
- Public API keys (ex: pub_***) - used for making requests to the API from the client side (ex. Tokenizer and Cart Sessions)
- Private API keys (ex: api_***) - used for making requests to the API from the server side (ex. Transaction Processing)
DANGER
Private API keys should never be exposed to the public. Please do not include them in client side code, emails or support ticket request.
DANGER
Use of Public API keys to make requests to the API from the server side will result in an unauthorzed response.
# Content-Type
Content-Type
should typically be set to application/json
, unless you need to send your request body in a different format. All API responses will be in JSON format.
# Users
# Create User
Create a new user account.
Request Method:
POST
URL Endpoint:
/api/user
Name | Type | Default | Description | Required |
---|---|---|---|---|
username | string | user's username (must contain alpha and numeric characters) | ||
name | string | user's first and last name | ||
phone | string | user's phone number, digits only | ||
string | user's email address (must be valid email format) | |||
timezone | string | user's timezone (ex. ETC/UTC) | ||
password | string | user's password | ||
status | string | user's status (active or disabled) | ||
role | string | user's defined role (admin or standard) |
{
"status": "success",
"msg": "success",
"data": {
"id": "b89227ij8m0nuanr1tk0",
"username": "testmerchant43",
"name": "test merchant user",
"phone": "6305555555",
"email": "info@website.com",
"timezone": "ETC/UTC",
"status": "active",
"role": "admin",
"account_type": "merchant",
"account_type_id": "aucio551tlv85l7moe5g",
"created_at": "2017-11-20T00:26:06.190264Z",
"updated_at": "2017-11-20T00:26:06.190264Z"
}
}
function createUser() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
username: "testmerchant43",
name: "test user",
phone: "6305555555",
email: "info@website.com",
timezone: "ETC/UTC",
password: "T@est12345678",
status: "active",
role: "admin",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/user", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var id = result.data.id;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class CreateUserResponse : ApiResponse {
public User Data { get; set; }
}
public class User {
public string Id { get; set; }
public string Username { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public string Timezone { get; set; }
public string Password { get; set; }
public string Status { get; set; }
public string Role { get; set; }
}
public void createUser(User user) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/user");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(user);
IRestResponse response = client.Execute(request);
var apiResponse = JsonConvert.DeserializeObject<CreateUserResponse>(response);
if (apiResponse.Status === "success") {
// handle success
var newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
<?php
function createUser($user) {
$curl = curl_init();
$payload = json_encode($user);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/user",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class User {
public String Id;
public String Username;
public String Name;
public String Phone;
public String Email;
public String Timezone;
public String Password;
public String Status;
public String Role;
}
public class CreateUserResponse extends ApiResponse {
public User Data;
}
public void createUser(User user) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(user);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/user")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CreateUserResponse entity = objectMapper.readValue(responseBody.string(), CreateUserResponse.class);
if (entity.status === "success") {
// handle success
String newId = entity.Data.Id;
} else {
// handle non success
}
}
# Get User By ID
Retrieve the properties of a specific user.
Request Method:
GET
URL Endpoint:
/api/user/{ user id }
{
"status": "success",
"msg": "success",
"data": {
"id": "b89227ij8m0nuanr1tk0",
"username": "testmerchant43",
"name": "test merchant user",
"phone": "6305555555",
"email": "info@website.com",
"timezone": "ETC/UTC",
"status": "active",
"role": "admin",
"account_type": "merchant",
"account_type_id": "aucio551tlv85l7moe5g",
"created_at": "2017-11-20T00:26:06.190264Z",
"updated_at": "2017-11-20T00:26:06.190264Z"
}
}
function getUser(id) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/user/" + id, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var user = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void getUser(int id) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/user/" + id);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
var apiResponse = JsonConvert.DeserializeObject<CreateUserResponse>(response);
if (apiResponse.Status === "success") {
// handle success
var user = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getUser($id) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/user/".$id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getUser(int id) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/user/" + id)
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CreateUserResponse entity = objectMapper.readValue(responseBody.string(), CreateUserResponse.class);
if (entity.status === "success") {
// handle success
User user = entity.Data;
} else {
// handle non success
}
}
# Get Authenticated User
Retrieve the properties of the currently authenticated user. This is intended as a helper function, it is recommended to get a specific user by providing the ID if possible.
Request Method:
GET
URL Endpoint:
/api/user
{
"status": "success",
"msg": "success",
"data": {
"id": "b89227ij8m0nuanr1tk0",
"username": "testmerchant43",
"name": "test merchant user",
"phone": "6305555555",
"email": "info@website.com",
"timezone": "ETC/UTC",
"status": "active",
"role": "admin",
"account_type": "merchant",
"account_type_id": "aucio551tlv85l7moe5g",
"created_at": "2017-11-20T00:26:06.190264Z",
"updated_at": "2017-11-20T00:26:06.190264Z"
}
}
function getAuthenticatedUser() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/user", requestOptions)
.then((response) => response.text())
.then((result) => {
var user = result.data;
})
.catch((error) => console.log("error", error));
}
public void getAuthenticatedUser() {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/user");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
var apiResponse = JsonConvert.DeserializeObject<CreateUserResponse>(response);
if (apiResponse.Status === "success") {
// handle success
var user = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getAuthenticatedUser() {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/user",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getAuthenticatedUser() {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/user")
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CreateUserResponse entity = objectMapper.readValue(responseBody.string(), CreateUserResponse.class);
if (entity.status === "success") {
// handle success
User user = entity.Data;
} else {
// handle non success
}
}
# Get All Users
Retrieve the properties of all users for the gateway or partner account associated with the API Key or JWT token provided in the Authorization header.
Request Method:
GET
URL Endpoint:
/api/users
{
"status": "success",
"msg": "success",
"total_count": 3,
"data": [
{
"id": "b89227ij8m0nuanr1tk0",
"username": "testmerchant43",
"name": "test merchant user",
"phone": "6305555555",
"email": "info@website.com",
"timezone": "ETC/UTC",
"status": "active",
"role": "admin",
"account_type": "merchant",
"account_type_id": "aucio551tlv85l7moe5g",
"created_at": "2017-11-20T00:26:06.190264Z",
"updated_at": "2017-11-20T00:26:06.190264Z"
}
]
}
function getAllUsers() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow",
};
fetch("https://sandbox.durangomsgateway.com/api/users", requestOptions)
.then((response) => response.text())
.then((result) => {
var users = result.data;
users.array.forEach((user) => {
// do something with each user
});
})
.catch((error) => console.log("error", error));
}
public class GetAllUsersResponse : ApiResponse {
public List<User> Data { get; set; }
}
public void getAllUsers() {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/users");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
var apiResponse = JsonConvert.DeserializeObject<GetAllUsersResponse>(response);
if (apiResponse.Status === "success") {
// handle success
var users = apiResponse.Data;
foreach(var user in users) {
// do something with each user
}
} else {
// handle non success
}
}
<?php
function getAllUsers() {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/users",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class GetUserResponse extends ApiResponse {
public ArrayList<User> Data;
}
public void getAllUsers() {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/users")
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
GetUserResponse entity = objectMapper.readValue(responseBody.string(), GetUserResponse.class);
if (entity.status === "success") {
// handle success
ArrayList<User> user = entity.Data;
} else {
// handle non success
}
}
# Update User
Edit the properties of an existing user account.
Request Method:
POST
URL Endpoint:
/api/user/{ user id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
name | string | user's first and last name | ||
phone | string | user's phone number, digits only | ||
string | user's email address (must be valid email format) | |||
timezone | string | user's timezone (ex. ETC/UTC) | ||
status | string | user's status (active or disabled) | ||
role | string | user's defined role (admin or standard) | ||
permissions | object | (account defaults) | users permissions | |
permissions.manage_users | boolean | false | ||
permissions.manage_api_keys | boolean | false | ||
permissions.manage_terminals | boolean | false | ||
permissions.manage_rule_engine | boolean | false | ||
permissions.view_settlement_batches | boolean | false | ||
permissions.view_billing_reports | boolean | false | ||
permissions.process_authorization | boolean | false | ||
permissions.process_capture | boolean | false | ||
permissions.process_sale | boolean | false | ||
permissions.process_void | boolean | false | ||
permissions.process_credit | boolean | false | ||
permissions.process_refund | boolean | false | ||
permissions.process_verification | boolean | false | ||
permissions.allow_dashboard_stats | boolean | false | ||
permissions.vault_create | boolean | false | ||
permissions.vault_update | boolean | false | ||
permissions.vault_delete | boolean | false | ||
permissions.access_file_batch | boolean | false | ||
permissions.view_others_transactions | boolean | false | ||
permissions.manage_card_bans | boolean | false | ||
permissions.restrict_viewing_others_invoices | boolean | false | ||
permissions.recurring_status_change | boolean | false | ||
notifications.merchant | object | (account defaults) | user notification values | |
notifications.merchant.transaction_receipts | boolean | false | ||
notifications.merchant.settlement_reports | boolean | false | ||
notifications.merchant.triggered_rules | boolean | false | ||
notifications.merchant.security_alerts | boolean | false | ||
notifications.merchant.invoice_create | boolean | false | ||
notifications.merchant.transaction_void | boolean | false | ||
defaults | object | users default settings | ||
defaults.processor_id | string | user's default processor | ||
defaults.terminal_id | string | user's default terminal_id | ||
defaults.transaction_csv_format_id | string | user's default transaction csv export format | ||
defaults.transaction_report_format_id | string | user's default transaction report format | ||
defaults.vault_table_format_id | string | user's default vault report format | ||
defaults.show_transaction_totals | boolean | user's reports should show transaction totals |
{
"status": "success",
"msg": "success",
"data": {
"id": "b89227ij8m0nuanr1tk0",
"username": "testmerchant43",
"name": "test merchant user",
"phone": "6305555555",
"email": "info@website.com",
"timezone": "ETC/UTC",
"status": "active",
"role": "admin",
"account_type": "merchant",
"account_type_id": "aucio551tlv85l7moe5g",
"permissions": {
"manage_users": true,
"manage_api_keys": true,
"manage_terminals": true,
"manage_rule_engine": true,
"view_settlement_batches": true,
"view_billing_reports": true,
"process_authorization": true,
"process_capture": true,
"process_sale": true,
"process_void": true,
"process_credit": true,
"process_refund": true,
"process_verification": true,
"allow_dashboard_stats": true,
"vault_create": true,
"vault_update": true,
"vault_delete": true,
"access_file_batch": true,
"view_others_transactions": true,
"manage_card_bans": true,
"restrict_viewing_others_invoices": false,
"recurring_status_change": false
},
"notifications": {
"merchant": {
"transaction_receipts": true,
"settlement_reports": false,
"triggered_rules": false,
"security_alerts": false,
"invoice_create": false,
"transaction_void": false
}
},
"defaults": {
"processor_id": "",
"terminal_id": "1ucio551tlv85l7moe5s",
"transaction_csv_format_id": "",
"transaction_table_format_id": "",
"vault_table_format_id": "c5o3vak6lr8og69n5j8g",
"show_transaction_totals": false
},
"access_restrictions": {
"ip": null,
"password_change_required": null
}
"created_at": "2017-11-20T00:26:06.190264Z",
"updated_at": "2017-11-20T00:26:06.190264Z"
}
}
function updateUser() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
name: "test user",
phone: "6305555555",
email: "info@website.com",
timezone: "ETC/UTC",
status: "active",
role: "admin",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/user/{ user id }", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void updateUser(User user) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/user/" + user.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(user);
IRestResponse response = client.Execute(request);
var apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function updateUser($user) {
$curl = curl_init();
$payload = json_encode($user);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/user/".$user->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updateUser(User user) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(user);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/user/{ user id }")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse entity = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (entity.status === "success") {
// handle success
} else {
// handle non success
}
}
# Delete User
Delete a specific user.
Request Method:
DELETE
URL Endpoint:
/api/user/{ user id }
{
"status": "success",
"msg": "successfully deleted",
"data": null
}
function deleteUser(int id) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "DELETE",
headers: myHeaders
};
fetch("https://sandbox.durangomsgateway.com/api/user/" + id, requestOptions)
.then(response => response.text())
.then(result => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch(error => console.log("error", error));
}
public void deleteUser(int id) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/user/" + id);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
var apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deleteUser($id) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/user/".$id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deleteUser(int id) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/user/{ user id }")
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse entity = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (entity.status === "success") {
// handle success
} else {
// handle non success
}
}
# Change Password
Change a user's password. Must provide an API Key or JWT token associated with the user as the Authorization header value.
Request Method:
POST
URL Endpoint:
/api/user/change-password
Name | Type | Default | Description | Required |
---|---|---|---|---|
username | string | User's username | ||
current_password | string | User's current password | ||
new_password | string | The new password to be set on the user's account. Must be 8-64 characters and contain an uppercase character, a number, and a special character. |
{
"status": "success",
"msg": "Request processed successfully",
"data": null
}
function changePassword(username, currentPassword, newPassword) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
username: username,
current_password: currentPassword,
new_password: newPassword,
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/user/change-password", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class ApiResponse {
public string Status { get; set; }
public string Msg { get; set; }
}
public class ChangePasswordModel {
public string Username { get; set; }
public string CurrentPassword { get; set; }
public string NewPassword { get; set; }
}
public void changePassword(ChangePasswordModel model) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/user/change-password");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(model);
IRestResponse response = client.Execute(request);
var apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
$passwordChange = array(
"username" => "<username>",
"current_password" => "<current_password>",
"new_password" => "<new_password>"
);
function changePassword($passwordChange) {
$curl = curl_init();
$payload = json_encode($passwordChange);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/user/change-password",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class ApiResponse {
String status;
String msg;
}
public class ChangePasswordRequest {
String username;
@JsonProperty("current_password")
String currentPassword;
@JsonProperty("new_password")
String newPassword;
}
public void changePassword(ChangePasswordRequest requestData) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(requestData);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/user/change-password")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse entity = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (entity.status === "success") {
// handle success
} else {
// handle non success
}
}
# Transactions
# Process a Transaction
Process a transaction through the gateway.
TIP
If you do not have a default processor set, you must include the processor_id
property in the request body or the transaction will fail.
TIP
Base Amount - If you are using base_amount it will be the base amount of the transaction. The surcharge and other related fees(if applicable) will be calculated and added unless those values are specifically passed in.
Amount - This will be the final amount you want charged and will include all surcharges and related fees(if applicable).
Request Method:
POST
URL Endpoint:
/api/transaction
Name | Type | Default | Description | Required |
---|---|---|---|---|
idempotency_key | uint(uuid format) | used to identify duplicate transactions. Default time is 5 minutes | ||
type | string | "sale", "authorize", "verification" or "credit" | ||
amount | integer | Amount to process in cents (should contain all applicable fees and taxes) (1299 = $12.99) | ||
base_amount | integer | Amount to process in cents (surcharge and related fees will be added to this amount during processing) (1299 = $12.99) | ||
tax_exempt | boolean | false | Is the transaction tax exempt | Required for L3 |
tax_amount | integer | 0 | Tax Amount in cents | Required for L3 |
shipping_amount | integer | 0 | Shipping Amount in cents (should be included in Amount) | |
discount_amount | integer | 0 | Discount Amount in cents (should be included in Amount) | |
currency | string | "USD" | ISO 4217 currency (ex "USD") | |
description | string | "" | Text field for miscellaneous notes (max 255 characters) | |
order_id | string | Supports up to 15 alphanumeric characters | Required for L3 | |
po_number | string | Supports up to 15 alphanumeric characters | ||
processor_id | string | "" | Designates a specific processor for the transaction. If no value is provided, the transaction will run against the default processor set on your gateway. If no value is provided and there is no default set, the transaction will fail. | see description |
ip_address | string | Server IP | IPv4 or IPv6 value of the end user | |
allow_partial | bool | false | Allow partial transactions to be approved (only if supported by processor) | |
email_receipt | boolean | false | If true, sends an email receipt (email_address must be provided) | |
email_address | string | Email address (must be valid email format, "example@mail.com") | required if email_receipt is true | |
create_vault_record | boolean | false | If true, triggers the creation of a customer vault record after a successful transaction. Multiple transactions with the same details will create duplicative customer records. | |
vendor_id | string | "" | Vendor ID passed along to certain processors if supported (Special Field, only use if instructed by support) | |
billing_method | string | "straight" | "straight", "initial_recurring", or "recurring" | |
summary_commodity_code | string | Summary Commodity Code 4 AlphaNumeric characters | Required for L3 | |
ship_from_postal_code | string | Ship From Postal Code | Required for L3 | |
payment_adjustment | object | Object containing payment adjustment details. (ex. convenience fees, service fees, and surcharges) | ||
payment_adjustment .type | string | "" | "flat" or "percentage" | |
payment_adjustment .value | integer | 0 | Amount of adjustment in cents for "flat" (ex. 199 = $1.99) or 3 decimal places for "percentage" (ex. 1000 = 1.000%) | |
payment_method | object | Object containing payment method details, must contain only one of the following: card, ach, customer, terminal, token, apm | must include one payment method | |
payment_method .card | object | Object containing details for processing a transaction against a debit or credit card | ||
payment_method .card.entry_type | string | Must be "keyed" or "swiped" | ||
payment_method .card.number | string | Card number (digits only) | required if payment_method.card is present | |
payment_method .card.expiration_date | string | Expiration date (format MM/YY) | required if payment_method.card is present | |
payment_method .card.cvc | string | Card Verification Code | required if the applicable rule is set on the gateway | |
payment_method .card.track_1 | string | Decrypted track_1 | ||
payment_method .card.track_2 | string | Decrypted track_2 | ||
payment_method .card.encrypted_track_1 | string | Encrypted Track 1 | ||
payment_method .card.encrypted_track_2 | string | Encrypted Track 2 | ||
payment_method .card.ksn | string | KSN used to encrypt the supplied encrypted tracks | ||
payment_method .card.cardholder_authentication | object | Optionally pass 3DS collected data | if passed, it must contain valid values | |
payment_method .card.cardholder_authentication.eci | string | ECI indicator, ie 01,02,05,07..etc | ||
payment_method .card.cardholder_authentication.cavv | string | CAVV | ||
payment_method .card.cardholder_authentication.xid | string | XID | ||
payment_method .card.cardholder_authentication.cryptogram | string | Cryptogram | ||
payment_method .card.cardholder_authentication.version | string | Version, 1 or 2 | ||
payment_method .card.cardholder_authentication.ds_transaction_id | string | DS Transaction ID | ||
payment_method .card.cardholder_authentication.acs_transaction_id | string | ACS Transaction ID | ||
payment_method .ach | object | Object containing details for processing a transaction via ACH | ||
payment_method .ach.routing_number | string | Routing number for account to be charged | required if payment_method.ach is present | |
payment_method .ach.account_number | string | Account number for account to be charged | required if payment_method.ach is present | |
payment_method .ach.sec_code | string | SEC code for ACH transaction type: "web", "ccd", "ppd", or "tel" | required if payment_method.ach is present | |
payment_method .ach.account_type | string | ACH account type: "checking" or "savings" | required if payment_method.ach is present | |
payment_method .ach.check_number | string | Check number | required if payment_method.ach.sec_code = "tel" | |
payment_method .ach.accountholder_authentication | string | Object containing details for accountholder authentication | if required by processor | |
payment_method .ach.accountholder_authentication.dl_state | string | Driver's License state | required if payment_method.ach.accountholder_authentication is present | |
payment_method .ach.accountholder_authentication.dl_number | string | Driver's License number | required if payment_method.ach.accountholder_authentication is present | |
payment_method .customer | object | Object containing details for processing a transaction against a vaulted customer record | ||
payment_method .customer.id | string | Customer ID | required if payment_method.customer is present | |
payment_method .customer.payment_method_id | string | Customer default | ID of customer's saved payment method to be charged | |
payment_method .customer.payment_method_type | string | Customer default | The type of the payment method referenced in payment_method_id | |
payment_method .customer.billing_address_id | string | Customer default | ID of customer's saved billing address to be used | |
payment_method .customer.shipping_address_id | string | Customer default | ID of customer's saved shipping address to be used | |
payment_method .terminal | object | Object containing details for processing a transaction against a Terminal | ||
payment_method .terminal.id | string | ID of the terminal to be used for the transaction | required if payment_method.terminal is present | |
payment_method .terminal.expiration_date | string | Optionally pass an expiration date along with the transaction | ||
payment_method .terminal.cvc | string | Optionally pass a CVV along with the transaction | ||
payment_method .terminal.print_receipt | string | "no" (no receipt), "customer" (customer copy only), "merchant" (merchant copy only), or "both" (both copies) | required if payment_method.terminal is present | |
payment_method .terminal.signature_required | string | If true, requests that the terminal capture a signature (if supported) | required if payment_method.terminal is present | |
payment_method .apm | object | Object containing details for processing APM transactions | ||
payment_method .apm.type | string | APM type (see chart below) | required if payment_method.apm is present | |
payment_method .apm.merchant_redirect_url | string | This is the redirect url you wish to send the customer to after processing the payment | required if payment_method.apm is present | |
payment_method .apm.locale | string | Locale to be used for the payment page, if supported by the APM (ex. "en-US") | required if payment_method.apm is present | |
payment_method .apm.mobile_view | boolean | If true, tells the APM to render a mobile version of the landing page (if supported by the APM) | required if payment_method.apm is present | |
payment_method .apm.national_id | string | Consumer's National ID (max 30 characters) | ||
payment_method .apm.consumer_ref | string | Unique reference identifiying the customer. May contain [a-z0-9-], max 20 characters | ||
billing_address | object | null | Object containing billing address details | |
billing_address .first_name | string | Up to 50 characters | ||
billing_address .last_name | string | Up to 50 characters | ||
billing_address .company | string | Up to 100 characters | ||
billing_address .address_line_1 | string | Up to 100 characters | ||
billing_address .address_line_2 | string | Up to 100 characters | ||
billing_address .city | string | Up to 50 characters | ||
billing_address .state | string | State abbrevation | ||
billing_address .postal_code | string | If payment_method.card is present, defaults to Postal Code associated with card | Required for L3 | |
billing_address .country | string | "US" | ||
billing_address | string | Email address (must be valid email format, "example@mail.com") | ||
billing_address .phone | string | Digits only | ||
billing_address .fax | string | Digits only | ||
shipping_address | object | null | Object containing billing address details | |
shipping_address .first_name | string | Up to 50 characters | ||
shipping_address .last_name | string | Up to 50 characters | ||
shipping_address .company | string | Up to 100 characters | ||
shipping_address .address_line_1 | string | Up to 100 characters | ||
shipping_address .address_line_2 | string | Up to 100 characters | ||
shipping_address .city | string | Up to 50 characters | ||
shipping_address .state | string | State abbreviation | ||
shipping_address .postal_code | string | Required for L3 | ||
shipping_address .country | string | |||
shipping_address | string | Email address (must be valid email format, "example@mail.com") | ||
shipping_address .phone | string | Digits only | ||
shipping_address .fax | string | Digits only | ||
group_name | string | "default" | custom fields group name | |
custom_fields | object | Object based where the key is the id of the custom field and the value is an array of strings(even is single value) | Only required if fields are set to required | |
iias_status | string | "" | Required for HSA/FSA Valid values are: "verified" or "exempt" | |
additional_amounts | object | |||
additional_amounts .hsa.total | int | 0 | Required for HSA/FSA Total amount for HSA/FSA, passed as an unsigned integer | |
additional_amounts .hsa.rx_amount | int | 0 | RX AMount for HSA/FSA, passed as an unsigned integer | |
additional_amounts .hsa.vision_amount | int | 0 | Vision Mount for HSA/FSA, passed as an unsigned integer | |
additional_amounts .hsa.clinic_amount | int | 0 | Clinic Mount for HSA/FSA, passed as an unsigned integer | |
additional_amounts .hsa.dental_amount | int | 0 | Dental Mount for HSA/FSA, passed as an unsigned integer | |
line_items | array | Array of line items | Required for L3 | |
line_items[] name | string | Friendly name up to 50 alpha characters | ||
line_items[] description | string | Product Description up to 50 alpha characters | ||
line_items[] product_code | string | Product Code/SKU up to 50 alpha characters | ||
line_items[] commodity_code | string | Commodity Code up to 12 alpha characters | ||
line_items[] quantity | float64 | Quantity ##.## | ||
line_items[] discount_amount | int | in cents | ||
line_items[] freight_amount | int | in cents | ||
line_items[] unit_price | int | in cents | ||
line_items[] tax_amount | int | in cents | ||
line_items[] national_tax_amount | int | in cents | ||
line_items[] amount | int | in cents | ||
line_items[] national_tax_rate | string | 3 decimal rate. 10% = 10.000 | ||
line_items[] tax_rate | string | 3 decimal rate. 10% = 10.000 | ||
line_items[] unit_of_measure | string | |||
processor_specific | object | Optional: this only applys to specific processor types | ||
processor_specific .paysafe_direct.subscription_trial_solution | bool | |||
processor_specific .paysafe_direct.subscription_start_date | string | YYYY-MM-DD | ||
processor_specific .paysafe_direct.subscription_trial_start_date | string | YYYY-MM-DD | ||
processor_specific .paysafe_direct.subscription_trial_end_date | string | YYYY-MM-DD | ||
processor_specific .paysafe_direct.subscription_secondary_billing_date | string | YYYY-MM-DD | ||
processor_specific .paysafe_direct.subscription_cancel_url | string | weburl | ||
processor_specific .paysafe_direct.subscription_amount | uint | in cents | ||
processor_specific .paysafe_direct.subscription_unit_cost | uint | in cents | ||
processor_specific .paysafe_direct.subscription_item_quantity | uint | |||
processor_specific .paysafe_direct.subscription_product_desc | string | |||
descriptor | object | Optional: this only applys to specific processor types | ||
descriptor .name | string (38 Char) | |||
descriptor .address | string (38 Char) | |||
descriptor .city | string (21 Char) | |||
descriptor .state | string (2 Char) | |||
descriptor .postal_code | string (5 Char) | |||
card_on_file_indicator | string | [CR] | Optional value, C = General purpose storage, R = recurring payment | |
initiated_by | string | [CM] | Who is inititating the transaction. C = Card Holder, M = Merchant | |
initial_transaction_id | string | Optional if using our tokenization, otherwise this is transaction id used when storing the payment | ||
stored_credential_indicator | string | Optional if using our tokenization, otherwise "used" or "stored" |
Supported APMs
Type | Supported Processing Countries | Supported Currencies |
---|---|---|
alipay | CN | EUR, USD, GBP |
dragonpay | PH | PHP |
wechatpay | CN | EUR, USD |
oxxo | MX | USD, MXN |
klarna | AT, DK, FI, DE, NL, NO, SE, GB | EUR, DKK, GBP, NOK, SEK |
sepa | DE | EUR |
APM requirements
# SEPA
Field | Required |
---|---|
payment_method .apm.consumer_id | |
payment_method .apm.iban | |
payment_method .apm.mandate_reference | merchant assigned value referencing the mandate |
payment_method .apm.mandate_url | |
payment_method .apm.mandate_signature_date | YYYY-MM-DD |
# Alipay
Field | Required |
---|---|
payment_method .apm.mobile_view |
# DragonPay
Field | Required |
---|---|
billing_address | |
billing_address .phone |
# WeChatPay
Field | Required |
---|---|
payment_method .apm.locale |
# OXXO
Field | Description | Required |
---|---|---|
payment_method .apm.national_id | Consumer's national id (max 30 characters). Not required for OXXO MXN. | |
payment_method .apm.consumer_ref | Unique customer reference provided by merchant. (max 20 alphanumeric characters) | |
payment_method .apm.due_date | "YYYY-MM-DD" expiry date for payment voucher. Voucher expires at midnight local Mexico City Time. Only applies to OXXO MXN currency. | |
billing_address | Email address (must be valid email format, "example@mail.com") | |
billing_address .address_1 | ||
billing_address .postal_code |
# Klarna
Field | Description | Required |
---|---|---|
payment_method .apm.payment_method_category | "direct_debit", "direct_bank_transfer", "pay_now", "pay_later", or "pay_over_time" | |
payment_method .apm.purchase_type | "buy", "rent", "book", "subscribe", "download", "order", or "continue" (default = "continue") | |
payment_method .apm.hpp_title | Title to be used for Hosted Payment Page | |
payment_method .apm.logo_url | Logo Url to be used on Hosted Payment Page | |
billing_address | ||
shipping_address | ||
line_items[] .name | ||
line_items[] .quantity | ||
line_items[] .unit_of_measure | unit of measure | |
line_items[] .unit_price | unit price | |
line_items[] .amount | total amount | |
line_items[] .product_code | sku/reference | |
line_items[] .local_tax | tax amount per item | |
line_items[] .discount_amount | discount amount as an unsigned integer | |
tax_amount |
{
"status": "success",
"msg": "success",
"data": {
"id": "b7kgflt1tlv51er0fts0",
"type": "sale",
"amount": 1112,
"tax_amount": 100,
"tax_exempt": false,
"shipping_amount": 100,
"discount_amount": 0,
"payment_adjustment_type": "",
"payment_adjustment_value": 0,
"currency": "usd",
"description": "test transaction",
"order_id": "someOrderID",
"po_number": "somePONumber",
"ip_address": "4.2.2.2",
"email_receipt": false,
"email_address": "user@home.com",
"payment_method": "card",
"response": {
"card": {
"id": "b7kgflt1tlv51er0ftsg",
"card_type": "visa",
"first_six": "401200",
"last_four": "5439",
"masked_card": "401200******5439",
"expiration_date": "12/20",
"status": "approved",
"auth_code": "TAS731",
"processor_response_code": "00",
"processor_response_text": "APPROVAL TAS731 ",
"processor_type": "tsys_sierra",
"processor_id": "b7kgflt1tlv51er0f1sg",
"avs_response_code": "0",
"cvv_response_code": "M",
"processor_specific": {},
"created_at": "2017-10-19T20:15:19.80368Z",
"updated_at": "2017-10-19T20:15:20.777011Z"
}
},
"status": "pending_settlement",
"response_code": 100,
"customer_id": "aaaaaaaaaaaaaaaaaaaa",
"billing_address": {
"first_name": "John",
"last_name": "Smith",
"company": "Test Company",
"address_line_1": "123 Some St",
"address_line_2": "",
"city": "Wheaton",
"state": "IL",
"postal_code": "60187",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "help@website.com"
},
"shipping_address": {
"first_name": "John",
"last_name": "Smith",
"company": "Test Company",
"address_line_1": "123 Some St",
"address_line_2": "",
"city": "Wheaton",
"state": "IL",
"postal_code": "60187",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "help@website.com"
},
"created_at": "2017-10-19T20:15:19.560708Z",
"updated_at": "2017-10-19T20:15:20.832049Z"
}
}
{
"status": "success",
"msg": "success",
"data": {
"id": "b9efr9qj8m0ge2h7tat0",
"user_id": "aucio551tlv85l7moe60",
"idempotency_key": "",
"idempotency_time": 0,
"type": "sale",
"amount": 500,
"amount_authorized": 500,
"amount_captured": 500,
"amount_settled": 0,
"processor_id": "",
"processor_type": "",
"payment_method": "terminal",
"payment_type": "",
"tax_amount": 100,
"tax_exempt": false,
"shipping_amount": 100,
"discount_amount": 0,
"payment_adjustment_type": "",
"payment_adjustment_value": 0,
"currency": "usd",
"description": "test transaction",
"order_id": "someOrderID",
"po_number": "somePONumber",
"ip_address": "4.2.2.2",
"transaction_source": "api",
"email_receipt": false,
"customer_id": "",
"referenced_transaction_id": "",
"response_body": {
"terminal": {
"id": "b9efr9qj8m0ge2h7tatg",
"card_type": "mastercard",
"payment_type": "credit",
"entry_type": "swiped",
"first_four": "5424",
"last_four": "3333",
"masked_card": "5424********3333",
"cardholder_name": "FDCS TEST CARD /MASTERCARD",
"auth_code": "",
"response_code": 100,
"processor_response_text": "APPROVAL VTLMC1",
"processor_specific": {
"BatchNum": "8",
"CashBack": "0.00",
"ClerkID": "",
"DISC": "0.00",
"EBTCashAvailBalance": "",
"EBTCashBeginBalance": "",
"EBTCashLedgerBalance": "",
"EBTFSAvailBalance": "",
"EBTFSBeginBalance": "",
"EBTFSLedgerBalance": "",
"Fee": "0.00",
"InvNum": "someOrderID",
"Language": "English",
"ProcessData": "",
"RefNo": "",
"RewardCode": "",
"RewardQR": "",
"RwdBalance": "0",
"RwdIssued": "",
"RwdPoints": "0",
"SHFee": "0.00",
"SVC": "0.00",
"TableNum": "0",
"TicketNum": "",
"Tip": "0.00",
"TotalAmt": "5.00"
},
"emv_aid": "",
"emv_app_name": "",
"emv_tvr": "",
"emv_tsi": "",
"signature_data": "Qk0OIQAAAAAAAD4AAAAoAAAALgEAANIAAAABAAEAAAAAANAgAADEDgAAxA4AAAAA//////////////////////////8f//////////////8AAA=",
"created_at": "2018-01-15T19:14:47.225068Z",
"updated_at": "2018-01-15T19:15:02.335853Z"
}
},
"status": "pending_settlement",
"response": "approved",
"response_code": 100,
"billing_address": {
"first_name": "John",
"last_name": "Smith",
"company": "Test Company",
"address_line_1": "123 Some St",
"address_line_2": "",
"city": "Wheaton",
"state": "IL",
"postal_code": "60187",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "help@website.com"
},
"shipping_address": {
"first_name": "",
"last_name": "",
"company": "",
"address_line_1": "",
"address_line_2": "",
"city": "",
"state": "",
"postal_code": "",
"country": "",
"phone": "",
"fax": "",
"email": ""
},
"created_at": "2018-01-15T19:14:47.108371Z",
"updated_at": "2018-01-15T19:15:02.529558Z",
"captured_at": "2018-01-15T19:14:47.337763Z",
"settled_at": null
}
}
# Process a Transaction - Code Samples
curl -v -X POST \
-H "Authorization: APIKEY" \
-H "Content-Type: application/json" \
-d '{
"type": "sale",
"amount": 1112,
"tax_amount": 100,
"shipping_amount": 100,
"currency": "USD",
"description": "test transaction",
"order_id": "someOrderID",
"po_number": "somePONumber",
"ip_address": "4.2.2.2",
"email_receipt": false,
"email_address": "user@home.com",
"create_vault_record": true,
"payment_method": {
"card": {
"entry_type": "keyed",
"number": "4012000098765439",
"expiration_date": "12/20",
"cvc": "999"
}
... or ...
"customer": {
"id": "b798ls2q9qq646ksu070",
"payment_method_type": "card",
"payment_method_id": "b798ls2q9qq646ksu080",
"billing_address_id": "b798ls2q9qq646ksu07g",
"shipping_address_id": "b798ls2q9qq646ksu07g"
}
... or ...
"terminal": {
"id": "<terminal id>"
"expiration_date": "12/20",
"cvc": "999",
"print_receipt": "both"
"signature_required": true
}
... or ...
"token": "<tokenizer token goes here>",
... or ...
"ach": {
"routing_number": "490000018",
"account_number": "999999",
"sec_code": "ccd",
"account_type": "checking",
"check_number":"1223",
"accountholder_authentication": {
"dl_state": "IL",
"dl_number": "r500123123"
}
... or ...
"apm": {
"type": "alipay",
"merchant_redirect_url": "http://merchantwebsite.com/",
"locale": "en-US",
"mobile_view": false
}
}
},
"billing_address" : {
"first_name": "John",
"last_name": "Smith",
"company": "Test Company",
"address_line_1": "123 Some St",
"city": "Wheaton",
"state": "IL",
"postal_code": "60187",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "help@website.com"
},
"shipping_address" : {
"first_name": "John",
"last_name": "Smith",
"company": "Test Company",
"address_line_1": "123 Some St",
"city": "Wheaton",
"state": "IL",
"postal_code": "60187",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "help@website.com"
}
}' \
"https://sandbox.durangomsgateway.com/api/transaction"
var card = {
entry_type: "keyed",
number: "4111111111111111",
expiration_date: "12/22",
cvc: "999",
};
var customer = {
id: "{ customer id }",
payment_method_type: "card",
payment_method_id: "abcd1234",
billing_address_id: "abcd1234",
shipping_address_id: "abcd1234",
};
var terminal = {
id: "{ terminal id }",
expiration_date: "12/22",
cvc: "999",
print_receipt: "both",
signature_required: true,
};
var ach = {
routing_number: "123456789",
account_number: "234567890",
sec_code: "ccd",
account_type: "checking",
check_number: "1234",
accountholder_authentication: {
dl_state: "IL",
dl_number: "r123123123",
},
};
var billingAddress = {
first_name: "John",
last_name: "Smith",
company: "Test Company",
address_line_1: "123 Some St",
address_line_2: "",
city: "Wheaton",
state: "IL",
postal_code: "60187",
country: "US",
phone: "5555555555",
fax: "5555555555",
email: "help@website.com",
};
var shippingAddress = {
first_name: "John",
last_name: "Smith",
company: "Test Company",
address_line_1: "123 Some St",
address_line_2: "",
city: "Wheaton",
state: "IL",
postal_code: "60187",
country: "US",
phone: "5555555555",
fax: "5555555555",
email: "help@website.com",
};
var apm = {
type: "alipay",
merchant_redirect_url: "https://merchantwebsite.com/",
locale: "en-US",
mobile_view: false,
};
var transaction = {
type: "sale",
amount: 1112,
tax_amount: 100,
shipping_amount: 100,
currency: "USD",
description: "test transaction",
order_id: "someOrderID",
po_number: "somePONumber",
ip_address: "4.2.2.2",
email_receipt: false,
email_address: "user@home.com",
create_vault_record: true,
payment_method: {
card: card, // ... or ...
// token: "{ tokenizer token }" ... or ...
// customer: customer ... or ...
// terminal: terminal ... or ...
// ach: ach ... or ...
// apm: apm
},
billing_address: billingAddress,
shipping_address: shippingAddress,
};
// Process Transaction
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var jsonString = JSON.stringify(transaction); // Based upon your setup. You may or may not need to stringify
var requestOptions = {
method: "POST",
headers: myHeaders,
body: jsonString,
redirect: "follow",
};
fetch("https://sandbox.durangomsgateway.com/api/transaction", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
public class PaymentMethod {
public string Token { get; set; }
public Card Card { get; set; }
public Customer Customer { get; set; }
public Terminal Terminal { get; set; }
public Ach Ach { get; set; }
public Apm Apm { get; set; }
}
public class Card {
public string EntryType { get; set; }
public string Number { get; set; }
public string ExpirationDate { get; set; }
public string Cvc { get; set; }
}
public class Customer {
public string Id { get; set; }
public string PaymentMethodType { get; set; }
public string PaymentMethodId { get; set; }
public string BillingAddressId { get; set; }
public string ShippingAddressId { get; set; }
}
public class Terminal {
public string ExpirationDate { get; set; }
public string Cvc { get; set; }
public string PrintReceipt { get; set; }
public string SignatureRequired { get; set; }
}
public class AccountholderAuthentication {
public string DlState { get; set; }
public string DlNumber { get; set; }
}
public class Ach {
public string RoutingNumber { get; set; }
public string AccountNumber { get; set; }
public string SecCode { get; set; }
public string AccountType { get; set; }
public string CheckNumber { get; set; }
public AccountholderAuthentication AccountholderAuthentication { get; set; }
}
public class Apm {
public string Type { get; set; }
public string MerchantRedirectUrl { get; set; }
public string Locale { get; set; }
public bool MobileView { get; set; }
}
public class Address {
public string First_name { get; set; }
public string Last_name { get; set; }
public string Company { get; set; }
public string Address_line_1 { get; set; }
public string Address_line_2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Postal_code { get; set; }
public string Country { get; set; }
public string Phone { get; set; }
public string Fax { get; set; }
public string Email { get; set; }
}
public class Transaction {
public string Type { get; set; }
public int Amount { get; set; }
public int TaxAmount { get; set; }
public int ShippingAmount { get; set; }
public string Currency { get; set; }
public string Description { get; set; }
public string OrderId { get; set; }
public string PoNumber { get; set; }
public string IpAddress { get; set; }
public bool EmailReceipt { get; set; }
public string EmailAddress { get; set; }
public bool CreateVaultRecord { get; set; }
public PaymentMethod PaymentMethod { get; set; }
public Address BillingAddress { get; set; }
public Address ShippingAddress { get; set; }
}
public void processTransaction(Transaction transaction) {
Transaction transaction = new Transaction();
transaction.PaymentMethod = new Card();
// Process Transaction
var client = new RestClient("https://sandbox.durangomsgateway.com/api/transaction");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "{ api key }");
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(transaction);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
}
<?php
$transaction = array(
"type" => "sale",
"amount" => 1112,
"tax_amount" => 100,
"shipping_amount" => 100,
"currency" => "USD",
"description" => "test transaction",
"order_id" => "someOrderID",
"po_number" => "somePONumber",
"ip_address" => "4.2.2.2",
"email_receipt" => false,
"email_address" => "user@home.com",
"create_vault_record" => true,
"payment_method" => array(
"card" => array(
"entry_type" => "keyed",
"number" => "4111111111111111",
"expiration_date" => "12/22",
"cvc" => "999"
)
/* ... or ...
"customer" => array(
"id" => "{ customer ID }",
"payment_method_type" => "card",
"payment_method_id" => "b798ls2q9qq646ksu080",
"billing_address_id" => "b798ls2q9qq646ksu07g",
"shipping_address_id" => "b798ls2q9qq646ksu07g"
)
*/
/* ... or ...
"terminal" => array(
"id" => "{ terminal id }"
"expiration_date" => "12/20",
"cvc" => "999",
"print_receipt" => "both"
"signature_required" => true
)
*/
/* ... or ...
"token" => "{ tokenizer token }",
*/
/* ... or ...
"ach" => array(
"routing_number" => "123456789",
"account_number" => "234567890",
"sec_code" => "ccd",
"account_type" => "checking",
"check_number" => "1234",
"accountholder_authentication" => array(
"dl_state" => "IL",
"dl_number" => "r123123123"
)
)
*/
/* ... or ...
"apm" => array(
"type" => "alipay",
"merchant_redirect_url" => "https://merchantwebsite.com/",
"locale" => "en-US",
"mobile_view" => false
)
*/
),
"billing_address" => array(
"first_name" => "John",
"last_name" => "Smith",
"company" => "Test Company",
"address_line_1" => "123 Some St",
"address_line_2" => "",
"city" => "Wheaton",
"state" => "IL",
"postal_code" => "60187",
"country" => "US",
"phone" => "5555555555",
"fax" => "5555555555",
"email" => "help@website.com"
),
"shipping_address" => array(
"first_name" => "John",
"last_name" => "Smith",
"company" => "Test Company",
"address_line_1" => "123 Some St",
"address_line_2" => "",
"city" => "Wheaton",
"state" => "IL",
"postal_code" => "60187",
"country" => "US",
"phone" => "5555555555",
"fax" => "5555555555",
"email" => "help@website.com"
)
);
function processTransaction ($transaction) {
$curl = curl_init();
$payload = json_encode($transaction);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/transaction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
processTransaction($transaction);
public class PaymentMethod {
public string token;
public Card card;
public Customer customer;
public Terminal terminal;
public Ach ach;
public Apm apm;
}
public class Card {
@JsonProperty("entry_type")
public string entryType;
public string number;
@JsonProperty("expiration_date")
public string expirationDate;
public string cvc;
}
public class Customer {
public string id;
@JsonProperty("payment_method_type")
public string paymentMethodType;
@JsonProperty("payment_method_id")
public string paymentMethodId;
@JsonProperty("billing_address_id")
public string billingAddressId;
@JsonProperty("shipping_address_id")
public string shippingAddressId;
}
public class Terminal {
@JsonProperty("expiration_date")
public string expirationDate;
public string cvc;
@JsonProperty("print_receipt")
public string printReceipt;
@JsonProperty("signature_required")
public string signatureRequired;
}
public class AccountholderAuthentication {
@JsonProperty("dl_state")
public string dlState;
@JsonProperty("dl_number")
public string dlNumber;
}
public class Ach {
@JsonProperty("routing_number")
public string routingNumber;
@JsonProperty("account_number")
public string accountNumber;
@JsonProperty("sec_code")
public string secCode;
@JsonProperty("account_type")
public string accountType;
@JsonProperty("check_number")
public string checkNumber;
@JsonProperty("accountholder_authentication")
public AccountholderAuthentication accountholderAuthentication;
}
public class Apm {
public string type;
@JsonProperty("merchant_redirect_url")
public string merchantRedirectUrl;
public string locale;
@JsonProperty("mobile_view")
public bool mobileView;
}
public class Address {
@JsonProperty("first_name")
public string firstName;
@JsonProperty("last_name")
public string lastName;
public string company;
@JsonProperty("address_line_1")
public string addressLine1;
@JsonProperty("address_line_2")
public string addressLine2;
public string city;
public string state;
@JsonProperty("postal_code")
public string postalCode;
public string country;
public string phone;
public string fax;
public string email;
}
public class Transaction {
public string id;
public string type;
public int amount;
@JsonProperty("tax_amount")
public int taxAmount;
@JsonProperty("shipping_amount")
public int shippingAmount;
public string currency;
public string description;
@JsonProperty("order_id")
public string orderId;
@JsonProperty("po_number")
public string poNumber;
@JsonProperty("ip_address")
public string ipAddress;
@JsonProperty("email_receipt")
public bool emailReceipt;
@JsonProperty("email_address")
public string emailAddress;
@JsonProperty("create_vault_record")
public bool createVaultRecord;
@JsonProperty("payment_method")
public PaymentMethod paymentMethod;
@JsonProperty("billing_address")
public Address billingAddress;
@JsonProperty("shipping_address")
public Address shippingAddress;
}
public void processTransaction(Transaction transaction) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(transaction);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/transaction")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
}
# CIT - MIT
TIP
When processing transactions the following variables are available for including CIT/MIT variables to the processors.
Name | Required | Description |
---|---|---|
card_on_file_indicator | Optional | |
initiated_by | Required | Indicates who initiated the transaction. |
initial_transaction_id | Optional | Optional if using our tokenization |
stored_credential_indicator | Optional | Indicates if a stored payment was used or not |
billing_method | Optional | Defaults to "straight", but if this is a recurring transaction, passing "recurring" will set recurring indicators on the transaction |
# Fee Calculation
TIP
Using this endpoint will calculate any applicable fees that should be applied to the transaction. This includes Surcharge, Cash Discount Fees and Payment Adjustment, if applicable.
Request Method:
POST
URL Endpoint:
/api/lookup/fees
Name | Type | Required | Description |
---|---|---|---|
type | string | yes | type of request, "integrations" |
state | string | no | billing address state |
bin | string | yes | 6 - 19 digits of a card |
payment_method | string | yes | card |
base_amount | uint | yes | amount in lowest form of currency. $1.00 = 100 |
➜ ~ curl -H 'Authorization: API_KEY' -H "Content-Type: application/json" -X POST -d '{
"type": "integrations",
"type_id":"",
"state": "IL",
"bin": "517246700",
"payment_method": "card",
"base_amount": 1000
}' { url goes here }/api/api/lookup/fees
{
"status": "success",
"msg": "success",
"data": {
"service_fee": 0,
"payment_adjustment": {
"value": 0,
"type": ""
},
"requested_amount": 1350,
"discount_amount": null,
"surcharge": 350
}
}
# Amount calculation
Request Method:
POST
URL Endpoint:
/api/calculate/amounts
Name | Type | Required | Default | Description |
---|---|---|---|---|
processor_id | string | true | ||
subtotal | uint | true | null | |
amount | uint | if line_items or products not present | null | |
currency | string | true | ||
payment_method | string | true | Can be 'card' or 'ach' | |
transaction_type | string | true | Can be 'verification', 'auth', 'sale', 'void', 'refund', 'credit' | |
products | array | if amount or line_items not present | null | |
products[].id | string | true | ||
products[].name | string | true | ||
products[].description | string | false | ||
products[].price | string | true | ||
products[].local_tax | string | false | ||
products[].national_tax | string | false | ||
products[].fixed_amount | bool | false | false | |
products[].fixed_qty | bool | false | false | |
products[].unit_of_measure | string | false | null | |
line_items | array | if amount or products not present | null | |
line_items[].id | string | true | ||
line_items[].status | string | true | Can be 'paid', 'pending', 'rejected' | |
line_items[].type | string | true | Can be 'flat' or 'percentage' | |
line_items[].name | string | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
line_items[].description | string | false | false | If true, the calculated amount will be added to the total amount |
line_items[].unit_price | int | true | ||
line_items[].quantity | float64 | true | ||
line_items[].quantity_shipped | float64 | false | ||
line_items[].product_code | string | false | ||
line_items[].commodity_code | string | false | ||
line_items[].unit_of_measure | string | false | ||
line_items[].alternate_tax_identifier | string | false | ||
line_items[].taxable | bool | false | false | |
line_items[].local_tax_rate | string | false | Format is 10.25 | |
line_items[].national_tax_rate | string | false | Format is 10.25 | |
line_items[].tax_rate | string | false | Format is 10.25 | |
line_items[].discount_amount | uint | false | ||
line_items[].freight_amount | uint | false | ||
line_items[].discount_rate | string | false | ||
processor_payment_adjustment | object | false | null | |
processor_payment_adjustment.type | string | true | Can be 'flat' or 'percentage' | |
processor_payment_adjustment.value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
processor_payment_adjustment.include | bool | false | false | If true, the calculated amount will be added to the total amount |
shipping_amount | object | false | null | |
shipping_amount.type | string | true | Can be 'flat' or 'percentage' | |
shipping_amount.value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
shipping_amount.include | bool | false | false | If true, the calculated amount will be added to the total amount |
addon_amount | array | false | null | |
addon_amount[].type | string | true | Can be 'flat' or 'percentage' | |
addon_amount[].value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
addon_amount[].include | bool | false | false | If true, the calculated amount will be added to the total amount |
discount_amount | array | false | null | |
discount_amount[].type | string | true | Can be 'flat' or 'percentage' | |
discount_amount[].value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
discount_amount[].include | bool | false | false | If true, the calculated amount will be added to the total amount |
duty_amount | object | false | null | |
duty_amount.type | string | true | Can be 'flat' or 'percentage' | |
duty_amount.value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
duty_amount.include | bool | false | false | If true, the calculated amount will be added to the total amount |
tip_amount | object | false | null | |
tip_amount.type | string | true | Can be 'flat' or 'percentage' | |
tip_amount.value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
tip_amount.include | bool | false | false | If true, the calculated amount will be added to the total amount |
additional_amounts | array | false | null | |
additional_amounts[].type | string | true | Can be 'flat' or 'percentage' | |
additional_amounts[].value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
additional_amounts[].include | bool | false | false | If true, the calculated amount will be added to the total amount |
tax_amount | object | false | null | |
tax_amount.type | string | true | Can be 'flat' or 'percentage' | |
tax_amount.value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
tax_amount.include | bool | false | false | If true, the calculated amount will be added to the total amount |
national_tax_amount | object | false | null | |
national_tax_amount.type | string | true | Can be 'flat' or 'percentage' | |
national_tax_amount.value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
national_tax_amount.include | bool | false | false | If true, the calculated amount will be added to the total amount |
local_tax_amount | object | false | null | |
local_tax_amount.type | string | true | Can be 'flat' or 'percentage' | |
local_tax_amount.value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
local_tax_amount.include | bool | false | false | If true, the calculated amount will be added to the total amount |
service_fee | object | false | null | |
service_fee.type | string | true | Can be 'flat' or 'percentage' | |
service_fee.value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
service_fee.include | bool | false | false | If true, the calculated amount will be added to the total amount |
surcharge | object | false | null | |
surcharge.type | string | true | Can be 'flat' or 'percentage' | |
surcharge.value | uint | true | If type is 'flat', round to 2 decimals (ex. $10.00 should be 1000), if 'percentage' round to 3 (ex. %10.000 should be 10000) | |
surcharge.include | bool | false | false | If true, the calculated amount will be added to the total amount |
cc_bin | string | if surcharge allowed | null | |
country | string | if surcharge allowed | null | |
state | string | if surcharge allowed | null | |
flags | object | false | ||
flags.skip_cash_discount | bool | false | false | If true, skips the cash discount calculation |
flags.skip_surcharge | bool | false | false | If true, skips the cash surcharge calculation |
flags.skip_service_fee | bool | false | false | If true, skips the cash service fee calculation |
flags.skip_consumer_choice | bool | false | false | If true, skips the cash consumer choice calculation |
flags.include_default_tax_to_total | bool | false | null | If true, and tax has not been overridden, the merchant's default tax amount will be added to the total amount |
flags.tax_exempt | bool | false | null | If true, sets the national, local and tax amount fields to 0 |
flags.processor_surcharge_fallback | bool | false | false | If true, processor's surcharge fallback will be available |
flags.add_tax_to_total | bool | false | null | If true, the tax will be added to the total amount |
source | string | false |
Workflow:
- Call the Amount calculation endpoint with the properly filled request
- Take the response of the Amount calculation and place it into the Transaction Request into the
amounts
field and fill the other fields of the request - Submit the transaction with the pre-calculated amounts
➜ ~ curl -H 'Authorization: API_KEY' -H "Content-Type: application/json" -X POST -d '{
"processor_id": "<processor id>",
"amount" : 1000,
"subtotal" : 1000,
"currency": "USD",
"payment_method": "card",
"transaction_type": "sale"
}' { url goes here }/api/calculate/amounts
{
"status": "success",
"msg": "success",
"data": {
"line_items": null,
"shipping_amount": null,
"discount_amount": null,
"freight_amount": null,
"addon_amount": null,
"duty_amount": null,
"tip_amount": null,
"additional_amounts": null,
"tax_amount": 180,
"national_tax_amount": null,
"local_tax_amount": null,
"service_fee": 350,
"surcharge": null,
"processor_id": "<processor id>",
"payment_method": "card",
"included_amounts": {
"shipping_amount": null,
"discount_amount": null,
"duty_amount": null,
"tip_amount": null,
"tax_amount": 180,
"national_tax_amount": null,
"local_tax_amount": null,
"service_fee": 350,
"surcharge": null
},
"subtotal": 1000,
"amount": 1000,
"additional_total": 0,
"total": 1530,
"features": {
"surcharge": false,
"cash_discount": false,
"dual_pricing": false,
"dual_pricing_v2": false
},
"display": {
"subtotal": {
"value": 1000,
"display": true
},
"amount": {
"value": 1000,
"display": true
},
"shipping": {
"value": 0,
"display": false
},
"freight": {
"value": 0,
"display": false
},
"duty": {
"value": 0,
"display": false
},
"discount": {
"value": 0,
"display": false
},
"service_fee": {
"value": 350,
"display": true
},
"surcharge": {
"value": 0,
"display": false
},
"tax": {
"value": 180,
"display": true
},
"national_tax": {
"value": 0,
"display": false
},
"local_tax": {
"value": 0,
"display": false
},
"tip": {
"value": 0,
"display": false
},
"total": {
"value": 1530,
"display": true
},
"consumer_choice": {
"card": 0,
"ach": 0,
"display": false
}
},
"disclaimer": {
"text": "",
"html": "",
"display": false
}
}
}
# Response Codes
TIP
Response Codes are grouped as follows: 100 thru 199 are Approvals and Partial Approvals. 200 thru 299 are Declined via the processor. 300 thru 399 are Gateway Declines. 400 thru 499 are processor rejection errors.
Response Code | Processor Definition | Description |
---|---|---|
0 | Unknown | Unknown, please contact support for more information |
99 | Pending payment | Used in redirect processors prior to payment being received |
100 | Approved | Transaction was successfully approved |
110 | Partial approval | Transaction was successfully approved, but for a lesser amount |
200 - 299 | Decline | Transaction has been declined by the issuer for various reasons |
300 - 399 | Gateway Decline | Platform decline for configuration or fraud reasons |
400 - 499 | Transaction error returned by processor | Errors returned from the processor |
Response Code | Processor Definition | Description |
---|---|---|
0 | Unknown | Unknown, please contact support for more information |
99 | Pending payment | Used in redirect processors prior to payment being received |
100 | Approved | Transaction was successfully approved |
110 | Partial approval | Transaction was successfully approved, but for a lesser amount |
101 | Approved, pending customer approval | Transaction is pending customer approval before release |
200 | Decline | Generic decline with no additional information provided by the issuer |
201 | Do not honor | Generic decline with no additional information provided by the issuer |
202 | Insufficient funds | Declined for insufficient funds |
203 | Exceeds withdrawn limit | Declined for exceeding a withdrawn limit set by the issuer |
204 | Invalid Transaction | Declined as the issuer does not recognize the transaction |
205 | SCA Decline | Soft Decline indicating that a SCA challenge is required |
220 | Invalid Amount | Provided amount is not supported by the issuer |
221 | No such Issuer | The issuing bank can not be found |
222 | No credit Acct | Invalid credit card number |
223 | Expired Card | Credit card as expired and can not be processed |
225 | Invalid CVC | Invalid CVC or CVV2 value has been provided |
226 | Cannot Verify Pin | Card requires PIN |
240 | Refer to issuer | Generic decline by the issuing bank |
250 | Pick up card (no fraud) | Decline where issuer is requesting the merchant hold the card |
251 | Lost card, pick up (fraud account) | Decline where issuer is requesting the merchant hold the card |
252 | Stolen card, pick up (fraud account) | Decline where issuer is requesting the merchant hold the card |
253 | Pick up card, special condition | Decline where issuer is requesting the merchant hold the card |
261 | Stop recurring | Decline requesting recurring be stopped |
262 | Stop recurring | Decline requesting recurring be stopped |
300 | Gateway Decline | Generic Platform decline |
301 | Gateway Decline - Duplicate Transaction | The gateway detected this as a duplicate transaction. Order ID, payment type, amount and payment method are used to detect duplicate transactions. |
310 | Gateway Decline - Rule Engine | Platform has declined based on a fraud rule |
320 | Gateway Decline - Chargeback | The transaction was declined because the previous transaction was charged back |
321 | Gateway Decline - Stop Fraud | The transaction was declined because the customer record has been flagged as "stop_fraud" |
322 | Gateway Decline - Closed Contact | The transaction was declined because the customer record has been flagged as "closed_contact" |
323 | Gateway Decline - Stop Recurring | The transaction was declined because the customer record has been flagged as "stop_recurring" |
400 | Transaction error returned by processor | Generic error returned from the processor |
410 | Invalid merchant configuration | Configuration error returned from the processor |
421 | Communication error with processor | Processor is unreachable |
430 | Duplicate transaction at processor | Processor is seeing this as a duplicate transaction |
440 | Processor Format error | Processor has indicated that there is a formating error |
# Address Verification Response Codes (AVS)
AVS Response Code | Definition | Code Applies to | Card Brands |
---|---|---|---|
0 | AVS Not Available | Domestic + International | V, MC, AX, D, PP, JCB |
A | Address match only | Domestic + International | V, AX, D,PP, JCB |
B | Address matches, ZIP not verified | Domestic + International | V |
C | Incompatible format | Domestic + International | V |
D | Exact match | International | V |
F | Exact match, UK-issued cards | Domestic + International | V |
G | Non-U.S. Issuer does not participate | International | V |
I | Not verified | International | V, D, PP, JCB |
M | Exact match | International | V |
N | No address or ZIP match | Domestic + International | V, MC, AX, D, PP, JCB |
P | Postal Code match | Domestic + International | V |
R | Issuer system unavailable | Domestic | V, MC, AX, D, PP, JCB |
S | Service not supported | Domestic | MC, AX, D, PP, JCB |
U | Address unavailable | Domestic | V, MC, AX, D, PP, JCB |
W | 9-character numeric ZIP match only | Domestic + International (MC) | MC, D, PP, JCB |
X | Exact match, 9-character numeric ZIP | Domestic + International (MC) | MC, D, PP, JCB |
Y | Exact match, 5-character numeric ZIP | Domestic | V, MC, AX, D, PP, JCB |
Z | 5-character ZIP match only | Domestic + International (V) | V, MC, AX, D, PP, JCB |
L | Partial match, Name and billing postal code match | For AMEX cards only | AX |
1 | Cardholder name and ZIP match | Domestic | AX |
2 | Cardholder name, address and ZIP match | Domestic | AX |
3 | Cardholder name and address match | Domestic | AX |
4 | Cardholder name matches | Domestic | AX |
5 | Cardholder name incorrect, ZIP matches | Domestic | AX |
6 | Cardholder name incorrect, address and zip match | Domestic | AX |
7 | Cardholder name incorrect, address matches | Domestic | AX |
8 | Cardholder name, address, and ZIP do not match | Domestic | AX |
# Get Transaction By ID
Retrieve details for a specific transaction.
Request Method:
GET
URL Endpoint:
/api/transaction/{ transaction ID }
{
"status": "success",
"msg": "success",
"data": [
{
"id": "b7kgflt1tlv51er0fts0",
"type": "sale",
"amount": 1112,
"tax_amount": 100,
"tax_exempt": false,
"shipping_amount": 100,
"currency": "usd",
"description": "test transaction",
"order_id": "someOrderID",
"po_number": "somePONumber",
"ip_address": "4.2.2.2",
"email_receipt": false,
"payment_method": "card",
"response": {
"card": {
"id": "b7kgflt1tlv51er0ftsg",
"card_type": "visa",
"first_six": "401200",
"last_four": "5439",
"masked_card": "401200******5439",
"expiration_date": "12/20",
"status": "approved",
"auth_code": "TAS731",
"processor_response_code": "00",
"processor_response_text": "APPROVAL TAS731 ",
"processor_type": "tsys_sierra",
"processor_id": "b7kgflt1tlv51er0f1sg",
"avs_response_code": "0",
"cvv_response_code": "M",
"processor_specific": {},
"created_at": "2017-10-19T20:15:19.80368Z",
"updated_at": "2017-10-19T20:15:20.777011Z"
}
},
"status": "pending_settlement",
"billing_address": {
"first_name": "John",
"last_name": "Smith",
"company": "Test Company",
"address_line_1": "123 Some St",
"address_line_2": "",
"city": "Wheaton",
"state": "IL",
"postal_code": "60187",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "help@website.com"
},
"shipping_address": {
"first_name": "John",
"last_name": "Smith",
"company": "Test Company",
"address_line_1": "123 Some St",
"address_line_2": "",
"city": "Wheaton",
"state": "IL",
"postal_code": "60187",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "help@website.com"
},
"created_at": "2017-10-19T20:15:19.560708Z",
"updated_at": "2017-10-19T20:15:20.832049Z"
}
],
"total_count": 1
}
function getTransactionStatus(transactionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/transaction/" + transactionId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var status = result.data.status;
var response = result.data.response;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class TransactionStatusData {
public string Id { get; set; }
public string Type { get; set; }
public int Amount { get; set; }
public int Tax_amount { get; set; }
public bool Tax_exempt { get; set; }
public int Shipping_amount { get; set; }
public string Currency { get; set; }
public string Description { get; set; }
public string Order_id { get; set; }
public string Po_number { get; set; }
public string Ip_address { get; set; }
public string Email_receipt { get; set; }
public string Payment_method { get; set; }
public TransactionResponse Response { get; set; }
public string Status { get; set; }
public Address Billing_Address { get; set; }
public Address Shipping_Address { get; set; }
public DateTime Created_at { get; set; }
public DateTime Updated_at { get; set; }
}
public void getTransactionStatus(string transactionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/transaction/" + transactionId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
var apiResponse = JsonConvert.DeserializeObject<GetTransactionStatusResponse>(response);
if (apiResponse.Status === "success") {
// handle success
var status = apiResponse.Data.Status;
var response = apiResponse.Data.Response;
} else {
// handle non success
}
}
<?php
function getTransactionStatus($transactionId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/transaction/".$transactionId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class GetTransactionStatusResponse extends ApiResponse {
public TransactionStatusData data;
}
public class TransactionStatusData {
public String id;
public String type;
public int amount;
public int tax_amount;
public bool tax_exempt;
public int shipping_amount;
public String currency;
public String description;
public String order_id;
public String po_number;
public String ip_address;
public String email_receipt;
public String payment_method;
public TransactionResponse response;
public String status;
public Address billing_Address;
public Address shipping_Address;
public DateTime created_at;
public DateTime updated_at;
}
public void getTransactionStatus(String transactionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/transaction/" + transactionId)
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
GetTransactionStatusResponse entity = objectMapper.readValue(responseBody.string(), GetTransactionStatusResponse.class);
if (entity.status === "success") {
// handle success
String status = apiResponse.data.status;
String responseString = apiResponse.data.response;
} else {
// handle non success
}
}
# Search Transactions
Retrieve details for all transactions that match provided search criteria.
Request Method:
POST
URL Endpoint:
/api/transaction/search
Name | Type | Description |
---|---|---|
transaction_id | QuerySearchString | Searches for transaction id |
user_id | QuerySearchString | Searches for user_id |
type | QuerySearchString | Searches for transaction type (sale, authorize...etc) |
ip_address | QuerySearchString | Searches for ip_address, either ipv4 or ipv6 |
amount | QuerySearchInt | Searches for originally requested amount |
amount_authorized | QuerySearchInt | Searches for amount_authorized |
amount_captured | QuerySearchInt | Searches for amount_captured |
amount_settled | QuerySearchInt | Searches for amount_settled |
tax_amount | QuerySearchInt | Searches for tax_amount |
po_number | QuerySearchString | Searches for po_number |
order_id | QuerySearchString | Searches for order_id |
payment_method | QuerySearchString | Searches by payment_method, (token, card, terminal) |
payment_type | QuerySearchString | Searches by payment_type (card, echeck) |
status | QuerySearchString | Searches by transaction status (unknown, declined, authorized, pending_settlement, settled, voided, reversed, refunded) |
processor_id | QuerySearchString | Searches by processor_id |
customer_id | QuerySearchString | Searches by customer_id |
created_at | QueryDateRange | Searches by created_at between the provided start_date and end_date. (Dates in UTC "YYYY-MM-DDTHH:II:SSZ") |
captured_at | QueryDateRange | Searches by captured_at between the provided start_date and end_date. (Dates in UTC "YYYY-MM-DDTHH:II:SSZ") |
settled_at | QueryDateRange | Searches by settled_at between the provided start_date and end_date. (Dates in UTC "YYYY-MM-DDTHH:II:SSZ") |
billing_address .address_id | QuerySearchString | Searches by billing_address.id |
billing_address .first_name | QuerySearchString | Searches by billing_address.first_name (0-50 characters) |
billing_address .last_name | QuerySearchString | Searches by billing_address.last_name (0-50 characters) |
billing_address .company | QuerySearchString | Searches by billing_address.company (0-50 characters) |
billing_address .address_line_1 | QuerySearchString | Searches by billing_address.address_line_1 (0-100 characters) |
billing_address .address_line_2 | QuerySearchString | Searches by billing_address.address_line_2 (0-100 characters) |
billing_address .city | QuerySearchString | Searches by billing_address.city (0-50 characters) |
billing_address .state | QuerySearchString | Searches by billing_address.state (2 Character) |
billing_address .postal_code | QuerySearchString | Searches by billing_address.postal_code (0-6 Characters) |
billing_address .country | QuerySearchString | Searches by billing_address.country (2 Characters) |
billing_address | QuerySearchString | Searches by billing_address.email |
billing_address .phone | QuerySearchString | Searches by billing_address.phone (0-14 digits only) |
billing_address .fax | QuerySearchString | Searches by billing_address.fax (0-14 digits only) |
shipping_address .address_id | QuerySearchString | Searches by shipping_address.id |
shipping_address .first_name | QuerySearchString | Searches by shipping_address.first_name (0-50 characters) |
shipping_address .last_name | QuerySearchString | Searches by shipping_address.last_name (0-50 characters) |
shipping_address .company | QuerySearchString | Searches by shipping_address.company (0-50 characters) |
shipping_address .address_line_1 | QuerySearchString | Searches by shipping_address.address_line_1 (0-100 characters) |
shipping_address .address_line_2 | QuerySearchString | Searches by shipping_address.address_line_2 (0-100 characters) |
shipping_address .city | QuerySearchString | Searches by shipping_address.city (0-50 characters) |
shipping_address .state | QuerySearchString | Searches by shipping_address.state (2 Character) |
shipping_address .postal_code | QuerySearchString | Searches by shipping_address.postal_code (0-6 Characters) |
shipping_address .country | QuerySearchString | Searches by shipping_address.country (2 Characters) |
shipping_address | QuerySearchString | Searches by shipping_address.email |
shipping_address .phone | QuerySearchString | Searches by shipping_address.phone (0-14 digits only) |
shipping_address .fax | QuerySearchString | Searches by shipping_address.fax (0-14 digits only) |
limit | integer | |
offset | integer |
Request Body Type Values
Type | Operators |
---|---|
QuerySearchString | =, != |
QuerySearchInt | =, !=, <, > |
{
"status": "success",
"msg": "",
"total_count": 1,
"data": [
{
"id": "b84vgb2j8m0jujadi4v0",
"user_id": "aucio551tlv85l7moe60",
"idempotency_key": "",
"idempotency_time": 0,
"type": "sale",
"amount": 1112,
"amount_authorized": 1112,
"amount_captured": 1112,
"amount_settled": 0,
"processor_id": "aucio551tlv85l7moe7g",
"processor_type": "tsys_sierra",
"payment_method": "token",
"payment_type": "card",
"tax_amount": 100,
"tax_exempt": false,
"shipping_amount": 100,
"currency": "usd",
"description": "test transaction",
"order_id": "someOrderID",
"po_number": "somePONumber",
"ip_address": "?01",
"transaction_source": "api",
"email_receipt": false,
"customer_id": "b81ko5qq9qq5v460r9i0",
"referenced_transaction_id": "",
"response_body": {},
"status": "pending_settlement",
"response": "approved",
"response_code": 100,
"billing_address": {
"first_name": "John",
"last_name": "Smith",
"company": "Some Company",
"address_line_1": "123 Some St",
"address_line_2": "STE 203",
"city": "SomeTown",
"state": "IL",
"postal_code": "55555",
"country": "US",
"phone": "5555555555",
"fax": "",
"email": "info@website.com"
},
"shipping_address": {
"first_name": "John",
"last_name": "Smith",
"company": "Some Company",
"address_line_1": "123 Some St",
"address_line_2": "STE 203",
"city": "SomeTown",
"state": "IL",
"postal_code": "55555",
"country": "US",
"phone": "5555555555",
"fax": "",
"email": "info@website.com"
},
"created_at": "2017-11-13T19:53:17Z",
"updated_at": "2017-11-13T19:53:18Z",
"captured_at": null,
"settled_at": null
}
]
}
function searchTransactions(transactionId, amount, billingAddressFirstName) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
transaction_id: {
operator: "=",
value: transactionId,
},
amount: {
operator: "=",
value: amount,
},
billing_address: {
first_name: {
operator: "=",
value: billingAddressFirstName,
},
},
// ... other search criteria as needed
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/transaction/search", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success" && result.data.length) {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class QueryResponse : ApiResponse {
public List<TransactionData> Data { get; set; }
}
public class TransactionData {
public string Id { get; set; }
public string Type { get; set; }
public int Amount { get; set; }
public int Tax_amount { get; set; }
public bool Tax_exempt { get; set; }
public int Shipping_amount { get; set; }
public string Currency { get; set; }
public string Description { get; set; }
public string Order_id { get; set; }
public string Po_number { get; set; }
public string Ip_address { get; set; }
public string Email_receipt { get; set; }
public string Payment_method { get; set; }
public string Response { get; set; }
public string Status { get; set; }
public Address Billing_Address { get; set; }
public Address Shipping_Address { get; set; }
public DateTime Created_at { get; set; }
public DateTime Updated_at { get; set; }
}
public class OperatorValueCriteria {
public string Order { get; set; }
public T Value { get; set; }
}
public class AddressCriteria {
public OperatorValueCriteria First_name { get; set; }
}
public class SearchCriteria {
public OperatorValueCriteria Transaction_id { get; set; }
public OperatorValueCriteria Amount { get; set; }
public AddressCriteria Billing_Address { get; set; }
}
public void searchTransactions(SearchCriteria criteria) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/transaction/search");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", , ParameterType.RequestBody);
request.AddJsonBody(criteria);
IRestResponse response = client.Execute(request);
QueryResponse apiResponse = JsonConvert.DeserializeObject<QueryResponse>(response);
if (apiResponse.Status === "success" && apiResponse.Data.Count) {
// handle success
} else {
// handle non success
}
}
<?php
$transactionSearchCriteria = array(
"transaction_id" => array(
"operator" => "=",
"value" => "bsdk191erttqnm79q5lg"
),
"amount" => array(
"operator" => "=",
"value" => 1112
),
"billing_address" => array(
"first_name" => array(
"operator" => "=",
"value" => "John"
)
)
)
function searchTransactions($transactionSearchCriteria) {
$curl = curl_init();
$payload = json_encode($transactionSearchCriteria);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/transaction/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
if ($result["Status"] === "success") {
$transactions = $result["data"];
}
else {
}
curl_close($curl);
echo $response;
}
public class QueryResponse extends ApiResponse {
public List<TransactionData> data;
}
public class TransactionData {
public string id;
public string type;
public int amount;
@JsonProperty("tax_amount")
public int taxAmount;
@JsonProperty("tax_exempt")
public bool taxExempt;
@JsonProperty("shipping_amount")
public int shippingAmount;
public string currency;
public string description;
@JsonProperty("order_id")
public string orderId;
@JsonProperty("po_number")
public string poNumber;
@JsonProperty("ip_address")
public string ipAddress;
@JsonProperty("email_receipt")
public string emailReceipt;
@JsonProperty("payment_method")
public string paymentMethod;
public string response;
public string status;
@JsonProperty("billing_address")
public Address billingAddress;
@JsonProperty("shipping_address")
public Address shippingAddress;
@JsonProperty("created_at")
public DateTime createdAt;
@JsonProperty("updated_at")
public DateTime updatedAt;
}
public class OperatorValueCriteria {
public string order;
public T value;
}
public class AddressCriteria {
@JsonProperty("first_name")
public OperatorValueCriteria firstName;
}
public class SearchCriteria {
@JsonProperty("transaction_id")
public OperatorValueCriteria transactionId;
public OperatorValueCriteria amount;
@JsonProperty("billing_address")
public AddressCriteria billingAddress;
}
public void searchTransactions(SearchCriteria criteria) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(request);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/transaction/search")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
QueryResponse entity = objectMapper.readValue(responseBody.string(), QueryResponse.class);
if (entity.status === "success") {
// handle success
var transactions = entity.Data;
} else {
// handle non success
}
}
# Capture
Capture funds for a specified transaction that has already been authorized.
Request Method:
POST
URL Endpoint:
/api/transaction/{ transaction ID }/capture
Name | Type | Default | Description | Required |
---|---|---|---|---|
amount | integer | amount from auth | Total amount to capture, in cents. (1299 = $12.99) | |
tax_amount | integer | tax_amount from auth | Tax amount to capture, in cents. (199 = $1.99) | |
shipping_amount | integer | shipping_amount from auth | Shipping amount to capture, in cents. (299 = $2.99) | |
tax_exempt | boolean | false | Is the transaction tax exempt | |
order_id | string | order_id from auth | Alphanumeric (max 17 characters) | |
po_number | string | po_number from auth | Alphanumeric (max 17 characters) | |
ip_address | string | ip_address from auth | IPV4 or IPV6 address |
{
"status": "success",
"msg": "success",
"data": null
}
function captureFunds(transactionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
amount: 1000,
tax_amount: 100,
tax_exempt: false,
shipping_amount: 0,
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/transaction/" + transactionId + "/capture",
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class TransactionCaptureRequest {
public int Amount { get; set; }
[JsonProperty("tax_amount")]
public int TaxAmount { get; set; }
[JsonProperty("tax_exempt")]
public bool TaxExempt { get; set; }
[JsonProperty("shipping_amount")]
public int ShippingAmount { get; set; }
}
public void captureFunds(TransactionCaptureRequest request) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/transaction/bsdk191erttqnm79q5lg/capture");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(request);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<php?
$transaction = array(
"amount" => 1000,
"tax_amount" => 100,
"tax_exempt" => false,
"shipping_amount" => 0
);
function captureFunds($transaction) {
$curl = curl_init();
$payload = json_encode($transaction);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/transaction/".$transaction->transactionId."/capture",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
public class TransactionCaptureRequest {
@JsonProperty("transaction_id")
public string transactionId;
public int amount;
@JsonProperty("tax_amount")
public int taxAmount;
@JsonProperty("tax_exempt")
public boolean taxExempt;
@JsonProperty("shipping_amount")
public int shippingAmount;
}
public void captureFunds(TransactionCaptureRequest request) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(request);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/transaction/" + request.TransactionId + "/capture")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse response = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (response.status === "success") {
// handle success
} else {
// handle non success
}
}
# Void / Auth Reversal
Void a transaction that is pending settlement. Where applicable, a void will be processed as an auth reversal.
Request Method:
POST
URL Endpoint:
/api/transaction/{ transaction ID }/void
{
"status": "success",
"msg": "success",
"data": null
}
function voidTransaction(transactionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "POST",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/transaction/" + transactionId + "/void",
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void voidTransaction(string transactionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/transaction/" + transactionId + "/void");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "<api key>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function voidTransaction($transaction) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/transaction/".$transaction->id."/void",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
public void voidTransaction(int transactionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/transaction/" + transactionId + "/void")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse response = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (response.status === "success") {
// handle success
} else {
// handle non success
}
}
# Refund
Process a refund for a transaction that has already been settled. Multiple partial refunds can be processed, but the total amount of all refunds cannot exceed the previously settled amount.
Request Method:
POST
URL Endpoint:
/api/transaction/{ transaction ID }/refund
Name | Type | Default | Description | Required |
---|---|---|---|---|
amount | integer | amount from auth | Total amount to capture, in cents. (1299 = $12.99) |
{
"status": "success",
"msg": "success",
"data": null
}
function refundTransaction(transactionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({ amount: 1000 });
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/transaction/" + transactionId + "/refund",
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void refundTransaction(string transactionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/transaction/" + transactionId + "/refund");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "<api key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n \"amount\": 1000\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function refundTransaction($transaction) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/transaction/".$transaction->id."/refund",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"amount\": 1000\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
public void refundTransaction(int transactionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \"amount\": 1000}");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/transaction/" + transactionId + "/refund")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse response = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (response.status === "success") {
// handle success
} else {
// handle non success
}
}
# Settlement Batches
# Search Settlement Batches
Retrieve details for all settlement batches that match provided search criteria.
Request Method:
POST
URL Endpoint:
/api/settlement/batch/search
Name | Type | Default | Description | Required |
---|---|---|---|---|
batch_date | object | Object containing details defining a batch date range | ||
batch_date .start_date | string | "" | Searches by batch_date between the provided start_date and end_date. (Dates in UTC "YYYY-MM-DDTHH:II:SSZ") | |
batch_date .end_date | string | "" | Searches by batch_date between the provided start_date and end_date. (Dates in UTC "YYYY-MM-DDTHH:II:SSZ") | |
settlement_batch_id | object | Object containing details defining a range of id's | ||
settlement_batch_id .operator | string literal | "=" or "!=" | ||
settlement_batch_id .value | string | The settlement batch id to match or exclude | ||
limit | integer | 10 | The number of results to return (1-100) | |
offset | integer | 0 | The number of results to skip (1-1000) |
{
"status": "success",
"msg": "success",
"data": {
"summary": [
{
"merchant_id": "aaaaaaaaaaaaaaaaaaaa",
"batch_date": "2018-12-04",
"processor_id": "bbbbbbbbbbbbbbbbbbbb",
"processor_name": "main mid",
"num_transactions": 1,
"captured": 10000,
"credit": 0
}
],
"results": [
{
"id": "cccccccccccccccccccc",
"merchant_id": "aaaaaaaaaaaaaaaaaaaa",
"batch_date": "2018-12-04T13:31:02Z",
"processor_id": "bbbbbbbbbbbbbbbbbbbb",
"processor_name": "main mid",
"processor_type": "tsys_sierra",
"batch_number": 1,
"num_transactions": 1,
"amount_captured": 10000,
"amount_credit": 0,
"net_deposit": 10000,
"response_code": 100,
"response_message": " ACCEPT"
}
]
},
"total_count": 1
}
function searchSettlements() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
batch_date: {
start_date: "2018-12-01T00:00:00Z",
end_date: "2018-12-26T23:59:59Z",
},
offset: 0,
limit: 10,
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/settlement/batch/search", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class ApiResponse {
public string Status { get; set; }
public string Msg { get; set; }
public ResponseData Data { get; set; }
[JsonProperty("total_count")]
public int TotalCount { get; set; }
// totalCount
}
public class ResponseData {
public SummaryRecord Summary { get; set; }
public List<ResultRecord> Results { get; set; }
}
public class SummaryRecord {
public string MerchantId { get; set; }
[JsonProperty("batch_date")]
public string BatchDate { get; set; }
[JsonProperty("processor_id")]
public string ProcessorId { get; set; }
[JsonProperty("processor_name")]
public string ProcessorName { get; set; }
[JsonProperty("num_transactions")]
public int NumTransactions { get; set; }
public int Captured { get; set; }
public int Credit { get; set; }
}
public class ResultRecord {
public string Id { get; set; }
[JsonProperty("merchant_id")]
public string MerchantId { get; set; }
[JsonProperty("batch_date")]
public DateTime BatchDate { get; set; }
public string ProcessorId { get; set; }
[JsonProperty("processor_name")]
public string ProcessorName { get; set; }
[JsonProperty("num_transactions")]
public int NumTransactions { get; set; }
[JsonProperty("amount_captured")]
public int AmountCaptured { get; set; }
[JsonProperty("amount_credit")]
public int AmountCredit { get; set; }
[JsonProperty("processor_type")]
public string ProcessorType { get; set; }
[JsonProperty("batch_number")]
public int BatchNumber { get; set; }
[JsonProperty("net_deposit")]
public int NetDeposit { get; set; }
[JsonProperty("response_code")]
public int ResponseCode { get; set; }
[JsonProperty("response_message")]
public string ResponseMessage { get; set; }
}
public class BatchDate {
[JsonProperty("start_date")]
public DateTime StartDate { get; set; }
[JsonProperty("end_date")]
public DateTime EndDate { get; set; }
}
public class SearchCriteria {
[JsonProperty("batch_date")]
public BatchDate BatchDate { get; set; }
public int Offset { get; set; }
public int Limit { get; set; }
}
public void searchSettlements(SearchCriteria criteria) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/settlement/batch/search");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(criteria);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
SummaryRecord summary = apiResponse.Data.Summary;
java.util.ArrayList<ResultRecord> results = apiResponse.Data.Results;
} else {
// handle non success
}
}
<?php
$criteria = array(
"batch_date" => array(
"start_date" => "2018-12-01T00:00:00Z",
"end_date" => "2018-12-26T23:59:59Z"
),
"offset" => 0,
"limit" => 10
);
function searchSettlements($criteria) {
$curl = curl_init();
$payload = json_encode($criteria);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/settlement/batch/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class ApiResponse {
public String status;
public String msg;
public ResponseData data;
@JsonProperty("total_count")
public int totalCount;
// totalCount
}
public class ResponseData {
public SummaryRecord summary;
public java.util.ArrayList<ResultRecord> results;
}
public class SummaryRecord {
public String merchantId;
@JsonProperty("batch_date")
public String batchDate;
@JsonProperty("processor_id")
public String processorId;
@JsonProperty("processor_name")
public String processorName;
@JsonProperty("num_transactions")
public int numTransactions;
public int captured;
public int credit;
}
public class ResultRecord {
public String id;
@JsonProperty("merchant_id")
public String merchantId;
@JsonProperty("batch_date")
public DateTime batchDate;
public String processorId;
@JsonProperty("processor_name")
public String processorName;
@JsonProperty("num_transactions")
public int numTransactions;
@JsonProperty("amount_captured")
public int amountCaptured;
@JsonProperty("amount_credit")
public int amountCredit;
@JsonProperty("processor_type")
public String processorType;
@JsonProperty("batch_number")
public int batchNumber;
@JsonProperty("net_deposit")
public int netDeposit;
@JsonProperty("response_code")
public int responseCode;
@JsonProperty("response_message")
public String responseMessage;
}
public class BatchDate {
@JsonProperty("start_date")
public DateTime startDate;
@JsonProperty("end_date")
public DateTime endDate;
}
public class SearchCriteria {
@JsonProperty("batch_date")
public BatchDate batchDate;
public int offset;
public int limit;
}
public void searchSettlements(SearchCriteria criteria) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(criteria);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/settlement/batch/search")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
SummaryRecord summary = apiResponse.data.summary;
java.util.ArrayList<ResultRecord> results = apiResponse.data.results;
} else {
// handle non success
}
}
# File Batch
# Upload Batch File
Upload a CSV file for batch processing.
TIP
CSV File Format
The input file for the upload endpoint should contain records to process in the following format (example below):
- First row should be a header using the fields below, fields can be in any order and not all fields are required.
- Each field should be wrapped in quotes and should not contain any quotes
- Each field should be seperated with a comma
- Each row should be terminated with a newline \n character.
Request Method:
POST
URL Endpoint:
/api/filebatch
Name | Type | Default | Description | Required |
---|---|---|---|---|
transaction_type | string | "verification", "authorize", "capture", "sale", "credit" or "refund" | * | |
cc_number | string | CC Number | if credit card | |
cc_expiration | string | CC Expiration Date | if credit card | |
cc_cvc | string | Optional unless your account requires CVC for processing | ||
ach_account_number | string | ACH account number | if ACH | |
ach_routing_number | string | ACH routing number | if ACH | |
ach_account_type | string | "checking" or "savings" | if ACH | |
ach_sec_code | string | SEC code: "WEB", "CCD", or "PPD" | if ACH | |
customer_id | string | customer vault id to charge | if using customer vault | |
amount | integer | Total amount to process in cents (100 = $1.00) | * | |
shipping_amount | integer | Shipping amount to process in cents (100 = $1.00) | ||
tax_amount | integer | Tax amount to process in cents (100 = $1.00) | ||
discount_amount | integer | Discount amount to process in cents (100 = $1.00) | ||
order_id | string | Alphanumeric string for reference (max 17 characters) | ||
description | string | Alphanumeric string for notes (max 100 characters) | ||
po_number | string | Alphanumeric string for reference (max 17 characters) | ||
tax_exempt | boolean | false | is the transaction tax exempt | |
email_address | string | Email address to tag to the transaction, emails are not sent. | ||
processor_id | string | Processor ID to process the transaction, otherwise the default is used. | ||
billing_first_name | string | |||
billing_last_name | string | |||
billing_company | string | |||
billing_address_line_1 | string | |||
billing_address_line_2 | string | |||
billing_city | string | |||
billing_state | string | |||
billing_postal_code | string | |||
billing_country | string | |||
billing_phone | string | |||
billing_fax | string | |||
billing_email | string | |||
shipping_first_name | string | |||
shipping_last_name | string | |||
shipping_company | string | |||
shipping_address_line_1 | string | |||
shipping_address_line_2 | string | |||
shipping_city | string | |||
shipping_state | string | |||
shipping_postal_code | string | |||
shipping_country | string | |||
shipping_phone | string | |||
shipping_fax | string | |||
shipping_email | string |
function uploadFile() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var formdata = new FormData();
formdata.append("file", "testBatch.csv");
var requestOptions = {
method: "POST",
headers: myHeaders,
body: formdata,
redirect: "follow",
};
fetch("https://sandbox.durangomsgateway.com/api/filebatch", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var batchId = result.data.id;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class ApiResponse {
public string Status { get; set; }
public string Msg { get; set; }
}
public class Batch {
public string Id { get; set; }
[JsonProperty("file_name")]
public string FileName { get; set; }
public string Status { get; set; }
[JsonProperty("num_lines")]
public string NumLines { get; set; }
[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
}
public class BatchResponse : ApiResponse {
public Batch Data { get; set; }
}
public void uploadFile(string filePath, string contentType) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/filebatch");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AlwaysMultipartFormData = true;
request.AddFile("file", filePath, contentType);
IRestResponse response = client.Execute(request);
BatchResponse apiResponse = JsonConvert.DeserializeObject\>BatchResponse>(response);
if (apiResponse.Status === "success") {
// handle success
string newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
<?php
function uploadFile() {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/filebatch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array("file" => $_FILES["userfile"]["tmp_name"]),
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
json_decode($response);
curl_close($curl);
echo $response;
}
public class ApiResponse {
String status;
String msg;
}
public class BatchData {
String id;
@JsonProperty("file_name")
String fileName;
String status;
@JsonProperty("num_lines")
String numLines;
@JsonProperty("created_at")
String createdAt;
@JsonProperty("updated_at")
String updatedAt;
}
public class BatchResponse extends ApiResponse {
BatchData data;
}
public void uploadFile(String filePath) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file", filePath)
.build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/filebatch")
.method("POST", body)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
BatchResponse apiResponse = objectMapper.readValue(responseBody.string(), BatchResponse.class);
if (apiResponse.status === "success") {
// handle success
String newId = apiResponse.data.id;
} else {
// handle non success
}
}
# Get Batch Status
Get the current status of a specified settlement batch.
Request Method:
GET
URL Endpoint:
/api/filebatch/{ batch id }
function getBatchStatus(batchId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/filebatch/" + batchId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var message = result.msg;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void getBatchStatus(string batchId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/filebatch/" + batchId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject\>ApiResponse>(response.Content);
if (apiResponse.Status === "success") {
// handle success
string message = apiResponse.Msg;
} else {
// handle non success
}
}
<?php
function getBatchStatus($batchId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/filebatch/".$batchId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
json_decode($response);
curl_close($curl);
echo $response;
}
public void getBatchStatus(String batchId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/filebatch/" + batchId)
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
String message = apiResponse.msg;
} else {
// handle non success
}
}
# Download Batch File
Returns a CSV text response for the specified batch.
Request Method:
GET
URL Endpoint:
/api/filebatch/{ batch id }/download
function downloadBatchFile(batchId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/filebatch/" + batchId + "/download",
requestOptions
)
.then((response) => {
if (response.ok) {
return response.text().then((csvData) => {
// return csv file.. csvData
});
} else {
return response.text().then((result) => {
var msg = result.msg;
});
}
})
.catch((error) => console.log("error", error));
}
public void downloadBatchFile(string batchId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/filebatch/" + batchId + "/download");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
if (response.StatusCode == HttpStatusCode.OK) {
byte[] bytes = Encoding.ASCII.GetBytes(response.Content);
var resultFile = new File(DeriveBytes, "text/csv", "results.csv");
}
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response.Content);
string message = apiResponse.Msg;
}
<?php
function downloadBatchFile($batchId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/filebatch/".$batchId."/download",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
public void downloadBatchFile(String batchId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/filebatch/" + batchId + "/download")
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ResponseBody responseBody = response.body();
if (response.getStatus() == Response.Status.OK.getStatusCode()) {
String responseCSVString = responseBody.string();
} else {
ObjectMapper objectMapper = new ObjectMapper();
ApiResponse apiResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
String message = apiResponse.msg;
} else {
// handle non success
}
}
}
# Recurring
# Create Add-On
Create a new recurring plan add-on. Add-ons are used to adjust a recurring charge amount, either by a set amount or a percentage of the subscription amount.
Request Method:
POST
URL Endpoint:
/api/recurring/addon
Name | Type | Default | Description | Required |
---|---|---|---|---|
name | string | "" | Display name for the add-on | |
description | string | "" | Description for the add-on | |
amount | integer | null | Amount to be added in cents (100 = $1.00) | * (see note below) |
percentage | integer | null | Percentage of original charge to be added (must be 0 or a percentage between .1% and 100%, expressed in thousandths. 43440 = 43.440%) | * (see note below) |
duration | integer | 0 | Number of times for the add-on to be billed (use 0 if you want the add-on to persist until cancelled) |
TIP
Either amount or percentage may be provided, but not both.
:::
{
"status": "success",
"msg": "success",
"data": {
"id": "b89ffdqj8m0o735i19i0",
"name": "test plan",
"description": "just a simple test plan",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": "2017-11-20T15:41:43.330315Z",
"updated_at": "2017-11-20T15:41:43.330315Z"
}
}
function createAddOn() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
name: "test plan",
description: "just a simple test plan",
amount: 100,
duration: 0,
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/addon", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class ApiResponse {
public string Status { get; set; }
public string Msg { get; set; }
}
public class AddOnResponse : ApiResponse {
public AddOn Data { get; set; }
}
public class AddOn {
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int Amount { get; set; }
public int Percentage { get; set; }
public int Duration { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
public void createAddOn(AddOn addon) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/addon");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(addon);
IRestResponse response = client.Execute(request);
AddOnResponse apiResponse = JsonConvert.DeserializeObject<AddOnResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
$addOn = array(
"name" => "test plan",
"description" => "just a simple test plan",
"amount" => 100,
"duration" => 0
);
function createAddOn($addOn) {
$curl = curl_init();
$payload = json_encode($addOn);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/addon",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class ApiResponse {
String status;
String msg;
}
public class AddOnResponse extends ApiResponse {
AddOn data;
}
public class AddOn {
String id;
String name;
String description;
int amount;
int percentage;
int duration;
java.util.Date createdAt;
java.util.Date updatedAt;
}
public void createAddOn(AddOn addon) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(addon);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/addon")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
AddOnResponse apiResponse = objectMapper.readValue(responseBody.String(), AddOnResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Get Add-On By ID
Retrieve details for the specified add-on.
Request Method:
GET
URL Endpoint:
/api/recurring/addon/{ add-on id }
{
"status": "success",
"msg": "success",
"data": {
"id": "b89ffdqj8m0o735i19i0",
"name": "test plan",
"description": "just a simple test plan",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": "2017-11-20T15:41:43.330315Z",
"updated_at": "2017-11-20T15:41:43.330315Z"
}
}
function getAddOn(addOnId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/addon/" + addOnId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var addon = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void getAddOn(string addOnId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/addon/" + addOnId);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
AddOnResponse apiResponse = JsonConvert.DeserializeObject<AddOnResponse>(response);
if (apiResponse.Status === "success") {
// handle success
AddOn addon = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getAddOn($addOnId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/addon/".$addOnId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getAddOn(String addOnId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/addon/" + addOnId)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
AddOnResponse apiResponse = objectMapper.readValue(responseBody.String(), AddOnResponse.class);
if (apiResponse.status === "success") {
// handle success
AddOn addon = apiResponse.data;
} else {
// handle non success
}
}
# Get All Add-Ons
Retrieve details for all add-ons accosciated with the gateway account.
Request Method:
GET
URL Endpoint:
/api/recurring/addons
{
"status": "success",
"msg": "success",
"data": [
{
"id": "b75cvl51tlv38t0o7o30",
"name": "test_addon",
"description": "some description",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": "2017-09-26T22:08:20Z",
"updated_at": "2017-09-26T22:08:20Z"
},
{
"id": "b779mpt1tlv96kdv2n20",
"name": "test_addon_percent",
"description": "",
"amount": null,
"percentage": 10,
"duration": 0,
"created_at": "2017-10-09T20:39:41Z",
"updated_at": "2017-10-09T20:39:41Z"
},
{
"id": "b89ffdqj8m0o735i19i0",
"name": "test plan",
"description": "just a simple test plan",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": "2017-11-20T15:41:43Z",
"updated_at": "2017-11-20T15:41:43Z"
}
],
"total_count": 3
}
function getAllAddOns() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/addons", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var addons = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class AllAddOnsResponse : ApiResponse {
public List<AddOn> Data { get; set; }
public int TotalCount { get; set; }
}
public void getAllAddOns() {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/addons");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
AllAddOnsResponse apiResponse = JsonConvert.DeserializeObject<AllAddOnsResponse>(response);
if (apiResponse.Status === "success") {
// handle success
List<AddOn> addons = apiResponse.Data;
int total = apiResponse.TotalCount;
} else {
// handle non success
}
}
<?php
function getAllAddOns() {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/addons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class AllAddOnsResponse extends ApiResponse {
java.util.ArrayList<AddOn> data;
int totalCount;
}
public void getAllAddOns() {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/addons")
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
AllAddOnsResponse apiResponse = objectMapper.readValue(responseBody.String(), AllAddOnsResponse.class);
if (apiResponse.status === "success") {
// handle success
java.util.ArrayList<AddOn> addon = apiResponse.data;
int total = apiResponse.totalCount;
} else {
// handle non success
}
}
# Update Add-On
Edit details for the specified add-on.
Request Method:
POST
URL Endpoint:
/api/recurring/addon/{ add-on id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
name | string | "" | Display name for the add-on | |
description | string | "" | Description for the add-on | |
amount | integer | null | Amount to be added in cents (100 = $1.00) | * (see note below) |
percentage | integer | null | Percentage of original charge to be added (must be 0 or a percentage between .1% and 100%, expressed in thousandths. 43440 = 43.440%) | * (see note below) |
duration | integer | 0 | Number of times for the add-on to be billed (use 0 if you want the subscription to persist until cancelled) |
TIP
Either amount or percentage may be provided, but not both.
:::
{
"status": "success",
"msg": "success",
"data": {
"id": "b89ffdqj8m0o735i19i0",
"name": "test plan",
"description": "just a simple test plan",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": "2017-11-20T15:41:43.330315Z",
"updated_at": "2017-11-20T15:41:43.330315Z"
}
}
function updateAddOn(addOnId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
name: "test plan",
description: "just a simple test plan",
amount: 100,
duration: 0,
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/addon/" + addOnId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void updateAddOn(AddOn addon) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/addon/" + addon.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(addon);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function updateAddOn($addOn) {
$curl = curl_init();
$payload = json_encode($addOn);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/addon/".$addOn->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updateAddOn(AddOn addon) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(addon);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/addon/" + addon.id
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.String(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Delete Add-On
Delete the specified add-on.
Request Method:
DELETE
URL Endpoint:
/api/recurring/addon/{ add-on id }
{
"status": "success",
"msg": "success",
"data": null
}
function deleteAddOn(addOnId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/addon/" + addOnId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void deleteAddOn(string addonId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/addon/" + addonId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deleteAddOn($addOn) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/addon/".$addOn->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deleteAddOn(String addOnId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/addon/" + addOnId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ApiResponse apiResponse = objectMapper.readValue(responseBody.String(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
java.util.ArrayList<AddOn> addon = apiResponse.data;
int total = apiResponse.totalCount;
} else {
// handle non success
}
}
# Create Discount
Create a new recurring plan discount. Discounts are used to adjust a recurring charge amount either by a set amount or a percentage of the subscription amount.
Request Method:
POST
URL Endpoint:
/api/recurring/discount
Name | Type | Default | Description | Required |
---|---|---|---|---|
name | string | "" | Display name for the discount | |
description | string | "" | Description for the discount | |
amount | integer | null | Amount to be discounted in cents (100 = $1.00) | * (see note below) |
percentage | integer | null | Percentage of original charge to be discounted (must be 0 or a percentage between .1% and 100%, expressed in thousandths. 43440 = 43.440%) | * (see note below) |
duration | integer | 0 | Number of times for the discount to be billed (use 0 if you want the discount to persist until cancelled) |
TIP
Either amount or percentage may be provided, but not both.
:::
{
"status": "success",
"msg": "success",
"data": {
"id": "b89flfqj8m0o735i19ig",
"name": "test discount",
"description": "just a simple test discount",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": "2017-11-20T15:54:39.851636Z",
"updated_at": "2017-11-20T15:54:39.851636Z"
}
}
function createDiscount() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
name: "test discount",
description: "just a simple test discount",
amount: 100,
duration: 0,
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/discount", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var newId = result.data.id;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class Discount {
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int Amount { get; set; }
public int Duration { get; set; }
public int Percentage { get; set; }
public DateTime CreateAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
public class DiscountResponse : ApiResponse {
public Discount Data { get; set; }
}
public void createDiscount(Discount discount) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/discount");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(discount);
IRestResponse response = client.Execute(request);
DiscountResponse apiResponse = JsonConvert.DeserializeObject<DiscountResponse>(response);
if (apiResponse.Status === "success") {
// handle success
var newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
<?php
$discount = array(
"name" => "test discount",
"description" => "just a simple test discount",
"amount" => 100,
"duration" => 0
);
function createDiscount($discount) {
$curl = curl_init();
$payload = json_encode($discount);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/discount",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class Discount {
String id;
String name;
String description;
int amount;
int duration;
int percentage;
java.util.Date createAt;
java.util.Date updatedAt;
}
public class DiscountResponse extends ApiResponse {
Discount data;
}
public void createDiscount(Discount discount) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(discount);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/discount")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
DiscountResponse apiResponse = objectMapper.readValue(responseBody.String(), DiscountResponse.class);
if (apiResponse.status === "success") {
// handle success
var newId = apiResponse.data.Id;
} else {
// handle non success
}
}
# Get Discount By ID
Retrieve details for the specified discount.
Request Method:
GET
URL Endpoint:
/api/recurring/discount/{ discount id }
{
"status": "success",
"msg": "success",
"data": {
"id": "b89flfqj8m0o735i19ig",
"name": "test discount",
"description": "just a simple test discount",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": "2017-11-20T15:54:39.851636Z",
"updated_at": "2017-11-20T15:54:39.851636Z"
}
}
function getDiscount(discountId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/recurring/discount/" + discountId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var discount = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void getDiscount(string discountId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/discount/" + discountId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
DiscountResponse apiResponse = JsonConvert.DeserializeObject<DiscountResponse>(response);
if (apiResponse.Status === "success") {
// handle success
var discount = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getDiscount($discountId)
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/discount/".$discountId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$discountId,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getDiscount(String discountId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/discount/" + discountId)
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
DiscountResponse apiResponse = objectMapper.readValue(responseBody.String(), DiscountResponse.class);
if (apiResponse.status === "success") {
// handle success
var discount = apiResponse.data;
} else {
// handle non success
}
}
# Get All Discounts
Retrieve the properties of all discounts for the gateway account associated with the API Key or JWT token provided in the Authorization header.
Request Method:
GET
URL Endpoint:
/api/recurring/discounts
{
"status": "success",
"msg": "success",
"data": [
{
"id": "b89flfqj8m0o735i19ig",
"name": "test discount",
"description": "just a simple test discount",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": "2017-11-20T15:54:40Z",
"updated_at": "2017-11-20T15:54:40Z"
},
{
"id": "b779mpt1tlv96kdv2n20",
"name": "test_discount_percent",
"description": "",
"amount": null,
"percentage": 10,
"duration": 0,
"created_at": "2017-10-09T20:59:52Z",
"updated_at": "2017-10-09T20:59:52Z"
}
],
"total_count": 2
}
function getAllDiscounts() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/discounts", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var discounts = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class AllDiscountsResponse : ApiResponse {
public List<Discount> Data { get; set; }
}
public void getAllDiscounts() {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/discounts");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
AllDiscountsResponse apiResponse = JsonConvert.DeserializeObject<AllDiscountsResponse>(response);
if (apiResponse.Status === "success") {
// handle success
var discounts = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getAllDiscounts() {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/discounts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class AllDiscountsResponse extends ApiResponse {
java.util.ArrayList<Discount> data;
}
public void getAllDiscounts() {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/discounts")
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
AllDiscountsResponse apiResponse = objectMapper.readValue(responseBody.String(), AllDiscountsResponse.class);
if (apiResponse.status === "success") {
// handle success
var discounts = apiResponse.data;
} else {
// handle success
}
}
# Update Discount
Edit details for the specified discount.
Request Method:
POST
URL Endpoint:
/api/recurring/discount/{ discount id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
name | string | "" | Display name for the discount | |
description | string | "" | Description for the discount | |
amount | integer | null | Amount to be discounted in cents (100 = $1.00) | * (see note below) |
percentage | integer | null | Percentage of original charge to be discounted (must be 0 or a percentage between .1% and 100%, expressed in thousandths. 43440 = 43.440%) | * (see note below) |
duration | integer | 0 | Number of times for the discount to be billed (use 0 if you want the discount to persist until cancelled) |
TIP
Either amount or percentage may be provided, but not both.
:::
{
"status": "success",
"msg": "success",
"data": {
"id": "b89flfqj8m0o735i19ig",
"name": "test discount",
"description": "just a simple test discount",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": "2017-11-20T15:54:39.851636Z",
"updated_at": "2017-11-20T15:54:39.851636Z"
}
}
function updateDiscount(discountId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
name: "test discount",
description: "just a simple test discount",
amount: 120,
duration: 0,
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/recurring/discount/" + discountId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void updateDiscount(Discount discount) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/discount/" + discount.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(discount);
IRestResponse response = client.Execute(request);
DiscountResponse apiResponse = JsonConvert.DeserializeObject<DiscountResponse>(response);
if (apiResponse.Status === "success") {
// handle success
var discount = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function updateDiscount($discount) {
$curl = curl_init();
$payload = json_encode($discount);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/discount/".$discount->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updateDiscount(Discount discount) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(discount);
RequestBody body = RequestBody.create(mediaType, "{\n \"name\": \"test discount\",\n \"description\": \"just a simple test discount\",\n \"amount\": 120,\n \"duration\": 0\n }");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/discount/" + discount.id)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
DiscountResponse apiResponse = objectMapper.readValue(responseBody.String(), DiscountResponse.class);
if (apiResponse.status === "success") {
// handle success
var discount = apiResponse.data;
} else {
// handle non success
}
}
# Delete Discount
Delete the specified discount.
Request Method:
DELETE
URL Endpoint:
/api/recurring/discount/{ discount id }
{
"status": "success",
"msg": "success",
"data": null
}
function deleteDiscount(discountId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/recurring/discount/" + discountId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var discount = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void deleteDiscount(string discountId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/discount/" + discountId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deleteDiscount($discountId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/discount/".$discountId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deleteDiscount(String discountId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/discount/" + discountId)
.method("DELETE", body)
.addHeader("Authorization", apiKey
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.String(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Create Plan
Creates a new recurring plan with discounts and/or add-ons.
Request Method:
POST
URL Endpoint:
/api/recurring/plan
Name | Type | Default | Description | Required |
---|---|---|---|---|
name | string | "" | Display name for the plan | |
description | string | "" | Description for the plan | |
amount | integer | null | Amount to be billed in cents (100 = $1.00) | * |
billing_cycle_interval | integer | null | How often to run the billing cycle (run every X months) | * |
billing_frequency | string literal | "monthly" | How often to run the plan within a billing cycle. ("monthly", "twice_monthly", "daily") | * |
billing_days | string | null | Which day of the month to bill on. If "twice_monthly" then comma separate dates ("1, 15"). For the last day of the month, use "0". | * |
duration | integer | 0 | Number of times for the discount to be billed (use 0 if you want the plan to persist until cancelled) | |
add_ons | array of objects | Enumerates add-ons for a recurring plan | ||
add_ons[#] .id | string | ID of the referenced add_on | ||
add_ons[#] .name | string | Display name for the add_on (optional, this overrides the add_ons value) | ||
add_ons[#] .description | string | Description for the add_on (optional, this overrides the add_ons value) | ||
add_ons[#] .amount | int | Amount to be added (optional, this overrides the add_ons value) | ||
add_ons[#] .duration | int | Duration for the add_on to be billed (optional, this overrides the add_ons value) | ||
discounts | array of objects | Enumerates discounts for a recurring plan | ||
discounts[#] .id | string | ID of the referenced discount | ||
discounts[#] .name | string | Display name for the discount (optional, this overrides the discount value) | ||
discounts[#] .description | string | Description for the discount (optional, this overrides the discount value) | ||
discounts[#] .amount | int | Amount to be discounted (optional, this overrides the discount value) | ||
discounts[#] .duration | int | Duration for the discount to be billed (optional, this overrides the discount value) |
{
"status": "success",
"msg": "success",
"data": {
"id": "b89g35qj8m0o735i19jg",
"name": "test plan",
"description": "just a simple test plan",
"amount": 100,
"billing_cycle_interval": 1,
"billing_frequency": "twice_monthly",
"billing_days": "1,15",
"total_add_ons": 100,
"total_discounts": 50,
"duration": 0,
"add_ons": [
{
"id": "b75cvl51tlv38t0o7o30",
"name": "test_addon",
"description": "this will add to the cost of the subscription",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": null,
"updated_at": null
}
],
"discounts": [
{
"id": "b89flfqj8m0o735i19ig",
"name": "test discount",
"description": "this will discount the cost of the subscription",
"amount": 50,
"percentage": null,
"duration": 0,
"created_at": null,
"updated_at": null
}
],
"created_at": "2017-11-20T16:23:51.990051Z",
"updated_at": "2017-11-20T16:23:51.990051Z"
}
}
function createPlan() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "__cfduid=123abc");
var raw = JSON.stringify({
name: "test plan",
description: "just a simple test plan",
amount: 100,
billing_cycle_interval: 1,
billing_frequency: "twice_monthly",
billing_days: "1,15",
duration: 0,
add_ons: [],
discounts: [],
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/plan", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class Plan {
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int Amount { get; set; }
[JsonProperty("billing_cycle_interval")]
public int BillingCycleInterval { get; set; }
[JsonProperty("billing_frequency")]
public string BillingFrequency { get; set; }
[JsonProperty("billing_days")]
public string BillingDays { get; set; }
public int Duration { get; set; }
[JsonProperty("add_ons")]
public List<AddOn> AddOns { get; set; }
public List<Discount> Discounts { get; set; }
[JsonProperty("created_at")]
public DateTime CreatedAt { get; set; }
[JsonProperty("updated_at")]
public DateTime UpdatedAt { get; set; }
}
public class PlanResponse : ApiResponse {
public Plan Data { get; set; }
}
public void createPlan(Plan plan) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/plan");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(plan);
IRestResponse response = client.Execute(request);
PlanResponse apiResponse = JsonConvert.DeserializeObject<PlanResponse>(response);
if (apiResponse.Status === "success") {
// handle success
string newId = apiResponse.Data;
} else {
// handle non success
}
}
<?php
$plan = array(
"name" => "test plan",
"description" => "just a simple test plan",
"amount" => 100,
"billing_cycle_interval" => 1,
"billing_frequency" => "twice_monthly",
"billing_days" => "1,15",
"duration" => 0,
"add_ons" => array(),
"discounts" => array()
);
function createPlan($plan) {
$curl = curl_init();
$payload = json_encode($plan);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/plan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class Plan {
String id;
String name;
String description;
int amount;
@JsonProperty("billing_cycle_interval")
int billingCycleInterval;
@JsonProperty("billing_frequency")
String billingFrequency;
@JsonProperty("billing_days")
String billingDays;
int duration;
@JsonProperty("add_ons")
java.util.ArrayList<AddOn> addOns;
java.util.ArrayList<Discount> discounts;
@JsonProperty("created_at")
java.util.Date createdAt;
@JsonProperty("updated_at")
java.util.Date updatedAt;
}
public class PlanResponse extends ApiResponse {
Plan data;
}
public void createPlan(Plan plan) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(plan);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/plan")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
PlanResponse apiResponse = objectMapper.readValue(responseBody.String(), PlanResponse.class);
if (apiResponse.status === "success") {
// handle success
String newId = apiResponse.data.id;
} else {
// handle non success
}
}
# Get Plan By ID
Retrieve details for the specified plan.
Request Method:
GET
URL Endpoint:
/api/recurring/plan/{ plan id }
{
"status": "success",
"msg": "success",
"data": {
"id": "b89g35qj8m0o735i19jg",
"name": "test plan",
"description": "just a simple test plan",
"amount": 100,
"billing_cycle_interval": 1,
"billing_frequency": "twice_monthly",
"billing_days": "1,15",
"total_add_ons": 100,
"total_discounts": 50,
"duration": 0,
"add_ons": [
{
"id": "b75cvl51tlv38t0o7o30",
"name": "test_addon",
"description": "this will add to the cost of the subscription",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": null,
"updated_at": null
}
],
"discounts": [
{
"id": "b89flfqj8m0o735i19ig",
"name": "test discount",
"description": "this will discount the cost of the subscription",
"amount": 50,
"percentage": null,
"duration": 0,
"created_at": null,
"updated_at": null
}
],
"created_at": "2017-11-20T16:23:51.990051Z",
"updated_at": "2017-11-20T16:23:51.990051Z"
}
}
function getPlan(planId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/plan/" + planId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var plan = result.data[0];
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class PlanListResponse : ApiResponse {
public List<Plan> Data { get; set; }
[JsonProperty("total_count")]
public int TotalCount { get; set; }
}
public void getPlan(string planId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/plan/" + planId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
PlanListResponse apiResponse = JsonConvert.DeserializeObject<PlanListResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Plan plan = apiResponse.Data.FirstOrDefault(); // return first in array
} else {
// handle non success
}
}
<?php
function getPlan($planId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/plan/".$planId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class PlanListResponse extends ApiResponse {
java.util.ArrayList<Plan> data;
@JsonProperty("total_count")
int totalCount;
}
public void getPlan(String planId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/plan/" + planId)
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
PlanListResponse apiResponse = objectMapper.readValue(responseBody.String(), PlanListResponse.class);
if (apiResponse.status === "success") {
// handle success
Plan plan = apiResponse.data.get(0);
} else {
// handle non success
}
}
# Get All Plans
Retrieve the properties of all plans for the gateway account associated with the API Key or JWT token provided in the Authorization header.
Request Method:
GET
URL Endpoint:
/api/recurring/plans
{
"status": "success",
"msg": "success",
"data": [
{
"id": "b89g35qj8m0o735i19jg",
"name": "test plan",
"description": "just a simple test plan",
"amount": 100,
"billing_cycle_interval": 1,
"billing_frequency": "twice_monthly",
"billing_days": "1,15",
"total_add_ons": 100,
"total_discounts": 50,
"duration": 0,
"add_ons": [
{
"id": "b75cvl51tlv38t0o7o30",
"name": "test_addon",
"description": "this will add to the cost of the subscription",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": null,
"updated_at": null
}
],
"discounts": [
{
"id": "b89flfqj8m0o735i19ig",
"name": "test discount",
"description": "this will discount the cost of the subscription",
"amount": 50,
"percentage": null,
"duration": 0,
"created_at": null,
"updated_at": null
}
],
"created_at": "2017-11-20T16:23:52Z",
"updated_at": "2017-11-20T16:23:52Z"
}
],
"total_count": 1
}
function getAllPlans() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/plans", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var plans = result.data;
var total = result.total_count;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void getAllPlans() {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/plans");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
PlanListResponse apiResponse = JsonConvert.DeserializeObject<PlanListResponse>(response);
if (apiResponse.Status === "success") {
// handle success
List<Plan> plan = apiResponse.Data;
int total = apiResponse.TotalCount;
} else {
// handle non success
}
}
<?php
function getAllPlans() {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/plans",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getAllPlans() {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/plans")
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
PlanListResponse apiResponse = objectMapper.readValue(responseBody.String(), PlanListResponse.class);
if (apiResponse.status === "success") {
// handle success
java.util.ArrayList<Plan> plan = apiResponse.data;
int total = apiResponse.totalCount;
} else {
// handle non success
}
}
# Update Plan
Edit details for the specified plan.
Request Method:
POST
URL Endpoint:
/api/recurring/plan/{ plan id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
name | string | "" | Display name for the plan | |
description | string | "" | Description for the plan | |
amount | integer | null | Amount to be billed in cents (100 = $1.00) | * |
billing_cycle_interval | integer | null | How often to run the billing cycle (run every X months) | * |
billing_frequency | string literal | "monthly" | How often to run the plan within a billing cycle. ("monthly", "twice_monthly", "daily") | * |
billing_days | string | null | Which day of the month to bill on. If "twice_monthly" then comma separate dates ("1, 15"). For the last day of the month, use "0". | * |
duration | integer | 0 | Number of times for the discount to be billed (use 0 if you want the plan to persist until cancelled) | |
add_ons | array of objects | Enumerates add-ons for a recurring plan | ||
add_ons[#] .id | string | ID of the referenced add_on | ||
add_ons[#] .name | string | Display name for the add_on (optional, this overrides the add_ons value) | ||
add_ons[#] .description | string | Description for the add_on (optional, this overrides the add_ons value) | ||
add_ons[#] .amount | int | Amount to be added (optional, this overrides the add_ons value) | ||
add_ons[#] .duration | int | Duration for the add_on to be billed (optional, this overrides the add_ons value) | ||
discounts | array of objects | Enumerates discounts for a recurring plan | ||
discounts[#] .id | string | ID of the referenced discount | ||
discounts[#] .name | string | Display name for the discount (optional, this overrides the discount value) | ||
discounts[#] .description | string | Description for the discount (optional, this overrides the discount value) | ||
discounts[#] .amount | int | Amount to be discounted (optional, this overrides the discount value) | ||
discounts[#] .duration | int | Duration for the discount to be billed (optional, this overrides the discount value) |
{
"status": "success",
"msg": "success",
"data": {
"id": "b89g35qj8m0o735i19jg",
"name": "test plan",
"description": "just a simple test plan",
"amount": 100,
"billing_cycle_interval": 1,
"billing_frequency": "twice_monthly",
"billing_days": "1,15",
"total_add_ons": 100,
"total_discounts": 50,
"duration": 0,
"add_ons": [
{
"id": "b75cvl51tlv38t0o7o30",
"name": "test_addon",
"description": "this will add to the cost of the subscription",
"amount": 100,
"percentage": null,
"duration": 0,
"created_at": null,
"updated_at": null
}
],
"discounts": [
{
"id": "b89flfqj8m0o735i19ig",
"name": "test discount",
"description": "this will discount the cost of the subscription",
"amount": 50,
"percentage": null,
"duration": 0,
"created_at": null,
"updated_at": null
}
],
"created_at": "2017-11-20T16:23:51.990051Z",
"updated_at": "2017-11-20T16:23:51.990051Z"
}
}
function updatePlan(planId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
name: "test plan",
description: "just a simple test plan",
amount: 100,
billing_cycle_interval: 1,
billing_frequency: "twice_monthly",
billing_days: "1,15",
duration: 0,
add_ons: [],
discounts: [],
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/plan/" + planId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void updatePlan(Plan plan) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/plan/" + plan.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(plan);
IRestResponse response = client.Execute(request);
PlanResponse apiResponse = JsonConvert.DeserializeObject<PlanResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function updatePlan($plan) {
$curl = curl_init();
$payload = json_encode($plan);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/plan/".$plan->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updatePlan(Plan plan) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(plan);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/plan/" + plan.id)
.method("POST", body)
.addHeader("Authorization", apiKey
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
PlanResponse apiResponse = objectMapper.readValue(responseBody.String(), PlanResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Delete Plan
Delete the specified plan.
Request Method:
DELETE
URL Endpoint:
/api/recurring/plan/{ plan id }
{
"status": "success",
"msg": "success",
"data": null
}
function deletePlan(planId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/plan/" + planId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void deletePlan(string planId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/plan/" + planId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deletePlan($planId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/plan/".$planId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deletePlan(String planId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/plan/" + planId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.String(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Create Subscription
Creates a new subscription which applies a recurring billing plan to a customer.
Request Method:
POST
URL Endpoint:
/api/recurring/subscription
Name | Type | Default | Description | Required |
---|---|---|---|---|
plan_id | string | "" | ID of the plan being subscribed to | |
description | string | "" | Description for the subscription | |
customer | object | Object containing details for the customer being subscribed to the plan | ||
customer .id | string | ID for the customer being subscribed to the billing plan | * | |
customer .payment_method_type | string | default payment method type | "card" or "ach" | |
customer .payment_method_id | string | default payment method id | ID of the customer's saved payment method to use for the billing plan | required if payment_method_type is present |
customer .billing_address_id | string | default billing address | ID of the customer's saved billing address to use for the billing plan | |
customer .shipping_address_id | string | default shipping address | ID of the customer's saved shipping address to use for the billing plan | |
amount | integer | null | Amount to be billed in cents (100 = $1.00) | * |
billing_cycle_interval | integer | null | How often to run the billing cycle (run every X months) | * |
billing_frequency | string literal | "monthly" | How often to run the subscription within a billing cycle. ("monthly", "twice_monthly", "daily") | * |
billing_days | string | null | Which day of the month to bill on. If "twice_monthly" then comma separate dates ("1, 15"). For the last day of the month, use "0". | * |
duration | integer | 0 | Number of times for the discount to be billed (use 0 if you want the subscription to persist until cancelled) | |
next_bill_date | string "YYYY-MM-DD" | The date of the next time the billing plan will be processed | ||
add_ons | array of objects | Enumerates add-ons for a recurring subscription | ||
add_ons[#] .id | string | ID of the referenced add_on | ||
add_ons[#] .name | string | Display name for the add_on (optional, this overrides the add_ons value) | ||
add_ons[#] .description | string | Description for the add_on (optional, this overrides the add_ons value) | ||
add_ons[#] .amount | int | Amount to be added (optional, this overrides the add_ons value) | ||
add_ons[#] .duration | int | Duration for the add_on to be billed (optional, this overrides the add_ons value) | ||
discounts | array of objects | Enumerates discounts for a recurring subscription | ||
discounts[#] .id | string | ID of the referenced discount | ||
discounts[#] .name | string | Display name for the discount (optional, this overrides the discount value) | ||
discounts[#] .description | string | Description for the discount (optional, this overrides the discount value) | ||
discounts[#] .amount | int | Amount to be discounted (optional, this overrides the discount value) | ||
discounts[#] .duration | int | Duration for the discount to be billed (optional, this overrides the discount value) |
{
"status": "success",
"msg": "success",
"data": {
"id": "b89gftaj8m0oft7upk80",
"plan_id": "b89g35qj8m0o735i19jg",
"description": "some description to describe the subscription",
"customer": {
"id": "b81ko5qq9qq5v460r9i0",
"payment_method_type": "card",
"payment_method_id": "b81ko5qq9qq5v460r9i0",
"billing_address_id": "b81ko5qq9qq5v460r9i0",
"shipping_address_id": "b81ko5qq9qq5v460r9i0"
},
"amount": 100,
"total_adds": 0,
"total_discounts": 50,
"billing_cycle_interval": 1,
"billing_frequency": "twice_monthly",
"billing_days": "1,15",
"duration": 0,
"next_bill_date": "2017-11-22",
"add_ons": null,
"discounts": [
{
"id": "b89flfqj8m0o735i19ig",
"description": "this will discount the cost of the subscription",
"amount": 50,
"percentage": null,
"duration": 0
}
],
"created_at": "2017-11-20T16:51:01.798736Z",
"updated_at": "2017-11-20T16:51:01.798736Z"
}
}
function createSubscription() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
plan_id: "123abc",
description: "some description to describe the subscription",
customer: {
id: "bsi33eherttr51onq1rg",
},
amount: 100,
billing_cycle_interval: 1,
billing_frequency: "twice_monthly",
billing_days: "1,15",
duration: 0,
next_bill_date: "2019-11-21",
add_ons: [],
discounts: [],
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/subscription", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var newId = result.data.id;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class Subscription {
public string Id { get; set; }
[JsonProperty("plan_id")]
public string PlanId { get; set; }
public string Description { get; set; }
public Customer Customer { get; set; }
public int Amount { get; set; }
[JsonProperty("billing_cycle_interval")]
public int BillingCycleInterval { get; set; }
[JsonProperty("billing_frequency")]
public string BillingFrequency { get; set; }
[JsonProperty("billing_days")]
public string BillingDays { get; set; }
public int Duration { get; set; }
[JsonProperty("next_bill_date")]
public DateTime NextBillDate { get; set; }
[JsonProperty("add_ons")]
public List<AddOn> AddOns { get; set; }
public List<Discount> Discounts { get; set; }
[JsonProperty("created_at")]
public DateTime CreatedAt { get; set; }
[JsonProperty("updated_at")]
public DateTime UpdatedAt { get; set; }
}
public class SubscriptionResponse : ApiResponse {
public Subscription Data { get; set; }
}
public void createSubscription(Subscription subscription) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/subscription");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(subscription);
IRestResponse response = client.Execute(request);
SubscriptionResponse apiResponse = JsonConvert.DeserializeObject<SubscriptionResponse>(response);
if (apiResponse.Status === "success") {
// handle success
string newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
<?php
$subscription = array(
"plan_id" => "123abc",
"description" => "some description to describe the subscription",
"customer" => {
"id" => "bsi33eherttr51onq1rg"
},
"amount" => 100,
"billing_cycle_interval" => 1,
"billing_frequency" => "twice_monthly",
"billing_days" => "1,15",
"duration" => 0,
"next_bill_date" => "2019-11-21",
"add_ons" => array(),
"discounts" => array()
);
function createSubscription($subscription) {
$curl = curl_init();
$payload = json_encode($subscription);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/subscription",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class Subscription {
String id;
@JsonProperty("plan_id")
String planId;
String description;
Customer customer;
int amount;
@JsonProperty("billing_cycle_interval")
int billingCycleInterval;
@JsonProperty("billing_frequency")
String billingFrequency;
@JsonProperty("billing_days")
String billingDays;
int duration;
@JsonProperty("next_bill_date")
java.util.Date nextBillDate;
@JsonProperty("add_ons")
java.util.ArrayList<AddOn> addOns;
java.util.ArrayList<Discount> discounts;
@JsonProperty("created_at")
java.util.Date createdAt;
@JsonProperty("updated_at")
java.util.Date updatedAt;
}
public class SubscriptionResponse extends ApiResponse {
public Subscription data;
}
public void createSubscription(Subscription subscription) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(subscription);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/subscription")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
SubscriptionResponse apiResponse = objectMapper.readValue(responseBody.String(), SubscriptionResponse.class);
if (apiResponse.status === "success") {
// handle success
String newId = apiResponse.data.id;
} else {
// handle non success
}
}
# Get Subscription By ID
Retrieve details for the specified subscription.
Request Method:
GET
URL Endpoint:
/api/recurring/subscription/{ subscription id }
{
"status": "success",
"msg": "success",
"data": {
"id": "b89gftaj8m0oft7upk80",
"plan_id": "b89g35qj8m0o735i19jg",
"description": "some description to describe the subscription",
"customer": {
"id": "b81ko5qq9qq5v460r9i0",
"payment_method_type": "card",
"payment_method_id": "b81ko5qq9qq5v460r9i0",
"billing_address_id": "b81ko5qq9qq5v460r9i0",
"shipping_address_id": "b81ko5qq9qq5v460r9i0"
},
"amount": 100,
"total_adds": 0,
"total_discounts": 50,
"billing_cycle_interval": 1,
"billing_frequency": "twice_monthly",
"billing_days": "1,15",
"duration": 0,
"next_bill_date": "2017-11-22",
"add_ons": null,
"discounts": [
{
"id": "b89flfqj8m0o735i19ig",
"description": "this will discount the cost of the subscription",
"amount": 50,
"percentage": null,
"duration": 0
}
],
"created_at": "2017-11-20T16:51:01.798736Z",
"updated_at": "2017-11-20T16:51:01.798736Z"
}
}
function getSubscription(subscriptionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/subscription/" + subscriptionId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var subscription = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void getSubscription(string subscriptionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/subscription/" + subscriptionId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
SubscriptionResponse apiResponse = JsonConvert.DeserializeObject<SubscriptionResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Subscription subscription = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getSubscription($subscriptionId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/subscription/".$subscriptionId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getSubscription(String subscriptionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/subscription/" + subscriptionId)
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
SubscriptionResponse apiResponse = objectMapper.readValue(responseBody.String(), SubscriptionResponse.class);
if (apiResponse.status === "success") {
// handle success
Subscription subscription = apiResponse.data;
} else {
// handle non success
}
}
# Update Subscription
Edit details for the specified subscription.
Request Method:
POST
URL Endpoint:
/api/recurring/subscription/{ subscription id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
plan_id | string | "" | ID of the plan being subscribed to | |
description | string | "" | Description for the subscription | |
customer | object | Object containing details for the customer being subscribed to the plan | ||
customer .id | string | ID for the customer being subscribed to the billing plan | * | |
customer .payment_method_type | string | default payment method type | "card" or "ach" | |
customer .payment_method_id | string | default payment method id | ID of the customer's saved payment method to use for the billing plan | required if payment_method_type is present |
customer .billing_address_id | string | default billing address | ID of the customer's saved billing address to use for the billing plan | |
customer .shipping_address_id | string | default shipping address | ID of the customer's saved shipping address to use for the billing plan | |
amount | integer | null | Amount to be billed in cents (100 = $1.00) | * |
billing_cycle_interval | integer | null | How often to run the billing cycle (run every X months) | * |
billing_frequency | string literal | "monthly" | How often to run the subscription within a billing cycle. ("monthly", "twice_monthly", "daily") | * |
billing_days | string | null | Which day of the month to bill on. If "twice_monthly" then comma separate dates ("1, 15"). For the last day of the month, use "0". | * |
duration | integer | 0 | Number of times for the discount to be billed (use 0 if you want the subscription to persist until cancelled) | |
next_bill_date | string "YYYY-MM-DD" | The date of the next time the billing plan will be processed | ||
add_ons | array of objects | Enumerates add-ons for a recurring subscription | ||
add_ons[#] .id | string | ID of the referenced add_on | ||
add_ons[#] .name | string | Display name for the add_on (optional, this overrides the add_ons value) | ||
add_ons[#] .description | string | Description for the add_on (optional, this overrides the add_ons value) | ||
add_ons[#] .amount | int | Amount to be added (optional, this overrides the add_ons value) | ||
add_ons[#] .duration | int | Duration for the add_on to be billed (optional, this overrides the add_ons value) | ||
discounts | array of objects | Enumerates discounts for a recurring subscription | ||
discounts[#] .id | string | ID of the referenced discount | ||
discounts[#] .name | string | Display name for the discount (optional, this overrides the discount value) | ||
discounts[#] .description | string | Description for the discount (optional, this overrides the discount value) | ||
discounts[#] .amount | int | Amount to be discounted (optional, this overrides the discount value) | ||
discounts[#] .duration | int | Duration for the discount to be billed (optional, this overrides the discount value) |
{
"status": "success",
"msg": "success",
"data": {
"id": "b89gftaj8m0oft7upk80",
"plan_id": "b89g35qj8m0o735i19jg",
"description": "some description to describe the subscription",
"customer": {
"id": "b81ko5qq9qq5v460r9i0",
"payment_method_type": "card",
"payment_method_id": "b81ko5qq9qq5v460r9i0",
"billing_address_id": "b81ko5qq9qq5v460r9i0",
"shipping_address_id": "b81ko5qq9qq5v460r9i0"
},
"amount": 100,
"total_adds": 0,
"total_discounts": 50,
"billing_cycle_interval": 1,
"billing_frequency": "twice_monthly",
"billing_days": "1,15",
"duration": 0,
"next_bill_date": "2017-11-22",
"add_ons": null,
"discounts": [
{
"id": "b89flfqj8m0o735i19ig",
"description": "this will discount the cost of the subscription",
"amount": 50,
"percentage": null,
"duration": 0
}
],
"created_at": "2017-11-20T16:51:01.798736Z",
"updated_at": "2017-11-20T16:51:01.798736Z"
}
}
function updateSubscription(subscriptionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
plan_id: "123abc",
description: "some description to describe the subscription",
customer: {
id: "bsi33eherttr51onq1rg",
},
amount: 100,
billing_cycle_interval: 1,
billing_frequency: "twice_monthly",
billing_days: "1,15",
duration: 0,
next_bill_date: "2017-11-22",
add_ons: [],
discounts: [],
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void updateSubscription(Subscription subscription) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscription.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(subscription);
IRestResponse response = client.Execute(request);
SubscriptionResponse apiResponse = JsonConvert.DeserializeObject<SubscriptionResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function updateSubscription($subscription) {
$curl = curl_init();
$payload = json_encode($subscription)
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/subscription/".$subscription->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updateSubscription(Subscription subscription) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(subscription);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscription.id)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
SubscriptionResponse apiResponse = objectMapper.readValue(responseBody.String(), SubscriptionResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Pause Subscription
Pause the specified subscription.
Request Method:
GET
URL Endpoint:
/api/recurring/subscription/{ subscription id }/status/paused
{
"status": "success",
"msg": "success",
"data": {
"id": "cn9rrqbug2jpf9mtp6c0",
"plan_id": "cn9rrkrug2jpf9mtp6bg",
"plan_name": "",
"status": "paused",
"description": "",
"customer_name": "",
"shared": false,
"customer": {
"id": "cn9nrfbug2jpejn1kbeg",
"payment_method_type": "",
"payment_method_id": "",
"billing_address_id": "",
"shipping_address_id": ""
},
"amount": 100,
"currency": "USD",
"processor_id": "",
"total_adds": 0,
"total_discounts": 0,
"billing_cycle_interval": 1,
"billing_frequency": "monthly",
"billing_days": "1",
"duration": 0,
"next_bill_date": "2024-02-19",
"add_ons": null,
"discounts": null,
"expiration_date": "",
"events": null,
"created_at": "2024-02-19T20:45:30Z",
"updated_at": "2024-02-19T20:45:50.953717Z",
"charge_on_day": false
}
}
function pauseSubscription(subscriptionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/subscription/" + subscriptionId + "/status/paused", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var subscription = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void pauseSubscription(string subscriptionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/subscription/" + subscriptionId + "/status/paused");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
SubscriptionResponse apiResponse = JsonConvert.DeserializeObject<SubscriptionResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Subscription subscription = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function pauseSubscription($subscriptionId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/subscription/".$subscriptionId."/status/paused",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void pauseSubscription(String subscriptionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/subscription/" + subscriptionId + "/status/paused")
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
SubscriptionResponse apiResponse = objectMapper.readValue(responseBody.String(), SubscriptionResponse.class);
if (apiResponse.status === "success") {
// handle success
Subscription subscription = apiResponse.data;
} else {
// handle non success
}
}
# Mark Subscription Past Due
Mark the specified subscription as past due.
Request Method:
GET
URL Endpoint:
/api/recurring/subscription/{ subscription id }/status/past_due
{
"status": "success",
"msg": "success",
"data": {
"id": "cnb14e3ug2jpf9mtp6k0",
"plan_id": "cn9rrkrug2jpf9mtp6bg",
"plan_name": "",
"status": "past_due",
"description": "",
"customer_name": "",
"shared": false,
"customer": {
"id": "cn9nrfbug2jpejn1kbeg",
"payment_method_type": "",
"payment_method_id": "",
"billing_address_id": "",
"shipping_address_id": ""
},
"amount": 100,
"currency": "USD",
"processor_id": "",
"total_adds": 0,
"total_discounts": 0,
"billing_cycle_interval": 1,
"billing_frequency": "monthly",
"billing_days": "1",
"duration": 0,
"next_bill_date": "2024-02-21",
"add_ons": null,
"discounts": null,
"expiration_date": "",
"events": null,
"created_at": "2024-02-21T15:09:45Z",
"updated_at": "2024-02-21T15:13:03.001456Z",
"charge_on_day": false
}
}
function makrSubscriptionPastDue(subscriptionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/subscription/" + subscriptionId + "/status/past_due", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var subscription = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void makrSubscriptionPastDue(string subscriptionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/subscription/" + subscriptionId + "/status/past_due");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
SubscriptionResponse apiResponse = JsonConvert.DeserializeObject<SubscriptionResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Subscription subscription = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function makrSubscriptionPastDue($subscriptionId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/subscription/".$subscriptionId."/status/past_due",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void makrSubscriptionPastDue(String subscriptionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/subscription/" + subscriptionId + "/status/past_due")
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
SubscriptionResponse apiResponse = objectMapper.readValue(responseBody.String(), SubscriptionResponse.class);
if (apiResponse.status === "success") {
// handle success
Subscription subscription = apiResponse.data;
} else {
// handle non success
}
}
# Cancel Subscription
Cancel the specified subscription.
Request Method:
GET
URL Endpoint:
/api/recurring/subscription/{ subscription id }/status/cancelled
{
"status": "success",
"msg": "success",
"data": {
"id": "cn9rrqbug2jpf9mtp6c0",
"plan_id": "cn9rrkrug2jpf9mtp6bg",
"plan_name": "",
"status": "cancelled",
"description": "",
"customer_name": "",
"shared": false,
"customer": {
"id": "cn9nrfbug2jpejn1kbeg",
"payment_method_type": "",
"payment_method_id": "",
"billing_address_id": "",
"shipping_address_id": ""
},
"amount": 100,
"currency": "USD",
"processor_id": "",
"total_adds": 0,
"total_discounts": 0,
"billing_cycle_interval": 1,
"billing_frequency": "monthly",
"billing_days": "1",
"duration": 0,
"next_bill_date": "2024-02-19",
"add_ons": null,
"discounts": null,
"expiration_date": "",
"events": null,
"created_at": "2024-02-19T20:45:30Z",
"updated_at": "2024-02-19T21:05:39.561726Z",
"charge_on_day": false
}
}
function cancelSubscription(subscriptionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId + "/status/cancelled", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var subscription = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void cancelSubscription(string subscriptionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId + "/status/cancelled");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
SubscriptionResponse apiResponse = JsonConvert.DeserializeObject<SubscriptionResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Subscription subscription = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function cancelSubscription($subscriptionId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/subscription/".$subscriptionId."/status/cancelled",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void cancelSubscription(String subscriptionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId + "/status/cancelled")
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
SubscriptionResponse apiResponse = objectMapper.readValue(responseBody.String(), SubscriptionResponse.class);
if (apiResponse.status === "success") {
// handle success
Subscription subscription = apiResponse.data;
} else {
// handle non success
}
}
# Activate Subscription
Activate the specified subscription.
Request Method:
GET
URL Endpoint:
/api/recurring/subscription/{ subscription id }/status/active
Query Params
Name | Default | Description |
---|---|---|
next_bill_date | Date in 'YYYY-MM-DD' format |
{
"status": "success",
"msg": "success",
"data": {
"id": "cn9rrqbug2jpf9mtp6c0",
"plan_id": "cn9rrkrug2jpf9mtp6bg",
"plan_name": "",
"status": "active",
"description": "",
"customer_name": "",
"shared": false,
"customer": {
"id": "cn9nrfbug2jpejn1kbeg",
"payment_method_type": "",
"payment_method_id": "",
"billing_address_id": "",
"shipping_address_id": ""
},
"amount": 100,
"currency": "USD",
"processor_id": "",
"total_adds": 0,
"total_discounts": 0,
"billing_cycle_interval": 1,
"billing_frequency": "monthly",
"billing_days": "1",
"duration": 0,
"next_bill_date": "2024-02-19",
"add_ons": null,
"discounts": null,
"expiration_date": "",
"events": null,
"created_at": "2024-02-19T20:45:30Z",
"updated_at": "2024-02-19T21:10:36.976006Z",
"charge_on_day": false
}
}
function activateSubscription(subscriptionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId + "/status/active?next_bill_date=2024-02-19", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var subscription = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void activateSubscription(string subscriptionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId + "/status/active?next_bill_date=2024-02-19");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
SubscriptionResponse apiResponse = JsonConvert.DeserializeObject<SubscriptionResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Subscription subscription = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function activateSubscription($subscriptionId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/subscription/".$subscriptionId."/status/active?next_bill_date=2024-02-19",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void activateSubscription(String subscriptionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId + "/status/active?next_bill_date=2024-02-19")
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
SubscriptionResponse apiResponse = objectMapper.readValue(responseBody.String(), SubscriptionResponse.class);
if (apiResponse.status === "success") {
// handle success
Subscription subscription = apiResponse.data;
} else {
// handle non success
}
}
# Complete Subscription
Complete the specified subscription.
Request Method:
GET
URL Endpoint:
/api/recurring/subscription/{ subscription id }/status/completed
{
"status": "success",
"msg": "success",
"data": {
"id": "cn9rrqbug2jpf9mtp6c0",
"plan_id": "cn9rrkrug2jpf9mtp6bg",
"plan_name": "",
"status": "completed",
"description": "",
"customer_name": "",
"shared": false,
"customer": {
"id": "cn9nrfbug2jpejn1kbeg",
"payment_method_type": "",
"payment_method_id": "",
"billing_address_id": "",
"shipping_address_id": ""
},
"amount": 100,
"currency": "USD",
"processor_id": "",
"total_adds": 0,
"total_discounts": 0,
"billing_cycle_interval": 1,
"billing_frequency": "monthly",
"billing_days": "1",
"duration": 0,
"next_bill_date": "2024-02-19",
"add_ons": null,
"discounts": null,
"expiration_date": "",
"events": null,
"created_at": "2024-02-19T20:45:30Z",
"updated_at": "2024-02-19T21:25:01.161503Z",
"charge_on_day": false
}
}
function completeSubscription(subscriptionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId + "/status/completed", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var subscription = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void completeSubscription(string subscriptionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId + "/status/completed");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
SubscriptionResponse apiResponse = JsonConvert.DeserializeObject<SubscriptionResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Subscription subscription = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function completeSubscription($subscriptionId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/subscription/".$subscriptionId."/status/completed",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void completeSubscription(String subscriptionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId + "/status/completed")
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
SubscriptionResponse apiResponse = objectMapper.readValue(responseBody.String(), SubscriptionResponse.class);
if (apiResponse.status === "success") {
// handle success
Subscription subscription = apiResponse.data;
} else {
// handle non success
}
}
# Delete Subscription
Delete the specified subscription.
Request Method:
DELETE
URL Endpoint:
/api/recurring/subscription/{ subscription id }
{
"status": "success",
"msg": "success",
"data": null
}
function deleteSubscription(subscriptionId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void deleteSubscription(string subscriptionId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deleteSubscription($subscriptionId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/recurring/subscription/".$subscriptionId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deleteSubscription(String subscriptionId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/recurring/subscription/" + subscriptionId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.String(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Terminals
All transaction requests should be processed via the /transaction
endpoint referencing the specific terminal to handle the request. Please see the Processing a Transaction section for more information.
# Get All Terminals
Retrieve all terminals associated with the gateway account. This will include inactive/disabled terminals as well.
Request Method:
GET
URL Endpoint:
/api/terminals
{
"status": "success",
"msg": "",
"total_count": 1,
"data": [
{
"id": "1ucio551tlv85l7moe5s",
"merchant_id": "aucio551tlv85l7moe5g",
"manufacturer": "dejavoo",
"model": "z11",
"serial_number": "1811000XXXX",
"tpn": "1811000XXXX",
"description": "front counter z11",
"status": "active",
"auth_key": "wcR1c9o1",
"register_id": "1",
"auto_settle": true,
"settle_at": "00:00:00",
"created_at": "2018-01-12T03:57:59Z",
"updated_at": "0001-01-01T00:00:00Z"
}
]
}
function getTerminals() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/terminals", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class ApiResponse {
public string Status { get; set; }
public string Msg { get; set; }
public List<Terminal> Data { get; set; }
[JsonProperty("total_count")]
public int TotalCount { get; set; }
}
public class Terminal {
public string Id { get; set; }
[JsonProperty("merchant_id")]
public string MerchantId { get; set; }
public string Manufacturer { get; set; }
public string Model { get; set; }
[JsonProperty("serial_number")]
public string SerialNumber { get; set; }
public string Tpn { get; set; }
public string Description { get; set; }
public string Status { get; set; }
[JsonProperty("auth_key")]
public string AuthKey { get; set; }
[JsonProperty("register_id")]
public string RegisterId { get; set; }
[JsonProperty("auto_settle")]
public bool AutoSettle { get; set; }
[JsonProperty("settle_at")]
public DateTime SettleAt { get; set; }
[JsonProperty("created_at")]
public DateTime CreatedAt { get; set; }
[JsonProperty("updated_at")]
public DateTime UpdatedAt { get; set; }
}
public void getTerminals() {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/terminals");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
List<Terminal> terminals = apiResponse.Data;
int total = apiResponse.TotalCount;
} else {
// handle non success
}
}
<?php
function getTerminals($criteria) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/terminals",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
json_decode($response);
curl_close($curl);
echo $response;
}
public class ApiResponse {
String status;
String msg;
public java.util.ArrayList<Terminal> data;
@JsonProperty("total_count")
public int totalCount;
}
public class Terminal {
String id;
@JsonProperty("merchant_id")
String merchantId;
String manufacturer;
String model;
@JsonProperty("serial_number")
String serialNumber;
String tpn;
String description;
String status;
@JsonProperty("auth_key")
String authKey;
@JsonProperty("register_id")
String registerId;
@JsonProperty("auto_settle")
boolean autoSettle;
@JsonProperty("settle_at")
java.util.Date settleAt;
@JsonProperty("created_at")
java.util.Date createdAt;
@JsonProperty("updated_at")
java.util.Date updatedAt;
}
public void getTerminals(SearchCriteria criteria) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/terminals")
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
java.util.ArrayList<Terminal> results = apiResponse.data;
int total = apiResponse.totalCount;
} else {
// handle non success
}
}
# Invoices
# Create Invoice
Create a new invoice.
Request Method:
POST
URL Endpoint:
/api/invoice
Name | Type | Default | Description | Required |
---|---|---|---|---|
currency | string literal | Currency that invoice amounts should be in ("USD", etc.) | * | |
company_name | string | Name of company issuing the invoice | ||
company_logo_url | string | Hosted location of logo image to include on invoice | ||
customer_number | string | Optional identifier for the invoiced customer to match merchant records | ||
customer_id | string | ID of the saved customer being invoiced (must be a valid customer id if included) | ||
invoice_number | string | Optional identifier for the invoice to match merchant records | ||
payable_to | object | object containing details for the person the invoice is being paid to | * | |
payable_to .id | string | ID of the stored address you want to make the invoice payable to | ||
payable_to .first_name | string | First name | ||
payable_to .last_name | string | Last name | ||
payable_to .company | string | Company name | ||
payable_to .address_line_1 | string | Address line 1 | * | |
payable_to .address_line_2 | string | Address line 2 | ||
payable_to .city | string | City | * | |
payable_to .state | string literal | State, in 2-character format ("KS", "QC", etc.)) | * | |
payable_to .postal_code | string | Postal code (must be a valid postal code for the country provided) | * | |
payable_to .country | string literal | Country, in 2-character format ("US", "CA", "MX", etc.) | * | |
payable_to .phone | string | Phone number | ||
payable_to .fax | string | Fax number | ||
payable_to | string | Email address (must be valid email format, "example@mail.com") | ||
bill_to | object | object containing details for the person the invoice is being billed to | * | |
bill_to .id | string | ID of the stored address you want to make the invoice billable to | ||
bill_to .first_name | string | First name | ||
bill_to .last_name | string | Last name | ||
bill_to .company | string | Company name | ||
bill_to .address_line_1 | string | Address line 1 | * | |
bill_to .address_line_2 | string | Address line 2 | ||
bill_to .city | string | City | * | |
bill_to .state | string literal | State, in 2-character ("KS", "QC", etc.)format | * | |
bill_to .postal_code | string | Postal (must be a valid postal code for the country provided) code | * | |
bill_to .country | string literal | Country, in 2-character ("US", "CA", "MX", etc.) format | * | |
bill_to .phone | string | Phone number | ||
bill_to .fax | string | Fax number | ||
bill_to | string | Email address (must be valid email format, "example@mail.com") | ||
date_due | datetime string | Date the invoice is due ("2021-02-13T06:00:00.000Z")by | * | |
items[#] | object array | array containing line items included in the invoice | * | |
items[#] .status | string literal | "pending" or "paid" | * | |
items[#] .type | string | "" | Type of item | |
items[#] .name | string | "" | Name of item | |
items[#] .description | string | "" | Description of item | |
items[#] .unit_price | integer | Unit price of item | * | |
items[#] .quantity | integer | Quantity of item | * | |
items[#] .quantity_shipped | integer | 0 | Quantity of items shipped to customer | |
items[#] .product_code | string | "" | Product Code of item | |
items[#] .commodity_code | string | "" | Commodity Code of item | |
items[#] .unit_of_measure | string | "" | Unit of measure of item ("lb", "kg", etc.) | |
items[#] .alternate_tax_identifier | string | "" | Alternate tax ID for item | |
items[#] .taxable | boolean | false | Whether local and national tax should be applied at the item level rather than the invoice level | |
items[#] .local_tax_rate | string | "" | Local tax rate for item ("1.000") | |
items[#] .local_tax | integer | 0 | Local tax amount to be added to the item's total, expressed in cents (100 = $1.00) | |
items[#] .national_tax_rate | string | "" | National tax rate for item ("1.000") | |
items[#] .national_tax | integer | 0 | National tax amount to be added to the item's total, expressed in cents (100 = $1.00) | |
items[#] .tax_rate | string | "" | Combined tax rate for item (local tax + national tax) | |
items[#] .tax_amount | integer | 0 | Tax amount to be added to the item's total, expressed in cents (100 = $1.00) | |
items[#] .discount_amount | integer | 0 | Discount to take off the item's total amount, expressed in cents (100 = $1.00)) | |
items[#] .freight_amount | integer | 0 | Freight amount to add to the item's total, expressed in cents (100 = $1.00) | |
advanced_fields | boolean | false | Whether or not to include additional fields for line items (advanced fields include quantity_shipped, freight_amount, unit_of_measure, taxable, local_tax_rate, local_tax, national_tax_rate, national_tax) | |
enable_tax | boolean | false | Whether or not to enable tax (if enabled, tax applied at the invoice level will override taxes applied at the item level) | |
enable_shipping | boolean | false | Whether or not to enable shipping | |
require_shipping_details | boolean | false | Whether or not to require shipping details | |
require_billing_details_on_payment_only | boolean | false | Whether or not to require billing details only at time of payment | |
tax_percent | string | Tax rate to apply to invoice total if enable_tax is true. A rate of "0.000" will cause tax to be read as a flat amount. | * | |
tax | integer | calculated amount | Total tax amount of the invoice, expressed in cents (100 = $1.00). If tax_percent is included and is not "0", this field will be overridden with the calculated amount. | |
shipping | integer | calculated amount | Shipping amount of the invoice, expressed in cents (100 = $1.00) | |
amount_paid | integer | calculated amount | Amount of the invoice that has already been paid, expressed in cents (100 = $1.00) | |
service_fees_paid | integer | calculated amount | Service fee amount that has already been paid, expressed in cents (100 = $1.00) | |
surcharge_paid | integer | calculated amount | Surcharge amount that has already been paid, expressed in cents (100 = $1.00) | |
discount_credited | integer | calculated amount | Discount amount that has already been credited, expressed in cents (100 = $1.00) | |
adjustment | integer | 0 | Apply a payment adjustment to the total amount of the invoice, expressed in cents (100 = $1.00) | |
allow_partial_payment | boolean | false | Whether or not to allow partial payment of the amount due | |
transaction_type | string literal | "sale" | "sale" or "authorize" | |
payment_methods[#] | string array | Allowable payment method types ("card", "ach", and/or "mail") | * | |
card_processor_id (can be "") | string | ID of the payment processor to use for credit card payments | * | |
ach_processor_id (can be "") | string | ID of the payment processor to use for ACH payments | * | |
message | string | Message for customers viewing the invoice | ||
send_via | string literal | How to send invoice notifications ("email", "text", "both", or "none") | * | |
email_to | string | Email address (must be valid email format, "xxxxx@xxxxx.xxx") |
{
"status": "success",
"msg": "success",
"data": {
"id": "bhi9vado3hogrne0u4tg",
"currency": "USD",
"company_name": "ACME Inc.",
"company_logo_url": "",
"customer_number": "123Customer",
"payable_to": {
"id": "",
"first_name": "First",
"last_name": "Last",
"company": "Merchant Business",
"address_line_1": "123 Some St",
"address_line_2": "",
"city": "Some City",
"state": "IL",
"postal_code": "60000",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "info@somewebsite.com"
},
"bill_to": {
"id": "",
"first_name": "First",
"last_name": "Last",
"company": "Some Business",
"address_line_1": "123 Drury Lane",
"address_line_2": "",
"city": "Some City",
"state": "IL",
"postal_code": "60000",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "info@somesite.com"
},
"created_at": "2019-02-13T16:52:25.563509-06:00",
"date_due": "2019-02-13T06:00:00Z",
"items": [
{
"id": "bhi9vado3hogrne0u4t0",
"name": "Widget",
"description": "A widget for processors",
"quantity": 1,
"quantity_shipped": 0,
"unit_of_measure": "",
"unit_price": 100,
"discount": 0,
"discount_type": "$",
"taxable": false,
"local_tax": "0",
"national_tax": "0",
"tax_rate": "0",
"tax_amount": 0,
"amount": 100,
"status": "pending"
}
],
"advanced_fields": false,
"subtotal": 100,
"tax_percent": "0.00",
"tax": 0,
"total": 100,
"amount_paid": 0,
"adjustment": 0,
"amount_due": 100,
"payment_methods": ["card"],
"card_processor_id": "bhi5qa5o3hogms88jojg",
"ach_processor_id": "",
"status": "pending",
"message": "Thank you for your business!",
"reject_message": "",
"send_via": "none",
"last_sent_at": "0001-01-01T00:00:00Z",
"updated_at": "2019-02-13T16:52:25.563509-06:00",
"public_url": "d038ea94-3f4f-4703-9e94-74792605944e",
"hosted_url": "http://localhost:8080/invoice/d038ea94-3f4f-4703-9e94-74792605944e"
}
}
var invoice = {
currency: "USD",
company_name: "ACME Inc.",
customer_number: "123Customer",
customer_id: "123CustomerId",
payable_to: {
id: null,
first_name: "First",
last_name: "Last",
company: "Merchant Business",
address_line_1: "123 Some St",
address_line_2: "",
city: "Some City",
state: "IL",
postal_code: "60000",
country: "US",
phone: "5555555555",
fax: "5555555555",
email: "info@somewebsite.com"
},
bill_to: {
id: null,
first_name: "First",
last_name: "Last",
company: "Merchant Business",
address_line_1: "123 Some St",
address_line_2: "",
city: "Some City",
state: "IL",
postal_code: "60000",
country: "US",
phone: "5555555555",
fax: "5555555555",
email: "info@somewebsite.com"
},
date_due: "2019-02-13T06:00:00.000Z",
items: [
{
name: "Widget",
description: "A widget for processors",
quantity: 1,
unit_price: "1000",
discount_amount: 0,
taxable: true,
local_tax_rate: "1.000",
local_tax: 10,
national_tax_rate: "1.000",
national_tax: 10,
tax_rate: "2.000",
tax_amount: 20,
status: "pending"
}
],
advanced_fields: false,
enable_tax: false,
tax_percent: 0.00,
tax: 0,
amount_due: 1000,
amount_paid: 0,
adjustment: 0,
message: "Thank you for your business!",
send_via: "none",
payment_methods: ["card"],
card_processor_id: "123abc",
ach_processor_id:
};
function createInvoice(invoice) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", application/json);
var raw = JSON.stringify(invoice);
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw
};
fetch("https://sandbox.durangomsgateway.com/api/invoice", requestOptions)
.then(response => response.text())
.then(result => {
if (result.status === "success") {
// handle success
var newId = result.data.id;
} else {
// handle non success
}
})
.catch(error => console.log("error", error));
}
public class ApiResponse {
public string Status { get; set; }
public string Msg { get; set; }
}
public class Address {
public string Id { get; set; }
[JsonProperty(first_name)]
public string FirstName { get; set; }
[JsonProperty(last_name)]
public string LastName { get; set; }
public string Company { get; set; }
[JsonProperty(address_line_1)]
public string AddressLine1 { get; set; }
[JsonProperty(address_line_2)]
public string AddressLine2 { get; set; }
public string City { get; set; }
public string State { get; set; }
[JsonProperty(postal_code)]
public string PostalCode { get; set; }
public string Country { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Fax { get; set; }
}
public class Item {
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int Quantity { get; set; }
[JsonProperty(quantity_shipped)]
public int QuantityShipped { get; set; }
[JsonProperty(unit_of_measure)]
public string UnitOfMeasure { get; set; }
[JsonProperty(unit_price)]
public int UnitPrice { get; set; }
public int Discount { get; set; }
[JsonProperty(discount_type)]
public string DiscountType { get; set; }
public bool Taxable { get; set; }
[JsonProperty(local_tax)]
public int LocalTax { get; set; }
[JsonProperty(national_tax)]
public int NationalTax { get; set; }
[JsonProperty(tax_rate)]
public string TaxRate { get; set; }
public int Amount { get; set; }
public string Status { get; set; }
}
public class Invoice {
public string Currency { get; set; }
[JsonProperty(company_name)]
public string CompanyName { get; set; }
[JsonProperty(customer_number)]
public string CustomerNumber { get; set; }
[JsonProperty(customer_id)]
public string CustomerId { get; set; }
[JsonProperty(payable_to)]
public Address PayableTo { get; set; }
[JsonProperty(bill_to)]
public Address BillTo { get; set; }
[JsonProperty(date_due)]
public DateTime DateDue { get; set; }
public List<Item> Items { get; set; }
[JsonProperty(advanced_fields)]
public bool AdvancedFields { get; set; }
[JsonProperty(enable_tax)]
public bool EnableTax { get; set; }
[JsonProperty(tax_percent)]
public string TaxPercent { get; set; }
public int Tax { get; set; }
[JsonProperty(amount_paid)]
public int AmountPaid { get; set; }
public int Adjustment { get; set; }
[JsonProperty(amount_due)]
public int AmountDue { get; set; }
public string Message { get; set; }
[JsonProperty(send_via)]
public string SendVia { get; set; }
[JsonProperty(payment_methods)]
public List<string> PaymentMethods { get; set; }
[JsonProperty(card_processor_id)]
public string CardProcessorId { get; set; }
[JsonProperty(ach_processor_id)]
public string AchProcessorId { get; set; }
}
public class InvoiceResponse : ApiResponse {
public Invoice Data { get; set; }
}
public void createInvoice(Invoice invoice) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/invoice");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(invoice);
IRestResponse response = client.Execute(request);
InvoiceResponse apiResponse = JsonConvert.DeserializeObject<InvoiceResponse>(response);
if (apiResponse.Status === "success") {
// handle success
string newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
$invoice = array(
"currency" => "USD",
"company_name" => "ACME Inc.",
"customer_number" => "123Customer",
"payable_to" => array(
"id" => null,
"first_name" => "First",
"last_name" => "Last",
"company" => "Merchant Business",
"address_line_1" => "123 Some St",
"address_line_2" => null,
"city" => "Some City",
"state" => "IL",
"postal_code" => "60000",
"country" => "US",
"phone" => "5555555555",
"fax" => "5555555555",
"email" => "info@somewebsite.com"
),
"bill_to" => array(
"id" => null,
"first_name" => "First",
"last_name" => "Last",
"company" => "Merchant Business",
"address_line_1" => "123 Some St",
"address_line_2" => null,
"city" => "Some City",
"state" => "IL",
"postal_code" => "60000",
"country" => "US",
"phone" => "5555555555",
"fax" => "5555555555",
"email" => "info@somewebsite.com"
),
"date_due" => "2019-02-13T06:00:00.000Z",
"items" => array(array(
"name" => "Widget",
"description" => "A widget for processors",
"quantity" => 1,
"quantity_shipped" => 0,
"unit_of_measure" => "",
"unit_price" => 100,
"discount_rate" => "0.00",
"discount_amount" => 0,
"taxable" => false,
"local_tax_rate" => "0.00",
"local_tax" => 0,
"national_tax_rate" => "0.00",
"national_tax" => 0,
"tax_rate" => "0.00",
"tax_amount" => 0,
"status" => "pending"
)),
"advanced_fields" => false,
"tax_percent" => "0.00",
"tax" => 0,
"amount_paid" => 0,
"adjustment" => 0,
"amount_due" => 0,
"message" => "Thank you for your business!",
"send_via" => "none",
"payment_methods" => ["card"],
"card_processor_id" => "123abc",
"ach_processor_id" => ""
);
function createInvoice($invoice) {
$curl = curl_init();
$payload = json_encode($invoice);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/invoice",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
private String apiKey = <api key>;
public class ApiResponse {
String status;
String msg;
}
public class Address {
String id;
@JsonProperty(first_name)
String firstName;
@JsonProperty(last_name)
String lastName;
String company;
@JsonProperty(address_line_1)
String addressLine1;
@JsonProperty(address_line_2)
String addressLine2;
String city;
String state;
@JsonProperty(postal_code)
String postalCode;
String country;
String email;
String phone;
String fax;
}
public class Item {
String name;
String description;
int quantity;
@JsonProperty(quantity_shipped)
int quantityShipped;
@JsonProperty(unit_of_measure)
String unitOfMeasure;
@JsonProperty(unit_price)
int unitPrice;
@JsonProperty(discount_rate)
String discountRate;
int discountAmount;
boolean taxable;
@JsonProperty(local_tax_rate)
String localTaxRate;
@JsonProperty(local_tax)
int localTax;
@JsonProperty(national_tax_rate)
String nationalTaxRate;
@JsonProperty(national_tax)
int nationalTax;
@JsonProperty(tax_rate)
String taxRate;
@JsonProperty(tax_amount)
int taxAmount;
String status;
}
public class Invoice {
String currency;
@JsonProperty(company_name)
String companyName;
@JsonProperty(customer_number)
String customerNumber;
@JsonProperty(customer_id)
String customerId;
@JsonProperty(payable_to)
Address payableTo;
@JsonProperty(bill_to)
Address billTo;
@JsonProperty(date_due)
java.util.Date dateDue;
java.util.ArrayList<Item> items;
@JsonProperty(advanced_fields)
boolean advancedFields;
@JsonProperty(tax_percent)
String taxPercent;
int tax;
@JsonProperty(amount_paid)
int amountPaid;
int adjustment;
@JsonProperty(amount_due)
int amountDue;
String message;
@JsonProperty(send_via)
String sendVia;
@JsonProperty(payment_methods)
java.util.ArrayList<String> paymentMethods;
@JsonProperty(card_processor_id)
String cardProcessorId;
@JsonProperty(ach_processor_id)
String achProcessorId;
}
public class InvoiceResponse extends ApiResponse {
public Invoice data;
}
public void createInvoice(Invoice invoice) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(request);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/invoice")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
InvoiceResponse apiResponse = objectMapper.readValue(responseBody.String(), InvoiceResponse.class);
if (apiResponse.status === "success") {
// handle success
String newId = apiResponse.data.id;
} else {
// handle non success
}
}
# Get Invoice By ID
Retrieve details for the specified invoice.
Request Method:
GET
URL Endpoint:
/api/invoice/{ invoice id }
{
"status": "success",
"msg": "success",
"data": {
"id": "bhi9vado3hogrne0u4tg",
"currency": "USD",
"company_name": "ACME Inc.",
"company_logo_url": "",
"customer_number": "123Customer",
"payable_to": {
"id": "",
"first_name": "First",
"last_name": "Last",
"company": "Merchant Business",
"address_line_1": "123 Some St",
"address_line_2": "",
"city": "Some City",
"state": "IL",
"postal_code": "60000",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "info@somewebsite.com"
},
"bill_to": {
"id": "",
"first_name": "First",
"last_name": "Last",
"company": "Some Business",
"address_line_1": "123 Drury Lane",
"address_line_2": "",
"city": "Some City",
"state": "IL",
"postal_code": "60000",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "info@somesite.com"
},
"created_at": "2019-02-13T22:52:26Z",
"date_due": "2019-02-13T06:00:00Z",
"items": [
{
"id": "bhi9vado3hogrne0u4t0",
"name": "Widget",
"description": "A widget for processors",
"quantity": 1,
"quantity_shipped": 0,
"unit_of_measure": "",
"unit_price": 100,
"discount": 0,
"discount_type": "$",
"taxable": false,
"local_tax": "0",
"national_tax": "0",
"tax_rate": "0",
"tax_amount": 0,
"amount": 100,
"status": "pending"
}
],
"advanced_fields": false,
"subtotal": 100,
"tax_percent": "0.00",
"tax": 0,
"total": 100,
"amount_paid": 0,
"adjustment": 0,
"amount_due": 100,
"payment_methods": ["card"],
"card_processor_id": "bhi5qa5o3hogms88jojg",
"ach_processor_id": "",
"status": "pending",
"message": "Thank you for your business!",
"reject_message": "",
"send_via": "none",
"last_sent_at": "0001-01-01T00:00:00Z",
"updated_at": "2019-02-13T23:15:43Z",
"public_url": "d038ea94-3f4f-4703-9e94-74792605944e",
"hosted_url": "http://localhost:8080/invoice/d038ea94-3f4f-4703-9e94-74792605944e"
}
}
function getInvoice(invoiceId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/invoice/" + invoiceId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var invoice = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void getInvoice(string invoiceId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/invoice/" + invoiceId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
InvoiceResponse apiResponse = JsonConvert.DeserializeObject<InvoiceResponse>(response);
if (apiResponse.Status === "success") {
// handle success
string newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
<?php
function getInvoice($invoiceId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/invoice/".$invoiceId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization": .$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getInvoice(String invoiceId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/invoice/" + invoiceId)
.method("GET", null)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
InvoiceResponse apiResponse = objectMapper.readValue(responseBody.String(), InvoiceResponse.class);
if (apiResponse.status === "success") {
// handle success
Invoice invoice = apiResponse.data;
} else {
// handle non success
}
}
# Search Invoices
Retrieve details for all invoices that match provided search criteria.
Request Method:
POST
URL Endpoint:
/api/invoices/search
Name | Type | Description |
---|---|---|
id | object | Object containing details for searching by id |
id .operator | string literal | "=" or "!=" |
id .value | string | invoice id to match or exclude |
amount_due | object | Object containing details for searching by amount_due |
amount_due .operator | string literal | "=", "!=", "<", or ">" |
amount_due .value | integer | amount to match or exclude |
date_due | object | Object containing details for searching by date_due |
date_due .start_date | date string | Searches by date_due between the provided start_date and end_date. (Dates in UTC "YYYY-MM-DDTHH:II:SSZ") |
date_due .end_date | date string | Searches by date_due between the provided start_date and end_date. (Dates in UTC "YYYY-MM-DDTHH:II:SSZ") |
limit | integer | Maximum records to return (0-100) |
offset | integer | Number of records to offset the return by |
{
"status": "success",
"msg": "success",
"data": [
{
"id": "bhi9vado3hogrne0u4tg",
"currency": "USD",
"company_name": "ACME Inc.",
"company_logo_url": "",
"customer_number": "123Customer",
"payable_to": {
"id": "",
"first_name": "First",
"last_name": "Last",
"company": "Merchant Business",
"address_line_1": "123 Some St",
"address_line_2": "",
"city": "Some City",
"state": "IL",
"postal_code": "60000",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "info@somewebsite.com"
},
"bill_to": {
"id": "",
"first_name": "First",
"last_name": "Last",
"company": "Some Business",
"address_line_1": "123 Drury Lane",
"address_line_2": "",
"city": "Some City",
"state": "IL",
"postal_code": "60000",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "info@somesite.com"
},
"created_at": "2019-02-13T22:52:26Z",
"date_due": "2019-02-13T06:00:00Z",
"items": [
{
"id": "bhi9vado3hogrne0u4t0",
"name": "Widget",
"description": "A widget for processors",
"quantity": 1,
"quantity_shipped": 0,
"unit_of_measure": "",
"unit_price": 100,
"discount": 0,
"discount_type": "$",
"taxable": false,
"local_tax": "0",
"national_tax": "0",
"tax_rate": "0",
"tax_amount": 0,
"amount": 100,
"status": "pending"
}
],
"advanced_fields": false,
"subtotal": 100,
"tax_percent": "0.00",
"tax": 0,
"total": 100,
"amount_paid": 0,
"adjustment": 0,
"amount_due": 100,
"payment_methods": ["card"],
"card_processor_id": "bhi5qa5o3hogms88jojg",
"ach_processor_id": "",
"status": "pending",
"message": "Thank you for your business!",
"reject_message": "",
"send_via": "none",
"last_sent_at": "0001-01-01T00:00:00Z",
"updated_at": "2019-02-13T23:15:43Z",
"public_url": "d038ea94-3f4f-4703-9e94-74792605944e",
"hosted_url": "http://localhost:8080/invoice/d038ea94-3f4f-4703-9e94-74792605944e"
}
],
"total_count": 1
}
function searchInvoices() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
id: {
operator: "=",
value: "123abc",
},
amount_due: {
operator: "=",
value: 100,
},
date_due: {
start_date: "2019-02-12T00:00:00Z",
end_date: "2021-02-14T23:59:59Z",
},
limit: 10,
offset: 0,
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow",
};
fetch("https://sandbox.durangomsgateway.com/api/invoices/search", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var invoices = result.data;
var total = result.total_count;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class OperatorValueCriteria {
public string Operator { get; set; }
public string Value { get; set; }
}
public class DateRangeCriteria {
[JsonProperty(start_date)]
public DateTime StartDate { get; set; }
[JsonProperty(end_date)]
public DateTime EndDate { get; set; }
}
public class InvoiceSearchCriteria {
public OperatorValueCriteria Id { get; set; }
[JsonProperty(amount_due)]
public OperatorValueCriteria AmountDue { get; set; }
[JsonProperty(date_due)]
public DateRangeCriteria DateDue { get; set; }
public int Limit { get; set; }
public int Offset { get; set; }
}
public class InvoiceSearchResponse {
public List<Invoice> Data { get; set; }
[JsonProperty(total_count)]
public int TotalCount { get; set; }
}
public void searchInvoices(InvoiceSearchCriteria searchCriteria) {
// Search Invoices
var client = new RestClient("https://sandbox.durangomsgateway.com/api/invoices/search");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(searchCriteria);
IRestResponse response = client.Execute(request);
InvoiceSearchResponse apiResponse = JsonConvert.DeserializeObject<InvoiceSearchResponse>(response);
if (apiResponse.status === "success") {
// handle success
List<Invoice> invoices = apiResponse.Data;
int total = apiResponse.TotalCount;
} else {
// handle non success
}
}
<?php
$searchCriteria = array(
id => array(
operator => "=",
value => "123abc"
),
amount_due => array(
operator => "=",
value => 100
),
date_due => array(
start_date => "2019-02-12T00:00:00Z",
end_date => "2019-02-14T23:59:59Z"
),
limit => 10,
offset => 0
);
function searchInvoices($searchCriteria) {
$curl = curl_init();
$payload = json_encode($searchCriteria);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/invoices/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class OperatorValueCriteria {
public string Operator { get; set; }
public string Value { get; set; }
}
public class DateRangeCriteria {
[JsonProperty(start_date)]
public DateTime StartDate { get; set; }
[JsonProperty(end_date)]
public DateTime EndDate { get; set; }
}
public class InvoiceSearchCriteria {
public OperatorValueCriteria Id { get; set; }
[JsonProperty(amount_due)]
public OperatorValueCriteria AmountDue { get; set; }
[JsonProperty(date_due)]
public DateRangeCriteria DateDue { get; set; }
public int Limit { get; set; }
public int Offset { get; set; }
}
public class InvoiceSearchResponse {
public java.util.ArrayList<Invoice> Data;
@JsonProperty(total_count)
public int TotalCount;
}
public void searchInvoices(SearchCriteria searchCriteria) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
String jsonObject = gson.toJson(searchCriteria);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/invoices/search")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
InvoiceSearchResponse apiResponse = objectMapper.readValue(responseBody.String(), InvoiceSearchResponse.class);
if (apiResponse.status === "success") {
// handle success
java.util.ArrayList<Invoice> invoice = apiResponse.data;
} else {
// handle non success
}
}
# Update Invoice
Update an existing invoice.
Request Method:
POST
URL Endpoint:
/api/invoice/{ invoice id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
currency | string literal | Currency that invoice amounts should be in ("USD", etc.) | * | |
company_name | string | Name of company issuing the invoice | ||
company_logo_url | string | Hosted location of logo image to include on invoice | ||
customer_number | string | Optional identifier for the invoiced customer to match merchant records | ||
customer_id | string | ID of the saved customer being invoiced (must be a valid customer id if included) | ||
invoice_number | string | Optional identifier for the invoice to match merchant records | ||
payable_to | object | object containing details for the person the invoice is being paid to | * | |
payable_to .id | string | ID of the stored address you want to make the invoice payable to | ||
payable_to .first_name | string | First name | ||
payable_to .last_name | string | Last name | ||
payable_to .company | string | Company name | ||
payable_to .address_line_1 | string | Address line 1 | * | |
payable_to .address_line_2 | string | Address line 2 | ||
payable_to .city | string | City | * | |
payable_to .state | string literal | State, in 2-character format ("KS", "QC", etc.)) | * | |
payable_to .postal_code | string | Postal code (must be a valid postal code for the country provided) | * | |
payable_to .country | string literal | Country, in 2-character format ("US", "CA", "MX", etc.) | * | |
payable_to .phone | string | Phone number | ||
payable_to .fax | string | Fax number | ||
payable_to | string | Email address (must be valid email format, "example@mail.com") | ||
bill_to | object | object containing details for the person the invoice is being billed to | * | |
bill_to .id | string | ID of the stored address you want to make the invoice billable to | ||
bill_to .first_name | string | First name | ||
bill_to .last_name | string | Last name | ||
bill_to .company | string | Company name | ||
bill_to .address_line_1 | string | Address line 1 | * | |
bill_to .address_line_2 | string | Address line 2 | ||
bill_to .city | string | City | * | |
bill_to .state | string literal | State, in 2-character ("KS", "QC", etc.)format | * | |
bill_to .postal_code | string | Postal (must be a valid postal code for the country provided) code | * | |
bill_to .country | string literal | Country, in 2-character ("US", "CA", "MX", etc.) format | * | |
bill_to .phone | string | Phone number | ||
bill_to .fax | string | Fax number | ||
bill_to | string | Email address (must be valid email format, "example@mail.com") | ||
date_due | datetime string | Date the invoice is due ("2021-02-13T06:00:00.000Z")by | * | |
items[#] | object array | array containing line items included in the invoice | * | |
items[#] .status | string literal | "pending" or "paid" | * | |
items[#] .type | string | "" | Type of item | |
items[#] .name | string | "" | Name of item | |
items[#] .description | string | "" | Description of item | |
items[#] .unit_price | integer | Unit price of item | * | |
items[#] .quantity | integer | Quantity of item | * | |
items[#] .quantity_shipped | integer | 0 | Quantity of items shipped to customer | |
items[#] .product_code | string | "" | Product Code of item | |
items[#] .commodity_code | string | "" | Commodity Code of item | |
items[#] .unit_of_measure | string | "" | Unit of measure of item ("lb", "kg", etc.) | |
items[#] .alternate_tax_identifier | string | "" | Alternate tax ID for item | |
items[#] .taxable | boolean | false | Whether local and national tax should be applied at the item level rather than the invoice level | |
items[#] .local_tax_rate | string | "" | Local tax rate for item ("1.000") | |
items[#] .local_tax | integer | 0 | Local tax amount to be added to the item's total, expressed in cents (100 = $1.00) | |
items[#] .national_tax_rate | string | "" | National tax rate for item ("1.000") | |
items[#] .national_tax | integer | 0 | National tax amount to be added to the item's total, expressed in cents (100 = $1.00) | |
items[#] .tax_rate | string | "" | Combined tax rate for item (local tax + national tax) | |
items[#] .tax_amount | integer | 0 | Tax amount to be added to the item's total, expressed in cents (100 = $1.00) | |
items[#] .discount_amount | integer | 0 | Discount to take off the item's total amount, expressed in cents (100 = $1.00)) | |
items[#] .freight_amount | integer | 0 | Freight amount to add to the item's total, expressed in cents (100 = $1.00) | |
advanced_fields | boolean | false | Whether or not to include additional fields for line items (advanced fields include quantity_shipped, freight_amount, unit_of_measure, taxable, local_tax_rate, local_tax, national_tax_rate, national_tax) | |
enable_tax | boolean | false | Whether or not to enable tax (if enabled, tax applied at the invoice level will override taxes applied at the item level) | |
enable_shipping | boolean | false | Whether or not to enable shipping | |
require_shipping_details | boolean | false | Whether or not to require shipping details | |
require_billing_details_on_payment_only | boolean | false | Whether or not to require billing details only at time of payment | |
tax_percent | string | Tax rate to apply to invoice total if enable_tax is true. A rate of "0.000" will cause tax to be read as a flat amount. | * | |
tax | integer | calculated amount | Total tax amount of the invoice, expressed in cents (100 = $1.00). If tax_percent is included and is not "0", this field will be overridden with the calculated amount. | |
shipping | integer | calculated amount | Shipping amount of the invoice, expressed in cents (100 = $1.00) | |
amount_paid | integer | calculated amount | Amount of the invoice that has already been paid, expressed in cents (100 = $1.00) | |
service_fees_paid | integer | calculated amount | Service fee amount that has already been paid, expressed in cents (100 = $1.00) | |
surcharge_paid | integer | calculated amount | Surcharge amount that has already been paid, expressed in cents (100 = $1.00) | |
discount_credited | integer | calculated amount | Discount amount that has already been credited, expressed in cents (100 = $1.00) | |
adjustment | integer | 0 | Apply a payment adjustment to the total amount of the invoice, expressed in cents (100 = $1.00) | |
amount_due | integer | calculated amount | Amount of the invoice that remains due, expressed in cents (100 = $1.00) | |
allow_partial_payment | boolean | false | Whether or not to allow partial payment of the amount due | |
transaction_type | string literal | "sale" | "sale" or "authorize" | |
payment_methods[#] | string array | Allowable payment method types ("card", "ach", and/or "mail") | * | |
card_processor_id (can be "") | string | ID of the payment processor to use for credit card payments | * | |
ach_processor_id (can be "") | string | ID of the payment processor to use for ACH payments | * | |
message | string | Message for customers viewing the invoice | ||
send_via | string literal | How to send invoice notifications ("email", "text", "both", or "none") | * | |
email_to | string | Email address (must be valid email format, "xxxxx@xxxxx.xxx") |
{
"status": "success",
"msg": "success",
"data": {
"id": "bhi9vado3hogrne0u4tg",
"currency": "USD",
"company_name": "ACME Inc.",
"company_logo_url": "",
"customer_number": "123Customer",
"payable_to": {
"id": "",
"first_name": "First",
"last_name": "Last",
"company": "Merchant Business",
"address_line_1": "123 Some St",
"address_line_2": "",
"city": "Some City",
"state": "IL",
"postal_code": "60000",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "info@somewebsite.com"
},
"bill_to": {
"id": "",
"first_name": "First",
"last_name": "Last",
"company": "Some Business",
"address_line_1": "123 Drury Lane",
"address_line_2": "",
"city": "Some City",
"state": "IL",
"postal_code": "60000",
"country": "US",
"phone": "5555555555",
"fax": "5555555555",
"email": "info@somesite.com"
},
"created_at": "2019-02-13T22:52:26Z",
"date_due": "2019-02-13T06:00:00Z",
"items": [
{
"id": "bhi9vado3hogrne0u4t0",
"name": "Widget",
"description": "A widget for processors",
"quantity": 1,
"quantity_shipped": 0,
"unit_of_measure": "",
"unit_price": 100,
"discount": 0,
"discount_type": "$",
"taxable": false,
"local_tax": "0",
"national_tax": "0",
"tax_rate": "0",
"tax_amount": 0,
"amount": 100,
"status": "pending"
}
],
"advanced_fields": false,
"subtotal": 100,
"tax_percent": "0.00",
"tax": 0,
"total": 100,
"amount_paid": 0,
"adjustment": 0,
"amount_due": 100,
"payment_methods": ["card"],
"card_processor_id": "bhi5qa5o3hogms88jojg",
"ach_processor_id": "",
"status": "pending",
"message": "Thank you for your business!",
"reject_message": "",
"send_via": "none",
"last_sent_at": "0001-01-01T00:00:00Z",
"updated_at": "2019-02-13T23:15:42.799495Z",
"public_url": "d038ea94-3f4f-4703-9e94-74792605944e",
"hosted_url": "http://localhost:8080/invoice/d038ea94-3f4f-4703-9e94-74792605944e"
}
}
function updateInvoice(invoice) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify(invoice);
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/invoice/" + invoice.id, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void updateInvoice(Invoice invoice) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/invoice/" + invoice.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(invoice);
IRestResponse response = client.Execute(request);
InvoiceResponse apiResponse = JsonConvert.DeserializeObject<InvoiceResponse>(response);
if (apiResponse.Status === "success") {
// handle success
string newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
<?php
function updateInvoice($invoice) {
$curl = curl_init();
$payload = json_encode($invoice);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/invoice/".$invoice->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updateInvoice(Invoice invoice) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(request);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/invoice/" + invoice.id)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
InvoiceResponse apiResponse = objectMapper.readValue(responseBody.String(), InvoiceResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Delete Invoice
Delete the specified invoice.
Request Method:
DELETE
URL Endpoint:
/api/invoice/{ invoice id }
{
"status": "success",
"msg": "success"
}
function deleteInvoice(invoiceId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api / invoice /" + invoiceId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void deleteInvoice(int id) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/invoice/" + id);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deleteInvoice($id) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/invoice/".$id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deleteInvoice(int invoiceId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, );
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/invoice/" + invoiceId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ApiResponse apiResponse = objectMapper.readValue(responseBody.String(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Customer Vault
TIP
This section describes the canonical methods for creating and managing Customer records. The endpoints described in the Customers (Deprecated) section are still available for use, but be advised that using endpoints from both groups in your application simultaneously can result in unintended behaviors.
# Create Customer Record
Creates a new Customer record that can contain stored preferences, payment methods, and addresses.
Request Method:
POST
URL Endpoint:
/api/vault/customer
Name | Type | Default | Description | Required |
---|---|---|---|---|
id | string | generated value | Optionally, you may provide a custom id for storing the vaulted customer. Max 40 characters (a-z, A-Z, 0-9) | |
id_format | string literal | Optionally defines a format for the gateway to use when auto-generating an id ("xid_type_last4"). Cannot be used if providing a custom id. | ||
description | string | "" | Text field, max 255 characters | |
flags | string array | [] | Array containing flags for customer settings ("surcharge_exempt") | |
default_payment | object | null | Object containing ach payment method details | |
default_payment .card | object | null | Object containing card payment method details | |
default_payment .card .number | string | "" | Card number | |
default_payment .card .expiration_date | string | "" | Card expiration date ("MMYY" or "MM/YY") | required if default_payment.card is present |
default_payment .ach | object | null | Object containing ach payment method details | |
default_payment .ach .account_number | string | "" | Account number | |
default_payment .ach .routing_number | string | "" | Routing number | |
default_payment .ach .account_type | string literal | Ach account type ("checking" or "savings") | required if default_payment.ach is present | |
default_payment .ach .sec_code | string literal | Ach sec code ("web", "ccd", or "ppd") | required if default_payment.ach is present | |
default_payment .token | string | Payment method token generated by Tokenizer form | ||
default_billing_address | object | null | Object containing billing address details | |
default_billing_address .first_name | string | "" | Addressee first name | |
default_billing_address .last_name | string | "" | Addressee last name | |
default_billing_address .company | string | "" | Company name | |
default_billing_address .line_1 | string | "" | Street address | |
default_billing_address .line_2 | string | "" | Additional delivery details | |
default_billing_address .city | string | "" | City name | |
default_billing_address .state | string | "" | State code ("CA") | |
default_billing_address .postal_code | string | "" | Postal code ("12345") | |
default_billing_address .country | string | "" | Country code ("US") | |
default_billing_address | string | "" | Email address (must be valid email format, "example@mail.com") | |
default_billing_address .phone | string | "" | Phone number ("3216540987") | |
default_billing_address .fax | string | "" | ("3216540987") | |
default_shipping_address | object | null | Object containing shipping address details | |
default_shipping_address .first_name | string | "" | Addressee first name | |
default_shipping_address .last_name | string | "" | Addressee last name | |
default_shipping_address .company | string | "" | Company name | |
default_shipping_address .line_1 | string | "" | Street address | |
default_shipping_address .line_2 | string | "" | Additional delivery details | |
default_shipping_address .city | string | "" | City name | |
default_shipping_address .state | string | "" | State code ("CA") | |
default_shipping_address .postal_code | string | "" | Postal code ("12345") | |
default_shipping_address .country | string | "" | Country code ("US") | |
default_shipping_address | string | "" | Email address (must be valid email format, "example@mail.com") | |
default_shipping_address .phone | string | "" | Phone number ("3216540987") | |
default_shipping_address .fax | string | "" | ("3216540987") |
{
"status": "success",
"msg": "success",
"data": {
"id": "952f250d-fa85-40ac-a45e-3886f98032c6",
"owner_id": "testmerchant12345678",
"data": {
"customer": {
"addresses": [
{
"city": "Some Town",
"company": "Some Business",
"country": "US",
"email": "user@somesite.com",
"fax": "555555555",
"first_name": "John",
"hash": "cV9qS6UvnnRDJCkgfitHqGrKSRfTARDsLy5zfkNNTcM=",
"id": "bl6nqk69ku6897l45fp0",
"last_name": "Smith",
"line_1": "",
"line_2": "",
"phone": "5555555555",
"postal_code": "60187",
"state": "IL"
}
],
"defaults": {
"billing_address_id": "bl6nqk69ku6897l45fp0",
"payment_method_id": "bl6nqk69ku6897l45fq0",
"payment_method_type": "card",
"shipping_address_id": "bl6nqk69ku6897l45fp0"
},
"description": "test description",
"notes": "",
"flags": ["surcharge_exempt"],
"payments": {
"ach": [],
"cards": [
{
"card_type": "visa",
"expiration_date": "2020-12-31T00:00:00Z",
"id": "bl6nqk69ku6897l45fq0",
"masked_number": "411111******1111"
}
]
}
}
},
"created_at": "2019-08-09T09:04:00.786094073-05:00",
"updated_at": "2019-08-09T09:04:00.786094116-05:00"
}
}
function createCustomerRecord() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
id_format: "xid_type_last4",
description: "test description",
flags: ["surcharge_exempt"],
default_payment: {
card: {
number: "4111111111111111",
expiration_date: "1220",
},
},
default_billing_address: {
first_name: "John",
last_name: "Smith",
company: "Some Business",
line_1: "123 Some St",
line_2: "STE 1",
city: "Some Town",
state: "IL",
postal_code: "60187",
country: "US",
email: "user@somesite.com",
phone: "5555555555",
fax: "555555555",
},
default_shipping_address: {
first_name: "John",
last_name: "Smith",
company: "Some Business",
line_1: "123 Some St",
line_2: "STE 1",
city: "Some Town",
state: "IL",
postal_code: "60187",
country: "US",
email: "user@somesite.com",
phone: "5555555555",
fax: "555555555",
},
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/vault/customer", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class ApiResponse {
public string Status { get; set; }
public string Msg { get; set; }
}
public class Address {
public string Id { get; set; }
[JsonProperty("first_name")]
public string FirstName { get; set; }
[JsonProperty("last_name")]
public string LastName { get; set; }
public string Company { get; set; }
[JsonProperty("address_line_1")]
public string AddressLine1 { get; set; }
[JsonProperty("line_1")]
public string Line1 { get; set { AddressLine1 = value; } }
[JsonProperty("address_line_2")]
public string AddressLine2 { get; set; }
[JsonProperty("line_2")]
public string Line2 { get; set { AddressLine2 = value; } }
public string City { get; set; }
public string State { get; set; }
[JsonProperty("postal_code")]
public string PostalCode { get; set; }
public string Country { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Fax { get; set; }
}
public class Customer {
public string Id { get; set; }
[JsonProperty("id_format")]
public string IdFormat { get; set; }
public string Description { get; set; }
public List<string> Flags { get; set; }
[JsonProperty("default_payment")]
public PaymentMethod DefaultPayment { get; set; }
[JsonProperty("billing_address")]
public Address BillingAddress { get; set; }
[JsonProperty("shipping_address")]
public Address ShippingAddress { get; set; }
}
public class PaymentMethod {
public Card Card { get; set; }
}
public class Card {
public string Number { get; set; }
[JsonProperty("expiration_date")]
public string ExpirationDate { get; set; }
}
public class CustomerDefaults {
[JsonProperty("billing_address_id")]
public string BillingAddressId { get; set; }
[JsonProperty("payment_method_id")]
public string PaymentMethodId { get; set; }
[JsonProperty("payment_method_type")]
public string PaymentmethodType { get; set; }
[JsonProperty("shipping_address_id")]
public string ShippingAddressId { get; set; }
}
public class Card {
[JsonProperty("card_type")]
public string CardType { get; set; }
[JsonProperty("expiration_date")]
public DateTime ExpirationDate { get; set; }
public List<string> Flags { get; set; }
public string Id { get; set; }
[JsonProperty("masked_number")]
public string MaskedNumber { get; set; }
[JsonProperty("processor_id")]
public string ProcessorId { get; set; }
}
public class Ach {
[JsonProperty("account_number")]
public string AccountNumber { get; set; }
[JsonProperty("routing_number")]
public string RoutingNumber { get; set; }
[JsonProperty("account_type")]
public string AccountType { get; set; }
[JsonProperty("sec_code")]
public string SecCode { get; set; }
}
public class Payments {
public List<Card> Cards { get; set; }
}
public class CreateCustomerResponseData {
public string Id { get; set; }
public List<Address> Addresses { get; set; }
public CustomerDefaults Defaults { get; set; }
public string Description { get; set; }
public List<string> Flags { get; set; }
public string Notes { get; set; }
public Payments Payments { get; set; }
}
public class CreateCustomerResponse : ApiResponse {
public CreateCustomerResponseData Data { get; set; }
}
public void CreateCustomer(Customer customer) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/customer");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(customer);
IRestResponse response = client.Execute(request);
CreateCustomerResponse apiResponse = JsonConvert.DeserializeObject<CreateCustomerResponse>(response);
if (apiResponse.Status === "success" && apiResponse.Data.Count) {
// handle success
CreateCustomerResponseData responseData = apiResponse.Data;
} else {
// handle non success
}
}
<?php
$customer = array(
"id_format" => "xid_type_last4",
"description" => "test description",
"flags" => ["surcharge_exempt"],
"default_payment" => array(
"card" => array(
"number" => "4111111111111111",
"expiration_date" => "1220"
)
),
"default_billing_address" => array(
"first_name" => "John",
"last_name" => "Smith",
"company" => "Some Business",
"line_1" => "123 Some St",
"line_2" => "STE 1",
"city" => "Some Town",
"state" => "IL",
"postal_code" => "60187",
"country" => "US",
"email" => "user@somesite.com",
"phone" => "5555555555",
"fax" => "555555555"
),
"default_shipping_address" => array(
"first_name" => "John",
"last_name" => "Smith",
"company" => "Some Business",
"line_1" => "123 Some St",
"line_2" => "STE 1",
"city" => "Some Town",
"state" => "IL",
"postal_code" => "60187",
"country" => "US",
"email" => "user@somesite.com",
"phone" => "5555555555",
"fax" => "555555555"
)
);
function createCustomer($customer) {
$curl = curl_init();
$payload = json_encode($customer);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/customer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>$payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class ApiResponse {
public String status;
public String msg;
}
public class Address {
public String id;
@JsonProperty("first_name")
public String firstName;
@JsonProperty("last_name")
public String lastName;
public String company;
@JsonProperty("address_line_1")
public String addressLine1;
@JsonProperty("line_1")
public String line1;
@JsonProperty("address_line_2")
public String addressLine2;
@JsonProperty("line_2")
public String line2;
public String city;
public String state;
@JsonProperty("postal_code")
public String postalCode;
public String country;
public String email;
public String phone;
public String fax;
}
public class Customer {
public String id;
@JsonProperty("id_format")
public String idFormat;
public String description;
public java.util.ArrayList<String> flags;
@JsonProperty("default_payment")
public PaymentMethod defaultPayment;
@JsonProperty("billing_address")
public Address billingAddress;
@JsonProperty("shipping_address")
public Address shippingAddress;
}
public class PaymentMethod {
public Card card;
}
public class Card {
public String id;
public String number;
@JsonProperty("expiration_date")
public String expirationDate;
}
public class CustomerDefaults {
@JsonProperty("billing_address_id")
public String billingAddressId;
@JsonProperty("payment_method_id")
public String paymentMethodId;
@JsonProperty("payment_method_type")
public String paymentmethodType;
@JsonProperty("shipping_address_id")
public String shippingAddressId;
}
public class Card {
@JsonProperty("card_type")
public String cardType;
@JsonProperty("expiration_date")
public DateTime expirationDate;
public java.util.ArrayList<String> flags;
public String id;
@JsonProperty("masked_number")
public String maskedNumber;
@JsonProperty("processor_id")
public String processorId;
}
public class Ach {
@JsonProperty("account_number")
public String accountNumber;
@JsonProperty("routing_number")
public String routingNumber;
@JsonProperty("account_type")
public String accountType;
@JsonProperty("sec_code")
public String secCode;
}
public class Payments {
public java.util.ArrayList<Card> cards;
}
public class CreateCustomerResponseData {
public String id;
public java.util.ArrayList<Address> addresses;
public CustomerDefaults defaults;
public String description;
public java.util.ArrayList<String> flags;
public String notes;
public Payments payments;
}
public class CreateCustomerResponse extends ApiResponse {
public CreateCustomerResponseData data;
}
public void CreateCustomer(Customer customer) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(customer);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/customer")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CreateCustomerResponse createResponse = objectMapper.readValue(responseBody.string(), CreateCustomerResponse.class);
if (createResponse.status === "success") {
// handle success
CreateCustomerResponseData data = createResponse.data;
} else {
// handle non success
}
}
# Get Customer Record By ID
Retrieve details for the specified customer.
Request Method:
GET
URL Endpoint:
/api/vault/{ customer id }
{
"status": "success",
"msg": "success",
"data": {
"id": "952f250d-fa85-40ac-a45e-3886f98032c6",
"owner_id": "testmerchant12345678",
"data": {
"customer": {
"addresses": [
{
"city": "Some Town",
"company": "Some Business",
"country": "US",
"email": "user@somesite.com",
"fax": "555555555",
"first_name": "John",
"hash": "cV9qS6UvnnRDJCkgfitHqGrKSRfTARDsLy5zfkNNTcM=",
"id": "bl6nqk69ku6897l45fp0",
"last_name": "Smith",
"line_1": "",
"line_2": "",
"phone": "5555555555",
"postal_code": "60187",
"state": "IL"
}
],
"defaults": {
"billing_address_id": "bl6nqk69ku6897l45fp0",
"payment_method_id": "bl6nqk69ku6897l45fq0",
"payment_method_type": "card",
"shipping_address_id": "bl6nqk69ku6897l45fp0"
},
"description": "test description",
"payments": {
"ach": [],
"cards": [
{
"card_type": "visa",
"expiration_date": "2020-12-31T00:00:00Z",
"id": "bl6nqk69ku6897l45fq0",
"masked_number": "411111******1111"
}
]
}
}
},
"created_at": "2019-08-09T09:04:00.786094073-05:00",
"updated_at": "2019-08-09T09:04:00.786094116-05:00"
}
}
function getCustomerRecord(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/vault/" + customerId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var customer = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void GetCustomer(string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/" + customerId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
CreateCustomerResponse apiResponse = JsonConvert.DeserializeObject<CreateCustomerResponse>(response);
if (apiResponse.Status === "success" && apiResponse.Data.Count) {
// handle success
CreateCustomerResponseData responseData = apiResponse.Data;
}
else {
// handle non success
}
}
<?php
function getCustomer($id) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/".$id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getCustomer(String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/" + customerId)
.method("GET", null)
.addHeader("Authorization", apiKey
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CreateCustomerResponse createResponse = objectMapper.readValue(responseBody.string(), CreateCustomerResponse.class);
if (createResponse.status === "success") {
// handle success
CreateCustomerResponseData data = createResponse.data;
} else {
// handle non success
}
}
# Search Customer Records
Retrieve details for all customer records that match provided search criteria.
Request Method:
POST
URL Endpoint:
/api/vault/customer/search
Name | Type | Default | Description | Required |
---|---|---|---|---|
id | object | Object containing details defining a customer id to match or exclude | ||
id .value | string | "" | Customer record ID to match or exclude | |
id .operator | string | "" | "=" or "!=" | |
address_id | object | Object containing details defining an address id to match or exclude | ||
address_id .value | string | "" | Address ID to match or exclude | |
address_id .operator | string | "" | "=" or "!=" | |
first_name | object | Object containing details defining a customer first name to match or exclude | ||
first_name .value | string | "" | Customer first name to match or exclude | |
first_name .operator | string | "" | "=" or "!=" | |
last_name | object | Object containing details defining a customer last name to match or exclude | ||
last_name .value | string | "" | Customer last name to match or exclude | |
last_name .operator | string | "" | "=" or "!=" | |
company | object | Object containing details defining a company name to match or exclude | ||
company .value | string | "" | Customer company to match or exclude | |
company .operator | string | "" | "=" or "!=" | |
address_line_1 | object | Object containing details defining a street address to match or exclude | ||
address_line_1 .value | string | "" | Customer street address to match or exclude | |
address_line_1 .operator | string | "" | "=" or "!=" | |
address_line_2 | object | Object containing details defining additional address details to match or exclude | ||
address_line_2 .value | string | "" | Customer address details to match or exclude | |
address_line_2 .operator | string | "" | "=" or "!=" | |
city | object | Object containing details defining a city to match or exclude | ||
city .value | string | "" | Customer city to match or exclude | |
city .operator | string | "" | "=" or "!=" | |
state | object | Object containing details defining a state to match or exclude | ||
state .value | string | "" | Customer state to match or exclude | |
state .operator | string | "" | "=" or "!=" | |
postal_code | object | Object containing details defining a postal code to match or exclude | ||
postal_code .value | string | "" | Customer postal code to match or exclude | |
postal_code .operator | string | "" | "=" or "!=" | |
country | object | Object containing details defining a country to match or exclude | ||
country .value | string | "" | Customer country to match or exclude | |
country .operator | string | "" | "=" or "!=" | |
object | Object containing details defining a customer email to match or exclude | |||
email .value | string | "" | Customer email to match or exclude | |
email .operator | string | "" | "=" or "!=" | |
phone | object | Object containing details defining a phone number to match or exclude | ||
phone .value | string | "" | Customer phone to match or exclude | |
phone .operator | string | "" | "=" or "!=" | |
fax | object | Object containing details defining a fax number to match or exclude | ||
fax .value | string | "" | Customer fax to match or exclude | |
fax .operator | string | "" | "=" or "!=" | |
payment_method_type | object | Object containing details defining a payment method type to match or exclude | ||
payment_method_type .value | string | "" | Customer payment method type to match or exclude | |
payment_method_type .operator | string | "" | "=" or "!=" | |
billing_address_id | object | Object containing details defining a billing address id to match or exclude | ||
billing_address_id .value | string | "" | Customer billing address id to match or exclude | |
billing_address_id .operator | string | "" | "=" or "!=" | |
shipping_address_id | object | Object containing details defining a shipping address id to match or exclude | ||
shipping_address_id .value | string | "" | Customer shipping address id to match or exclude | |
shipping_address_id .operator | string | "" | "=" or "!=" | |
created_at | object | Object containing details defining a date range to match | ||
created_at .start_date | string | "" | Beginning of date range | |
created_at .end_date | string | "" | End of date range | |
updated_at | object | Object containing details defining a date range to match | ||
updated_at .start_date | string | "" | Beginning of date range | |
updated_at .end_date | string | "" | End of date range | |
limit | integer | 10 | The number of results to return (1-100) | |
offset | integer | 0 | The number of results to skip (1-1000) |
{
"status": "success",
"msg": "success",
"data": [
{
"created_at": "2019-07-17T20:20:26.255763044Z",
"data": {
"customer": {
"addresses": [
{
"city": "Some Town",
"company": "",
"country": "US",
"email": "the.original.e@gmail.com",
"fax": "",
"first_name": "TEST",
"hash": "Prk83qffXbR358Q/5oH29LqUwx+L8AwMUVrFWjHt1Ic=",
"id": "bgl4vq1erttokpdi1kk0",
"last_name": "TEST",
"line_1": "ABC LANE",
"line_2": "",
"phone": "",
"postal_code": "66219",
"state": "KS"
}
],
"defaults": {
"billing_address_id": "bgl4vq1erttokpdi1kk0",
"payment_method_id": "bgl4vq1erttokpdi1kk0",
"payment_method_type": "card",
"shipping_address_id": "bgl4vq1erttokpdi1kk0"
},
"description": "",
"flags": [],
"notes": "",
"payments": {
"ach": [],
"cards": [
{
"card_type": "visa",
"expiration_date": "12/19",
"flags": [],
"id": "bmak1e1erttvtct22910",
"masked_number": "411111******1111",
"processor_id": ""
},
{
"card_type": "visa",
"expiration_date": "12/20",
"flags": [],
"id": "bo572hherttokc9v84t0",
"masked_number": "400551******0004",
"processor_id": ""
}
]
}
}
},
"id": "bgl4vq1erttokpdi1kj0",
"owner_id": "bevs7q9erttoq1lrgmug",
"updated_at": "2019-07-17T20:20:26.255763179Z"
}
],
"total_count": 81
}
function searchCustomers(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
id: {
operator: "=",
value: customerId,
},
created_at: {
start_date: "2020-12-06T00:00:00Z",
end_date: "2020-12-06T23:59:59Z",
},
limit: 100,
offset: 0,
// ... other search criteria as needed
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/vault/customer/search", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success" && result.data.length) {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class QueryResponse : ApiResponse {
public List<CustomerData> Data { get; set; }
}
public class CustomerData {
public string Id { get; set; }
public DateTime Created_at { get; set; }
public DateTime Updated_at { get; set; }
public int Limit { get; set; }
public int Offset { get; set; }
}
public void searchCustomers(SearchCriteria criteria) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/customer/search");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", ParameterType.RequestBody);
request.AddJsonBody(criteria);
IRestResponse response = client.Execute(request);
QueryResponse apiResponse = JsonConvert.DeserializeObject<QueryResponse>(response);
if (apiResponse.Status === "success" && apiResponse.Data.Count) {
// handle success
} else {
// handle non success
}
}
<?php
$customerSearchCriteria = array(
"id" => array(
"operator" => "=",
"value" => "123abc"
),
"created_at" => array(
"start_date" => "2020-10-06T00:00:00Z",
"end_date" => "2020-10-06T23:59:59Z"
),
"updated_at" => array(
"start_date" => "2020-12-06T00:00:00Z",
"end_date" => "2020-12-06T23:59:59Z"
),
"limit" => 1,
"offset" => 0
)
function searchCustomers($customerSearchCriteria) {
$curl = curl_init();
$payload = json_encode($customerSearchCriteria);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/customer/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
)
));
$response = curl_exec($curl);
$result = json_decode($response, true);
if ($result["Status"] === "success") {
$transactions = $result["data"];
} else {
}
curl_close($curl);
echo $response;
}
public class QueryResponse extends ApiResponse {
public List<CustomerData> data;
}
public class CustomerData {
public string id;
@JsonProperty("created_at")
public DateTime createdAt;
@JsonProperty("updated_at")
public DateTime updatedAt;
public int limit;
public int offset;
}
public void searchCustomers(SearchCriteria criteria) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(request);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/customer/search")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
QueryResponse entity = objectMapper.readValue(responseBody.string(), QueryResponse.class);
if (entity.status === "success") {
// handle success
var transactions = entity.Data;
} else {
// handle non success
}
}
# Update Customer Record
Update an existing customer record.
Request Method:
POST
URL Endpoint:
/api/vault/customer/{ customer id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
description | string | "" | Text field, max 255 characters | |
notes | string | "" | Text field, max 255 characters | |
flags | string array | [] | Array containing flags for customer settings ("surcharge_exempt") | |
defaults | object | null | Object containing id's designating payment methods and addresses to be used as defaults for the customer's transactions | |
defaults .billing_address_id | string | If only one stored address exists on the customer record, that will be used by default | Id of stored address to use as the default billing address for transactions | |
defaults .shipping_address_id | string | If only one stored address exists on the customer record, that will be used by default | Id of stored address to use as the default shipping address for transactions | |
defaults .payment_method_id | string | Id of stored payment method to use as the default payment method for transactions | required if defaults.payment_method_type is present | |
defaults .payment_method_type | string literal | "" | Type of the payment method id supplied ("card" or "ach") | required if defaults.payment_method_id is present |
{
"status": "success",
"msg": "success",
"data": {
"id": "952f250d-fa85-40ac-a45e-3886f98032c6",
"owner_id": "testmerchant12345678",
"data": {
"customer": {
"addresses": [
{
"city": "Some Town",
"company": "Some Business",
"country": "US",
"email": "user@somesite.com",
"fax": "555555555",
"first_name": "John",
"hash": "cV9qS6UvnnRDJCkgfitHqGrKSRfTARDsLy5zfkNNTcM=",
"id": "bl6nqk69ku6897l45fp0",
"last_name": "Smith",
"line_1": "",
"line_2": "",
"phone": "5555555555",
"postal_code": "60187",
"state": "IL"
}
],
"defaults": {
"billing_address_id": "bl6nqk69ku6897l45fp0",
"payment_method_id": "bl6nqk69ku6897l45fq0",
"payment_method_type": "card",
"shipping_address_id": "bl6nqk69ku6897l45fp0"
},
"description": "test description",
"notes": "",
"flags": ["surcharge_exempt"],
"payments": {
"ach": [],
"cards": [
{
"card_type": "visa",
"expiration_date": "2020-12-31T00:00:00Z",
"id": "bl6nqk69ku6897l45fq0",
"masked_number": "411111******1111"
}
]
}
}
},
"created_at": "2019-08-09T09:04:00.786094073-05:00",
"updated_at": "2019-08-09T09:04:00.786094116-05:00"
}
}
function updateCustomerRecord(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
description: "test description",
notes: "test notes",
flags: ["surcharge_exempt"],
defaults: {
billing_address_id: "abc123",
shipping_address_id: "abc123",
payment_method_id: "abc123",
payment_method_type: "card",
},
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void UpdateCustomer(CreateCustomerResponseData customer) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/customer/" + customer.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(customer);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
$customerData = array(
"description" => "test description",
"notes" => "test notes",
"flags" => ["surcharge_exempt"],
"defaults" => array(
"billing_address_id" => "abc123",
"shipping_address_id" => "abc123",
"payment_method_id" => "abc123",
"payment_method_type" => "card"
)
);
function updateCustomer($customerData) {
$curl = curl_init();
$payload = json_encode($customerData);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/customer/".$customer->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
)
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updateCustomer(CreateCustomerResponseData customer) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(customer);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/customer/" + customer.id)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse createResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (createResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Delete Customer Record
Delete the specified customer record.
Request Method:
DELETE
URL Endpoint:
/api/vault/{ customer id }
{
"status": "success",
"msg": "success"
}
function deleteCustomer(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/vault/" + customerId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void DeleteCustomer(string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/" + customerId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deleteCustomer($customerId)
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/".$customerId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deleteCustomer(String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/" + customerId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse createResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (createResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Create Address Record
Create a new address record that will be stored within the customer record. A stored address can be used as the billing and/or shipping address on transactions processed for the customer.
Request Method:
POST
URL Endpoint:
/api/vault/customer/{ customer id }/address
Name | Type | Default | Description | Required |
---|---|---|---|---|
first_name | string | "" | Addressee first name | |
last_name | string | "" | Addressee last name | |
company | string | "" | Company name | |
line_1 | string | "" | Street address | |
line_2 | string | "" | Additional delivery details | |
city | string | "" | City name | |
state | string | "" | State code ("CA") | |
postal_code | string | "" | Postal code ("12345") | |
country | string | "" | Country code ("US") | |
string | "" | Email address (must be valid email format, "example@mail.com") | ||
phone | string | "" | Phone number ("3216540987") | |
fax | string | "" | Fax number ("3216540987") |
{
"status": "success",
"msg": "success",
"data": {
"id": "952f250d-fa85-40ac-a45e-3886f98032c6",
"owner_id": "testmerchant12345678",
"data": {
"customer": {
"addresses": [
{
"city": "Some Town",
"company": "Some Business",
"country": "US",
"email": "user@somesite.com",
"fax": "555555555",
"first_name": "John",
"hash": "cV9qS6UvnnRDJCkgfitHqGrKSRfTARDsLy5zfkNNTcM=",
"id": "bl6nqk69ku6897l45fp0",
"last_name": "Smith",
"line_1": "",
"line_2": "",
"phone": "5555555555",
"postal_code": "60187",
"state": "IL"
}
],
"defaults": {
"billing_address_id": "bl6nqk69ku6897l45fp0",
"payment_method_id": "bl6nqk69ku6897l45fq0",
"payment_method_type": "card",
"shipping_address_id": "bl6nqk69ku6897l45fp0"
},
"description": "test description",
"notes": "",
"flags": ["surcharge_exempt"],
"payments": {
"ach": [],
"cards": [
{
"card_type": "visa",
"expiration_date": "2020-12-31T00:00:00Z",
"id": "bl6nqk69ku6897l45fq0",
"masked_number": "411111******1111"
}
]
}
}
},
"created_at": "2019-08-09T09:04:00.786094073-05:00",
"updated_at": "2019-08-09T09:04:00.786094116-05:00"
}
}
function createAddress(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
first_name: "Mary",
last_name: "Smith",
company: "Some Business",
line_1: "",
line_2: "",
city: "Some Town",
state: "IL",
postal_code: "60187",
country: "US",
email: "user@somesite.com",
fax: "555555555",
phone: "5555555555",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/address",
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void CreateAddress(Address address, string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/address");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(address);
IRestResponse response = client.Execute(request);
CreateCustomerResponse apiResponse = JsonConvert.DeserializeObject<CreateCustomerResponse>(response);
if (apiResponse.Status == "success" && apiResponse.Data.Count) {
// handle success
CreateCustomerResponseData responseData = apiResponse.Data;
} else {
// handle non success
}
}
<?php
$address = array(
"id" => "<id>",
"first_name" => "John",
"last_name" => "Smith",
"company" => "Some Business",
"line_1" => "123 Some St",
"line_2" => "STE 1",
"city" => "Some Town",
"state" => "IL",
"postal_code" => "60187",
"country" => "US",
"email" => "user@somesite.com",
"phone" => "5555555555",
"fax" => "555555555"
)
function createAddress($address, $customerId) {
$curl = curl_init();
$payload = json_encode($address);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/customer/".$customerId."/address",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void createAddress(Address address, String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(address);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/address")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "__cfduid=123abc")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CreateCustomerResponse createResponse = objectMapper.readValue(responseBody.string(), CreateCustomerResponse.class);
if (createResponse.status == "success") {
// handle success
CreateCustomerResponseData data = createResponse.data;
} else {
// handle non success
}
}
# Get Address Record By ID
TIP
Address records cannot be fetched individually, please use the Get Customer Record By ID endpoint to retrieve the collection of address records for a specified customer.
# Update Address Record
Update an existing address within a customer record.
Request Method:
POST
URL Endpoint:
/api/vault/customer/{ customer id }/address/{ address id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
first_name | string | "" | Addressee first name | |
last_name | string | "" | Addressee last name | |
company | string | "" | Company name | |
line_1 | string | "" | Street address | |
line_2 | string | "" | Additional delivery details | |
city | string | "" | City name | |
state | string | "" | State code ("CA") | |
postal_code | string | "" | Postal code ("12345") | |
country | string | "" | Country code ("US") | |
string | "" | Email address (must be valid email format, "example@mail.com") | ||
phone | string | "" | Phone number ("3216540987") | |
fax | string | "" | Fax number ("3216540987") |
{
"status": "success",
"msg": "success",
"data": {
"id": "952f250d-fa85-40ac-a45e-3886f98032c6",
"owner_id": "testmerchant12345678",
"data": {
"customer": {
"addresses": [
{
"city": "Some Town",
"company": "Some Business",
"country": "US",
"email": "user@somesite.com",
"fax": "555555555",
"first_name": "John",
"hash": "cV9qS6UvnnRDJCkgfitHqGrKSRfTARDsLy5zfkNNTcM=",
"id": "bl6nqk69ku6897l45fp0",
"last_name": "Smith",
"line_1": "",
"line_2": "",
"phone": "5555555555",
"postal_code": "60187",
"state": "IL"
}
],
"defaults": {
"billing_address_id": "bl6nqk69ku6897l45fp0",
"payment_method_id": "bl6nqk69ku6897l45fq0",
"payment_method_type": "card",
"shipping_address_id": "bl6nqk69ku6897l45fp0"
},
"description": "test description",
"notes": "",
"flags": ["surcharge_exempt"],
"payments": {
"ach": [],
"cards": [
{
"card_type": "visa",
"expiration_date": "2020-12-31T00:00:00Z",
"id": "bl6nqk69ku6897l45fq0",
"masked_number": "411111******1111"
}
]
}
}
},
"created_at": "2019-08-09T09:04:00.786094073-05:00",
"updated_at": "2019-08-09T09:04:00.786094116-05:00"
}
}
function updateAddress(customerId, addressId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
first_name: "John",
last_name: "Smith",
company: "Some Business",
line_1: "",
line_2: "",
city: "Some Town",
state: "IL",
postal_code: "60187",
country: "US",
email: "user@somesite.com",
fax: "555555555",
phone: "5555555555",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/vault/customer/" +
customerId +
"/address/" +
addressId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void UpdateAddress(Address address, string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/address/" + address.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(address);
IRestResponse response = client.Execute(request);
CreateCustomerResponse apiResponse = JsonConvert.DeserializeObject<CreateCustomerResponse>(response);
if (apiResponse.Status == "success" && apiResponse.Data.Count) {
// handle success
CreateCustomerResponseData responseData = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function updateAddress($address, $customerId) {
$curl = curl_init();
$payload = json_encode($address);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/customer/".$customerId."/address/".$address->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updateAddress(Address address, String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(address);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/address/" + address.id)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CreateCustomerResponse createResponse = objectMapper.readValue(responseBody.string(), CreateCustomerResponse.class);
if (createResponse.status === "success") {
// handle success
CreateCustomerResponseData data = createResponse.data;
} else {
// handle non success
}
}
# Delete Address Record
Delete the specified address within a customer record.
Request Method:
DELETE
URL Endpoint:
/api/vault/customer/{ customer id }/address/{ address id }
{
"status": "success",
"msg": "success"
}
function deleteAddress(addressId, customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/vault/customer/" +
customerId +
"/address/" +
addressId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void DeleteAddress(string addressId, string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/address/" + addressId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deleteAddress($addressId, $customerId)
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/customer/".$customerId."/address/".$addressId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deleteAddress(String addressId, String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/address/" + addressId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse createResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (createResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Create Payment Method Record
Create a new stored payment method on the specified customer record. The url endpoint and request body properties vary depending on the type of payment method being created.
Request Method:
POST
Create Card - URL Endpoint:
/api/vault/customer/{ customer id }/card
Create ACH - URL Endpoint:
/api/vault/customer/{ customer id }/ach
Create Card or ACH with Token - URL Endpoint:
/api/vault/customer/{ customer id }/token
Name | Type | Default | Description | Required |
---|---|---|---|---|
number | string | "" | Card number | |
expiration_date | string | "" | Card expiration date ("MMYY" or "MM/YY") | * |
Name | Type | Default | Description | Required |
---|---|---|---|---|
account_number | string | "" | Account number | |
routing_number | string | "" | Routing number | |
account_type | string literal | Ach account type ("checking" or "savings") | * | |
sec_code | string literal | Ach sec code ("web", "ccd", or "ppd") | * |
Name | Type | Default | Description | Required |
---|---|---|---|---|
token | string | Payment method token generated by Tokenizer form | * |
{
"status": "success",
"msg": "success",
"data": {
"id": "952f250d-fa85-40ac-a45e-3886f98032c6",
"owner_id": "testmerchant12345678",
"data": {
"customer": {
"addresses": [
{
"city": "Some Town",
"company": "Some Business",
"country": "US",
"email": "user@somesite.com",
"fax": "555555555",
"first_name": "John",
"hash": "cV9qS6UvnnRDJCkgfitHqGrKSRfTARDsLy5zfkNNTcM=",
"id": "bl6nqk69ku6897l45fp0",
"last_name": "Smith",
"line_1": "",
"line_2": "",
"phone": "5555555555",
"postal_code": "60187",
"state": "IL"
}
],
"defaults": {
"billing_address_id": "bl6nqk69ku6897l45fp0",
"payment_method_id": "bl6nqk69ku6897l45fq0",
"payment_method_type": "card",
"shipping_address_id": "bl6nqk69ku6897l45fp0"
},
"description": "test description",
"notes": "",
"flags": ["surcharge_exempt"],
"payments": {
"ach": [],
"cards": [
{
"card_type": "visa",
"expiration_date": "2020-12-31T00:00:00Z",
"id": "bl6nqk69ku6897l45fq0",
"masked_number": "411111******1111"
}
]
}
}
},
"created_at": "2019-08-09T09:04:00.786094073-05:00",
"updated_at": "2019-08-09T09:04:00.786094116-05:00"
}
}
# Create Payment Method Record Code Samples
function createPaymentMethod(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
number: "4111111111111111",
expiration_date: "1225",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/card",
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void CreatePaymentMethod(Card card, string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/card");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(card);
IRestResponse response = client.Execute(request);
CreateCustomerResponse apiResponse = JsonConvert.DeserializeObject<CreateCustomerResponse>(response);
if (apiResponse.Status === "success" && apiResponse.Data.Count) {
// handle success
CreateCustomerResponseData responseData = apiResponse.Data;
} else {
// handle non success
}
}
<?php
$card = array(
"id" => "<id>",
"number" => "4111111111111111",
"expiration_date" => "1220"
);
function createPaymentMethod($card, $customerId) {
$curl = curl_init();
$payload = json_encode($card);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/customer/".$customerId."/card",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
)
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void createPaymentMethod(Card card, String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(card);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/card")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CreateCustomerResponse createResponse = objectMapper.readValue(responseBody.string(), CreateCustomerResponse.class);
if (createResponse.status === "success") {
// handle success
CreateCustomerResponseData data = createResponse.data;
} else {
// handle non success
}
}
# Get Payment Method Record By ID
TIP
Payment method records cannot be fetched individually, please use the Get Customer Record By ID endpoint to retrieve the collection of payment method records for a specified customer.
# Update Payment Method Record
Update an existing payment method within a customer record.
Request Method:
POST
Update Card - URL Endpoint:
/api/vault/customer/{ customer id }/card/{ payment method id }
Update ACH - URL Endpoint:
/api/vault/customer/{ customer id }/ach/{ payment method id }
Update Token - URL Endpoint:
/api/vault/customer/{ customer id }/token/{ payment method id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
number | string | "" | Card number | |
expiration_date | string | "" | Card expiration date ("MMYY" or "MM/YY") | * |
flags | array | [] | "surcharge_exempt", "applepay", "closed_contact", "contact", "locked_security", "locked_stop_recurring" |
Name | Type | Default | Description | Required |
---|---|---|---|---|
account_number | string | "" | Account number | |
routing_number | string | "" | Routing number | |
account_type | string literal | Ach account type ("checking" or "savings") | * | |
sec_code | string literal | Ach sec code ("web", "ccd", or "ppd") | * |
Name | Type | Default | Description | Required |
---|---|---|---|---|
token | string | Payment method token generated by Tokenizer form | * |
{
"status": "success",
"msg": "success",
"data": {
"id": "952f250d-fa85-40ac-a45e-3886f98032c6",
"owner_id": "testmerchant12345678",
"data": {
"customer": {
"addresses": [
{
"city": "Some Town",
"company": "Some Business",
"country": "US",
"email": "user@somesite.com",
"fax": "555555555",
"first_name": "John",
"hash": "cV9qS6UvnnRDJCkgfitHqGrKSRfTARDsLy5zfkNNTcM=",
"id": "bl6nqk69ku6897l45fp0",
"last_name": "Smith",
"line_1": "",
"line_2": "",
"phone": "5555555555",
"postal_code": "60187",
"state": "IL"
}
],
"defaults": {
"billing_address_id": "bl6nqk69ku6897l45fp0",
"payment_method_id": "bl6nqk69ku6897l45fq0",
"payment_method_type": "card",
"shipping_address_id": "bl6nqk69ku6897l45fp0"
},
"description": "test description",
"notes": "",
"flags": ["surcharge_exempt"],
"payments": {
"ach": [],
"cards": [
{
"card_type": "visa",
"expiration_date": "2020-12-31T00:00:00Z",
"id": "bl6nqk69ku6897l45fq0",
"masked_number": "411111******1111"
}
]
}
}
},
"created_at": "2019-08-09T09:04:00.786094073-05:00",
"updated_at": "2019-08-09T09:04:00.786094116-05:00"
}
}
# Update Payment Method Record Code Samples
function updatePaymentMethod(customerId, paymentMethodId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({ expiration_date: "1220" });
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/vault/customer/" +
customerId +
"/card/" +
paymentMethodId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void UpdatePaymentMethod(Card card, string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/card/" + card.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(card);
IRestResponse response = client.Execute(request);
CreateCustomerResponse apiResponse = JsonConvert.DeserializeObject<CreateCustomerResponse>(response);
if (apiResponse.Status === "success" && apiResponse.Data.Count) {
// handle success
CreateCustomerResponseData responseData = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function updatePaymentMethod($card, $customerId) {
$curl = curl_init();
$payload = json_encode($card);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/customer/".$customerId."/card/".$card->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
)
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updatePaymentMethod(Card card, String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(card);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/card/" + card.id)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CreateCustomerResponse createResponse = objectMapper.readValue(responseBody.string(), CreateCustomerResponse.class);
if (createResponse.status === "success") {
// handle success
CreateCustomerResponseData data = createResponse.data;
} else {
// handle non success
}
}
# Delete Payment Method Record
Delete the specified payment method within a customer record.
Request Method:
DELETE
Delete Card - URL Endpoint:
/api/vault/customer/{ customer id }/card/{ card id }
Delete ACH - URL Endpoint:
/api/vault/customer/{ customer id }/ach/{ ach id }
{
"status": "success",
"msg": "success"
}
function deletePaymentMethod(customerId, paymentMethodId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/vault/customer/" +
customerId +
"/card/" +
paymentMethodId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void DeletePaymentMethod(string customerId, string paymentMethodId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/card/" + paymentMethodId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deletePaymentMethod($customerId, $paymentId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/vault/customer/".$customer."/card/".$paymentId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deletePaymentMethod(String customerId, String paymentMethodId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/vault/customer/" + customerId + "/card/" + paymentMethodId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse createResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (createResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Customers (Deprecated)
WARNING
This section has been deprecated and is no longer under active development. Please see the Customer Vault section for the most up to date methods for managing customers.
# Create Customer (Deprecated)
Create a new customer.
Request Method:
POST
URL Endpoint:
/api/customer
Query Params
Name | Default | Description |
---|---|---|
validate | "false" | passing "true" will cause credit cards to have a $0 verification processed |
Name | Type | Default | Description | Required |
---|---|---|---|---|
description | string | "" | Text field, max 255 characters | |
payment_method | object | null | ||
payment_method .processor_id | string | "" | Specify which processor to validate on | |
payment_method .card | object | null | Object containing details for processing a transaction against a debit or credit card | |
payment_method .card .card_number | string | "4111111111111111" | required if payment_method.card is present | |
payment_method .card .expiration_date | string | "MMYY" or "MM/YY" | required if payment_method.card is present | |
payment_method .ach | object | null | Object containing details for processing a transaction via ACH | |
payment_method .ach .account_number | string | "111111111" | ||
payment_method .ach .routing_number | string | "111111111" | ||
payment_method .ach .account_type | string literal | "checking" or "savings" | required if payment_method.ach is present | |
payment_method .ach .sec_code | string literal | "web", "ppd", or "ccd" | required if payment_method.ach is present | |
payment_method .apple_pay_token | string | |||
billing_address | object | null | Object containing billing address details | |
billing_address .first_name | string | "" | Addressee first name | |
billing_address .last_name | string | "" | Addressee last name | |
billing_address .company | string | "" | Company name | |
billing_address .address_line_1 | string | "" | Street address | |
billing_address .address_line_2 | string | "" | Additional delivery details | |
billing_address .city | string | "" | City name | |
billing_address .state | string | "" | State code ("CA") | |
billing_address .postal_code | string | "" | Postal code ("12345") | |
billing_address .country | string | "" | Country code ("US") | |
billing_address | string | "" | Email address (must be valid email format, "example@mail.com") | |
billing_address .phone | string | "" | Phone number ("3216540987") | |
billing_address .fax | string | "" | ("3216540987") | |
shipping_address | object | null | Object containing shipping address details | |
shipping_address .first_name | string | "" | Addressee first name | |
shipping_address .last_name | string | "" | Addressee last name | |
shipping_address .company | string | "" | Company name | |
shipping_address .address_line_1 | string | "" | Street address | |
shipping_address .address_line_2 | string | "" | Additional delivery details | |
shipping_address .city | string | "" | City name | |
shipping_address .state | string | "" | State code ("CA") | |
shipping_address .postal_code | string | "" | Postal code ("12345") | |
shipping_address .country | string | "" | Country code ("US") | |
shipping_address | string | "" | Email address (must be valid email format, "example@mail.com") | |
shipping_address .phone | string | "" | Phone number ("3216540987") | |
shipping_address .fax | string | "" | ("3216540987") |
{
"status": "success",
"msg": "success",
"data": {
"id": "b798ls2q9qq646ksu070",
"description": "test description",
"payment_method": {
"card": {
"id": "b798ls2q9qq646ksu080",
"card_type": "visa",
"first_six": "411111",
"last_four": "1111",
"masked_card": "411111******1111",
"expiration_date": "12/20",
"processor_id": "",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
}
},
"billing_address": {
"id": "b798ls2q9qq646ksu07g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
},
"shipping_address": {
"id": "b798ls2q9qq646ksu07g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
},
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
}
}
var customer = {
description: "test description",
payment_method: {
processor_id: "",
card: {
card_number: "4111111111111111",
expiration_date: "12/20",
},
},
billing_address: {
first_name: "John",
last_name: "Smith",
company: "Some Business",
address_line_1: "123 Some St",
address_line_2: "STE 1",
city: "Some Town",
state: "IL",
postal_code: "60187",
country: "US",
email: "user@somesite.com",
phone: "5555555555",
fax: "555555555",
},
shipping_address: {
first_name: "John",
last_name: "Smith",
company: "Some Business",
address_line_1: "123 Some St",
address_line_2: "STE 1",
city: "Some Town",
state: "IL",
postal_code: "60187",
country: "US",
email: "user@somesite.com",
phone: "5555555555",
fax: "555555555",
},
};
function createCustomer(customer) {
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", apiKey);
var raw = JSON.stringify(customer);
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/customer", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var newId = result.data.id;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class Customer {
public string Id { get; set; }
public string description { get; set; }
public PaymentMethod PaymentMethod { get; set; }
public Address BillingAddress { get; set; }
public Address ShippingAddress { get; set; }
}
public class PaymentMethod {
public string ProcessorId { get; set; }
public Card Card { get; set; }
}
public class Card {
public string Id { get; set; }
[JsonProperty("card_number")]
public string CardNumber { get; set; }
[JsonProperty("expiration_date")]
public string ExpirationDate { get; set; }
}
public class Address {
public string Id { get; set; }
[JsonProperty("first_name")]
public string FirstName { get; set; }
[JsonProperty("last_name")]
public string LastName { get; set; }
public string Company { get; set; }
[JsonProperty("address_line_1")]
public string AddressLine1 { get; set; }
[JsonProperty("address_line_2")]
public string AddressLine2 { get; set; }
public string City { get; set; }
public string State { get; set; }
[JsonProperty("postal_code")]
public string PostalCode { get; set; }
public string Country { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Fax { get; set; }
}
public class CustomerResponse : ApiResponse {
public Customer Data { get; set; }
}
public void CreatCustomer(Customer customer) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", _apiKey);
request.AddJsonBody(customer);
IRestResponse response = client.Execute(request);
CustomerResponse apiResponse = JsonConvert.DeserializeObject<CustomerResponse>(response);
if (apiResponse.Status === "success") {
// handle success
string newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
<?php
$card = array(
"card_number" => "4111111111111111",
"expiration_date" => "12/20"
);
$paymentMethod = array(
"processor_id" => "",
"card" => $card
);
$billingAddress = array(
"first_name" => "John",
"last_name" => "Smith",
"company" => "Some Business",
"address_line_1" => "123 Some St",
"address_line_2" => "STE 1",
"city" => "Some Town",
"state" => "IL",
"postal_code" => "60187",
"country" => "US",
"email" => "user@somesite.com",
"phone" => "5555555555",
"fax" => "555555555"
);
$shippingAddress = array(
"first_name" => "John",
"last_name" => "Smith",
"company" => "Some Business",
"address_line_1" => "123 Some St",
"address_line_2" => "STE 1",
"city" => "Some Town",
"state" => "IL",
"postal_code" => "60187",
"country" => "US",
"email" => "user@somesite.com",
"phone" => "5555555555",
"fax" => "555555555"
);
$customer = array(
"description" => "test description",
"payment_method" => $paymentMethod,
"billing_address" => $billingAddress,
"shipping_address" => $shippingAddress
);
$apiKey = "<api key>";
function CreateCustomer($customer) {
$curl = curl_init();
$payload = json_encode($customer);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Authorization: ".$apiKey
)
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
return $response;
}
public class Card {
String id;
@JsonProperty("card_number")
String cardNumber;
@JsonProperty("expiration_date")
String expirationDate;
}
public class PaymentMethod {
@JsonProperty("processor_id")
String processorId;
Card card;
}
public class Address {
String id;
@JsonProperty("first_name")
String firstName;
@JsonProperty("last_name")
String lastName;
String company;
@JsonProperty("address_line_1")
String addressLine1;
@JsonProperty("address_line_2")
String addressLine2;
String city;
String state;
@JsonProperty("postal_code")
String postalCode;
String country;
String phone;
String fax;
String email;
}
public class Customer {
String id;
String description;
@JsonProperty("payment_method")
PaymentMethod paymentMethod;
@JsonProperty("billing_address")
Address billingAddress;
@JsonProperty("shipping_address")
Address shippingAddress;
}
public class ApiResponse {
String status;
String msg;
}
public class CustomerResponse extends ApiResponse {
Customer data;
}
private String apiKey = "<api key>";
public void createCustomer(Customer customer) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(customer);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request
.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CustomerResponse apiResponse = objectMapper.readValue(responseBody.string(), CustomerResponse.class);
if (apiResponse.status === "success") {
// handle success
String newId = apiResponse.data.id;
} else {
// handle non success
}
}
# Get Customer By ID (Deprecated)
Retrieve details for the specified customer.
Request Method:
GET
URL Endpoint:
/api/customer/{ customer id }
{
"status": "success",
"msg": "success",
"data": {
"id": "b798ls2q9qq646ksu070",
"description": "test description",
"payment_method": {
"card": {
"id": "b798ls2q9qq646ksu080",
"card_type": "visa",
"first_six": "411111",
"last_four": "1111",
"masked_card": "411111******1111",
"expiration_date": "12/20",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
}
},
"billing_address": {
"id": "b798ls2q9qq646ksu07g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
},
"shipping_address": {
"id": "b798ls2q9qq646ksu07g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
},
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
}
}
function getCustomer(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/customer/" + customerId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var customer = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void GetCustomer(string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
CustomerResponse apiResponse = JsonConvert.DeserializeObject<CustomerResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Customer customer = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getCustomer($customerId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getCustomer(String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId)
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CustomerResponse apiResponse = objectMapper.readValue(responseBody.string(), CustomerResponse.class);
if (apiResponse.status === "success") {
// handle success
Customer customer = apiResponse.data;
} else {
// handle non success
}
}
# Search Customers (Deprecated)
Retrieve details for all customers that match provided search criteria.
Request Method:
POST
URL Endpoint:
/api/customer/search
Name | Type | Default | Description | Required |
---|---|---|---|---|
id | object | null | Object containing details for searching by customer id | |
id .operator | string literal | Search operator "=" or "!=" | required if id is present | |
id .value | string | "" | Customer ID to match or exclude | |
payment_method_id | object | null | Object containing details for searching by payment_method_id | |
payment_method_id .id | string | "" | Search customers with the provided value set as the default payment_method_id | |
payment_method_id .operator | string literal | "=" or "!=" | required if payment_method_id is present | |
payment_method_id .value | string | "" | Value to match or exclude | |
billing_address_id | object | null | Object containing details for searching by billing_address_id | |
billing_address_id .id | string | "" | Search customers with the provided value set as the default billing_address_id | |
billing_address_id .operator | string literal | "=" or "!=" | required if billing_address_id is present | |
billing_address_id .value | string | "" | Value to match or exclude | |
shipping_address_id | object | null | Object containing details for searching by shipping_address_id | |
shipping_address_id .id | string | "" | Search customers with the provided value set as the default shipping_address_id | |
shipping_address_id .operator | string literal | "=" or "!=" | required if shipping_address_id is present | |
shipping_address_id .value | string | "" | Value to match or exclude | |
created_at | object | null | Object containing details defining a date range to match | |
created_at .start_date | string | "" | Beginning of date range | |
created_at .end_date | string | "" | End of date range | |
limit | integer | 10 | The number of results to return (1-100) | |
offset | integer | 0 | The number of results to skip (1-1000) |
{
"status": "success",
"msg": "success",
"data": [
{
"id": "b798ls2q9qq646ksu070",
"description": "test description",
"payment_method": {
"card": {
"id": "b798ls2q9qq646ksu080",
"card_type": "visa",
"first_six": "411111",
"last_four": "1111",
"masked_card": "411111******1111",
"expiration_date": "12/20",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
}
},
"billing_address": {
"id": "b798ls2q9qq646ksu07g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
},
"shipping_address": {
"id": "b798ls2q9qq646ksu07g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
},
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
}
],
"total_count": 1
}
function queryCustomers() {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
id: {
operator: "=",
value: "123abc",
},
limit: 10,
offset: 0,
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/customer/search", requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var customers = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class OperatorValueCriteria {
public string Order { get; set; }
public T Value { get; set; }
}
public class SearchCriteria {
public OperatorValueCriteria Id { get; set; }
public int Limit { get; set; }
public int Offset { get; set; }
}
public class CustomersResponse : ApiResponse {
public List<Customer> Data { get; set; }
}
public void QueryCustomer(SearchCriteria criteria) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/search");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(criteria);
IRestResponse response = client.Execute(request);
CustomersResponse apiResponse = JsonConvert.DeserializeObject<CustomersResponse>(response);
if (apiResponse.Status === "success") {
// handle success
List<Customer> customers = apiResponse.Data;
} else {
// handle non success
}
}
<?php
$searchCriteria = array(
"id" => array(
"operator" => "=",
"value" => "123abc"
),
"limit" => 10,
"offset" => 0
);
function queryCustomers($searchCriteria) {
$curl = curl_init();
$payload = json_encode($searchCriteria);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class OperatorValueCriteria {
String order;
String value;
}
public class SearchCriteria {
OperatorValueCriteria id;
int limit;
int offset;
}
public class CustomersResponse extends ApiResponse {
java.util.ArrayList<Customer> data;
}
public void queryCustomer(SearchCriteria criteria) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(customer);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/search")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CustomersResponse apiResponse = objectMapper.readValue(responseBody.string(), CustomersResponse.class);
if (apiResponse.status === "success") {
// handle success
java.util.ArrayList<Customer> customers = apiResponse.data;
}
else {
// handle non success
}
}
# Update Customer (Deprecated)
Edit details for the specified customer. If you have used the Create Customer Payment Method Token (Deprecated) endpoint to create a payment method token, or the Create Customer Address Token (Deprecated) endpoint to create an address token, the id's of those stored items can be supplied here to be set as the default payment method and billing/shipping addresses when a transaction is processed against the customer.
Request Method:
POST
URL Endpoint:
/api/customer/{ customer id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
description | string | "" | Text field, max 255 characters | |
payment_method | string literal | "card" or "ach" | ||
payment_method_id | string | "" | Id of the payment method token to use as the default for transactions processed on this customer | |
billing_address_id | string | "" | Id of the address token to use as the default billing address for transactions processed on this customer | |
shipping_address_id | string | "" | Id of the address token to use as the default shipping address for transactions processed on this customer |
{
"status": "success",
"msg": "success",
"data": null
}
function updateCustomer(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
description: "test description",
payment_method: "card",
payment_method_id: "123abc",
billing_address_id: "123abc",
shipping_address_id: "123abc",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch("https://sandbox.durangomsgateway.com/api/customer/" + customerId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void UpdateCustomer(Customer customer) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customer.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(customer);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function updateCustomer($customer) {
$curl = curl_init();
$payload = json_encode($customer);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customer->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void updateCustomer(Customer customer) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(customer);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customer.id)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Delete Customer (Deprecated)
Delete the specified customer.
Request Method:
DELETE
URL Endpoint:
/api/customer/{ customer id }
{
"status": "success",
"msg": "success",
"data": null
}
function deleteCustomer(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch("https://sandbox.durangomsgateway.com/api/customer/" + customerId, requestOptions)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void DeleteCustomer(string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deleteCustomer($customerId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void deleteCustomer(String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Create Address Token (Deprecated)
Create a new stored address token.
Request Method:
POST
URL Endpoint:
/api/customer/{ customer id }/address
Name | Type | Default | Description | Required |
---|---|---|---|---|
first_name | string | "" | Addressee first name | |
last_name | string | "" | Addressee last name | |
company | string | "" | Company name | |
line_1 | string | "" | Street address | |
line_2 | string | "" | Additional delivery details | |
city | string | "" | City name | |
state | string | "" | State code ("CA") | |
postal_code | string | "" | Postal code ("12345") | |
country | string | "" | Country code ("US") | |
string | "" | Email address (must be valid email format, "example@mail.com") | ||
phone | string | "" | Phone number ("3216540987") | |
fax | string | "" | Fax number ("3216540987") |
{
"status": "success",
"msg": "success",
"data": {
"id": "b7994biq9qq646ksu08g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1 ",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T19:23:26.902395Z",
"updated_at": "2017-10-02T19:23:26.902395Z"
}
}
function createAddress(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
first_name: "John",
last_name: "Smith",
company: "Some Business",
address_line_1: "123 Some St",
address_line_2: "STE 1",
city: "Some Town",
state: "IL",
postal_code: "60187",
country: "US",
email: "user@somesite.com",
phone: "5555555555",
fax: "555555555",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address",
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var newId = result.data.id;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class AddressResponse : ApiResponse {
public Address Data { get; set; }
}
public void CreateAddress(Address address, string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(address);
IRestResponse response = client.Execute(request);
AddressResponse apiResponse = JsonConvert.DeserializeObject<AddressResponse>(response);
if (apiResponse.Status === "success") {
// handle success
string newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
<?php
function createAddress($address, $customerId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId."/address",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class AddressResponse extends ApiResponse {
Address data;
}
public void createAddress(String customerId, Address address) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"first_name\": \"John\",\n \"last_name\": \"Smith\",\n \"company\": \"Some Business\",\n \"address_line_1\": \"123 Some St\",\n \"address_line_2\": \"STE 1\",\n \"city\": \"Some Town\",\n \"state\": \"IL\",\n \"postal_code\": \"60187\",\n \"country\": \"US\",\n \"email\": \"user@somesite.com\",\n \"phone\": \"5555555555\",\n \"fax\": \"555555555\"\n }");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
AddressResponse apiResponse = objectMapper.readValue(responseBody.string(), AddressResponse.class);
if (apiResponse.status === "success") {
// handle success
String newId = apiResponse.data.id;
} else {
// handle non success
}
}
# Get Address Token By ID (Deprecated)
Retrieve details for the specified address token.
Request Method:
GET
URL Endpoint:
/api/customer/{ customer id }/address/{ address id }
{
"status": "success",
"msg": "success",
"data": [
{
"id": "b798ls2q9qq646ksu07g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
}
],
"count": 1
}
function getCustomerAddress(customerId, addressId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address/" + addressId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var address = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void GetCustomerAddress(string customerId, string addressId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address/" + addressId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
AddressResponse apiResponse = JsonConvert.DeserializeObject<AddressResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Address address = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getCustomerAddress($customerId, $addressId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId."/address/".$addressId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public void getCustomerAddress(String customerId, String addressId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address/" + addressId
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
AddressResponse apiResponse = objectMapper.readValue(responseBody.string(), AddressResponse.class);
if (apiResponse.status === "success") {
// handle success
Address address = apiResponse.data;
} else {
// handle non success
}
}
# Get All Address Tokens (Deprecated)
Retrieve details for all address tokens stored on the customer record.
Request Method:
GET
URL Endpoint:
/api/customer/{ customer id }/addresses
{
"status": "success",
"msg": "success",
"data": [
{
"id": "b798ls2q9qq646ksu07g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
},
{
"id": "b7994biq9qq646ksu08g",
"customer_id": "b798ls2q9qq646ksu070",
"first_name": "John",
"last_name": "Smith",
"company": "Some Business",
"address_line_1": "123 Some St",
"address_line_2": "STE 1 ",
"city": "Some Town",
"state": "IL",
"postal_code": "60187",
"country": "US",
"email": "user@somesite.com",
"phone": "5555555555",
"fax": "555555555",
"created_at": "2017-10-02T19:23:27Z",
"updated_at": "2017-10-02T19:23:27Z"
}
],
"count": 2
}
function getAllCustomerAddresses(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/addresses",
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var addresses = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class AddressesResponse : ApiResponse {
public List<Address> Data { get; set; }
}
public void GetAllAddresses(string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/addresses");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
AddressesResponse apiResponse = JsonConvert.DeserializeObject<AddressesResponse>(response);
if (apiResponse.Status === "success") {
// handle success
List<Address> addresses = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getAllAddresses($customerId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId."/addresses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
echo $response;
}
public class AddressesResponse extends ApiResponse {
public java.util.ArrayList<Address> data;
}
public void getAllAddresses(String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/addresses")
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
AddressesResponse apiResponse = objectMapper.readValue(responseBody.string(), AddressesResponse.class);
if (apiResponse.status === "success") {
// handle success
java.util.ArrayList<Address> addresses = apiResponse.data;
} else {
// handle non success
}
}
# Update Address Token (Deprecated)
Edit details for the specified address token.
Request Method:
POST
URL Endpoint:
/api/customer/{ customer id }/address/{ address id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
first_name | string | "" | Addressee first name | |
last_name | string | "" | Addressee last name | |
company | string | "" | Company name | |
line_1 | string | "" | Street address | |
line_2 | string | "" | Additional delivery details | |
city | string | "" | City name | |
state | string | "" | State code ("CA") | |
postal_code | string | "" | Postal code ("12345") | |
country | string | "" | Country code ("US") | |
string | "" | Email address (must be valid email format, "example@mail.com") | ||
phone | string | "" | Phone number ("3216540987") | |
fax | string | "" | Fax number ("3216540987") |
{
"status": "success",
"msg": "success",
"data": null
}
function updateCustomerAddress(customerId, addressId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
first_name: "John",
last_name: "Smith",
company: "Some Business",
address_line_1: "123 New St",
address_line_2: "",
city: "New Town",
state: "IL",
postal_code: "60187",
country: "US",
email: "user@somesite.com",
phone: "5555555555",
fax: "555555555",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address/" + addressId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void UpdateCustomerAddress(string customerId, Address address) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address/" + address.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(address);
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function updateCustomerAddress($customerId, $address) {
$curl = curl_init();
$payload = json_encode($address);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId"/address/".$address->id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response);
curl_close($curl);
echo $response;
}
public void updateCustomerAddress(String customerId, Address address) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(customer);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address/" + address.id)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Delete Address Token (Deprecated)
Delete the specified address token.
Request Method:
DELETE
URL Endpoint:
/api/customer/{ customer id }/address/{ address id }
{
"status": "success",
"msg": "success",
"data": null
}
function deleteCustomerAddress(customerId, addressId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address/" + addressId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void DeleteCustomerAddress(string customerId, string addressId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address/" + addressId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deleteCustomerAddress($customerId, $addressId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId."/address/".$addressId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response);
curl_close($curl);
echo $response;
}
public void deleteCustomerAddress(String customerId, String addressId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/address/" + addressId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Create Payment Method Token (Deprecated)
Create a new stored payment method token on the specified customer. The url endpoint and request body properties vary depending on the type of payment method being created. When creating a new payment method using a token generated by the Tokenizer form, the resulting payment method will be stored as card or ach.
Request Method:
POST
Create Card - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/card
Create ACH - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/ach
Create with Token - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/token
Query Params
Name | Default | Description |
---|---|---|
validate | "false" | passing "true" will cause credit cards to have a $0 verification processed |
Name | Type | Default | Description | Required |
---|---|---|---|---|
number | string | "" | Card number | |
expiration_date | string | "" | Card expiration date ("MMYY" or "MM/YY") | * |
Name | Type | Default | Description | Required |
---|---|---|---|---|
account_number | string | "" | Account number | |
routing_number | string | "" | Routing number | |
account_type | string literal | Ach account type ("checking" or "savings") | * | |
sec_code | string literal | Ach sec code ("web", "ccd", or "ppd") | * |
Name | Type | Default | Description | Required |
---|---|---|---|---|
token | string | Payment method token generated by Tokenizer form | * |
{
"status": "success",
"msg": "success",
"data": {
"card": {
"id": "b799g1iq9qq6dk5l39i0",
"card_type": "visa",
"first_six": "411111",
"last_four": "1112",
"masked_card": "411111******1112",
"expiration_date": "12/20",
"created_at": "2017-10-02T19:48:22.468483Z",
"updated_at": "2017-10-02T19:48:22.468483Z"
}
}
}
# Create Payment Method Token - Code Samples
function createPaymentToken(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
card_number: "4111111111111111",
expiration_date: "12/20",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card",
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var newId = result.data.id;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class FullCard {
public string Id { get; set; }
public string Card_type { get; set; }
public string First_six { get; set; }
public string Last_four { get; set; }
public string Masked_card { get; set; }
public string Expiration_date { get; set; }
public string Status { get; set; }
public string Auth_code { get; set; }
public string Processor_response_code { get; set; }
public string Processor_response_text { get; set; }
public string Processor_type { get; set; }
public string Processor_id { get; set; }
public string Avs_response_code { get; set; }
public string Cvv_response_code { get; set; }
public string Processor_specific { get; set; }
public DateTime Created_at { get; set; }
public DateTime Updated_at { get; set; }
}
public class CardResponse : ApiResponse {
public FullCard Data { get; set; }
}
public void CreatePaymentToken(string customerId, Card card) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(card);
IRestResponse response = client.Execute(request);
CardResponse apiResponse = JsonConvert.DeserializeObject<CardResponse>(response);
if (apiResponse.Status === "success") {
// handle success
string newId = apiResponse.Data.Id;
} else {
// handle non success
}
}
<?php
function createPaymentToken($customerId, $card) {
$curl = curl_init();
$payload = json_encode($card);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId."/paymentmethod/card",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response);
curl_close($curl);
echo $response;
}
public class FullCard {
String Id;
@JsonProperty("card_type")
String CardType;
@JsonProperty("first_six")
String FirstSix;
@JsonProperty("last_four")
String LastFour;
@JsonProperty("masked_card")
String MaskedCard;
@JsonProperty("expiration_date")
String ExpirationDate;
String Status;
@JsonProperty("auth_code")
String AuthCode;
@JsonProperty("processor_response_code")
String ProcessorResponseCode;
@JsonProperty("processor_response_text")
String ProcessorResponseText;
@JsonProperty("processor_type")
String ProcessorType;
@JsonProperty("processor_id")
String ProcessorId;
@JsonProperty("avs_response_code")
String AvsResponseCode;
@JsonProperty("cvv_response_code")
String CvvResponseCode;
@JsonProperty("processor_specific")
String ProcessorSpecific;
@JsonProperty("created_at")
java.util.Date CreatedAt;
@JsonProperty("updated_at")
java.util.Date UpdatedAt;
}
public class CardResponse extends ApiResponse {
Card data;
}
public void createPaymentToken(String customerId, Card card) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(card);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card")
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CardResponse apiResponse = objectMapper.readValue(responseBody.string(), CardResponse.class);
if (apiResponse.status === "success") {
// handle success
String newId = apiResponse.data.id;
} else {
// handle non success
}
}
# Get Payment Method Token By ID (Deprecated)
Retrieve details for the specified payment method token.
Request Method:
GET
Get Card Token - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/card/{ card id }
Get ACH Token - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/ach/{ ach id }
{
"status": "success",
"msg": "success",
"data": [
{
"id": "b798ls2q9qq646ksu080",
"card_type": "visa",
"first_six": "411111",
"last_four": "1111",
"masked_card": "411111******1111",
"expiration_date": "12/20",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
}
],
"count": 1
}
function getPaymentToken(customerId, paymentId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" +
customerId +
"/paymentmethod/card/" +
paymentId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var card = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void GetPaymentToken(string customerId, string paymentId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card/" + paymentId);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
CardResponse apiResponse = JsonConvert.DeserializeObject<CardResponse>(response);
if (apiResponse.Status === "success") {
// handle success
Card card = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getPaymentToken($customerId, $paymentId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId"/paymentmethod/card/".$paymentId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response);
curl_close($curl);
echo $response;
}
public void getPaymentToken(String customerId, String paymentId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card/" + paymentId)
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CardResponse apiResponse = objectMapper.readValue(responseBody.string(), CardResponse.class);
if (apiResponse.status === "success") {
// handle success
Card card = apiResponse.data;
} else {
// handle non success
}
}
# Get All Payment Method Tokens (Deprecated)
Retrieve details for all card or ach payment method tokens stored on the customer.
Request Method:
GET
Get Card Tokens - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/card
Get ACH Tokens - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/ach
{
"status": "success",
"msg": "success",
"data": [
{
"id": "b798ls2q9qq646ksu080",
"card_type": "visa",
"first_six": "411111",
"last_four": "1111",
"masked_card": "411111******1111",
"expiration_date": "12/20",
"created_at": "2017-10-02T18:52:32Z",
"updated_at": "2017-10-02T18:52:32Z"
},
{
"id": "b799g1iq9qq6dk5l39i0",
"card_type": "visa",
"first_six": "411111",
"last_four": "1112",
"masked_card": "411111******1112",
"expiration_date": "12/20",
"created_at": "2017-10-02T19:48:22Z",
"updated_at": "2017-10-02T19:48:22Z"
}
],
"count": 2
}
function getAllPaymentTokens(customerId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
var requestOptions = {
method: "GET",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card",
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
var cards = result.data;
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public class CardsResponse : ApiResponse {
public List<Card> Data { get; set; }
}
public void GetAllPaymentTokens(string customerId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", _apiKey);
IRestResponse response = client.Execute(request);
CardsResponse apiResponse = JsonConvert.DeserializeObject<CardsResponse>(response);
if (apiResponse.Status === "success") {
// handle success
List<Card> cards = apiResponse.Data;
} else {
// handle non success
}
}
<?php
function getAllPaymentTokens($customerId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId"/paymentmethod/card",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey
),
));
$response = curl_exec($curl);
$result = json_decode($response);
curl_close($curl);
echo $response;
}
public class CardsResponse extends ApiResponse {
java.util.ArrayList<Card> data;
}
public void getAllPaymentTokens(String customerId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card")
.method("GET", null)
.addHeader("Authorization", apiKey)
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CardsResponse apiResponse = objectMapper.readValue(responseBody.string(), CardsResponse.class);
if (apiResponse.status === "success") {
// handle success
java.util.ArrayList<Card> cards = apiResponse.data;
} else {
// handle non success
}
}
# Update Payment Method Token (Deprecated)
Edit details for the specified payment method token.
Request Method:
POST
Update Card - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/card/{ card id }
Update ACH - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/ach/{ ach id }
Update with Token - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/{ card or ach }/{ payment method id }
Name | Type | Default | Description | Required |
---|---|---|---|---|
card | object | Object containing details for updating a stored card payment method | * | |
card .card_number | string | Card number | * | |
card .expiration_date | string | Card expiration date ("MMYY" or "MM/YY") | * |
Name | Type | Default | Description | Required |
---|---|---|---|---|
ach | object | Object containing details for updating a stored ach payment method | * | |
ach .account_number | string | Account number | * | |
ach .routing_number | string | Routing number | * | |
ach .account_type | string literal | Ach account type ("checking" or "savings") | * | |
ach .sec_code | string literal | Ach sec code ("web", "ccd", or "ppd") | * |
Name | Type | Default | Description | Required |
---|---|---|---|---|
token | string | Payment method token generated by Tokenizer form | * |
{
"status": "success",
"msg": "success",
"data": null
}
# Update Payment Method Token - Code Samples
function updatePaymentToken(customerId, paymentId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
card: {
card_number: "4111111111111111",
expiration_date: "12/20",
},
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" +
customerId +
"/paymentmethod/card/" +
paymentId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void UpdatePaymentToken(string customerId, Card card) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card/" + card.Id);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(card);
IRestResponse response = client.Execute(request);
CardResponse apiResponse = JsonConvert.DeserializeObject<CardResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function updatePaymentToken($customerId, $card) {
$curl = curl_init();
$payload = json_encode($card);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/123abc/paymentmethod/card/123abc",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response);
curl_close($curl);
echo $response;
}
public void updatePaymentToken(String customerId, Card card) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
Gson gson = new Gson();
String jsonObject = gson.toJson(card);
RequestBody body = RequestBody.create(mediaType, jsonObject);
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card/" + card.id)
.method("POST", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
CardResponse apiResponse = objectMapper.readValue(responseBody.string(), CardResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}
# Delete Payment Method Token (Deprecated)
Edit details for the specified add-on.
Request Method:
DELETE
Delete Card Token - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/card/{ card id }
Delete ACH Token - URL Endpoint:
/api/customer/{ customer id }/paymentmethod/ach/{ ach id }
{
"status": "success",
"msg": "success",
"data": null
}
function deletePaymentToken(customerId, paymentId) {
var myHeaders = new Headers();
myHeaders.append("Authorization", apiKey);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: "DELETE",
headers: myHeaders,
};
fetch(
"https://sandbox.durangomsgateway.com/api/customer/" +
customerId +
"/paymentmethod/card/" +
paymentId,
requestOptions
)
.then((response) => response.text())
.then((result) => {
if (result.status === "success") {
// handle success
} else {
// handle non success
}
})
.catch((error) => console.log("error", error));
}
public void DeletePaymentToken(string customerId, string paymentId) {
var client = new RestClient("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card/" + paymentId);
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", _apiKey);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(response);
if (apiResponse.Status === "success") {
// handle success
} else {
// handle non success
}
}
<?php
function deletePaymentToken($customerId, $paymentId) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://sandbox.durangomsgateway.com/api/customer/".$customerId."/paymentmethod/card/".$paymentId,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: ".$apiKey,
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$result = json_decode($response);
curl_close($curl);
echo $response;
}
public void deletePaymentToken(String customerId, String paymentId) {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://sandbox.durangomsgateway.com/api/customer/" + customerId + "/paymentmethod/card/" + paymentId)
.method("DELETE", body)
.addHeader("Authorization", apiKey)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
ResponseBody responseBody = response.body();
ApiResponse apiResponse = objectMapper.readValue(responseBody.string(), ApiResponse.class);
if (apiResponse.status === "success") {
// handle success
} else {
// handle non success
}
}