Charge Transaction
curl --request POST \
--url https://api.example.com/api/v2/transactions/charge \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"amount": 123,
"source": "<string>",
"expiry_month": 123,
"expiry_year": 123,
"billing_info": {
"first_name": "<string>",
"last_name": "<string>",
"street": "<string>",
"street2": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"transaction_details": {
"description": "<string>",
"clerk": "<string>",
"terminal": "<string>",
"client_ip": "<string>",
"signature": "<string>",
"invoice_number": "<string>",
"po_number": "<string>",
"order_number": "<string>"
}
}
'import requests
url = "https://api.example.com/api/v2/transactions/charge"
payload = {
"amount": 123,
"source": "<string>",
"expiry_month": 123,
"expiry_year": 123,
"billing_info": {
"first_name": "<string>",
"last_name": "<string>",
"street": "<string>",
"street2": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"transaction_details": {
"description": "<string>",
"clerk": "<string>",
"terminal": "<string>",
"client_ip": "<string>",
"signature": "<string>",
"invoice_number": "<string>",
"po_number": "<string>",
"order_number": "<string>"
}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
amount: 123,
source: '<string>',
expiry_month: 123,
expiry_year: 123,
billing_info: {
first_name: '<string>',
last_name: '<string>',
street: '<string>',
street2: '<string>',
city: '<string>',
state: '<string>',
zip: '<string>',
country: '<string>'
},
transaction_details: {
description: '<string>',
clerk: '<string>',
terminal: '<string>',
client_ip: '<string>',
signature: '<string>',
invoice_number: '<string>',
po_number: '<string>',
order_number: '<string>'
}
})
};
fetch('https://api.example.com/api/v2/transactions/charge', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v2/transactions/charge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123,
'source' => '<string>',
'expiry_month' => 123,
'expiry_year' => 123,
'billing_info' => [
'first_name' => '<string>',
'last_name' => '<string>',
'street' => '<string>',
'street2' => '<string>',
'city' => '<string>',
'state' => '<string>',
'zip' => '<string>',
'country' => '<string>'
],
'transaction_details' => [
'description' => '<string>',
'clerk' => '<string>',
'terminal' => '<string>',
'client_ip' => '<string>',
'signature' => '<string>',
'invoice_number' => '<string>',
'po_number' => '<string>',
'order_number' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v2/transactions/charge"
payload := strings.NewReader("{\n \"amount\": 123,\n \"source\": \"<string>\",\n \"expiry_month\": 123,\n \"expiry_year\": 123,\n \"billing_info\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"street\": \"<string>\",\n \"street2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"transaction_details\": {\n \"description\": \"<string>\",\n \"clerk\": \"<string>\",\n \"terminal\": \"<string>\",\n \"client_ip\": \"<string>\",\n \"signature\": \"<string>\",\n \"invoice_number\": \"<string>\",\n \"po_number\": \"<string>\",\n \"order_number\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v2/transactions/charge")
.header("Authorization", "<authorization>")
.header("Content-Type", "<content-type>")
.body("{\n \"amount\": 123,\n \"source\": \"<string>\",\n \"expiry_month\": 123,\n \"expiry_year\": 123,\n \"billing_info\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"street\": \"<string>\",\n \"street2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"transaction_details\": {\n \"description\": \"<string>\",\n \"clerk\": \"<string>\",\n \"terminal\": \"<string>\",\n \"client_ip\": \"<string>\",\n \"signature\": \"<string>\",\n \"invoice_number\": \"<string>\",\n \"po_number\": \"<string>\",\n \"order_number\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v2/transactions/charge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"amount\": 123,\n \"source\": \"<string>\",\n \"expiry_month\": 123,\n \"expiry_year\": 123,\n \"billing_info\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"street\": \"<string>\",\n \"street2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"transaction_details\": {\n \"description\": \"<string>\",\n \"clerk\": \"<string>\",\n \"terminal\": \"<string>\",\n \"client_ip\": \"<string>\",\n \"signature\": \"<string>\",\n \"invoice_number\": \"<string>\",\n \"po_number\": \"<string>\",\n \"order_number\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"status": "Approved",
"status_code": "A",
"reference_number": 46364493,
"auth_code": "034674",
"auth_amount": 100,
"card_type": "Visa",
"last_4": "6713",
"avs_result": "Address: No Match & 5 Digit Zip: Match",
"avs_result_code": "NYZ",
"cvv2_result": "Match",
"cvv2_result_code": "M",
"version": "2.0.0",
"transaction": {
"id": 46364493,
"created_at": "2025-09-09T09:48:23.000Z",
"status_details": {
"status": "captured"
},
"amount_details": {
"amount": 100,
"subtotal": 100,
"tax": 0,
"tax_percent": 0,
"shipping": 0,
"discount": 0,
"tip": 0,
"surcharge": 0,
"original_requested_amount": 100,
"original_authorized_amount": 100
},
"card_details": {
"card_type": "Visa",
"last4": "6713",
"bin": "423223",
"expiry_month": 1,
"expiry_year": 2026,
"auth_code": "034674",
"avs_result": "Address: No Match & 5 Digit Zip: Match",
"avs_result_code": "NYZ",
"avs_street": "1234 Main Street",
"avs_zip": "12345",
"cvv_result": "Match",
"cvv_result_code": "M",
"cavv_result": "N/A",
"cavv_result_code": null,
"bin_details": {
"type": "D"
},
"name": null
},
"billing_info": {
"first_name": "John",
"last_name": "Smith",
"street": "1234 Main Street",
"street2": "Apt 2E",
"city": "Springfield",
"state": "CA",
"zip": "12345",
"country": "US",
"phone": "5551234567"
},
"shipping_info": {
"first_name": null,
"last_name": null,
"street": null,
"street2": null,
"city": null,
"state": null,
"zip": null,
"country": null,
"phone": null
},
"transaction_details": {
"type": "charge",
"source": "BrightProd",
"batch_id": 3209846,
"description": null,
"order_number": null,
"invoice_number": null,
"po_number": null,
"reference_number": null,
"clerk": null,
"terminal": null,
"client_ip": null,
"schedule_id": null
},
"customer": {
"customer_id": null,
"identifier": null,
"email": null,
"fax": null
},
"custom_fields": {},
"settled_date": null
}
}
{
"id": "txn_1234567891",
"status": "declined",
"amount": 5.00,
"currency": "USD",
"error": {
"code": "card_declined",
"message": "The card was declined"
},
"card": {
"last_four": "0002",
"card_type": "visa"
},
"created_at": "2024-01-15T10:31:00Z"
}
{
"error": {
"code": "invalid_nonce",
"message": "The provided nonce is invalid or has expired"
}
}
Endpoints
Charge Transaction
Process card payments using the charge endpoint
POST
/
api
/
v2
/
transactions
/
charge
Charge Transaction
curl --request POST \
--url https://api.example.com/api/v2/transactions/charge \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"amount": 123,
"source": "<string>",
"expiry_month": 123,
"expiry_year": 123,
"billing_info": {
"first_name": "<string>",
"last_name": "<string>",
"street": "<string>",
"street2": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"transaction_details": {
"description": "<string>",
"clerk": "<string>",
"terminal": "<string>",
"client_ip": "<string>",
"signature": "<string>",
"invoice_number": "<string>",
"po_number": "<string>",
"order_number": "<string>"
}
}
'import requests
url = "https://api.example.com/api/v2/transactions/charge"
payload = {
"amount": 123,
"source": "<string>",
"expiry_month": 123,
"expiry_year": 123,
"billing_info": {
"first_name": "<string>",
"last_name": "<string>",
"street": "<string>",
"street2": "<string>",
"city": "<string>",
"state": "<string>",
"zip": "<string>",
"country": "<string>"
},
"transaction_details": {
"description": "<string>",
"clerk": "<string>",
"terminal": "<string>",
"client_ip": "<string>",
"signature": "<string>",
"invoice_number": "<string>",
"po_number": "<string>",
"order_number": "<string>"
}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
amount: 123,
source: '<string>',
expiry_month: 123,
expiry_year: 123,
billing_info: {
first_name: '<string>',
last_name: '<string>',
street: '<string>',
street2: '<string>',
city: '<string>',
state: '<string>',
zip: '<string>',
country: '<string>'
},
transaction_details: {
description: '<string>',
clerk: '<string>',
terminal: '<string>',
client_ip: '<string>',
signature: '<string>',
invoice_number: '<string>',
po_number: '<string>',
order_number: '<string>'
}
})
};
fetch('https://api.example.com/api/v2/transactions/charge', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v2/transactions/charge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123,
'source' => '<string>',
'expiry_month' => 123,
'expiry_year' => 123,
'billing_info' => [
'first_name' => '<string>',
'last_name' => '<string>',
'street' => '<string>',
'street2' => '<string>',
'city' => '<string>',
'state' => '<string>',
'zip' => '<string>',
'country' => '<string>'
],
'transaction_details' => [
'description' => '<string>',
'clerk' => '<string>',
'terminal' => '<string>',
'client_ip' => '<string>',
'signature' => '<string>',
'invoice_number' => '<string>',
'po_number' => '<string>',
'order_number' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v2/transactions/charge"
payload := strings.NewReader("{\n \"amount\": 123,\n \"source\": \"<string>\",\n \"expiry_month\": 123,\n \"expiry_year\": 123,\n \"billing_info\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"street\": \"<string>\",\n \"street2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"transaction_details\": {\n \"description\": \"<string>\",\n \"clerk\": \"<string>\",\n \"terminal\": \"<string>\",\n \"client_ip\": \"<string>\",\n \"signature\": \"<string>\",\n \"invoice_number\": \"<string>\",\n \"po_number\": \"<string>\",\n \"order_number\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v2/transactions/charge")
.header("Authorization", "<authorization>")
.header("Content-Type", "<content-type>")
.body("{\n \"amount\": 123,\n \"source\": \"<string>\",\n \"expiry_month\": 123,\n \"expiry_year\": 123,\n \"billing_info\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"street\": \"<string>\",\n \"street2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"transaction_details\": {\n \"description\": \"<string>\",\n \"clerk\": \"<string>\",\n \"terminal\": \"<string>\",\n \"client_ip\": \"<string>\",\n \"signature\": \"<string>\",\n \"invoice_number\": \"<string>\",\n \"po_number\": \"<string>\",\n \"order_number\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v2/transactions/charge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"amount\": 123,\n \"source\": \"<string>\",\n \"expiry_month\": 123,\n \"expiry_year\": 123,\n \"billing_info\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"street\": \"<string>\",\n \"street2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"zip\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"transaction_details\": {\n \"description\": \"<string>\",\n \"clerk\": \"<string>\",\n \"terminal\": \"<string>\",\n \"client_ip\": \"<string>\",\n \"signature\": \"<string>\",\n \"invoice_number\": \"<string>\",\n \"po_number\": \"<string>\",\n \"order_number\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"status": "Approved",
"status_code": "A",
"reference_number": 46364493,
"auth_code": "034674",
"auth_amount": 100,
"card_type": "Visa",
"last_4": "6713",
"avs_result": "Address: No Match & 5 Digit Zip: Match",
"avs_result_code": "NYZ",
"cvv2_result": "Match",
"cvv2_result_code": "M",
"version": "2.0.0",
"transaction": {
"id": 46364493,
"created_at": "2025-09-09T09:48:23.000Z",
"status_details": {
"status": "captured"
},
"amount_details": {
"amount": 100,
"subtotal": 100,
"tax": 0,
"tax_percent": 0,
"shipping": 0,
"discount": 0,
"tip": 0,
"surcharge": 0,
"original_requested_amount": 100,
"original_authorized_amount": 100
},
"card_details": {
"card_type": "Visa",
"last4": "6713",
"bin": "423223",
"expiry_month": 1,
"expiry_year": 2026,
"auth_code": "034674",
"avs_result": "Address: No Match & 5 Digit Zip: Match",
"avs_result_code": "NYZ",
"avs_street": "1234 Main Street",
"avs_zip": "12345",
"cvv_result": "Match",
"cvv_result_code": "M",
"cavv_result": "N/A",
"cavv_result_code": null,
"bin_details": {
"type": "D"
},
"name": null
},
"billing_info": {
"first_name": "John",
"last_name": "Smith",
"street": "1234 Main Street",
"street2": "Apt 2E",
"city": "Springfield",
"state": "CA",
"zip": "12345",
"country": "US",
"phone": "5551234567"
},
"shipping_info": {
"first_name": null,
"last_name": null,
"street": null,
"street2": null,
"city": null,
"state": null,
"zip": null,
"country": null,
"phone": null
},
"transaction_details": {
"type": "charge",
"source": "BrightProd",
"batch_id": 3209846,
"description": null,
"order_number": null,
"invoice_number": null,
"po_number": null,
"reference_number": null,
"clerk": null,
"terminal": null,
"client_ip": null,
"schedule_id": null
},
"customer": {
"customer_id": null,
"identifier": null,
"email": null,
"fax": null
},
"custom_fields": {},
"settled_date": null
}
}
{
"id": "txn_1234567891",
"status": "declined",
"amount": 5.00,
"currency": "USD",
"error": {
"code": "card_declined",
"message": "The card was declined"
},
"card": {
"last_four": "0002",
"card_type": "visa"
},
"created_at": "2024-01-15T10:31:00Z"
}
{
"error": {
"code": "invalid_nonce",
"message": "The provided nonce is invalid or has expired"
}
}
Overview
The charge endpoint processes a payment using a nonce token obtained from card tokenization. This endpoint debits the customer’s card and credits your merchant account.Endpoint
- Sandbox
- Production
POST https://api.sandbox.approvelygateway.com/api/v2/transactions/charge
POST https://banking.cashqbot.com/api/v2/transactions/charge
Authentication
string
required
Basic Authentication header with Base64 encoded
[API_KEY]:[PIN]Format: Basic [base64_credentials]string
required
Must be
application/jsonRequest Body
number
required
Transaction amount in dollars (e.g.,
5 for $5.00)string
required
Nonce token obtained from card tokenization (e.g.,
"nonce-pft4uav4cker5g8bk3db")integer
required
Card expiry month (1-12)
integer
required
Card expiry year (e.g.,
2028)object
required
Customer billing information
Show Billing info properties
Show Billing info properties
string
required
Customer’s first name
string
required
Customer’s last name
string
required
Street address
string
Additional address line (apartment, suite, etc.)
string
required
City name
string
required
State/Province code (e.g.,
"FL", "CA")string
required
ZIP/Postal code
string
required
Country code (e.g.,
"US")object
Optional transaction metadata for your internal tracking
Request Example
curl -i -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_BASE64_CREDENTIALS" \
-d '{
"amount": 100,
"source": "nonce-6d7a7yelkl2pjokjs6rq",
"expiry_month": 1,
"expiry_year": 2026,
"billing_info": {
"first_name": "John",
"last_name": "Smith",
"street": "1234 Main Street",
"street2": "Apt 2E",
"city": "Springfield",
"state": "CA",
"zip": "12345",
"country": "US",
"phone": "5551234567"
}
}' \
'https://api.sandbox.approvelygateway.com/api/v2/transactions/charge'
const apiKey = 'your_api_key';
const pin = 'your_pin';
const credentials = Buffer.from(`${apiKey}:${pin}`).toString('base64');
const chargeData = {
amount: 100,
source: 'nonce-6d7a7yelkl2pjokjs6rq',
expiry_month: 1,
expiry_year: 2026,
billing_info: {
first_name: 'John',
last_name: 'Smith',
street: '1234 Main Street',
street2: 'Apt 2E',
city: 'Springfield',
state: 'CA',
zip: '12345',
country: 'US',
phone: '5551234567'
}
};
const response = await fetch(
'https://api.sandbox.approvelygateway.com/api/v2/transactions/charge',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${credentials}`
},
body: JSON.stringify(chargeData)
}
);
const data = await response.json();
console.log(data);
import requests
import base64
import json
api_key = 'your_api_key'
pin = 'your_pin'
credentials = base64.b64encode(f'{api_key}:{pin}'.encode()).decode()
charge_data = {
'amount': 100,
'source': 'nonce-6d7a7yelkl2pjokjs6rq',
'expiry_month': 1,
'expiry_year': 2026,
'billing_info': {
'first_name': 'John',
'last_name': 'Smith',
'street': '1234 Main Street',
'street2': 'Apt 2E',
'city': 'Springfield',
'state': 'CA',
'zip': '12345',
'country': 'US',
'phone': '5551234567'
}
}
response = requests.post(
'https://api.sandbox.approvelygateway.com/api/v2/transactions/charge',
headers={
'Content-Type': 'application/json',
'Authorization': f'Basic {credentials}'
},
json=charge_data
)
data = response.json()
print(data)
<?php
$apiKey = 'your_api_key';
$pin = 'your_pin';
$credentials = base64_encode($apiKey . ':' . $pin);
$chargeData = [
'amount' => 100,
'source' => 'nonce-6d7a7yelkl2pjokjs6rq',
'expiry_month' => 1,
'expiry_year' => 2026,
'billing_info' => [
'first_name' => 'John',
'last_name' => 'Smith',
'street' => '1234 Main Street',
'street2' => 'Apt 2E',
'city' => 'Springfield',
'state' => 'CA',
'zip' => '12345',
'country' => 'US',
'phone' => '5551234567'
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.sandbox.approvelygateway.com/api/v2/transactions/charge');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Basic ' . $credentials
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($chargeData));
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
?>
Response
string
Unique transaction identifier
string
Transaction status (e.g.,
"approved", "declined")number
Transaction amount
string
Currency code (e.g.,
"USD")object
string
Transaction timestamp (ISO 8601 format)
string
Authorization code from payment processor
Response Examples
{
"status": "Approved",
"status_code": "A",
"reference_number": 46364493,
"auth_code": "034674",
"auth_amount": 100,
"card_type": "Visa",
"last_4": "6713",
"avs_result": "Address: No Match & 5 Digit Zip: Match",
"avs_result_code": "NYZ",
"cvv2_result": "Match",
"cvv2_result_code": "M",
"version": "2.0.0",
"transaction": {
"id": 46364493,
"created_at": "2025-09-09T09:48:23.000Z",
"status_details": {
"status": "captured"
},
"amount_details": {
"amount": 100,
"subtotal": 100,
"tax": 0,
"tax_percent": 0,
"shipping": 0,
"discount": 0,
"tip": 0,
"surcharge": 0,
"original_requested_amount": 100,
"original_authorized_amount": 100
},
"card_details": {
"card_type": "Visa",
"last4": "6713",
"bin": "423223",
"expiry_month": 1,
"expiry_year": 2026,
"auth_code": "034674",
"avs_result": "Address: No Match & 5 Digit Zip: Match",
"avs_result_code": "NYZ",
"avs_street": "1234 Main Street",
"avs_zip": "12345",
"cvv_result": "Match",
"cvv_result_code": "M",
"cavv_result": "N/A",
"cavv_result_code": null,
"bin_details": {
"type": "D"
},
"name": null
},
"billing_info": {
"first_name": "John",
"last_name": "Smith",
"street": "1234 Main Street",
"street2": "Apt 2E",
"city": "Springfield",
"state": "CA",
"zip": "12345",
"country": "US",
"phone": "5551234567"
},
"shipping_info": {
"first_name": null,
"last_name": null,
"street": null,
"street2": null,
"city": null,
"state": null,
"zip": null,
"country": null,
"phone": null
},
"transaction_details": {
"type": "charge",
"source": "BrightProd",
"batch_id": 3209846,
"description": null,
"order_number": null,
"invoice_number": null,
"po_number": null,
"reference_number": null,
"clerk": null,
"terminal": null,
"client_ip": null,
"schedule_id": null
},
"customer": {
"customer_id": null,
"identifier": null,
"email": null,
"fax": null
},
"custom_fields": {},
"settled_date": null
}
}
{
"id": "txn_1234567891",
"status": "declined",
"amount": 5.00,
"currency": "USD",
"error": {
"code": "card_declined",
"message": "The card was declined"
},
"card": {
"last_four": "0002",
"card_type": "visa"
},
"created_at": "2024-01-15T10:31:00Z"
}
{
"error": {
"code": "invalid_nonce",
"message": "The provided nonce is invalid or has expired"
}
}
Transaction Statuses
| Status | Description | Action |
|---|---|---|
approved | Transaction successful | Fulfill order |
declined | Card declined by issuer | Request different payment method |
pending | Transaction pending review | Wait for final status |
failed | Transaction failed | Check error details and retry |
Complete Payment Flow
1
Tokenize card
Use the tokenization form to get a nonce token from the customer’s card data
const nonce = await tokenizeCard(cardData);
2
Send nonce to server
Send the nonce from your frontend to your backend server
const response = await fetch('/api/process-payment', {
method: 'POST',
body: JSON.stringify({ nonce, amount, billingInfo })
});
3
Process charge
Your server calls the Approvely charge endpoint with the nonce
const result = await chargeCard(nonce, amount, billingInfo);
4
Handle response
Check the transaction status and update your order accordingly
if (result.status === 'approved') {
fulfillOrder(orderId);
} else {
handleDecline(result.error);
}
Error Handling
card_declined
card_declined
Cause: Card issuer declined the transactionSolution:
- Ask customer to contact their bank
- Request alternative payment method
- Verify billing information is correct
invalid_nonce
invalid_nonce
Cause: Nonce token is invalid or expiredSolution:
- Re-tokenize the card to get a new nonce
- Ensure nonce is used immediately after generation
- Don’t reuse nonces
insufficient_funds
insufficient_funds
Cause: Card has insufficient fundsSolution:
- Request different payment method
- Ask customer to use another card
invalid_card
invalid_card
Cause: Card number or details are invalidSolution:
- Verify card number is correct
- Check expiry date is valid
- Ensure CVV is correct
authentication_error
authentication_error
Cause: Invalid API credentialsSolution:
- Verify API Key and PIN are correct
- Check Base64 encoding is proper
- Ensure using correct environment credentials
Best Practices
Use Nonce Immediately
Process charges immediately after receiving the nonce token
Validate Before Charging
Validate amount and billing info before calling the API
Handle All Statuses
Account for approved, declined, pending, and failed statuses
Log Transactions
Keep detailed logs of all charge attempts for reconciliation
Secure Credentials
Never expose API credentials on the client side
Use HTTPS Only
Always make API requests over HTTPS
Testing
Use these test scenarios in the sandbox:Successful Charge
- Card:
4111 1111 1111 1111 - Expected:
status: "approved"
Declined Card
- Card:
4000 0000 0000 0002 - Expected:
status: "declined"
Insufficient Funds
- Card:
4000 0000 0000 9995 - Expected:
status: "declined", error codeinsufficient_funds
Related Documentation
Tokenization
Learn how to tokenize card data
Authentication
Set up API authentication
⌘I
