Introduction
Charge cards in the Dominican Republic through Azul, with 3D Secure handled for you.
The Payments API runs card checkouts. It charges cards, Google Pay and Apple Pay through Azul, runs the 3D Secure flow, and tells your server about each payment with a signed webhook. A checkout can also start a subscription.
Base URLs
| Environment | API | Dashboard |
|---|---|---|
| Production | https://api.rapidopagos.com | https://app.rapidopagos.com |
| Development | https://dev-api.rapidopagos.com | https://dev-app.rapidopagos.com |
How a payment works
- Your server creates a checkout with
POST /checkoutand gets back itsid. - Your checkout page submits the payment details to
POST /checkout/{id}. - The page polls
GET /checkout/{id}. While the status ismethodorchallenged, it shows the 3D Secure form the status carries. - The checkout ends as
complete,failedorerrored, or asexpiredwhen nobody pays it within 10 minutes. Oncomplete, your server has already received the webhook.
Authenticate your requests
POST /checkout, POST /customer, POST /discount-code, GET /subscription/{id}, GET /subscription/{id}/invoices, GET /invoice/{id}, GET /payment/evidence and the routes of electronic invoicing require an API key of your organization. Sign in to the dashboard with your email and create an organization. An owner or admin then creates a key under Claves de API, and the dashboard shows it once. Send it in the Authorization header.
const response = await fetch('https://api.rapidopagos.com/checkout', {
method: 'POST',
headers: {
'content-type': 'application/json',
authorization: `Bearer ${process.env.PAYMENTS_API_KEY}`
},
body: JSON.stringify({
amount: 100_00,
ITBIS: 18_00,
currency: 'DOP',
metadata: 'order-12345',
webhookURL: 'https://example.com/webhooks/payment',
forceNo3DS: false
})
});
const { id } = await response.json();A missing, unknown or revoked key gets 401. Keep the key on your server, since anyone who holds it acts for your organization. Checkouts, customers, products and subscriptions belong to the organization of the key, so a key never sees another organization's data.
Each organization charges through its own Azul merchant, which rapidopagos connects for you. Until then, POST /checkout answers 403 with { "kind": "processor-not-connected" }, and the dashboard shows the organization as not connected with a way to reach us.
Receive the webhook
After a successful charge, the API sends a POST to the checkout's webhookURL.
{
"paymentId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"amount": 10000,
"currency": "DOP",
"charged": {
"amount": 10000,
"currency": "DOP"
},
"metadata": "order-12345",
"processorReference": "44012345"
}amount is in cents of the checkout currency. charged is what Azul charged the card, in cents of Dominican pesos. For a USD checkout, charged is the dollar amount converted at the exchange rate locked when the checkout was created.
processorReference is the reference the processor assigned to the payment. For Azul it is the order ID, the "No. de Secuencia" of a chargeback notice.
The x-hub-signature header carries the HMAC-SHA256 hex digest of the raw body, keyed with your organization's webhook secret. An owner or admin copies the secret from the Webhooks section of the dashboard. Verify the signature before you trust the payload.
Rotating the secret in the dashboard takes effect at once. Every delivery after it, retries included, is signed with the new secret only, so update your server right after you rotate.
Reply with any 2xx once the order is recorded. A failed delivery is retried for about two hours, so make your handler idempotent on paymentId. If the order can no longer be fulfilled, reply 409 with { "error": "ORDER_CANNOT_BE_FULFILLED" }. The checkout then ends as errored and the payment is flagged for review.
Start a subscription
Add subscription to POST /checkout to subscribe the customer to items that renew every week, month or year. The checkout needs a customer and 1 to 20 items, each of one product and with its unitItbis. The items add up to amount by quantity times unitPrice, and to ITBIS by quantity times unitItbis. Your organization needs a webhook endpoint, which an owner or admin sets in the Webhooks section of the dashboard. The response carries the checkout id.
const response = await fetch('https://api.rapidopagos.com/checkout', {
method: 'POST',
headers: {
'content-type': 'application/json',
authorization: `Bearer ${process.env.PAYMENTS_API_KEY}`
},
body: JSON.stringify({
amount: 500_00,
ITBIS: 76_27,
currency: 'DOP',
metadata: 'order-12346',
webhookURL: 'https://example.com/webhooks/payment',
forceNo3DS: false,
customer: {
externalId: 'user_8f2c1a',
email: 'ana.perez@example.com'
},
items: [
{
product: {
externalId: 'plan-pro',
name: 'Plan Pro'
},
quantity: 1,
unitPrice: {
amount: 500_00,
currency: 'DOP'
},
unitItbis: 76_27
}
],
subscription: {
recurringInterval: 'month',
externalId: 'company_4f1b',
onDunningExhausted: 'cancel',
metadata: 'crm-account-88231'
}
})
});
const { id } = await response.json();externalId, onDunningExhausted and metadata are optional, and the subscription carries them. onDunningExhausted is cancel when you leave it out. One subscription of your organization holds an externalId, whatever its status. A checkout with an externalId that a subscription holds gets 409 subscription-exists with its subscriptionId. A checkout with an externalId that an unfinished sign-up checkout carries gets 409 sign-up-in-progress with its checkoutId. A sign-up checkout that ends expired, failed or errored releases its externalId.
A subscription checkout takes card payments only. POST /checkout/{id} with google-pay or apple-pay gets 409 wallet-not-supported, and the checkout keeps waiting for payment details.
The sale of a subscription checkout saves the card. No subscription exists until the checkout is paid. When the checkout is paid, the subscription is created active for its first period, with its items, a paid subscription-start invoice and the saved card as its default card. Your organization's endpoint receives subscription.created and invoice.paid (see Webhook events), and the checkout's webhookURL receives no payment notice. The complete status of GET /checkout/{id} carries the subscriptionId and the invoiceId. When another subscription took the externalId after the checkout was created, the subscription is created without it.
At the end of each period, the subscription renews. A new invoice is charged to its saved card. When the charge is declined, the subscription becomes past-due, and the charge is retried within a 21-day collection window. After the fifth declined charge, or when the window ends unpaid, the subscription is canceled, or paused when onDunningExhausted is pause. GET /invoice/{id} returns an invoice, and GET /subscription/{id}/invoices lists the invoices of a subscription.
POST /subscription/{id}/cancel cancels a subscription, and canceled is final. With effectiveFrom immediately, the subscription is canceled at once, its open invoice is voided, and no credit or refund is given. With next-billing-period, the subscription stays active, scheduledChange holds the cancel, and the subscription is canceled at currentPeriodEnd with no renewal. A past-due or paused subscription can only be canceled immediately. Each cancel takes an initiator (customer or merchant), an optional reason and an optional comment, and the canceled subscription carries them. The saved card is deleted unless another subscription that is not canceled uses it. Your organization's endpoint receives subscription.updated for a cancel at period end and subscription.canceled when the subscription is canceled.