Saltar al contenido principal
A one-time payment (OTP) is a secure, single-use checkout link that allows your customers to complete a purchase through Compago’s hosted payment page. This is ideal for non-recurring transactions, custom payment requests, or integrations where the payment flow is triggered externally.

What You Can Do

With one-time payments, you can:
  • Generate Secure Payment Links: Create unique, time-limited checkout URLs for each transaction
  • Accept Card Payments: Process credit and debit card payments through Compago’s PCI-compliant infrastructure
  • Customize the Experience: Control where customers are redirected after payment completion
  • Track Payments: Use your own external IDs to link Compago payments with your internal systems
  • Offer Installment Plans: Support monthly installment payments (Meses Sin Intereses) when available, and choose exactly which plans each payment offers
  • Choose the Deposit Account: When your business has more than one bank account, decide which one receives each payment
  • Set Custom Expiration Times: Configure payment link expiration from 10 minutes to 48 hours based on your needs

Use Cases

One-time payments are perfect for:
  • Invoicing: Send payment links to customers via email or messaging
  • Custom Integrations: Trigger payments from CRM, ERP, or internal tools
  • eCommerce: Accept payments for online stores and marketplaces
  • Service Businesses: Request deposits or full payments for appointments or bookings
  • Point of Sale: Create payment links for in-person transactions (when integrated with terminal apps)

How It Works

  1. Create: Your backend calls the Compago API to create a payment link, providing the amount, customer details, and redirect URLs
  2. Receive: Compago returns a secure checkout URL where your customer will complete the payment
  3. Redirect: Send your customer to the checkout URL where they enter their payment details
  4. Process: Compago processes the payment securely through its payment infrastructure
  5. Callback: After successful payment, Compago redirects the customer back to your redirectUrl with query parameters id and externalId appended
  6. Verify: On your callback page, extract the payment id from the URL and fetch the final payment status using the GET endpoint
  7. Fulfill: Update your internal systems (mark order as paid, send confirmation email, etc.)

Prerequisites

Before creating one-time payments, ensure you have:
  • An active Compago account with API access
  • A valid API key, created at Configuraciones → Desarrollador in the dashboard of the environment you call (demo-app.compago.com for Demo, app.compago.com for Production). See Environments.
  • Your integration configured to use MXN currency
One-time payments currently support MXN (Mexican Peso) only. Transactions in other currencies will be rejected.

Creating a One-Time Payment

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

API reference: POST /one-time-payment

Authentication

Include your API key in the request headers:

Request Body

Field Descriptions

Billing Information

The object as a whole is optional. When you do send it, these fields are all required.

Address

Response

Use the returned redirectUrl to redirect your customer to Compago’s secure checkout page.

Example with cURL

Who provides the customer details

Compago needs the payer’s name, email and phone to process a card. There are two ways it gets them, and you choose per payment by including billingInformation or leaving it out. You already know the customer. Send billingInformation when you create the payment. The checkout page asks only for the card and lets the customer correct the phone number, so they type as little as possible. This is the right choice for invoicing, for an online store that already has an account, or for anywhere your system holds the customer record. You do not know the customer. Leave billingInformation out. The checkout page then asks the payer for their own name, email and phone alongside the card, exactly as a Compago payment link does. This is the right choice for a counter or a QR code handed to a walk-in, where asking a stranger to read out their email is slower than letting them type it themselves. Either way the details end up on the payment, so a charge created without them is fully attributed once it is paid. Nothing else about the integration changes.
Sending billingInformation remains fully supported and is unchanged. If your integration already sends it, you do not need to do anything.
A payment created without billingInformation reads back with billingInformation: null until it is paid. If your callback or reporting code reads the customer’s email off the payment, guard for that case.

Choosing the installment plans

By default the checkout offers every installment plan active on your account, and the customer picks one. Send allowedTerms to decide the financing yourself: the checkout offers only the plans you list, and the customer cannot choose any other. Each entry is a number of monthly installments, the same terms a payment carries once it is paid. 1 is a single payment, and any larger number is that many months without interest (MSI).
Rules for the list:
  • Every entry must be a whole number from 1 to 48, and the list cannot be empty. To offer every plan, leave the field out.
  • Every entry must be a plan active on your account when you create the payment. Otherwise the request is rejected with ALLOWED_TERMS_UNAVAILABLE, and the response lists both the terms that are not available and the ones that are.
  • Duplicates are removed and the list is stored sorted, so [12, 3, 12] is saved as [3, 12]. GET /developer/v1/one-time-payment/{id} returns it as allowedTerms.
