1. Go to this page and download the library: Download paybridge-np/sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$payment = $paybridgenp->payments->get('pay_xxxxxxxxxxxxxxxx');
echo $payment['status']; // success
echo $payment['provider_ref']; // provider's own transaction ID
echo $payment['metadata']['order_id']; // data you passed at checkout
// Create
$link = $paybridgenp->paymentLinks->create(['title' => 'Donation', 'amount' => 50000]);
// List, retrieve (with view/conversion stats), update, cancel, or delete
$links = $paybridgenp->paymentLinks->list(['active' => true]);
$detail = $paybridgenp->paymentLinks->get($link['id']);
$paybridgenp->paymentLinks->update($link['id'], ['active' => false]);
$paybridgenp->paymentLinks->cancel($link['id']); // deactivate, keep for records
$paybridgenp->paymentLinks->delete($link['id']); // only if never used
$qr = $paybridgenp->qr->fonepay([
'amount' => 10000, // paisa
'customer' => ['name' => 'Aarav Sharma', 'email' => '[email protected]'],
]);
// $qr['qr_image'] (PNG data URL), $qr['qr_message'], $qr['events_url'], $qr['expires_at']
// The QR display window is ~3 min. Refresh it for the SAME session - same id,
// events_url, and webhook - without spawning a new session. Lifetime unchanged.
$fresh = $paybridgenp->qr->refresh($qr['id']);
$endpoint = $paybridgenp->webhooks->create([
'url' => 'https://myshop.com/webhooks/paybridgenp',
'events' => ['payment.succeeded', 'payment.failed'],
]);
// Save $endpoint['signing_secret'] somewhere safe (e.g. .env)
// It is shown ONCE and cannot be retrieved again.
echo $endpoint['signing_secret']; // whsec_...
use PayBridgeNP\Exceptions\PayBridgeException;
use PayBridgeNP\Exceptions\AuthenticationException;
use PayBridgeNP\Exceptions\InvalidRequestException;
use PayBridgeNP\Exceptions\RateLimitException;
use PayBridgeNP\Exceptions\SignatureVerificationException;
try {
$session = $paybridgenp->checkout->create(['amount' => 5000, 'return_url' => 'https://...']);
} catch (AuthenticationException $e) {
// Invalid or missing API key
echo $e->getMessage(); // "Invalid or missing API key"
echo $e->getStatusCode(); // 401
echo $e->getErrorType(); // "authentication_error"
echo $e->getErrorCode(); // "api_key_invalid" — specific, may be null
} catch (InvalidRequestException $e) {
// Bad parameters - check $e->getRaw() for field-level details
print_r($e->getRaw());
} catch (RateLimitException $e) {
// Too many requests - back off and retry
sleep(5);
} catch (PayBridgeException $e) {
// Catch-all for any other API error
echo $e->getStatusCode();
echo $e->getErrorType(); // "api_error", "invalid_request_error", etc.
echo $e->getErrorCode(); // specific identifier, may be null
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.