Skip to content
Documentation
Get started

Get started

Create a payment

You need an active merchant account, an sk_test_… secret key, and a default tax configured for your merchant. Store the key in TIMBRO_PAYMENTS_SECRET_KEY on your server only. Prepare your account if you have not done that yet.

Install the SDK in a project with Node.js 24.19 or later:

Ventana de terminal
npm install @timbro/payments

In a server route that returns a Response:

import { createTimbroPayments } from "@timbro/payments";
const timbro = createTimbroPayments({ apiKey: process.env.TIMBRO_PAYMENTS_SECRET_KEY! });
export async function POST() {
const payment = await timbro.payments.create({
paymentReference: "order-123",
amount: { currency: "DOP", value: "1250.00" },
description: "Maintenance service",
returnUrl: "https://merchant.example/orders/123",
});
return Response.redirect(payment.checkout.url);
}

amount is the total, including tax. Use a different reference for each collection request and keep it the same when retrying. Save the payment id with the order.

Checkout stays open for 30 minutes with a returnUrl and 1 hour without one. To change that, send expiresAfterSeconds with a value from 300 to 86400 seconds, and read the deadline from expiresAt on the payment. A POS, for example, sends 600. More about the window.

These windows apply to ordinary payments. The first payment for a Subscription has a fixed 24-hour window; when it expires, the Subscription is terminal, so create another one with a new subscriptionReference. Automatic payments start with both expiresAt and checkout.expiresAt set to null. Timbro sets a 7-day deadline when the email provider accepts the pending payment notice. Do not show a countdown while the deadline is null, and resending the notice does not extend a deadline that is already set.

Use HTTP directly
Ventana de terminal
curl https://api.timbro.do/v1/payments \
-H "Authorization: Bearer $TIMBRO_PAYMENTS_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"paymentReference": "order-123",
"amount": { "currency": "DOP", "value": "1250.00" },
"description": "Maintenance service",
"returnUrl": "https://merchant.example/orders/123"
}'

The response includes id and checkout.url. You do not need to send an idempotency key for this operation.

Returning to returnUrl in the browser does not confirm the payment. Retrieve the payment from your server and apply the payment once when its status is succeeded. Use webhooks to receive the notification even if the customer closes the tab.

This example creates a payment without an invoice. If the sale needs an invoice, choose how to integrate your system.