Skip to Content
Payrudder

Examples

Preview

Seven starter web apps that count usage and receive webhooks: copy the one that matches your stack.

Seven small web apps, each doing the two things an app does with Payrudder:

  • Count usage: POST /usage sends one usage event for a customer.
  • Receive webhooks: POST /webhooks/payrudder checks the signature of a delivery before it trusts it.

Copy the one that matches your stack and change it. Each lives in the repository under examples/<name>/.

Express

examples/express/. Node 22.18+ (TypeScript), Express 5.

Run: npm ci && npm start

FastAPI

examples/fastapi/. Python 3.10+, FastAPI.

Run: pip install -r requirements.txt && uvicorn main:app

Go net/http

examples/go-nethttp/. Go 1.23+, net/http.

Run: go run .

Next.js

examples/nextjs/. Node 22.18+, Next.js 16 (App Router, TypeScript).

Run: npm ci && npm run build && npm start

Laravel

examples/laravel/. PHP 8.3+, Laravel 13.

Run: composer install && php artisan serve

Rails

examples/rails/. Ruby 3.2+, Rails 8.1 (API mode; no Ruby SDK, so a small client of its own).

Run: bundle install && bin/rails server

Django

examples/django/. Python 3.12+, Django 6.

Run: pip install -r requirements.txt && gunicorn payrudder_app.wsgi

Configure

They share the settings the SDKs read themselves:

VariableValue
PAYRUDDER_API_KEYa prk_test_... key of the sandbox
PAYRUDDER_BASE_URLyour Payrudder address, http://localhost:42800 on a local stack
PAYRUDDER_WEBHOOK_SECRETfor the webhook route: the whsec_... secret shown once when the endpoint was created

To reach your machine from Payrudder use payrudder webhooks listen (see Command line and Local webhooks) or a tunnel of your own.

The SDK comes from the checkout

The templates are not published. Each template installs the SDK from the repository checkout (a file: dependency, a path requirement, a replace directive, a Composer path repository). Build the TypeScript SDK first for Express and Next.js: cd sdk/typescript && npm ci && npm run build.

There is no Ruby SDK: the Rails template has a small client and the signature check of its own (app/lib/payrudder/), written from Webhooks and the OpenAPI file.

How they are checked

CI compiles each template (tsc, next build, python -m compileall, go vet, php -l, ruby -c) and runs node examples/smoke.mjs, which starts the app next to a stand-in for the API made from api/openapi/v1.yaml and checks over HTTP that:

  • a delivery signed the documented way is accepted, and a changed body, a wrong secret, an old timestamp and a missing header are refused;
  • POST /usage reaches the API as a usage event that fits the contract, with the app's key.

That proves the template starts and uses the SDK correctly. It does not prove anything about a real gateway, a real key or a real delivery: run it against your sandbox before you rely on it.