Skip to main content
POST
Charge Transaction

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

Authentication

string
required
Basic Authentication header with Base64 encoded [API_KEY]:[PIN]Format: Basic [base64_credentials]
string
required
Must be application/json

Request 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
object
Optional transaction metadata for your internal tracking

Request Example

Response

string
Unique transaction identifier
string
Transaction status (e.g., "approved", "declined")
number
Transaction amount
string
Currency code (e.g., "USD")
object
Card information
string
Transaction timestamp (ISO 8601 format)
string
Authorization code from payment processor

Response Examples

Transaction Statuses

Complete Payment Flow

1

Tokenize card

Use the tokenization form to get a nonce token from the customer’s card data
2

Send nonce to server

Send the nonce from your frontend to your backend server
3

Process charge

Your server calls the Approvely charge endpoint with the nonce
4

Handle response

Check the transaction status and update your order accordingly

Error Handling

Cause: Card issuer declined the transactionSolution:
  • Ask customer to contact their bank
  • Request alternative payment method
  • Verify billing information is correct
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
Cause: Card has insufficient fundsSolution:
  • Request different payment method
  • Ask customer to use another card
Cause: Card number or details are invalidSolution:
  • Verify card number is correct
  • Check expiry date is valid
  • Ensure CVV is correct
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 code insufficient_funds

Tokenization

Learn how to tokenize card data

Authentication

Set up API authentication