Download the PHP package nedarta/yii2-omnipay without Composer
On this page you can find all versions of the php package nedarta/yii2-omnipay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-omnipay
Yii 2 Omnipay Extension
A premium, elegant, and lightweight payment processing integration for the Yii 2 framework, built on top of the powerful Omnipay library. Configure payment gateways as standard Yii 2 components with clean, modern magic delegation.
Features
- ✨ One Component, One Gateway: Simple, modular architecture that integrates seamlessly into Yii 2's dependency injection container.
- 💳 Clean Magic Delegation: Call gateway methods (like
purchase,completePurchase, etc.) directly on the component. - 🛡️ Strict & Safe: Safe lazy-initialization guards and robust type validation to prevent runtime errors.
- ⚙️ Immutable Config & Reinitialization: Built to support reactive changes in dynamic execution contexts (e.g. CLI, tests).
- 🧪 Test-Driven: Structured to work seamlessly with PHPUnit.
Installation
Install the package via Composer:
To use specific gateways, you should also require their respective Omnipay drivers:
Configuration
Add the gateway components directly to your application configuration file (usually config/web.php or common/config/main.php):
Usage Examples
1. Stripe Checkout
Because of magic-method delegation, you can call all underlying gateway methods directly on the Yii 2 component (Yii::$app->stripe).
2. PayPal Express Checkout Workflow
PayPal Express requires a redirection to PayPal's checkout page and a secondary step to capture the payment on return.
Step A: Initiate the PayPal Purchase
Step B: Capture and Complete the Purchase
Advanced Usage: Dynamic Reinitialization
In multi-tenant setups, SaaS environments, or instances where merchant credentials must be loaded dynamically from a database at runtime, you can reconfigure components on the fly.
1. Update Parameters Dynamically
To update configuration parameters for the current gateway:
2. Complete Gateway Rebuilding
To reconfigure the entire component dynamically (e.g., swapping gateway drivers, updating test mode flags, and resetting parameters all at once):
[!NOTE] The
reinitialize()method uses strict safety validation. Attempting to assign unknown or read-only properties will throw ayii\base\InvalidConfigExceptionimmediately to prevent silent typos or configuration bugs in production.
Webhooks & CSRF Validation
When integrating payment gateways, they will send asynchronous payment update notifications via webhooks (e.g. Stripe webhooks or PayPal IPN notifications) as standard HTTP POST requests.
By default, Yii 2 validates CSRF tokens on all POST requests, which will block incoming gateway webhooks with an HTTP 400 Bad Request error. To resolve this, disable CSRF validation for your webhook action inside your payment controller:
Running Tests
This library includes automated unit tests written in PHPUnit. To run tests, use the following command:
Tests are located in the /tests/ directory.
License
This project is licensed under the MIT License - see the LICENCE.md file for details.
Developed with ❤️ by Edgars Karlsons.