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 — Nepal payment gateway aggregator
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 — no real money moves. 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.
Laravel example
Payments
List payments
Retrieve a payment
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
| Class | Status | getErrorCode() |
|---|---|---|
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 to test without real money. The sandbox uses provider test environments:
| Provider | Test credentials |
|---|---|
| eSewa | Merchant code: EPAYTEST, secret: 8gBm/:&EnhH.1/q — pre-configured, no setup needed |
| Khalti | Secret key: test_secret_key_f59e8b7d18b4499ca40f68195a846e9b — pre-configured |
In sandbox mode, no provider credentials need to be configured in the dashboard — built-in test credentials are used automatically.
Running the Tests
License
MIT
All versions of sdk with dependencies
ext-curl Version *
ext-json Version *