Skip to main content
POST
/
payments
{
  "errors": [
    {
      "status": "400",
      "title": "Bad Request",
      "detail": "Invalid token format",
      "source": {
        "pointer": "/data/attributes/token/tokenId"
      }
    }
  ]
}

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

HeaderValueRequired
x-api-keyYour API key from onboardingYes
AuthorizationBearer {appToken}Yes
appIdYour application IDYes
Content-Typeapplication/jsonYes

Request Body

data
object
required
Container for API data
data.requestId
string
UUID for idempotency. If provided, must be in valid UUID format. Recommended for preventing duplicate transactions.
data.type
string
required
Must be "payments"
data.attributes
object
required
Container for payment attributes
data.attributes.paymentType
string
required
Must be "tokenv3" for tokenized payments
data.attributes.merchantId
string
required
The merchant account identifier
data.attributes.miscData
string
Optional JSON string containing additional metadata like email, IP addresses, or custom data
data.attributes.token
object
required
Tokenized payment method information
data.attributes.transaction
object
required
Transaction details
data.attributes.billingAddress
object
required
Billing address information

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
data
object
Container for response data

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"
        }
      }
    }
  }'

AVS Result Codes

The avsResult field contains Address Verification System codes:
CodeDescription
YStreet address and ZIP code match
AStreet address matches, ZIP code does not
ZZIP code matches, street address does not
NNeither street address nor ZIP code match
UAddress information unavailable
RRetry - System unavailable
SService not supported
TAVS not supported for this card type

Error Responses

{
  "errors": [
    {
      "status": "400",
      "title": "Bad Request",
      "detail": "Invalid token format",
      "source": {
        "pointer": "/data/attributes/token/tokenId"
      }
    }
  ]
}

Common Error Scenarios

Error: 400 Bad RequestSolution: Ensure the tokenId is valid and was recently generated from the embedded checkout. Tokens may have a limited lifespan.
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.
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.
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

  1. Use Idempotency Keys: Include requestId to prevent duplicate charges if requests are retried
  2. Collect Complete Addresses: Provide full billing address information for better AVS verification
  3. Handle Declines Gracefully: Display user-friendly error messages and offer alternative payment methods
  4. Store Payment IDs: Save the returned payment ID for reconciliation and potential refunds
  5. Implement Retry Logic: Handle transient errors with exponential backoff
  6. 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