Use this file to discover all available pages before exploring further.
The PaymentsService class (accessed via client.payments) handles the core initialization and status verification for diverse payment providers including Stripe, Paystack, M-Pesa, and Airtel Money.
To prevent unauthorized payment initiation and duplicate charges, initializePayment requires both an HMAC-SHA256 signature and a mandatory Idempotency Key.
Retrieve all active payment methods configured in your Tybrite Admin Panel. This endpoint accepts both publishable (pk_*) and secret (sk_*) API keys β storefronts can safely call it client-side to discover available providers before checkout.
Create a payment session with your chosen provider. Requires a Secret Key, a valid HMAC signature, and a mandatory Idempotency-Key. On the first successful call this returns 201 Created; subsequent calls with the same idempotency key and identical payload return 200 OK with idempotent: true and the original session.
Secret Key required.initializePayment will reject publishable keys with 403. Never call this from untrusted client environments β keep your sk_* key and HMAC secret server-side.
const paymentData = { provider: 'stripe', amount: 5000, currency: 'USD', email: 'customer@email.com', success_url: 'https://store.com/thanks', cancel_url: 'https://store.com/checkout'};const timestamp = Math.floor(Date.now() / 1000);const idempotencyKey = `pay-stripe-${Date.now()}`;const signature = generateHmacSignature(`${timestamp}.${JSON.stringify(paymentData)}`, hmacSecret);// HTTP 201 Created on first call; HTTP 200 OK with idempotent:true on replayconst response = await client.payments.initializePayment({ idempotencyKey: idempotencyKey, xTimestamp: timestamp, xSignature: signature, requestBody: paymentData});// Example 201 response body// {// "provider": "stripe",// "reference": "pi_3Q...",// "checkout_url": "https://checkout.stripe.com/c/pay/cs_test_...",// "status": "pending",// "idempotent": false// }// Redirect to Stripe Checkoutwindow.location.href = (response as any).checkout_url;
Retrieve the absolute source of truth for a transaction. This is a read operation and does not require HMAC signing.
Secret Key required.verifyPayment will reject publishable keys with 403. Verification responses include charge details (amounts, customer email, payment intents) and must not be exposed to untrusted clients.
Stripe β success when the session/intent is paid, otherwise the raw Stripe payment_status (unpaid, no_payment_required, etc.).
Paystack β Mirrors Paystackβs status field (success, failed, abandoned).
M-Pesa β Enum: pending | success | cancelled | failed. Result code 1032 (user cancelled on phone) maps to cancelled.
Airtel β Sourced from the payment_transaction_logs table. If no log row exists for the reference, the response is { "status": "not_found", "message": "..." } instead of the shape above.
Formatting Tip: For African mobile money (M-Pesa/Airtel), always provide the phone number in international format without the + prefix (e.g., 2547...).