nowo-tech / openpay-php
Clean-room PHP SDK for the public Openpay REST API. PHP 8.3+ and FrankenPHP worker-safe (no static merchant credentials).
Fund package maintenance!
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- igor-php/igor-php: ^0.9.7 || ^0.10.0
- nowo-tech/phpstan-frankenphp: ^1.1
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- rector/rector: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
⭐ Found this useful? Install from Packagist · Star on GitHub.
Clean-room PHP SDK for the public Openpay REST API. Namespace Nowo\Openpay\. License MIT. Release 1.1.4.
Independent implementation from public docs — not a redistribution of openpay/sdk. No process-wide static merchant credentials (FrankenPHP worker-safe, including when the kernel is not reset between requests).
This bundle is FrankenPHP worker mode friendly.
Table of contents
Features
- Merchant resources: charges, customers, cards, tokens, webhooks (plus customer-scoped charges and cards).
- Request-scoped
Credentials/Session/Client— no static merchant state, safe in FrankenPHP workers. - Injectable
HttpClient(defaultCurlHttpClientwith connect/request timeouts and OS-store TLS). - Typed API errors (
OpenpayApiExceptionwith HTTP status, error code, category, request id). - Countries: Mexico, Colombia, Peru (sandbox and production hosts).
Installation
composer require nowo-tech/openpay-php:^1.1
See docs/INSTALLATION.md.
Quick start
use Nowo\Openpay\Client; use Nowo\Openpay\Country; use Nowo\Openpay\Credentials; use Nowo\Openpay\Session; $credentials = new Credentials( merchantId: getenv('OPENPAY_MERCHANT_ID') ?: '', privateKey: getenv('OPENPAY_PRIVATE_KEY') ?: '', country: Country::Mx, sandbox: true, publicIp: $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1', ); $session = new Session($credentials); $customer = $session->run(static fn (Client $client) => $client->customers->create([ 'name' => 'Demo', 'email' => 'demo@example.test', ]));
Requirements
- PHP 8.3+ (
>=8.3 <8.6) withext-curlandext-json - No framework dependency (plain PHP library; the Symfony 8 demo is illustrative)
Documentation
- Installation
- Configuration
- Usage
- Contributing
- Code of Conduct
- Changelog
- Upgrading
- Release
- Security
- Engram
- Spec-driven development
- GitHub Spec Kit
Additional documentation
- Coverage
- FrankenPHP demo
- FrankenPHP worker mode audit
- GitHub Actions CI requirements
- PSR evaluation (REQ-CS-007)
- Branching
Tests and coverage
composer test
composer test-coverage
make qa
- Tests: PHPUnit (unit)
- PHP: 100% lines (131/131; gate ≥ 99% via
make release-check, see docs/COVERAGE.md) - TS/JS: N/A
- Python: N/A
License
MIT — see LICENSE.
Independent clean-room client for the public Openpay REST API. Not a redistribution of openpay/sdk. “Openpay” is a trademark of its owners.
