What You Can Do
With payment intents, you can:- Initiate Terminal Payments: Create a payment request that a POS terminal picks up and processes
- Track Payment Status: Poll for real-time status updates as the terminal processes the card
- Cancel Pending Payments: Cancel payment intents that haven’t been completed yet
- Refund Approved Payments: Give the money back on a payment the terminal already charged, the same day
- Choose the Months (MSI): Limit the installment plans the terminal offers, or fix the one your cashier already chose
- Link to Your Systems: Use external IDs to correlate Compago payments with your internal records
- Target Specific Terminals: Optionally route payment requests to a specific terminal by its serial number
- Return to Your App: Optionally tell the Compago POS app which app to open once the payment finishes (same-device flow)
Use Cases
Payment intents are designed for:- Custom POS Integrations: Build your own point-of-sale system that uses Compago terminals for card processing
- ERP Payment Modules: Add card-present payment capabilities to ERP systems (e.g., Odoo, SAP)
- Kiosk Applications: Self-service kiosks that accept card payments through connected terminals
- Restaurant/Retail Systems: Any in-person checkout flow where your software manages the transaction
How It Works
After creating a payment intent, there are two ways to handle the payment flow depending on your setup. Both start the same way (your backend creates the payment intent via the API), but differ in how the card payment is captured.Same-Device Flow (Deep Link)
Use this when the Compago POS app is installed on the same device as your integration (e.g., an Android tablet running both your POS app and the Compago app). Your app opens the Compago app via a deep link, and the Compago app handles the entire card capture flow. When the payment is complete, control returns to your app.1
Your system creates a payment intent
POST /api/developer/v1/payment-intent with amount, currency, externalId, and optionally terminalCode. Include redirectAppId with your app’s Android application id so the Compago app automatically returns to your app when the payment finishes. Compago returns the payment intent with status: PENDING.2
Your app opens the Compago POS app
Use the deep link
compago-pos-app:///charge/payment-intent/{id} to hand off to the Compago app. The Compago app displays the payment screen and handles card capture.3
The Compago app returns to your app
When the payment finishes (or is cancelled), the Compago app opens the app specified in
redirectAppId, handing control back to your app.4
Your system polls for status
While the Compago app handles the payment, your system polls
GET /api/developer/v1/payment-intent/{id} every 3 seconds to detect when the payment completes.5
Your system fulfills the order
Once
paymentSummary.status is SUCCESS, mark the order as paid, print a receipt, update inventory, etc.Separate-Device Flow (Polling Only)
Use this when the Compago POS terminal is a separate physical device from the one running your integration (e.g., your ERP runs on a desktop and the terminal sits on the counter). Your system simply polls for status while the terminal operator processes the card on the Compago device.1
Your system creates a payment intent
POST /api/developer/v1/payment-intent with amount, currency, externalId, and terminalCode. Compago returns the payment intent with status: PENDING.2
Compago notifies the POS terminal
The terminal automatically receives a notification alerting it that a new payment request is waiting.
3
The terminal processes the card
The terminal operator sees the incoming payment request on the Compago POS app and processes the customer’s card.
4
Your system polls for status
GET /api/developer/v1/payment-intent/{id} every 3 seconds. Once the terminal completes the payment, the response includes paymentSummary.status: "SUCCESS".5
Your system fulfills the order
Mark the order as paid, print a receipt, update inventory, etc.
Prerequisites
Before creating payment intents, ensure you have:- An active Compago merchant account with API access
- A valid API key, created at Configuraciones → Desarrollador in the dashboard of the environment you call (
demo-app.compago.comfor Demo,app.compago.comfor Production) - At least one Compago POS terminal registered to your organization, running the app for that same environment. A terminal shipped for Production runs the production app; to test in Demo, ask your Compago contact for the Demo app. See Environments.
- Your integration configured to use MXN currency
Payment intents currently support MXN (Mexican Peso) only. Transactions in other currencies will be rejected.
Creating a Payment Intent
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-intent
Authentication
Include your API key in the request headers:Request Body
Field Descriptions
Response
id. You will need it to poll for status, open the Compago app, or cancel the payment intent.
Example with cURL
Opening the Compago App (Same-Device Flow)
If the Compago POS app is installed on the same device as your integration, you can open it directly using a deep link. The Compago app will display the payment screen for the given payment intent and handle the full card capture flow.Deep Link Format
{id} with the payment intent ID returned from the create endpoint.
Implementation Example
On Android-based POS devices, you can trigger the deep link by navigating to the URL. For web-based integrations running on the same device, a common approach is using a hidden iframe:The deep link requires the Compago POS app to be installed on the device. If the app is not installed, the deep link will have no effect. Your integration should still poll for status regardless, so the payment can also be processed from a separate device.
Returning to Your App (redirectAppId)
In the same-device flow, you usually want the terminal to hand control back to your app once the payment finishes. Pass your app’s Android application id in theredirectAppId field when creating the payment intent:
Behavior
- When the payment completes successfully, the Compago POS app opens the app identified by
redirectAppId. - When the payment intent is cancelled, the Compago POS app also returns to that app.
redirectAppIdtakes precedence over the integration configured locally on the terminal (Settings, Integraciones). If the field is omitted, the terminal keeps using its local configuration.- The terminal’s local “Regresar automáticamente” setting controls the timing: when enabled, the app opens immediately; when disabled, the operator sees a confirmation screen with a button to return to your app.
- If the app is not installed on the terminal device, the terminal shows its standard completion screen instead.
redirectAppId only has an effect in the same-device flow. In the separate-device flow there is no app to return to on the terminal, so the field is ignored unless the app happens to be installed on the terminal device.Choosing the deposit account
A business can receive its sales in more than one bank account, for example one per branch. 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 payment intent is deposited:
bankAccountId is optional, and an integration that does not send it does not need to change. A payment intent created 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 no payment intent is created. nullis the same as leaving the field out.- The terminal does not ask its operator for an account on a payment intent: the account is the one you send, or the one your deposit rule picks.
- If the account you named is removed before the card is charged, the payment is deposited according to the rule of your business instead.
Splitting a payment between accounts
Sendallocations to split the money of one payment intent 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 payment intents 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, no payment intent is created. - 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 card is charged,
GET /developer/v1/payment/{id}returns the parts the payment was deposited in asallocations.
Your customer pays one amount and sees one payment. The split only decides where the money is deposited.
Choosing the months (MSI)
By default the terminal shows the customer every installment plan your account has active for card-present sales (Pago único, 3, 6, 12 meses sin intereses…). SendallowedTerms to change that for one payment intent:
- Each value is a number of months:
1is a single payment. The list is stored sorted and without repeats. - Every value must be a plan active for card-present sales in your account. Otherwise the request is refused with
400 ALLOWED_TERMS_UNAVAILABLE, which listsunavailableTermsandavailableTerms, and no payment intent is created. List your plans in the dashboard, at Configuraciones → Comisiones. - An empty list is refused: leave the field out to offer every plan.
- Whether a card can pay in months still depends on its issuing bank. If the customer’s card cannot, the terminal declines it and the customer can try another card.
- The months the customer actually paid in come back in
paymentSummary.payment.terms(see below).
allowedTerms needs the latest Compago POS app on the terminal. An older version still offers every plan, but the API refuses a plan outside allowedTerms, so the cashier sees an error before anything reaches the bank and can pick an allowed plan.Tips
A payment intent carries no tip unless you ask for one. There are two ways, and you send one or the other, never both:- A tip is at most 30% of
amount, in whole cents. A largertipAmountis refused with400 TIP_EXCEEDS_LIMIT, a fraction of a cent with400 TIP_INVALID_AMOUNT, and nothing is created. collectTipneeds tips turned on for your business, in the dashboard at Configuraciones → Organización → General («Propinas en la terminal»). Otherwise the request is refused with400 TIPS_DISABLED. A fixedtipAmountdoes not need it: the tip was taken at your till.- On meses sin intereses the tip is split into the monthly payments together with the sale.
- The tip that was charged comes back in
paymentSummary.payment.tipAmountandtipPercentage, and the total inpaymentSummary.payment.chargedAmount(see below). A refund gives back the sale and its tip together.
Tips on payment intents need the latest Compago POS app on the terminal. An older version does not show the tip screen, so with
collectTip it charges the sale with no tip, and with a tipAmount it shows an error before anything reaches the bank. Update your terminals before sending tips.Printing the voucher under your own receipt
Every card sale made on the terminal comes with its card voucher. Regulation requires the voucher to be printed for every card-present transaction, using the template certified with the acquirer. That is why the Compago terminal always prints it, and why its content and layout cannot be changed or printed by another system. You can still give your customer a single paper: your receipt first, then the Compago voucher right under it. SendprintVoucher: false, then give the terminal your receipt in one of two ways:
- From a system that runs on the terminal, print it on the terminal’s printer (Odoo does, see Print from Odoo on the terminal).
- From any other device (a till on a computer or a tablet), send it after the approval with
POST /api/developer/v1/payment-intent/{id}/receipt: a PNG of your receipt, 384 px wide in black and white.
status: CONFIRMED).
The cashier can reprint the voucher at any time from the terminal’s success screen.
Once the card is approved, GET /api/developer/v1/payment-intent/{id} also returns cardPresent: the details the voucher shows (affiliation, terminal, authorization code, AID, ARQC and how the cardholder was verified), so you can keep them with the sale.
Polling for Payment Status
After creating a payment intent (and optionally opening the Compago app via deep link), your system should poll the GET endpoint to detect when the terminal completes the payment.Endpoint
GET /payment-intent/{id}
Response
When the payment is still being processed:paymentSummary.payment.terms is the number of months the customer paid in: 1 for a single payment, 3, 6, 12… for meses sin intereses. refundedAt is the time the sale was refunded, or null while it stands.
How to Poll
The recommended approach is:- Wait 3 seconds between each request
- Check the response for a terminal state:
paymentSummary.statusis"SUCCESS": the payment was completed. Fulfill the order.expiredistrue: the payment intent timed out. Prompt the user to retry.statusis"CANCELLED": the payment intent was cancelled. Handle accordingly.
- Repeat until one of the above conditions is met, or until a maximum timeout (e.g., 10 minutes)
Example
Cancelling a Payment Intent
You can cancel a pending payment intent before it is completed or expires. This is useful when the user changes their mind, navigates away, or the order is voided.Endpoint
POST /payment-intent/{id}/cancel
For the full cancel guide, see Cancel Payment Intent.
Example
Cancelling a payment intent also notifies the POS terminal that the payment request has been withdrawn.
Refunding an Approved Payment
Cancelling only works while the intent isPENDING. Once the terminal charged the card, refund it:
Important Business Rules
Payment Intent Expiration
Terminal Routing
When you provide aterminalCode:
- The payment intent is routed to that specific terminal
- Any other
PENDINGpayment intents for that terminal are automatically cancelled - This ensures only one active payment intent exists per terminal at any time
terminalCode:
- The payment intent is available to any terminal in your organization
- This is useful when you don’t know which terminal will process the payment
External ID Uniqueness
TheexternalId must be unique within your organization. Attempting to create a payment intent with a duplicate externalId will result in an error.
Use a combination of your internal identifiers with a timestamp or random suffix to ensure uniqueness across retries. For example: order-789_1710150000_a1b2c3.
Currency Restriction
Currently, only MXN (Mexican Peso) is supported. Requests with other currencies will be rejected.Payment Intent Status
Payment intents have three statuses:Error Handling
Common Errors
Example Error Response
bankAccountId that cannot receive the payment answers 422, with its code and message inside error:
Best Practices
Use Terminal Codes for Directed Payments
Use Terminal Codes for Directed Payments
When you know which terminal should process the payment, always provide the
terminalCode. This ensures the payment intent is routed to the correct terminal and automatically cancels any stale pending intents on that terminal.Handle Expiration Gracefully
Handle Expiration Gracefully
Payment intents expire after 10 minutes. Your integration should:
- Detect expiration in your polling loop (when
expiredistrue) - Offer the user the option to retry
- Create a new payment intent with a new
externalIdif they choose to retry
Generate Unique External IDs
Generate Unique External IDs
Combine your internal identifiers with a timestamp or random suffix to avoid collisions. For example:
session-5_order-abc_1710150000. Avoid reusing the same ID for retries, since duplicate externalId values within the same organization will be rejected.Cancel on User Exit
Cancel on User Exit
If the user navigates away from the payment screen or cancels the order, send a cancel request for the pending payment intent. This frees up the terminal and prevents stale intents from blocking new payments.
Use redirectAppId in Same-Device Integrations
Use redirectAppId in Same-Device Integrations
When your app runs on the same device as the Compago POS app, always send
redirectAppId with your app’s application id. This guarantees a seamless round trip (your app, Compago app, your app) without relying on the terminal’s local integration configuration.Support
If you encounter issues with payment intents:- Verify your API key is valid in Configuraciones → Desarrollador of the dashboard of the environment you call (Demo or Production), and that you call the host of that same environment
- Ensure you have at least one terminal registered to your organization in that environment, running the Compago POS app for it
- Check that the
terminalCodematches your terminal’s serial number - Contact Compago support at help@compago.com for assistance
Why a request answers 401
A401 Unauthorized (body Unauthorized) means Compago could not identify who is calling: the endpoint never ran. A credential that is valid but lacks a permission answers 403 insufficient_scope instead. Check, in this order:
- One credential per request. When a request carries
Authorization: Bearer, the access token is the only credential read, and thex-api-keyheader is ignored. An expired token therefore answers 401 even next to a valid API key. - The access token is current. An installed app’s access token lasts one hour. Refresh it with your refresh token and retry once.
- The API key is still enabled. When an integration that used an API key is connected again as an installed app (OAuth), Compago disables the old key on the app’s first request with its token. From then on, use the token.
- The environment matches. A Demo credential is refused by Production and the other way around:
demo-api-harmony.compago.comtakes Demo credentials,api-harmony.compago.comtakes Production ones. - The header is spelled right.
x-api-key: YOUR_API_KEY, orAuthorization: Bearer YOUR_ACCESS_TOKEN.