Pay-in / Use cases
Collections with PSE links
Send a PSE link per invoice, hear about the payment by webhook and mark the invoice paid without reconciling by hand.
A company with receivables (installments, invoices, memberships) wants every customer to pay from their bank and its system to mark the invoice paid on its own.
The flow
- For every invoice you create a fixed-amount link with the invoice as
referenceand an expiry. - You send
checkoutUrlto the customer over the channel you already use. - The customer pays with PSE; zulu credits your balance.
- The
RECHARGE_LINKSwebhook tells you the link isPAIDand theDEPOSITSwebhook carries the deposit with yourreference. - You mark the invoice paid.
1. One link per invoice
POST/v1/recharge-linksCreate a PSE payment linkSandbox · coming soon
create-link.js
export async function linkForInvoice(invoice, token) {
const response = await fetch('https://sandbox.zulu.com.co/v1/recharge-links', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'X-API-Key': process.env.ZULU_API_KEY,
'Content-Type': 'application/json',
'Idempotency-Key': `invoice-${invoice.id}`,
},
body: JSON.stringify({
amount: invoice.amountCop,
concept: `Invoice ${invoice.number}`.slice(0, 60),
reference: invoice.number,
paymentMethod: 'PSE',
expiresInHours: 72,
}),
});
if (!response.ok) throw new Error(`zulu ${response.status}: ${await response.text()}`);
return response.json();
}- Use the invoice number as
reference(up to 25 characters): it arrives intact in the deposit. - The
Idempotency-Keyderived from the invoice keeps a retry from creating two links (preview, in the sandbox). - Store
slugandcheckoutUrlnext to the invoice.
2. Webhooks
When RECHARGE_LINKS arrives with PAID, or DEPOSITS with your reference, fetch the resource and mark the invoice:
webhook.js
export async function onDeposit(event) {
const deposit = await zulu.get(`/v1/deposits/${event.depositId}`);
const invoice = await invoices.findByNumber(deposit.reference);
if (!invoice || (await payments.exists(deposit.depositId))) return;
await payments.record({ depositId: deposit.depositId, invoiceId: invoice.id, amount: deposit.amount });
if (deposit.amount >= invoice.amountCop) await invoices.markPaid(invoice.id);
}Verify the signature before processing: Webhooks and signature verification.
3. Links that go unpaid
| What happens | What to do |
|---|---|
REFUSED | The bank refused the payment. The customer can retry with the same link; let them know. |
EXPIRED | It expired. Create a new link with the same reference if the invoice is still open. |
| Invoice voided | Cancel the link with DELETE /v1/recharge-links/{slug}. |
Mind the maximum of active links at once: cancel the links of voided invoices and use expiries.
| Limit | Value |
|---|---|
| PSE links active at once | 15 |
| Amount of a PSE link | 100,000 – 1,000,000,000 COP |
4. Test it end to end
Create a link, pay it with the simulator and check your system marks the invoice:
POST/v1/sandbox/recharge-links/{slug}/paySimulate a PSE link paymentSandbox only
Also simulate REFUSED and let a link expire with expiresInHours: 1 to test every branch.