Skip to Content
Payrudder

Let a customer pay

Give a customer a page to pay on, with an invoice link, a payment link or their own portal, without building a form.

Payrudder collects the money for the invoices it makes, through the payment provider you connected. A customer needs a page to pay on, and you have three ways to give it one, all without building a form. This tutorial makes each in the sandbox.

You wantUse
The customer to see and pay one invoiceAn invoice link
A page whose only job is to take a payment, for an invoice or an amount you nameA payment link
A "Billing" page with all of the customer's invoices, payments and receiptsThe customer portal

Before you start

You need a sandbox key and a customer that has an invoice. Usage-based billing, end to end makes one.

Shell setup
export BASE=https://api.payrudder.com
export PAYRUDDER_API_KEY=prk_test_...
api() { curl -sS -H "Authorization: Bearer $PAYRUDDER_API_KEY" -H "Content-Type: application/json" "$@"; }
INVOICE_ID=...        # the id of an invoice that is open

An invoice that is finalized and not paid can be opened by its customer without signing in.

Make the link

Create an invoice link
api -X POST $BASE/v1/invoices/$INVOICE_ID/links -d '{}'

The answer has the url. The token is unguessable and returned once: keep the url now.

Send the customer to it

The page shows the invoice (and its PDF once it is rendered) in English, Turkish, German, French, Spanish or Arabic (?lang= or the browser's language).

Revoke it when you are done

The link works for 90 days by default (expires_in_days, at most 365) or until you revoke it with DELETE /v1/invoices/{id}/links.

A payment link is a page whose only job is to take a payment.

Make the link

Create a payment link for an invoice
api -X POST $BASE/v1/payment-links -H "Idempotency-Key: pay-inv-1" -d '{"kind":"invoice","invoice_id":"'"$INVOICE_ID"'"}'

Both answer with the url and the token (once). The Idempotency-Key makes a retry return the link made the first time instead of a second one (Idempotency).

Fulfil on the event

When the customer pays, payment_link.paid and invoice.paid are sent to your webhook endpoints.

Fulfil the order on the event, not on the redirect.

The customer's own page

Make a portal link

Create a portal link
api -X POST $BASE/v1/customers/cus_42/portal-links -d '{}'

The url shows the customer's invoices, payments, PDFs and receipts, read-only, with a pay button on the open ones.

Make a fresh one on each click

Put it behind a button in your own application ("Billing") and make a fresh one when the customer clicks, since the token is only shown when it is made.

The link works for 30 days by default (at most 365) or until you revoke them with DELETE /v1/customers/{external_id}/portal-links.

In the sandbox

The pages are the real ones; the payment goes to the simulator. Choose the outcome with the customer's payment method or POST /v1/sandbox/customers/{external_id}/payment-scenario, so you can see a decline (Test mode). Nothing reaches a real card or a real mailbox.

Things to know

  • A customer you have blocked cannot start a new purchase. Blocking and unblocking are in the API reference.
  • The language of the page is the customer's locale (en, tr, de, fr, es, ar), else the browser's.
  • Amounts are minor units as strings ("2500" is 25.00 in a two-decimal currency).
  • A link you made and no longer want: revoke it. payment_link.expired is sent when one runs out unpaid.

Next steps