Months without interest require a credit card. When a payment offers only installment plans, a customer paying with a debit card is asked to use a credit card instead.
The plans on your account can change after you create the payment, for example if a plan is deactivated. The checkout never replaces a plan you listed with one you did not: a plan that stops being available is simply no longer offered, and if none of your listed plans is still available the checkout shows that the payment cannot be completed. If a plan stops being available while the customer is paying, the charge is refused and nothing is taken from the card.

Choosing the payment methods

By default the checkout offers every way to pay that your account takes: card and, where SPEI is enabled for your account, a bank transfer to a CLABE made for the purchase. Send paymentMethods to choose which ones this payment offers, and defaultPaymentMethod to choose the one it opens on.
Rules:
  • The list cannot be empty. To offer every method, leave the field out.
  • defaultPaymentMethod must be one of paymentMethods.
  • A payment that offers only bank transfers must be payable by SPEI when you create it: SPEI has to be enabled for your account and amount has to reach your SPEI minimum. Otherwise the request is rejected with SPEI_NOT_OFFERED.
  • GET /developer/v1/one-time-payment/{id} returns both fields as you sent them.
  • To offer one transfer rail rather than every bank transfer, name it: SPEI offers only SPEI transfers.
In an iframe you can also narrow the methods from the URL, for example https://app.compago.com/checkout/otp/{id}/embed?paymentMethods=BANK_TRANSFER&defaultPaymentMethod=BANK_TRANSFER. The URL can only remove methods the payment offers, never add one. A payment paid by SPEI reads back from GET /developer/v1/payment with type: "BANK_TRANSFER" and card: null. Filter by oneTimePaymentId to find the payment of one charge, or by type=BANK_TRANSFER to list every SPEI payment.

Showing the CLABE in your own screen

By default a payment that offers bank transfers gets its CLABE when the customer picks bank transfer on the checkout. A CLABE expires (60 minutes, and never after the payment itself), so a link you share ahead of time does not hold one that runs out before it is opened. When you would rather show the transfer details in your own app, ask Compago for the CLABE instead. It always belongs to the one-time payment: when the customer transfers, the payment is paid exactly as if they had paid on the checkout, and GET /developer/v1/payment shows it with type: "BANK_TRANSFER". At create. Send paymentMethodOptions.bankTransfer.generateAt: "CREATE" and the response carries bankTransfer:
Later. Create the payment as usual and call POST /developer/v1/one-time-payment/{id}/bank-transfer when the customer is ready to pay. It returns the live CLABE (200), or makes a new one (201) when the payment has none or the last one expired. Calling it again while the CLABE is live returns the same one, so a retry never makes a second. Use the same call to give the customer a new CLABE after one expires: the payment stays the same. Rules:
  • The CLABE is made out to the payment’s customer, so generateAt: "CREATE" needs billingInformation (CUSTOMER_REQUIRED otherwise). For a payment created without one, send customer to POST …/bank-transfer.
  • Options are only for a method the payment offers: paymentMethodOptions.bankTransfer with paymentMethods: ["CARD"] is rejected with PAYMENT_METHOD_NOT_OFFERED.
  • SPEI has to be enabled for your account and amount has to reach your SPEI minimum (SPEI_NOT_OFFERED otherwise).
  • If the CLABE cannot be made at create (the bank does not answer in time), the payment is still created and bankTransfer is null. Ask for it with POST …/bank-transfer.
  • The whole CLABE is returned only while it takes money (status: "AWAITING_TRANSFER"). Show beneficiary and your business name beside it: the customer’s bank shows the beneficiary when it validates the CLABE.
  • The customer also receives the transfer details by email, as on the checkout.
  • url opens the Compago checkout on that same CLABE. Encode it in a QR if you want the customer to continue on their phone.
To know when the money arrived, read GET /developer/v1/one-time-payment/{id}/bank-transfer (status: "PAID" and paymentId) or the bankTransfer field of GET /developer/v1/one-time-payment/{id}. A customer can pay in several transfers: amountReceived and amountDue say how much is still missing.

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. bankAccountId is the manual choice for one payment: the money of that payment is deposited in the account you name, whatever the rule of your business says.
bankAccountId is optional, and an integration that does not send it does not need to change. A payment created without it is deposited exactly as before.
List your accounts with GET /developer/v1/bank-account, which also tells you how your business shares its sales (routingMode) and which account is the default (isDefault):
Then send the id of the account you want:
Rules for the account:
  • It must be one of your own accounts, and it must be verified. An account that is still being verified, that was rejected, that was removed, or that belongs to someone else is refused with BANK_ACCOUNT_NOT_AVAILABLE, and no payment is created.
  • null is the same as leaving the field out.
  • With automatic sharing, a payment you send to an account also counts toward that account’s monthly amount.
  • GET /developer/v1/one-time-payment/{id} returns the account you asked for as bankAccountId. Once the payment is approved, GET /developer/v1/payment/{id} returns the account it was deposited in.
