Download the PHP package paybridge-np/sdk without Composer
On this page you can find all versions of the php package paybridge-np/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download paybridge-np/sdk
More information about paybridge-np/sdk
Files in paybridge-np/sdk
Package sdk
Short Description Official PHP SDK for PayBridgeNP — the payment gateway for Nepal
License MIT
Homepage https://paybridgenp.com
Informations about the package sdk
PayBridgeNP - PHP SDK
Official PHP SDK for PayBridgeNP - accept eSewa, Khalti, and Fonepay through a single API.
Requirements: PHP 7.4+, ext-curl, ext-json
Installation
Quick Start
The customer lands on a hosted checkout page, picks their payment method (eSewa / Khalti), pays, and is redirected back to your return_url with:
Configuration
Use sk_test_ keys for sandbox mode. eSewa and Khalti sandbox run on provider test environments, so no real money moves; sandbox Fonepay uses your own Fonepay credentials and moves real money within tight caps. Switch to sk_live_ for production.
Checkout
Create a session
If you pass provider upfront, the response also includes payment_method with the direct redirect URL or form fields - useful if you want to skip the hosted page entirely.
Expire a session
Use this when you mint a fresh session for a logical purchase that already had one outstanding (e.g. a customer requesting a new payment link), so the old URL stops being payable immediately rather than waiting for its 30-minute TTL. Idempotent on already-terminal sessions.
Retrieve / list sessions
Read-only. Sessions are created with create(). The read shape uses camelCase keys (customerName, expiresAt, …).
Laravel example
Payments
List payments
Retrieve a payment
Payment links
Reusable hosted payment pages. Responses use camelCase keys.
Direct-QR (Fonepay)
Premium feature - mint a Fonepay QR server-side and embed it in your own UI, skipping the hosted checkout page. Subscribe to events_url (SSE) for qr.scanned / qr.paid / qr.expired.
Webhooks
Webhooks let PayBridgeNP notify your server when a payment is completed or fails. You register an endpoint URL, and we POST a signed JSON payload to it for every event.
1. Register an endpoint
2. Handle incoming webhooks
Always verify the signature before trusting the payload.
Plain PHP:
Laravel:
Important: Always pass the raw request body to
constructEvent()- do notjson_decodeit first. The HMAC is computed over the raw string.Important: Disable CSRF verification for your webhook route in Laravel (
VerifyCsrfTokenmiddleware).
Manage endpoints
Webhook Events
| Event | When it fires |
|---|---|
payment.succeeded |
Payment verified successfully |
payment.failed |
Payment attempted but failed or cancelled |
Every event payload has this shape:
Error Handling
All API errors throw a subclass of PayBridgeNP\Exceptions\PayBridgeException.
Exception reference
getErrorType() is the broad category listed below. getErrorCode() is the
specific identifier for the failure (for example api_key_invalid) and may be
null.
| Class | Status | getErrorType() |
|---|---|---|
AuthenticationException |
401 | authentication_error |
PermissionException |
403 | permission_error |
NotFoundException |
404 | not_found_error |
InvalidRequestException |
400 / 422 | invalid_request_error |
RateLimitException |
429 | rate_limit_error |
SignatureVerificationException |
— | signature_verification_error |
ConnectionException |
— | connection_error |
PayBridgeException |
any | api_error |
Sandbox Testing
Use sk_test_ API keys for development. Sandbox eSewa and Khalti run on the providers' official test environments with built-in test credentials, so nothing needs configuring in the dashboard and no real money moves. Fonepay has no test environment: sandbox Fonepay uses your own Fonepay credentials and moves real money, capped at NPR 1,000 per payment and NPR 5,000 per month.
Running the Tests
License
MIT
All versions of sdk with dependencies
ext-curl Version *
ext-json Version *