Skip to main content

Accept Card Payments

Accept card payments in a single API request. Process credit and debit cards from Visa, Mastercard, and American Express through a unified checkout experience.
PCI Compliance RequiredIf you integrate directly with the Payments API and handle raw card data (card number, CVV, expiry), your business must be PCI DSS compliant. This involves annual security audits, network scans, and strict security controls.Not PCI compliant? Use our hosted payment page or JavaScript SDK instead - these solutions keep card data off your servers and remove PCI compliance requirements from your business.Contact support@cheqpay.com to learn about hosted payment options.

Create a Card Payment

POST /checkout/pay
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Complete Request Example

{
  "externalId": "order-123",
  "customer": {
    "externalId": "customer-abc",
    "firstName": "María",
    "lastName": "González",
    "email": "maria@example.com",
    "phoneNumber": "+521555123456"
  },
  "billingAddress": {
    "address": "Av. Reforma 123",
    "city": "Mexico City",
    "state": "CDMX",
    "postalCode": "01000",
    "country": "MX"
  },
  "amount": 10000,
  "currency": "MXN",
  "description": "Order #12345",
  "paymentMethod": {
    "type": "card",
    "cardDetails": {
      "number": "4000000000002503",
      "expiryMonth": "12",
      "expiryYear": "25",
      "cvc": "123"
    }
  }
}

Successful Response

{
  "paymentOrder": {
    "id": "ord_abc123",
    "externalId": "order-123",
    "amount": 10000,
    "currency": "MXN",
    "status": "COMPLETED",
    "description": "Order #12345"
  },
  "customer": {
    "id": "cus_xyz789",
    "firstName": "María",
    "lastName": "González",
    "email": "maria@example.com"
  },
  "paymentMethod": {
    "id": "pm_def456",
    "type": "card",
    "card": {
      "brand": "visa",
      "last4": "1111",
      "expiryMonth": "12",
      "expiryYear": "25"
    }
  }
}

What Happens During Payment

1

Customer Created or Updated

Cheqpay creates a new customer record or updates an existing one based on the externalId.
2

Card Tokenized

The card is securely tokenized. Sensitive data never touches your servers.
3

Authorization

The payment is authorized by the card network (Visa, Mastercard, Amex).
4

Funds Captured

Funds are captured immediately upon successful authorization.
5

Status Updated

Payment status updates to COMPLETED and you can fulfill the order.
6

Customer Notified

Customer receives a confirmation email (if notifications are enabled).
The entire process typically takes 2-5 seconds for successful payments.

Required Fields

Payment Information

FieldTypeRequiredDescription
externalIdstringYesYour unique order ID
amountintegerYesAmount in cents (10000 = $100.00)
currencystringYesISO currency code (MXN, USD)
descriptionstringNoPayment description

Customer Information

FieldTypeRequiredDescription
customer.firstNamestringYesCustomer’s first name
customer.lastNamestringYesCustomer’s last name
customer.emailstringYesCustomer’s email address
customer.phoneNumberstringNoPhone with country code
customer.externalIdstringNoYour customer ID

Card Details

FieldTypeRequiredDescription
paymentMethod.typestringYesMust be “card”
paymentMethod.cardDetails.numberstringYesCard number (13-19 digits)
paymentMethod.cardDetails.expiryMonthstringYesExpiry month (01-12)
paymentMethod.cardDetails.expiryYearstringYesExpiry year (2-digit YY format, e.g., “25” for 2025)
paymentMethod.cardDetails.cvcstringYesCard security code

Billing Address (Required)

Billing address is required for all card payments:
{
  "billingAddress": {
    "address": "Av. Reforma 123",
    "city": "Mexico City",
    "state": "CDMX",
    "postalCode": "01000",
    "country": "MX"
  }
}
Billing address is required when processing card payments. Including complete billing information also helps improve approval rates by 3-5%.

Save Cards for Future Use

Enable one-click checkout by saving the card:
{
  "paymentMethod": {
    "type": "card",
    "cardDetails": {
      "number": "4000000000002503",
      "expiryMonth": "12",
      "expiryYear": "25",
      "cvc": "123"
    },
    "persist": true
  }
}
The response includes a paymentMethodId you can use for future charges:
{
  "paymentMethod": {
    "id": "pm_abc123",
    "type": "card",
    "card": {
      "brand": "visa",
      "last4": "1111"
    }
  }
}

Learn More About Saved Cards

View complete payment methods documentation

Charge a Saved Card

Use a previously saved card with just the payment method ID:
{
  "externalId": "order-456",
  "amount": 5000,
  "currency": "MXN",
  "paymentMethod": {
    "type": "payment_method_id",
    "paymentMethodId": "pm_abc123",
    "cvc": "123"
  }
}
Always collect the CVC for saved card payments. This improves approval rates and reduces fraud.

Handle Authentication (3D Secure)

Some payments require 3D Secure authentication. When this happens, the status will be PAYER_AUTHENTICATION_CHALLENGE_REQUIRED:
{
  "paymentOrder": {
    "id": "ord_abc123",
    "status": "PAYER_AUTHENTICATION_CHALLENGE_REQUIRED"
  },
  "payerAuthentication": {
    "stepUpUrl": "https://...",
    "jwt": "eyJhbGc..."
  }
}
You’ll need to show an authentication challenge to the customer.

Complete 3D Secure Guide

Learn how to implement 3D Secure authentication

Improve Approval Rates

Include Device Information

Sending device data helps banks assess risk and approve more payments:
{
  "deviceInformation": {
    "ipAddress": "192.168.1.100",
    "userAgent": "Mozilla/5.0...",
    "httpBrowserLanguage": "es-MX",
    "httpBrowserScreenWidth": "1920",
    "httpBrowserScreenHeight": "1080"
  }
}

Best Practices

Billing address verification helps prevent fraud and improves approval rates by 3-5%.
Device information enables better fraud detection and smoother 3D Secure flows.
Keep customer information consistent across payments for better approval rates.
Returning customers with saved cards have higher approval rates.

Error Handling

Handle declined payments gracefully:
{
  "error": {
    "code": "DECLINED",
    "message": "Payment declined by issuing bank",
    "declineReason": "insufficient_funds"
  }
}

Error Handling Guide

Learn how to handle errors and declined payments

Testing

Use these test cards in sandbox:
Card NumberBrandResult
4000000000002503VisaSuccessful payment
5200000000002151MastercardSuccessful payment
4000000000000002VisaCard declined

Complete Testing Guide

View all test scenarios and cards

Next Steps