If the account you named is removed before the customer pays, the payment is not lost: it is deposited according to the rule of your business instead. Your customer never sees which account a payment goes to.

Splitting a payment between accounts

Send allocations to split the money of one payment 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:
The supplier’s account receives $600 MXN. The rest of the sale ($900 MXN) follows your deposit rule and pays Compago’s whole fee. Rules for the parts:
  • Up to 5 parts, on payments in MXN only, and never together with bankAccountId. What the parts leave counts as one more, so five parts must add up to the whole amount.
  • 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: false receives 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: false included, 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 with BANK_ACCOUNT_NOT_AVAILABLE. Either way, no payment 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.
  • GET /developer/v1/one-time-payment/{id} returns the parts you asked for as allocations. Once the payment is approved, GET /developer/v1/payment/{id} returns the parts it was deposited in.
Your customer pays one amount and sees one payment. The split only decides where the money is deposited.

Display Modes

Compago supports two display modes for the one-time payment checkout experience. In LINK mode, you redirect the customer to the redirectUrl returned by the API. The customer completes the payment on a full-page Compago checkout page and is then redirected back to your redirectUrl with id and externalId query parameters. This is the simplest integration. Just redirect the customer:

EMBEDDED Mode

In EMBEDDED mode, you embed the checkout URL in an iframe on your own page. This keeps the customer on your site throughout the process. Customize the submit button using buttonText and buttonColor.
Embed the checkout URL in your page. https://app.compago.com/checkout/otp/{id}/embed always opens in iframe mode, whatever displayMode the payment was created with, and https://app.compago.com/checkout/otp/{id} does too when the payment was created with displayMode: "EMBEDDED":
These dimensions are sized to comfortably contain the standard 3DS challenge window the buyer’s bank may render during payment authorization. Smaller envelopes risk clipping the bank’s verification dialog.
In EMBEDDED mode, the iframe handles the entire payment flow. Listen for iframe events to react to loading, success, and error states in real time. The iframe never self-redirects — your parent page decides what to render after a successful payment.

Iframe Events (EMBEDDED Mode)

In EMBEDDED mode, the checkout iframe sends postMessage events to the parent window so you can react without waiting for a redirect.

Events Reference

Listening for Events

Error Codes

The error.code field on COMPAGO_ONE_TIME_PAYMENT_ERROR events lets you distinguish failure modes:
Validate that event.data.type starts with COMPAGO_ONE_TIME_PAYMENT_ before processing. This filters out unrelated postMessage events from other scripts or browser extensions.
Even when using iframe events, always verify the payment status via the API before fulfilling the order. The COMPAGO_ONE_TIME_PAYMENT_SUCCESS event confirms the checkout completed, but your backend should call GET /api/one-time-payment/{id} to confirm the status is CONFIRMED.

Handling the Payment Callback

When a customer successfully completes a payment, Compago redirects them back to your redirectUrl with two query parameters automatically appended:
  • id: The Compago one-time payment ID
  • externalId: The external ID you provided when creating the payment
This allows you to identify which payment completed and take appropriate action in your system.

How the Redirect Works

If you created a payment with:
And Compago returns payment ID aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee, then after the customer completes payment, they’ll be redirected to:

Implementation Example

Here’s how to handle the callback in your application:

Best Practices for Callback Handling

Never trust the redirect alone. Always fetch the payment details from Compago’s API to confirm the status. The redirect happens client-side and could be manipulated.
Implement validation to handle cases where query parameters might be missing (user navigating directly to the URL, etc.).
The callback URL might be accessed multiple times (user refreshing page, browser back button). Ensure your fulfillment logic is idempotent.
Always use HTTPS URLs for your redirectUrl to ensure query parameters are transmitted securely.
If your redirectUrl already contains query parameters, Compago will append id and externalId to them. Design your callback handler to work with multiple parameters.

Security Considerations

Never skip verification! The redirect URL is visible to the customer and could potentially be manipulated. Always fetch the payment status from Compago’s API using the id parameter before fulfilling the order.
Your callback implementation should:
  1. Validate query parameters exist before processing
  2. Fetch payment status from Compago API - Don’t trust the redirect alone
  3. Verify the externalId matches your records - Ensure it corresponds to a real order in your system
  4. Check payment status is CONFIRMED before fulfilling the order
  5. Log all callback attempts for debugging and security monitoring
  6. Use rate limiting on your callback endpoint to prevent abuse

Testing Your Callback Handler

