Skip to main content
Create a hosted checkout, redirect the customer, and confirm the payment on your server.
Keep your order amount in your database. The browser should send an order ID, not the amount to charge.

1. Get your API keys

Sign up at dashboard.paybridgenp.com and copy your API key from Settings → API Keys.
  • Sandbox keys start with sk_test_ - use these for testing
  • Live keys start with sk_live_ - use these for real payments
Never expose your API key in client-side code or commit it to version control. Use environment variables.

2. Install the SDK

3. Create a checkout session

Call this from your server when a customer is ready to pay.
The response looks like:
Redirect your customer to checkout_url. They’ll see the PayBridgeNP hosted checkout page and can pay with any provider you’ve configured.
cancelUrl is optional. If you omit it, cancellations fall back to your returnUrl with ?status=cancelled appended - and the hosted picker hides its “Cancel” link. Set cancelUrl only if you want a dedicated cancel page and a visible Cancel link on the picker.

4. Handle the return redirect

After the customer pays (or cancels), they’re redirected to your returnUrl (or cancelUrl if set and the customer cancelled) with query parameters:
expired means the customer never finished and the session timed out. Treat it the same as failed for fulfilment purposes: no money moved. Branch on success and treat everything else as not-paid, rather than listing the failure values, so a future status can never be read as a payment.
Do not fulfill orders based solely on the redirect. The customer could manipulate query parameters. Always verify payment server-side using webhooks or GET /v1/payments/:id.

5. Verify payment server-side

Replace the example data-access helpers with your own database calls. Make fulfillment idempotent by storing the PayBridgeNP payment ID and ignoring a repeat you already processed. Only have the session_id from the redirect? Fetch the session - once it’s paid, the response includes paymentId:
See Get a checkout session.

6. Set up a webhook endpoint

Go to Webhooks in the dashboard, click Add endpoint, enter your URL, and select the events you want to receive. Save the signing secret - it’s shown only once. See the webhook verification guide for full details on signature verification.

Next steps

Sandbox Testing

Test the full flow with built-in test credentials before going live.

Provider Setup

Add your real eSewa, Khalti, and Fonepay credentials.

Idempotency

Make retries safe - avoid duplicate payments on network failures.

Billing

Set up recurring subscriptions and automated invoicing.