Skip to main content
Once a customer has saved their card and the payment method status is ACTIVE, you can charge it at any time by calling the charge endpoint. No customer interaction is required. The charge is processed entirely server-side.

Overview

Charging a saved card allows you to:
  • Bill customers for subscriptions, memberships, or recurring services
  • Charge after service delivery (on-demand services, freight, freelance work)
  • Process payments when orders ship or milestones are reached

Prerequisites

Before charging a saved card:
  • The payment method must have a status of ACTIVE
  • You must have the payment method id (returned when creating the payment method)
  • The card must not be expired or revoked

Creating a Charge

Endpoint

POST /api/payment-method/{id}/payment
API reference: POST /payment-method/{id}/payment

Authentication

Include your API key in the request headers:
x-api-key: YOUR_API_KEY
Content-Type: application/json

Path Parameters

id
string
required
The unique identifier of the payment method to charge (UUID).

Request Body

{
  "amount": 500,
  "currency": "MXN",
  "description": "Monthly subscription - January 2025"
}

Field Descriptions

FieldTypeRequiredDescription
amountnumberYesAmount to charge in MXN. Must be at least 1 MXN.
currencystringNoCurrency code. Defaults to "MXN".
descriptionstringNoDescription of the charge.

Response

{
  "id": "11111111-2222-3333-4444-555555555555",
  "status": "CONFIRMED",
  "amount": 500,
  "currency": "MXN"
}
FieldTypeDescription
idstringUnique identifier of the payment.
statusstringCurrent status of the payment (NOT_INITIALIZED, PENDING, CONFIRMED, CANCELLED, REFUNDED).
amountnumberThe charged amount.
currencystringCurrency code.

Code Examples

curl -X POST https://api.harmony.compago.com/api/payment-method/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/payment \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 500,
    "currency": "MXN",
    "description": "Monthly subscription - January 2025"
  }'

Checking Payment Status

After creating a charge, you can check its status at any time:
GET /api/payment-method/{id}/payment/{paymentId}
API reference: GET /payment-method/{id}/payment/{paymentId}
curl https://api.harmony.compago.com/api/payment-method/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/payment/11111111-2222-3333-4444-555555555555 \
  -H "x-api-key: YOUR_API_KEY"

Important Business Rules

Payment method must be ACTIVE. You can only charge payment methods with an ACTIVE status. Attempting to charge a PENDING, EXPIRED, or REVOKED payment method will result in a 400 error.
Card expiration. If the customer’s card has expired since it was saved, the charge will fail. In this case, you’ll need to create a new payment method and have the customer save an updated card.
Currency restriction. Only MXN (Mexican Peso) is currently supported. Charges in other currencies will be rejected.

Error Handling

Status CodeErrorSolution
400Payment method not ACTIVEVerify the payment method status is ACTIVE before charging.
400Invalid amountEnsure the amount is at least 1 MXN.
400Currency not supportedUse "MXN" as the currency.
401UnauthorizedCheck your API key is valid and included in headers.
404Payment method not foundVerify the payment method ID is correct.

Next Steps

Process Refunds

Issue full refunds for charges made against saved cards.

Manage Payment Methods

List, retrieve, and revoke payment methods and view payment history.