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
These examples call the production host. While you build, replace
https://api-harmony.compago.com with https://demo-api-harmony.compago.com and use a key from the Demo dashboard. See Environments.Endpoint
POST /payment-method/{id}/payment
Authentication
Include your API key in the request headers:Path Parameters
Request Body
Field Descriptions
Charging a card is unchanged. The contract you already use (
amount, currency, description) is untouched, and holdFunds is optional and defaults to false, so a request that omits it charges the card immediately, exactly as it always has. Send holdFunds: true only when you want to hold funds instead of charging them.Response
The response also carries the hold fields (
heldAmount, heldAt, capturedAt, holdReleasedAt, holdExpiresAt, holdExpired, holdDaysRemaining). On a regular charge they are null, with holdExpired set to false. They are only populated on holds, and are documented in Hold Funds.
Code Examples
Checking Payment Status
After creating a charge, you can check its status at any time:GET /payment-method/{id}/payment/{paymentId}
Choosing the deposit account
A business can receive its sales in more than one bank account, for example one per branch or per line of business. The accounts are registered in the dashboard, at Configuraciones → Organización → Cuentas bancarias, where the owner also decides how sales are shared between them: automatically, by a monthly amount for each account, by a percentage for each account, or manually, sale by sale. SendbankAccountId to decide where the money of one charge is deposited. A saved card can pay for several things, for example two subscriptions that belong to different accounts, so the account is chosen on each charge and is never remembered on the card:
bankAccountId is optional, and an integration that does not send it does not need to change. A charge made without it is deposited exactly as before.- List your accounts, and see how your business shares its sales, with
GET /developer/v1/bank-account. - The account must be one of your own and must be verified. Otherwise the request is refused with
BANK_ACCOUNT_NOT_AVAILABLEand the card is not charged. nullis the same as leaving the field out.- It works the same on a hold: the money is deposited in that account when you capture it.
- The response returns
bankAccountId: the account the charge is deposited in. Once the charge is approved,GET /developer/v1/payment/{id}returns it too. - If the account you named is removed before the charge is approved, the payment is deposited according to the rule of your business instead.
Splitting a payment between accounts
Sendallocations to split the money of one charge between several of your bank accounts. Each part names an account and the amount it receives. It is how a store that sells on consignment pays each supplier their share of a sale, or how a business keeps the money of two lines of business apart.
For example, a $1,500 MXN sale where $600 MXN belong to a supplier, who receives them whole:
Rules for the parts:
- Up to 5 parts, on charges in MXN only, and never together with
bankAccountId. What the parts leave counts as one more, so five parts must add up to the wholeamount. - The parts may add up to less than
amount: what they leave is deposited according to your deposit rule. They may not add up to more. - The fee and its IVA are worked out once on the whole payment. The tip, the fee and the IVA are shared out between the parts that pay the fee (and what your deposit rule receives), in proportion to their amounts. A part with
absorbsFee: falsereceives no tip. - Every figure of a part is in centavos. The largest part that pays the fee takes the fraction of a centavo left over, so the parts always add up to the payment exactly.
- If what is left for the parts that pay the fee does not cover the fee, every part pays its share of it, the ones with
absorbsFee: falseincluded, so leave enough of the amount to pay the fee. - When the parts add up to the whole
amount, at least one of them must pay the fee (absorbsFee: true). - A request that breaks one of these rules fails with
BANK_ACCOUNT_ALLOCATIONS_INVALID, and an account that is not one of your verified accounts fails withBANK_ACCOUNT_NOT_AVAILABLE. Either way, the card is not charged. - A refund made the same day is shared out between the parts in proportion to what each one received. A later refund is taken from your next settlements, never from an account that receives a part with
absorbsFee: false. - Once the charge is approved,
GET /developer/v1/payment/{id}returns the parts it was deposited in asallocations. On a hold, the parts apply when you capture it.
Your customer pays one amount and sees one payment. The split only decides where the money is deposited.
Idempotency (externalId)
POST /api/developer/v1/payment-method/{id}/payment accepts an optional externalId: your own key for this operation, up to 255 characters, unique across all payments in your organization. It is the supported way to make this endpoint safe to retry, and we recommend sending one on every charge.
Without it, a retry after a timeout charges the card a second time. A network error tells you nothing about whether the bank approved the first attempt, so a blind retry of a $500 MXN charge can take $1,000 MXN. With an externalId, the retry returns the payment you already made.
Replay Behaviour
Charges and holds share one
externalId namespace, because both are created by this same endpoint. order-1 cannot exist as a charge and also as a hold. Replaying a key with a different holdFunds value than the original returns the original payment rather than an error, so keep the flag stable across your retries.externalId on every payment response for a saved card (the charge itself, capture, release, refund, list and detail), so you can reconcile our payment id against your own order reference without keeping a mapping table.
Important Business Rules
Currency restriction. Only MXN (Mexican Peso) is currently supported. Charges in other currencies will be rejected.
Error Handling
A
bankAccountId that cannot receive the payment answers 422, with its code and message inside error:
Next Steps
Hold Funds
Hold funds on a card with
holdFunds, then capture them (in full or in part) or release them within 7 natural days.Process Refunds
Issue full refunds for charges made against saved cards.
Manage Payment Methods
List, retrieve, and revoke payment methods and view payment history.