sohagsrz / nowpayments-php-sdk
A professional, OOP-compliant PHP SDK for the NowPayments.io API.
dev-main
2026-03-05 19:56 UTC
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2026-03-05 19:58:49 UTC
README
A professional, standalone, and OOP-compliant PHP library for integrating with the NowPayments.io API.
Features
- Supports all main methods: Invoices, Payments, Estimates, Currencies, and Status.
- Environment Aware: Seamlessly switch between Sandbox and Production.
- Secure Webhooks: Built-in IPN signature verification.
- Exception Handling: Custom exceptions with raw API error detail.
- Standalone: Perfect for any PHP project or framework.
Installation
composer require sohagsrz/nowpayments-php-sdk
Basic Usage
use NowPayments\NowPayments; $sdk = new NowPayments('YOUR-API-KEY', true); // true for Sandbox // Get API Status $status = $sdk->getStatus(); // Create a professional crypto invoice $invoice = $sdk->createInvoice([ 'price_amount' => 10.00, 'price_currency' => 'usd', 'order_id' => '12345', 'order_description' => 'Premium Upgrade', 'success_url' => 'https://yoursite.com/success', 'ipn_callback_url' => 'https://yoursite.com/webhook' ]); // Redirect user to payment header('Location: ' . $invoice['invoice_url']);
Webhook Verification
$receivedSig = $_SERVER['HTTP_X_NOWPAYMENTS_SIG']; $payload = json_decode(file_get_contents('php://input'), true); $sdk = new NowPayments('API-KEY', false, 'YOUR-IPN-SECRET'); if ($sdk->verifyIPNSignature($payload, $receivedSig)) { // Payment is authentic! }
Requirements
- PHP >= 7.4
- GuzzleHTTP ^7.0
License
MIT