Create Token Payment
curl --request POST \
--url https://api.example.com/payments \
--header 'Content-Type: application/json' \
--data '
{
"data": {},
"data.requestId": "<string>",
"data.type": "<string>",
"data.attributes": {},
"data.attributes.paymentType": "<string>",
"data.attributes.merchantId": "<string>",
"data.attributes.miscData": "<string>",
"data.attributes.token": {
"data.attributes.token.tokenId": "<string>",
"data.attributes.token.holder": "<string>",
"data.attributes.token.expiry": "<string>",
"data.attributes.token.useAVS": true
},
"data.attributes.transaction": {
"data.attributes.transaction.amount": "<string>",
"data.attributes.transaction.currency": "<string>",
"data.attributes.transaction.invoice": "<string>"
},
"data.attributes.billingAddress": {
"data.attributes.billingAddress.line1": "<string>",
"data.attributes.billingAddress.line2": "<string>",
"data.attributes.billingAddress.city": "<string>",
"data.attributes.billingAddress.state": "<string>",
"data.attributes.billingAddress.zip": "<string>",
"data.attributes.billingAddress.country": "<string>"
}
}
'import requests
url = "https://api.example.com/payments"
payload = {
"data": {},
"data.requestId": "<string>",
"data.type": "<string>",
"data.attributes": {},
"data.attributes.paymentType": "<string>",
"data.attributes.merchantId": "<string>",
"data.attributes.miscData": "<string>",
"data.attributes.token": {
"data.attributes.token.tokenId": "<string>",
"data.attributes.token.holder": "<string>",
"data.attributes.token.expiry": "<string>",
"data.attributes.token.useAVS": True
},
"data.attributes.transaction": {
"data.attributes.transaction.amount": "<string>",
"data.attributes.transaction.currency": "<string>",
"data.attributes.transaction.invoice": "<string>"
},
"data.attributes.billingAddress": {
"data.attributes.billingAddress.line1": "<string>",
"data.attributes.billingAddress.line2": "<string>",
"data.attributes.billingAddress.city": "<string>",
"data.attributes.billingAddress.state": "<string>",
"data.attributes.billingAddress.zip": "<string>",
"data.attributes.billingAddress.country": "<string>"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
data: {},
'data.requestId': '<string>',
'data.type': '<string>',
'data.attributes': {},
'data.attributes.paymentType': '<string>',
'data.attributes.merchantId': '<string>',
'data.attributes.miscData': '<string>',
'data.attributes.token': {
'data.attributes.token.tokenId': '<string>',
'data.attributes.token.holder': '<string>',
'data.attributes.token.expiry': '<string>',
'data.attributes.token.useAVS': true
},
'data.attributes.transaction': {
'data.attributes.transaction.amount': '<string>',
'data.attributes.transaction.currency': '<string>',
'data.attributes.transaction.invoice': '<string>'
},
'data.attributes.billingAddress': {
'data.attributes.billingAddress.line1': '<string>',
'data.attributes.billingAddress.line2': '<string>',
'data.attributes.billingAddress.city': '<string>',
'data.attributes.billingAddress.state': '<string>',
'data.attributes.billingAddress.zip': '<string>',
'data.attributes.billingAddress.country': '<string>'
}
})
};
fetch('https://api.example.com/payments', 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/payments",
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([
'data' => [
],
'data.requestId' => '<string>',
'data.type' => '<string>',
'data.attributes' => [
],
'data.attributes.paymentType' => '<string>',
'data.attributes.merchantId' => '<string>',
'data.attributes.miscData' => '<string>',
'data.attributes.token' => [
'data.attributes.token.tokenId' => '<string>',
'data.attributes.token.holder' => '<string>',
'data.attributes.token.expiry' => '<string>',
'data.attributes.token.useAVS' => true
],
'data.attributes.transaction' => [
'data.attributes.transaction.amount' => '<string>',
'data.attributes.transaction.currency' => '<string>',
'data.attributes.transaction.invoice' => '<string>'
],
'data.attributes.billingAddress' => [
'data.attributes.billingAddress.line1' => '<string>',
'data.attributes.billingAddress.line2' => '<string>',
'data.attributes.billingAddress.city' => '<string>',
'data.attributes.billingAddress.state' => '<string>',
'data.attributes.billingAddress.zip' => '<string>',
'data.attributes.billingAddress.country' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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/payments"
payload := strings.NewReader("{\n \"data\": {},\n \"data.requestId\": \"<string>\",\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.merchantId\": \"<string>\",\n \"data.attributes.miscData\": \"<string>\",\n \"data.attributes.token\": {\n \"data.attributes.token.tokenId\": \"<string>\",\n \"data.attributes.token.holder\": \"<string>\",\n \"data.attributes.token.expiry\": \"<string>\",\n \"data.attributes.token.useAVS\": true\n },\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\",\n \"data.attributes.transaction.invoice\": \"<string>\"\n },\n \"data.attributes.billingAddress\": {\n \"data.attributes.billingAddress.line1\": \"<string>\",\n \"data.attributes.billingAddress.line2\": \"<string>\",\n \"data.attributes.billingAddress.city\": \"<string>\",\n \"data.attributes.billingAddress.state\": \"<string>\",\n \"data.attributes.billingAddress.zip\": \"<string>\",\n \"data.attributes.billingAddress.country\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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/payments")
.header("Content-Type", "application/json")
.body("{\n \"data\": {},\n \"data.requestId\": \"<string>\",\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.merchantId\": \"<string>\",\n \"data.attributes.miscData\": \"<string>\",\n \"data.attributes.token\": {\n \"data.attributes.token.tokenId\": \"<string>\",\n \"data.attributes.token.holder\": \"<string>\",\n \"data.attributes.token.expiry\": \"<string>\",\n \"data.attributes.token.useAVS\": true\n },\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\",\n \"data.attributes.transaction.invoice\": \"<string>\"\n },\n \"data.attributes.billingAddress\": {\n \"data.attributes.billingAddress.line1\": \"<string>\",\n \"data.attributes.billingAddress.line2\": \"<string>\",\n \"data.attributes.billingAddress.city\": \"<string>\",\n \"data.attributes.billingAddress.state\": \"<string>\",\n \"data.attributes.billingAddress.zip\": \"<string>\",\n \"data.attributes.billingAddress.country\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {},\n \"data.requestId\": \"<string>\",\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.merchantId\": \"<string>\",\n \"data.attributes.miscData\": \"<string>\",\n \"data.attributes.token\": {\n \"data.attributes.token.tokenId\": \"<string>\",\n \"data.attributes.token.holder\": \"<string>\",\n \"data.attributes.token.expiry\": \"<string>\",\n \"data.attributes.token.useAVS\": true\n },\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\",\n \"data.attributes.transaction.invoice\": \"<string>\"\n },\n \"data.attributes.billingAddress\": {\n \"data.attributes.billingAddress.line1\": \"<string>\",\n \"data.attributes.billingAddress.line2\": \"<string>\",\n \"data.attributes.billingAddress.city\": \"<string>\",\n \"data.attributes.billingAddress.state\": \"<string>\",\n \"data.attributes.billingAddress.zip\": \"<string>\",\n \"data.attributes.billingAddress.country\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "Invalid token format",
"source": {
"pointer": "/data/attributes/token/tokenId"
}
}
]
}
{
"errors": [
{
"status": "402",
"title": "Payment Failed",
"detail": "Card declined - insufficient funds"
}
]
}
{
"errors": [
{
"status": "422",
"title": "Unprocessable Entity",
"detail": "AVS verification failed - ZIP code mismatch"
}
]
}
Payments
Create Token Payment
Process a payment using a tokenized payment method from the embedded checkout
POST
/
payments
Create Token Payment
curl --request POST \
--url https://api.example.com/payments \
--header 'Content-Type: application/json' \
--data '
{
"data": {},
"data.requestId": "<string>",
"data.type": "<string>",
"data.attributes": {},
"data.attributes.paymentType": "<string>",
"data.attributes.merchantId": "<string>",
"data.attributes.miscData": "<string>",
"data.attributes.token": {
"data.attributes.token.tokenId": "<string>",
"data.attributes.token.holder": "<string>",
"data.attributes.token.expiry": "<string>",
"data.attributes.token.useAVS": true
},
"data.attributes.transaction": {
"data.attributes.transaction.amount": "<string>",
"data.attributes.transaction.currency": "<string>",
"data.attributes.transaction.invoice": "<string>"
},
"data.attributes.billingAddress": {
"data.attributes.billingAddress.line1": "<string>",
"data.attributes.billingAddress.line2": "<string>",
"data.attributes.billingAddress.city": "<string>",
"data.attributes.billingAddress.state": "<string>",
"data.attributes.billingAddress.zip": "<string>",
"data.attributes.billingAddress.country": "<string>"
}
}
'import requests
url = "https://api.example.com/payments"
payload = {
"data": {},
"data.requestId": "<string>",
"data.type": "<string>",
"data.attributes": {},
"data.attributes.paymentType": "<string>",
"data.attributes.merchantId": "<string>",
"data.attributes.miscData": "<string>",
"data.attributes.token": {
"data.attributes.token.tokenId": "<string>",
"data.attributes.token.holder": "<string>",
"data.attributes.token.expiry": "<string>",
"data.attributes.token.useAVS": True
},
"data.attributes.transaction": {
"data.attributes.transaction.amount": "<string>",
"data.attributes.transaction.currency": "<string>",
"data.attributes.transaction.invoice": "<string>"
},
"data.attributes.billingAddress": {
"data.attributes.billingAddress.line1": "<string>",
"data.attributes.billingAddress.line2": "<string>",
"data.attributes.billingAddress.city": "<string>",
"data.attributes.billingAddress.state": "<string>",
"data.attributes.billingAddress.zip": "<string>",
"data.attributes.billingAddress.country": "<string>"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
data: {},
'data.requestId': '<string>',
'data.type': '<string>',
'data.attributes': {},
'data.attributes.paymentType': '<string>',
'data.attributes.merchantId': '<string>',
'data.attributes.miscData': '<string>',
'data.attributes.token': {
'data.attributes.token.tokenId': '<string>',
'data.attributes.token.holder': '<string>',
'data.attributes.token.expiry': '<string>',
'data.attributes.token.useAVS': true
},
'data.attributes.transaction': {
'data.attributes.transaction.amount': '<string>',
'data.attributes.transaction.currency': '<string>',
'data.attributes.transaction.invoice': '<string>'
},
'data.attributes.billingAddress': {
'data.attributes.billingAddress.line1': '<string>',
'data.attributes.billingAddress.line2': '<string>',
'data.attributes.billingAddress.city': '<string>',
'data.attributes.billingAddress.state': '<string>',
'data.attributes.billingAddress.zip': '<string>',
'data.attributes.billingAddress.country': '<string>'
}
})
};
fetch('https://api.example.com/payments', 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/payments",
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([
'data' => [
],
'data.requestId' => '<string>',
'data.type' => '<string>',
'data.attributes' => [
],
'data.attributes.paymentType' => '<string>',
'data.attributes.merchantId' => '<string>',
'data.attributes.miscData' => '<string>',
'data.attributes.token' => [
'data.attributes.token.tokenId' => '<string>',
'data.attributes.token.holder' => '<string>',
'data.attributes.token.expiry' => '<string>',
'data.attributes.token.useAVS' => true
],
'data.attributes.transaction' => [
'data.attributes.transaction.amount' => '<string>',
'data.attributes.transaction.currency' => '<string>',
'data.attributes.transaction.invoice' => '<string>'
],
'data.attributes.billingAddress' => [
'data.attributes.billingAddress.line1' => '<string>',
'data.attributes.billingAddress.line2' => '<string>',
'data.attributes.billingAddress.city' => '<string>',
'data.attributes.billingAddress.state' => '<string>',
'data.attributes.billingAddress.zip' => '<string>',
'data.attributes.billingAddress.country' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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/payments"
payload := strings.NewReader("{\n \"data\": {},\n \"data.requestId\": \"<string>\",\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.merchantId\": \"<string>\",\n \"data.attributes.miscData\": \"<string>\",\n \"data.attributes.token\": {\n \"data.attributes.token.tokenId\": \"<string>\",\n \"data.attributes.token.holder\": \"<string>\",\n \"data.attributes.token.expiry\": \"<string>\",\n \"data.attributes.token.useAVS\": true\n },\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\",\n \"data.attributes.transaction.invoice\": \"<string>\"\n },\n \"data.attributes.billingAddress\": {\n \"data.attributes.billingAddress.line1\": \"<string>\",\n \"data.attributes.billingAddress.line2\": \"<string>\",\n \"data.attributes.billingAddress.city\": \"<string>\",\n \"data.attributes.billingAddress.state\": \"<string>\",\n \"data.attributes.billingAddress.zip\": \"<string>\",\n \"data.attributes.billingAddress.country\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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/payments")
.header("Content-Type", "application/json")
.body("{\n \"data\": {},\n \"data.requestId\": \"<string>\",\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.merchantId\": \"<string>\",\n \"data.attributes.miscData\": \"<string>\",\n \"data.attributes.token\": {\n \"data.attributes.token.tokenId\": \"<string>\",\n \"data.attributes.token.holder\": \"<string>\",\n \"data.attributes.token.expiry\": \"<string>\",\n \"data.attributes.token.useAVS\": true\n },\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\",\n \"data.attributes.transaction.invoice\": \"<string>\"\n },\n \"data.attributes.billingAddress\": {\n \"data.attributes.billingAddress.line1\": \"<string>\",\n \"data.attributes.billingAddress.line2\": \"<string>\",\n \"data.attributes.billingAddress.city\": \"<string>\",\n \"data.attributes.billingAddress.state\": \"<string>\",\n \"data.attributes.billingAddress.zip\": \"<string>\",\n \"data.attributes.billingAddress.country\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {},\n \"data.requestId\": \"<string>\",\n \"data.type\": \"<string>\",\n \"data.attributes\": {},\n \"data.attributes.paymentType\": \"<string>\",\n \"data.attributes.merchantId\": \"<string>\",\n \"data.attributes.miscData\": \"<string>\",\n \"data.attributes.token\": {\n \"data.attributes.token.tokenId\": \"<string>\",\n \"data.attributes.token.holder\": \"<string>\",\n \"data.attributes.token.expiry\": \"<string>\",\n \"data.attributes.token.useAVS\": true\n },\n \"data.attributes.transaction\": {\n \"data.attributes.transaction.amount\": \"<string>\",\n \"data.attributes.transaction.currency\": \"<string>\",\n \"data.attributes.transaction.invoice\": \"<string>\"\n },\n \"data.attributes.billingAddress\": {\n \"data.attributes.billingAddress.line1\": \"<string>\",\n \"data.attributes.billingAddress.line2\": \"<string>\",\n \"data.attributes.billingAddress.city\": \"<string>\",\n \"data.attributes.billingAddress.state\": \"<string>\",\n \"data.attributes.billingAddress.zip\": \"<string>\",\n \"data.attributes.billingAddress.country\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "Invalid token format",
"source": {
"pointer": "/data/attributes/token/tokenId"
}
}
]
}
{
"errors": [
{
"status": "402",
"title": "Payment Failed",
"detail": "Card declined - insufficient funds"
}
]
}
{
"errors": [
{
"status": "422",
"title": "Unprocessable Entity",
"detail": "AVS verification failed - ZIP code mismatch"
}
]
}
Endpoint
POST https://api.digitzs.com/payments
Overview
Use this endpoint to process payments using TokenEx tokens generated from the Digitzs embedded checkout. This secure method keeps sensitive payment data out of your application while maintaining PCI compliance.A TokenEx token must be generated through the Digitzs embedded checkout before using this endpoint. Contact Digitzs support to integrate the embedded checkout into your application.
Authentication
| Header | Value | Required |
|---|---|---|
x-api-key | Your API key from onboarding | Yes |
Authorization | Bearer {appToken} | Yes |
appId | Your application ID | Yes |
Content-Type | application/json | Yes |
Request Body
Container for API data
UUID for idempotency. If provided, must be in valid UUID format. Recommended for preventing duplicate transactions.
Must be
"payments"Container for payment attributes
Must be
"tokenv3" for tokenized paymentsThe merchant account identifier
Optional JSON string containing additional metadata like email, IP addresses, or custom data
Tokenized payment method information
Show Token object properties
Show Token object properties
The TokenEx token ID retrieved from the embedded checkout
Cardholder’s name as it appears on the card
Card expiration date in MMYY format (e.g., “0229” for February 2029)
Whether to require AVS (Address Verification System) match. Set to
true to require ZIP code match or better for payment capture.Transaction details
Show Transaction object properties
Show Transaction object properties
Payment amount in cents (e.g., “500” for $5.00)
Three-letter currency code (ISO 4217). Currently only
"USD" is supported.Invoice or reference number for the transaction
Billing address information
Show Billing address properties
Show Billing address properties
Primary street address. Optional but recommended for AVS verification.
Secondary address line (apartment, suite, etc.). Optional.
City. Optional but recommended.
State or province code (e.g., “CA”). Optional but recommended.
ZIP or postal code. Optional but recommended, especially when useAVS is true.
Country code (e.g., “USA”)
Example Request
{
"data": {
"requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "payments",
"attributes": {
"paymentType": "tokenv3",
"merchantId": "merchant_123456",
"miscData": "{\"email\":\"customer@example.com\",\"originIp\":\"192.168.1.1\",\"customerIp\":\"203.0.113.0\"}",
"token": {
"tokenId": "tok_abc123xyz789",
"holder": "John Doe",
"expiry": "0229",
"useAVS": true
},
"transaction": {
"amount": "2500",
"currency": "USD",
"invoice": "INV-2024-001"
},
"billingAddress": {
"line1": "123 Main Street",
"line2": "Suite 100",
"city": "San Francisco",
"state": "CA",
"zip": "94102",
"country": "USA"
}
}
}
}
Response
Success Response (201 Created)
Contains URLs related to the resource
Show properties
Show properties
URL of the current endpoint
Container for response data
Show properties
Show properties
Resource type - will be
"payments"Unique payment transaction identifier
Show properties
Show properties
Payment type -
"card"Show Transaction details
Show Transaction details
Response code -
"0" indicates successHuman-readable response message
Transaction amount in cents
Currency code
Invoice reference number
Authorization code from the payment processor
AVS verification result code
Gross transaction amount in cents
Net amount after fees in cents
Total fees charged in cents
Fixed fee component in cents
Percentage rate applied to the transaction
Example Response
{
"links": {
"self": "https://api.digitzs.com/payments"
},
"data": {
"type": "payments",
"id": "pay_card_abc123xyz",
"attributes": {
"paymentType": "card",
"transaction": {
"code": "0",
"message": "Success",
"amount": "2500",
"invoice": "INV-2024-001",
"currency": "USD",
"authCode": "A11111",
"avsResult": "Y",
"gross": "2500",
"net": "2399",
"grossMinusNet": "101",
"fee": "30",
"rate": "2.90"
}
}
}
}
Code Examples
curl -X POST https://api.digitzs.com/payments \
-H "x-api-key: your-api-key" \
-H "Authorization: Bearer your-app-token" \
-H "appId: your-app-id" \
-H "Content-Type: application/json" \
-d '{
"data": {
"type": "payments",
"attributes": {
"paymentType": "tokenv3",
"merchantId": "merchant_123456",
"token": {
"tokenId": "tok_abc123xyz789",
"holder": "John Doe",
"expiry": "0229",
"useAVS": true
},
"transaction": {
"amount": "2500",
"currency": "USD",
"invoice": "INV-2024-001"
},
"billingAddress": {
"line1": "123 Main Street",
"city": "San Francisco",
"state": "CA",
"zip": "94102",
"country": "USA"
}
}
}
}'
const axios = require('axios');
async function createTokenPayment(tokenId) {
const response = await axios.post(
'https://api.digitzs.com/payments',
{
data: {
type: 'payments',
attributes: {
paymentType: 'tokenv3',
merchantId: 'merchant_123456',
token: {
tokenId: tokenId,
holder: 'John Doe',
expiry: '0229',
useAVS: true
},
transaction: {
amount: '2500',
currency: 'USD',
invoice: 'INV-2024-001'
},
billingAddress: {
line1: '123 Main Street',
city: 'San Francisco',
state: 'CA',
zip: '94102',
country: 'USA'
}
}
}
},
{
headers: {
'x-api-key': 'your-api-key',
'Authorization': 'Bearer your-app-token',
'appId': 'your-app-id',
'Content-Type': 'application/json'
}
}
);
console.log('Payment ID:', response.data.data.id);
console.log('Auth Code:', response.data.data.attributes.transaction.authCode);
return response.data;
}
// Use with token from embedded checkout
createTokenPayment('tok_abc123xyz789');
import requests
def create_token_payment(token_id):
url = "https://api.digitzs.com/payments"
headers = {
"x-api-key": "your-api-key",
"Authorization": "Bearer your-app-token",
"appId": "your-app-id",
"Content-Type": "application/json"
}
payload = {
"data": {
"type": "payments",
"attributes": {
"paymentType": "tokenv3",
"merchantId": "merchant_123456",
"token": {
"tokenId": token_id,
"holder": "John Doe",
"expiry": "0229",
"useAVS": True
},
"transaction": {
"amount": "2500",
"currency": "USD",
"invoice": "INV-2024-001"
},
"billingAddress": {
"line1": "123 Main Street",
"city": "San Francisco",
"state": "CA",
"zip": "94102",
"country": "USA"
}
}
}
}
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
payment_id = response.json()["data"]["id"]
auth_code = response.json()["data"]["attributes"]["transaction"]["authCode"]
print(f"Payment ID: {payment_id}")
print(f"Auth Code: {auth_code}")
return response.json()
# Use with token from embedded checkout
create_token_payment("tok_abc123xyz789")
<?php
function createTokenPayment($tokenId) {
$url = "https://api.digitzs.com/payments";
$headers = [
"x-api-key: your-api-key",
"Authorization: Bearer your-app-token",
"appId: your-app-id",
"Content-Type: application/json"
];
$payload = json_encode([
"data" => [
"type" => "payments",
"attributes" => [
"paymentType" => "tokenv3",
"merchantId" => "merchant_123456",
"token" => [
"tokenId" => $tokenId,
"holder" => "John Doe",
"expiry" => "0229",
"useAVS" => true
],
"transaction" => [
"amount" => "2500",
"currency" => "USD",
"invoice" => "INV-2024-001"
],
"billingAddress" => [
"line1" => "123 Main Street",
"city" => "San Francisco",
"state" => "CA",
"zip" => "94102",
"country" => "USA"
]
]
]
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 201) {
$data = json_decode($response, true);
$paymentId = $data["data"]["id"];
$authCode = $data["data"]["attributes"]["transaction"]["authCode"];
echo "Payment ID: " . $paymentId . "\n";
echo "Auth Code: " . $authCode . "\n";
return $data;
} else {
throw new Exception("Error creating payment: " . $response);
}
}
// Use with token from embedded checkout
createTokenPayment("tok_abc123xyz789");
?>
require 'net/http'
require 'json'
require 'uri'
def create_token_payment(token_id)
uri = URI('https://api.digitzs.com/payments')
request = Net::HTTP::Post.new(uri)
request['x-api-key'] = 'your-api-key'
request['Authorization'] = 'Bearer your-app-token'
request['appId'] = 'your-app-id'
request['Content-Type'] = 'application/json'
request.body = {
data: {
type: 'payments',
attributes: {
paymentType: 'tokenv3',
merchantId: 'merchant_123456',
token: {
tokenId: token_id,
holder: 'John Doe',
expiry: '0229',
useAVS: true
},
transaction: {
amount: '2500',
currency: 'USD',
invoice: 'INV-2024-001'
},
billingAddress: {
line1: '123 Main Street',
city: 'San Francisco',
state: 'CA',
zip: '94102',
country: 'USA'
}
}
}
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
if response.code == '201'
data = JSON.parse(response.body)
payment_id = data['data']['id']
auth_code = data['data']['attributes']['transaction']['authCode']
puts "Payment ID: #{payment_id}"
puts "Auth Code: #{auth_code}"
data
else
raise "Error creating payment: #{response.body}"
end
end
# Use with token from embedded checkout
create_token_payment('tok_abc123xyz789')
AVS Result Codes
TheavsResult field contains Address Verification System codes:
| Code | Description |
|---|---|
| Y | Street address and ZIP code match |
| A | Street address matches, ZIP code does not |
| Z | ZIP code matches, street address does not |
| N | Neither street address nor ZIP code match |
| U | Address information unavailable |
| R | Retry - System unavailable |
| S | Service not supported |
| T | AVS not supported for this card type |
Error Responses
{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "Invalid token format",
"source": {
"pointer": "/data/attributes/token/tokenId"
}
}
]
}
{
"errors": [
{
"status": "402",
"title": "Payment Failed",
"detail": "Card declined - insufficient funds"
}
]
}
{
"errors": [
{
"status": "422",
"title": "Unprocessable Entity",
"detail": "AVS verification failed - ZIP code mismatch"
}
]
}
Common Error Scenarios
Invalid or expired token
Invalid or expired token
Error: 400 Bad RequestSolution: Ensure the tokenId is valid and was recently generated from the embedded checkout. Tokens may have a limited lifespan.
AVS verification failure
AVS verification failure
Error: 422 Unprocessable EntitySolution: When
useAVS is true, ensure the billing address ZIP code matches the card’s billing ZIP. You can disable AVS by setting useAVS to false, but this may increase fraud risk.Card declined
Card declined
Error: 402 Payment RequiredSolution: The card issuer declined the transaction. Common reasons include insufficient funds, expired card, or fraud prevention. Ask the customer to contact their bank or use a different payment method.
Invalid expiry format
Invalid expiry format
Error: 400 Bad RequestSolution: Ensure expiry is in MMYY format (4 digits, no separators). Example: “0229” for February 2029.
Important Notes
Token Security: Tokens should only be used once. Do not reuse tokens across multiple payment attempts.
AVS Recommendations: Enabling AVS (
useAVS: true) provides additional fraud protection but may decline legitimate transactions if address information doesn’t match. Consider your risk tolerance when configuring this setting.Embedded Checkout Required: Contact Digitzs support to integrate the embedded checkout into your application before using this endpoint. The checkout handles secure card data collection and tokenization.
Best Practices
- Use Idempotency Keys: Include
requestIdto prevent duplicate charges if requests are retried - Collect Complete Addresses: Provide full billing address information for better AVS verification
- Handle Declines Gracefully: Display user-friendly error messages and offer alternative payment methods
- Store Payment IDs: Save the returned payment ID for reconciliation and potential refunds
- Implement Retry Logic: Handle transient errors with exponential backoff
- Monitor AVS Results: Track AVS result codes to identify potential fraud patterns
Understanding Transaction Fees
The response includes detailed fee breakdown:- gross: Total amount charged to the customer
- fee: Fixed transaction fee (typically $0.30)
- rate: Percentage fee (typically 2.9%)
- grossMinusNet: Total fees charged (fee + percentage of gross)
- net: Amount deposited to merchant account (gross - grossMinusNet)
Next Steps
Get Payment Details
Retrieve full details of a completed payment
Create Split Payment
Learn how to split payment proceeds across multiple accounts
⌘I

