Skip to Content
Payrudder

E-commerce checkout

Sell a shop order through a payment link with items, a buyer and VAT per rate, and learn safely that it was paid.

A shop can sell an order through a payment link: the link carries the items, the buyer and the order reference, the buyer pays on a Payrudder page, and the invoice comes out with the right lines and VAT per rate. This guide makes one order and shows how the shop learns that it was paid. It builds on Let a customer pay.

Before you start

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" "$@"; }

Steps

Set the return addresses

Set the two return addresses once, in the console, in the Billing profile (https only): checkout_success_url and checkout_cancel_url. Saving them sets both environments, sandbox and live.

Make the link

Create a payment link for an order
api -X POST $BASE/v1/payment-links -H "Idempotency-Key: order-1001" -d '{
  "kind": "adhoc",
  "currency": "TRY",
  "order_ref": "ORD-1001",
  "customer_email": "ayse@example.com",
  "items": [
    { "ref": "sku-shirt", "name": "Shirt", "quantity": 2, "unit_amount_minor": 10100, "vat_rate_bps": 2000, "physical": true },
    { "ref": "sku-ebook", "name": "E-book", "quantity": 1, "unit_amount_minor": 120000, "vat_rate_bps": 100 }
  ],
  "buyer": {
    "name": "Ayşe Yılmaz",
    "tax_id": "",
    "billing_address": { "line1": "Moda Cad. 1", "city": "İstanbul", "postal_code": "34710", "country": "TR" }
  },
  "shipping_address": { "line1": "Moda Cad. 1", "city": "İstanbul", "postal_code": "34710", "country": "TR" }
}'

What each part means is in The order, field by field below.

Send the buyer to the page

Send the buyer to the url of the answer.

After a payment ends, the payment page shows a link back, with ?link=<link id>&order=<order_ref> added:

  • to the success address after a paid payment,
  • to the cancel address after a failed one that can no longer be paid. While the buyer can still try again, the page shows only the pay buttons.

Confirm the payment

Do not mark the order paid because the buyer arrived there. Anyone can open that address.

Confirm the payment one of two ways:

  • the webhook payment_link.paid (and invoice.paid), which carry order_ref and link_id so you can find the order (Webhooks), or
  • GET /v1/payment-links/{id} with the link of the address: status is paid when it is.

The event looks like this:

payment_link.paid
{ "type": "payment_link.paid", "data": { "link_id": "...", "order_ref": "ORD-1001", "invoice_id": "...", "currency": "TRY", "total_minor": "140200", "paid_count": 1 } }

An event can arrive more than once. Handle it by link_id and order_ref, and answer 2xx once the order is safe.

The order, field by field

Things to know

  • The link back is shown for an order that has an order_ref, once it is paid, or failed and no longer payable. With no return address set, the page shows none.
  • In the sandbox the page, the return addresses and the events are the real ones and the payment goes to the simulator (Test mode).
  • With iyzico the items are sent as the basket and <invoice id>:<order_ref> as the basket id (iyzico).

Next steps