To test your callback implementation:
  1. Create a one-time payment using your test API key
  2. Complete the payment in the Compago checkout page
  3. Verify your callback page receives the id and externalId parameters
  4. Confirm your system correctly fetches and processes the payment status
  5. Test the failure case by creating a payment and letting it expire
You can also manually test by navigating to your callback URL with test parameters:
(Your code should handle this gracefully, likely returning a “payment not found” or similar error.)

Important Business Rules

Payment Expiration

One-time payment links expire 48 hours after creation by default. If a customer does not complete the payment within this time, the link becomes invalid and cannot be used.
You can customize the expiration time using the ttlMinutes parameter (see Custom Expiration Times below). If your OTP expired and you need to create a new payment for the same transaction, generate a new OTP using a different externalId.

Custom Expiration Times

You can set a custom expiration time for payment links using the optional ttlMinutes parameter. This allows you to create payment links that expire sooner or later based on your business needs. Configuration:
  • Minimum: 10 minutes
  • Maximum: 2,880 minutes (48 hours)
  • Default: 2,880 minutes (48 hours) if not specified
Common use cases:
For time-sensitive promotions or limited inventory:
Use short expiration times (10-60 minutes) to create urgency and ensure inventory isn’t held indefinitely.
For typical invoice payments:
The default 48-hour window gives customers plenty of time to complete payment at their convenience.
For event registrations with registration deadlines:
Match the TTL to your event registration deadline to automatically close registration.
For quotes that customers need time to review:
Give customers the maximum time to review and approve quotes before they expire.
Best practices:
  • Balance security and convenience when setting expiration times
  • Shorter TTLs (10-60 min) work well for in-person transactions or time-sensitive offers
  • Longer TTLs (12-48 hours) are better for invoices and asynchronous payment flows
  • Consider your customer’s payment behavior and typical checkout time
  • Communicate the expiration time to customers (e.g., “Complete payment within 30 minutes”)

Amount

There is no minimum card payment amount: any amount greater than 0 is accepted. A zero or negative amount is rejected with a 400 error. SPEI keeps its own minimum (see SPEI_NOT_OFFERED below).

External ID Uniqueness

The externalId must be unique within your organization. Attempting to create a payment with a duplicate externalId will result in a 400 error:
Use unique identifiers for each payment attempt. If a payment fails or expires, create a new one-time payment with a new externalId.

Currency Restriction

Currently, only MXN (Mexican Peso) is supported. Requests with other currencies will be rejected.

Payment Status

One-time payments have three statuses:
  • PENDING: Payment link is active and waiting for customer to complete payment
  • CONFIRMED: Customer has successfully completed the payment
  • CANCELLED: Payment link has been cancelled and can no longer be used
Once a payment is marked as CONFIRMED or CANCELLED, the one-time payment link can no longer be used. See the Cancel One-Time Payment guide to learn how to cancel pending payments.

Retrieving Payment Details

You can retrieve the status and details of a one-time payment using the GET endpoint. Common use case: After receiving a payment callback at your redirectUrl, use the id query parameter to fetch the payment status and verify completion before fulfilling the order. See Handling the Payment Callback for complete implementation examples.

Endpoint

API reference: GET /one-time-payment/{id}

Response for Active Payments

If the payment is still PENDING and has not expired, you’ll receive full payment details:

Response for Completed or Expired Payments

If the payment is no longer PENDING or has expired, the response will contain limited information:
The expired field indicates whether the payment link has passed its 48-hour expiration time, regardless of its status.

Supported Mexican States

Use the following state codes in the address.state field:

Error Handling

Common Errors

Example Error Response

An allowedTerms entry that is not active on your account also carries a code to branch on, and both lists:
A bankAccountId that cannot receive the payment answers 422, with its code and message inside error:

Best Practices

  1. Generate Unique External IDs: Use a combination of order ID and timestamp to ensure uniqueness
  2. Handle Expiration: Implement logic to create new payment links if the 48-hour window expires
  3. Validate Amounts: Ensure amounts are greater than 0 before calling the API
  4. Store Payment IDs: Save the returned one-time payment ID to track and verify payments later
  5. Implement Webhooks: Use webhooks (if available) to receive real-time payment status updates
  6. Test Thoroughly: Use the demo environment to test your integration before going live
  7. Implement Robust Callback Handling: Always verify payment status in your redirectUrl callback by fetching the payment using the id query parameter. Never assume payment success based on the redirect alone. See Handling the Payment Callback.

Support

If you encounter issues with one-time payments:
  • 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 all required fields are included in your request
  • Check that amounts are greater than 0
  • Verify your organization settings are configured correctly
  • Contact Compago support at help@compago.com for assistance