Integrate TutuPay
Let your product charge for value-added services from the shared Tutu balance — no payment stack to build.
Integrate in three steps
- 1
Copy the SDK
Copy lib/pay-sdk/index.ts into your product repo.
- 2
Create an instance
Call createTutuPay({ clientId }) with your clientId.
- 3
Start checkout
Call pay.checkout({ sku }); the popup handles sign-in, order and payment.
import { createTutuPay } from '$lib/pay-sdk';
const pay = createTutuPay({
baseUrl: import.meta.env.VITE_TUTUPAY_URL,
clientId: 'tutuedit'
});
const r = await pay.checkout({ kind: 'export_credits', sku: 'pack_100' });
if (r.status === 'paid') {
// grant credits idempotently on your side; use r.orderId to double-check
}How it works
The hosted checkout completes sign-in, order and payment inside a popup (same tutuid trust root, no re-login) and posts the result back via postMessage; your product never touches balance or payment credentials. Add a SKU with one line in the backend orders.rs sku_price().
Open the integration demo