Testing credit card payment

Use test cards to validate credit card charges without moving real money.

In this flow, you can test approvals, declines, API responses, and the processing of Webhooks related to the charge.

📘

By the end of this guide, you will have tested the approval and decline scenarios for a credit card charge.

When to use it

Use this flow to validate:

  • one-time charges;
  • subscriptions and recurring payments;
  • card tokenization;
  • your own checkout;
  • handling of approvals and declines;
  • updates received via Webhook.

Before you start

You need to:

  1. Have a Sandbox account and API key.
  2. Create a customer to link to the charge.
  3. Configure the Webhooks used by the integration.
  4. Use the credit card charge endpoint.

See Create charge with credit card.

⚠️

Use only fictitious cards and data.

Never use real customer information during validation testing.

1. Create the charge

In the request, provide the customer, charge, and card data.

The main fields are:

FieldPurpose
customerID of the customer linked to the charge
billingTypeMust be CREDIT_CARD
valueCharge amount
dueDateDue date
creditCardData of the card used
creditCardHolderInfoCardholder data

See the endpoint reference for all fields and filling rules.

2. Simulate an approval

To simulate an approved transaction, use a valid fictitious card number. You can generate a test card using tools such as the 4Devs Credit Card Generator.

Use the following data:

InformationValue
Card numberValid fictitious card number
Expiration dateAny future date
CCV123 or any other three-digit number

The Sandbox should simulate successful processing of the charge.

⚠️

Use only fictitious cards and data during testing. Do not use real card data in the Sandbox environment.

3. Simulate a decline

Use one of the cards below:

BrandNumber
Mastercard5184019740373151
Visa4916561358240741

These numbers let you test how processing failures are handled.

4. Validate the result

After sending the request:

  1. check the HTTP status and the response body;
  2. store the charge ID;
  3. track the charge status;
  4. receive the corresponding Webhook;
  5. confirm that your application processed the result correctly.
Create customer
      ↓
Create card charge
      ↓
Receive API response
      ↓
Receive Webhook
      ↓
Update the status in the application
📘

Do not rely only on the synchronous response to complete processing.

Also take into account the events received via Webhook and later changes to the charge status.

Expected behavior

In the Sandbox:

  • test cards determine the simulated result;
  • no acquirer is contacted;
  • no real money is moved;
  • responses are exclusively for validation testing.

At a minimum, test:

ScenarioWhat to validate
ApprovalCharge update and Webhook processing
DeclineReturned message and failure handling
Repeated WebhookIdempotent processing
Unexpected errorLogs, alerts, and application behavior

Differences between Sandbox and Production

SandboxProduction
Uses test cardsUses real cards
Simulates approvals and declinesDepends on real processing
Does not move moneyMoves real money
Does not contact acquirersDepends on card networks and acquirers

A card approval in the Sandbox does not guarantee that a similar transaction will be approved in Production.


Validation checklist

Before considering the flow validated, confirm that your application:

  • handles approvals and declines;
  • processes Webhooks idempotently;
  • records operation IDs and timestamps;
  • does not store sensitive card data;
  • shows appropriate messages to the payer;
  • has logging and monitoring;
  • is prepared for different responses in Production.

Next steps


Did this page help you?