# PayProof Gateway — developer integration guide
PayProof verifies Ethiopian bank-transfer receipts for software products. It is
an API and hosted-checkout platform, not a settlement provider.
## Product rules
1. PayProof **verifies** bank transfers. It never holds or settles the money for
your product.
2. End-customers pay **your** bank accounts. PayProof matches the transfer to a
checkout and maintains payment/subscription status.
3. Verification is **credit-based** on the PayProof platform. One billable
verification consumes one credit after any free allowance.
4. The gateway never touches the merchant/verifier app, the mobile app, or the
verification engine. It only creates checkouts, verifies receipts, and
reports outcomes.
## Canonical flow
```
Create app → add receiving accounts → set product price
→ create checkout → customer transfers with reference_code
→ customer uploads receipt → PayProof verifies → checkout completes
→ signed webhook (payment.verified | subscription.activated)
```
Hosted pay page: `/pay/{checkout_public_id}`
Live states: `pending`, `partially_paid`, `verified`, `failed`, `expired`,
`canceled`, `manual_review`.
## Base URL
Use the API base URL shown in your dashboard. All examples below are relative
to that host.
Every response includes an `X-Request-Id` header; include it when contacting
support.
## Authentication
### Publishable key — `pk_live_…`
Safe to ship in a browser or mobile app. Scoped to one app.
Allowed:
- read the catalog (`GET /api/v1/offerings/`)
- create a checkout (`POST /api/v1/checkouts/`)
- read its status and verify a receipt
- read the customer's entitlement
Not allowed (unless noted):
- complete a checkout manually
- immediate cancel, refunds, list customers, rotate keys, or manage webhooks
- client cancel/resume unless the app enables `allow_client_subscription_changes`
### Secret key — `sk_live_…`
Server only. Full access to every endpoint. Never bundle it in a client app.
```
Authorization: Bearer sk_live_...
```
Keys are created per app in **Dashboard → Apps → [app] → API keys**.
### Dashboard
Dashboard routes (`/api/platform/*`) use a JWT from Telegram OIDC or phone OTP:
```
POST /api/auth/telegram-login/ { "id_token": "<OIDC JWT>" }
POST /api/auth/send-otp/ { "phone": "09xxxxxxxx" }
POST /api/auth/verify-otp/ { "phone", "code" }
```
### Diagnose a key
```
GET /api/v1/me/
→ { "key": { "type", "prefix", "app_id", "scopes" }, "app": {...}, "company": {...} }
```
Both SDKs expose `diagnose()`, which calls this endpoint and `/api/health/`.
## Create a checkout
```
POST /api/v1/checkouts/
Authorization: Bearer sk_live_...
Idempotency-Key: order_42
Content-Type: application/json
{
"app_id": 1, // optional with an app-scoped key
"product_id": 1, // or "package_id"
"amount_etb": "999.50", // required only for dynamic/open pricing
"customer_ref": "user_42",
"customer_email": "customer@example.com",
"success_url": "https://yoursite.com/orders/42/thanks",
"cancel_url": "https://yoursite.com/cart",
"expires_in_hours": 48
}
```
Response:
```json
{
"checkout": {
"id": "cs_...",
"public_id": "cs_...",
"app_id": 1,
"reference_code": "PP-1-AB12CD34",
"expected_amount_etb": "999.50",
"status": "pending",
"expires_at": "2026-10-25T12:00:00Z"
},
"payment_accounts": [
{ "bank_name": "CBE", "account_number": "1000...", "account_name": "Shop PLC" }
],
"pay_url": "/pay/cs_..."
}
```
`app_id` is inferred from an app-scoped key. Supplying a different app id
returns `403 app_mismatch`.
Send `Idempotency-Key` on every create. A retry with the same key returns the
original open checkout instead of creating a duplicate.
## Verify a receipt
Hosted page and customer clients use the public, rate-limited endpoint:
```
POST /api/public/gateway/checkouts/:public_id/verify/
Content-Type: multipart/form-data
images[] receipt image(s)
qr_payload optional QR payload
text optional SMS text
reference_number / bank_name / sender_account / receipt_url
```
App-scoped equivalent:
```
POST /api/v1/checkouts/:public_id/verify/
Authorization: Bearer pk_live_...
```
Response:
```json
{
"verification_id": 123,
"status": "PENDING",
"checkout": { "...": "..." },
"websocket": "/ws/gateway/checkouts/cs_..."
}
```
Poll `GET /api/public/gateway/checkouts/:public_id/status/` or subscribe to
`wss://{host}/ws/gateway/checkouts/:public_id/`.
## Subscriptions
```
GET /api/v1/subscriptions/:id/
GET /api/v1/subscriptions/:id/status/
GET /api/v1/subscriptions/:id/events/
POST /api/v1/subscriptions/:id/cancel/ { "immediate"?: false, "reason"?: "..." }
POST /api/v1/subscriptions/:id/resume/
GET /api/v1/billing/status/?customer_ref=user_42
GET /api/v1/entitlements/?customer_ref=user_42
POST /api/v1/entitlements/trial/ { "app_id", "customer_ref", "package_id" }
POST /api/v1/plan_changes/preview/ { "app_id", "customer_ref", "package_id" }
POST /api/v1/plan_changes/ { "app_id", "customer_ref", "package_id" }
```
Cancel defaults to end of period. `immediate: true` requires a secret key.
Lifetime plans always end immediately. Publishable keys may cancel/resume only
when the app enables **Allow client-side cancel and resume** in dashboard
settings (`allow_client_subscription_changes`). App-scoped keys can only read or
manage subscriptions belonging to that app.
`entitlements` returns the authoritative access decision plus server time for
offline caching, including `cancel_at_period_end` and `canceled_at`.
## Refunds and manual review
Overpayments can be refunded from the hosted page; merchants approve or reject
from the dashboard. Status is available on the checkout payload
(`refund_eligible`, `refund_status`).
```
POST /api/public/gateway/checkouts/:public_id/manual-review/
POST /api/platform/checkouts/:public_id/manual-review/approve/
POST /api/platform/checkouts/:public_id/manual-review/reject/
```
## Webhooks
```
POST /api/platform/webhooks/
{
"app_id": 1,
"url": "https://yoursite.com/webhooks/payproof",
"events": [
"checkout.created", "checkout.verified", "checkout.partially_paid",
"checkout.failed", "checkout.expired",
"checkout.manual_review_requested", "checkout.manual_review_approved",
"checkout.manual_review_rejected",
"subscription.activated", "subscription.ended",
"subscription.cancel_scheduled", "subscription.resumed",
"subscription.expiring_soon", "subscription.grace_entered",
"subscription.grace_ended", "subscription.trial_started",
"payment.verified", "payment.failed",
"verification.verified", "verification.failed"
],
"enabled": true
}
```
Signature header:
```
PayProof-Signature: t=<unix>,v1=<hex>
```
Compute `HMAC-SHA256(secret, "<t>.<raw_body>")` and compare in constant time.
Reject timestamps older than five minutes.
Delivery logs: `GET /api/platform/webhooks/:id/deliveries/`
Retry: `POST /api/platform/webhooks/:id/deliveries/:delivery_id/retry/`
## Verification API
Server-side receipt verification for your own workflows:
```
POST /api/v1/verifications/
Authorization: Bearer sk_live_...
Content-Type: multipart/form-data
images[], qr_payload?
```
The response includes a verification id and a WebSocket path. Billable terminal
states are `VERIFIED`, `FAILED`, and `REJECTED`.
## SDKs
### Svelte / SvelteKit — `@payproof/svelte` 0.4.2
```ts
import { PayProof } from '@payproof/svelte';
PayProof.init({
baseUrl: 'https://your-payproof-api-host',
clientKey: 'pk_live_...',
});
```
Provides `presentCheckout`, `Paywall`, `PackageList`, `StatusCard`,
`ManageSubscription`, and `PayProofAccess`. See `/docs/sdks/svelte`.
### Kotlin / Android — `et.payproof:payproof-android` 0.4.2
```kotlin
PayProof.init(
context,
PayProofConfig(
baseUrl = "https://your-payproof-api-host",
clientKey = "pk_live_...",
),
)
```
Provides a Compose checkout sheet, package list, status card, manage screen, and
entitlement access wrapper. See `/docs/sdks/kotlin`.
## Errors
Every error includes a stable machine code and a user-facing message:
```json
{
"error": { "code": "amount_mismatch", "message": "...", "hint": "..." },
"code": "amount_mismatch",
"message": "...",
"hint": "...",
"request_id": "req_..."
}
```
Common codes: `invalid_api_key`, `app_mismatch`, `customer_ref_required`,
`amount_mismatch`, `transaction_not_found`, `transaction_already_used`,
`checkout_expired`, `plan_not_found`, `trial_already_used`.
## Do not
- Expect PayProof to settle product funds.
- Ship a secret key (`sk_...`) to a browser or mobile app.
- Manually complete a checkout without a verified payment.
- Reuse another customer's receipt or reference code.