Download the PHP package aflorea4/laravel-netopia-payments without Composer
On this page you can find all versions of the php package aflorea4/laravel-netopia-payments. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aflorea4/laravel-netopia-payments
More information about aflorea4/laravel-netopia-payments
Files in aflorea4/laravel-netopia-payments
Package laravel-netopia-payments
Short Description Laravel package for Netopia Payments integration
License MIT
Informations about the package laravel-netopia-payments
Laravel Netopia Payments
A Laravel package for integrating with Netopia Payments (Romania) payment gateway.
Requirements
- PHP 7.4 or higher
- Laravel 8.0 or higher
- OpenSSL extension
- DOM extension
Installation
You can install the package via composer:
Configuration
Publish the configuration file:
This will create a config/netopia.php
file in your app that you can modify to set your configuration.
Configuration Options
Add the following variables to your .env
file:
Verifying Your Certificate and Private Key
Before using the package in production, it's important to verify that your certificate and private key are valid and working correctly. You can use the following commands to check them:
Verify the Public Certificate
This command should display information about your certificate, including the issuer, validity period, and public key details. If the command returns an error, your certificate may be invalid or corrupted.
Verify the Private Key
This command should display "RSA key ok" if your private key is valid. If it asks for a password, your key may be password-protected, which is not supported by this package.
Test Key Pair Matching
To verify that your public certificate and private key are a matching pair (which is essential for encryption/decryption to work):
Both commands should produce the same MD5 hash. If they don't match, your certificate and private key are not a valid pair, which will cause encryption/decryption failures.
Usage
Creating a Payment Request
Payment Redirect View
Create a view file resources/views/payment/redirect.blade.php
:
Handling Payment Notifications
The package automatically registers routes for handling payment notifications:
POST /netopia/confirm
- For Instant Payment Notifications (IPN)GET /netopia/return
- For redirecting the user after payment
These routes are handled by the package's internal controller and will dispatch events that you can listen for in your application. You don't need to create these routes yourself.
You can listen for the following events to handle payment notifications:
Creating a Payment Listener
Testing with a Test Transaction
Here's a complete example of how to handle a test transaction of 1.00 RON without using queues or listeners:
1. Create a Controller to Handle the Payment
2. Register the Routes
Note about routes: The example below registers custom routes for payment confirmation and return:
These custom routes are different from the auto-registered package routes (/netopia/confirm
and /netopia/return
). Use custom routes when:
- You want complete control over the payment flow
- You need custom logic that isn't covered by the event listeners
- You're not using the package's event system
If you're using the package's event system, you can use the auto-registered routes instead.
3. Create the Necessary Views
Create the redirect view as shown in the main usage example, and create success, pending, failed, and error views as needed.
4. Test Card Details
When testing in the sandbox environment, you can use the following test card details to simulate a successful transaction:
5. Testing Process
- Make sure your
.env
file hasNETOPIA_LIVE_MODE=false
to use the sandbox environment - Visit
/payment/initiate
to start a test payment of 1.00 RON - You'll be redirected to the Netopia sandbox payment page
- Enter the test card details provided above
- Complete the 3D Secure verification with password
123456
- The payment will be processed, and you'll be redirected back to your return URL
- The confirmation endpoint will also receive the payment notification
This approach doesn't use queues or event listeners, making it simpler for testing and development. All payment processing happens synchronously in the controller methods.
Security
The package uses the following security measures:
- Request authentication using an API Signature included in the request
- Data encryption using RSA keys with AES-256-CBC for symmetric encryption
- Secure Sockets Layer (SSL) data transport
Encryption Details
As of version 0.2.6, this package exclusively uses AES-256-CBC encryption for all payment data. This provides stronger security compared to older cipher methods like RC4. When processing payments, the initialization vector (IV) parameter is now required for all decryption operations.
Testing
This package uses PEST for testing. To run the tests, you can use the following command:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Alexandru Florea
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
The test suite includes:
- Unit tests for the NetopiaPayments class
- Feature tests for payment request generation
- Feature tests for payment response processing
- Integration tests for the controller
Writing Tests
If you want to add more tests, you can create them in the tests
directory. The package uses PEST's expressive syntax for writing tests. Here's an example of how to write a test for the NetopiaPayments class:
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-netopia-payments with dependencies
illuminate/support Version ^8.0|^9.0|^10.0
ext-openssl Version *
ext-dom Version *
guzzlehttp/guzzle Version ^7.9