Skip to main content
This guide walks through the full payment flow - from creating a checkout session on your server to receiving a webhook when payment succeeds.

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:
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

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.