Razorpay PHP

Official PHP client for the Razorpay payments, orders, and subscriptions API

SDK
Composer
v2.9.3
206stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
68/100Good
Development Activity64
Maintenance48
Community80
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
68/100Good
Architecture72
Code Quality76
Innovation60
Learning Curve64

Razorpay PHP is the official client library for Razorpay’s payment gateway API, giving PHP applications typed access to orders, payments, refunds, subscriptions, invoices, and payment links. Rather than exposing errors as return values, the library follows an exception-based error model and accepts request options as associative arrays, keeping call sites consistent across the dozens of Razorpay resources it wraps (payments, customers, cards, tokens, transfers, settlements, disputes, and more).

Beyond basic charge creation, the library covers Razorpay’s broader payments platform: recurring billing via subscriptions and e-mandate/NACH registration, virtual accounts, QR codes, OAuth-based Partner integrations, and webhook signature verification for securely validating incoming payment notifications. It is the standard integration path for PHP applications (including Laravel/WordPress e-commerce stacks) accepting payments through Razorpay in India and supported markets.

What You Get

  • Typed resource classes covering payments, orders, refunds, customers, cards, tokens, transfers, and settlements
  • Subscription and recurring-payment support, including e-mandate and NACH (paper/register) registration flows
  • Webhook signature verification helpers for validating incoming Razorpay event payloads
  • OAuth client support for Razorpay Partner integrations authenticating on behalf of merchant accounts
  • Consistent exception-based error handling instead of error-code return values across every resource

Common Use Cases

  • Accepting one-time and recurring payments in a PHP e-commerce or SaaS application via Razorpay Orders and Payments
  • Setting up subscription billing with e-mandate/NACH-based recurring debit registration for Indian bank accounts
  • Verifying Razorpay webhook signatures server-side before processing payment status updates
  • Building Razorpay Partner integrations that manage payments on behalf of connected merchant accounts via OAuth

Under The Hood

Architecture Razorpay.php is the package’s autoload entry point pulling in the Razorpay\Api namespace under src/, where Api.php acts as the central client that instantiates resource classes (Order.php, Payment.php, Subscription.php, Invoice.php, Transfer.php, and more, each extending a shared Entity.php/Resource.php base) and delegates HTTP calls to Request.php. OAuth.php/OAuthClient.php/OAuthValidator.php implement the separate OAuth-based Partner authentication flow, and Utility.php provides webhook signature verification. Every resource follows the same create/fetch/all/update pattern against Resource.php, keeping the dozens of endpoint wrappers structurally consistent. Tech Stack Supports PHP 7.3 through 8.1+ with no heavyweight framework dependency, making it usable directly in plain PHP, Laravel, or WordPress integrations; it ships its own lightweight HTTP request handling rather than depending on Guzzle or a PSR HTTP client. Code Quality The tests/ directory contains one dedicated PHPUnit test file per resource (PaymentTest, SubscriptionTest, RefundTest, SignatureVerificationTest, TokenTest, TransferTest, and around 25 more), plus a CoverageTest.php and separate non_composer_tests/ for validating the manual-download integration path — indicating deliberate parity testing across the library’s broad resource surface. API Design The library documents an explicit convention (namespaced under Razorpay\Api, exceptions instead of error returns, array-based options) that keeps every resource’s call shape predictable once learned, though the sheer number of resource classes and Razorpay-specific concepts (e-mandate, NACH, virtual accounts) means new integrators need to consult Razorpay’s own API docs alongside the library’s README.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search