medyat / parapos
Php client for Parapos API
Requires
- php: ^8.2.0
- ext-curl: *
- illuminate/contracts: ^10.0|^11.0|^12.0|^13.0
- illuminate/database: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- illuminate/translation: ^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- laravel/pint: ^1.10.1
- mockery/mockery: ^1.6
- nunomaduro/mock-final-classes: ^1.2
- orchestra/testbench: ^8.13
- pestphp/pest: ^2.6.3
- pestphp/pest-plugin-laravel: ^2.2
- phpstan/phpstan: ^1.10.18
- rector/rector: ^0.15.25
- symfony/var-dumper: ^6.3.0
README
This package provides php client for Parapos API.
Requires PHP 8.2+
Upgrading a major version? See UPGRADE.md.
Using your own payment model
Point config('parapos.model') at your own Eloquent model (e.g. a uuid-keyed, tenant-aware one). It must use MedyaT\Parapos\Concerns\InteractsWithParaposPayment and implement MedyaT\Parapos\Contracts\PaymentStatus:
// config/parapos.php 'model' => \App\Models\Payment::class, // Set to false when your app owns the payments schema // (e.g. uuid primary key) and ships its own migration. 'load_migrations' => false,
The bundled (bigint) migration can be published as a starting point:
php artisan vendor:publish --tag=parapos-migrations
Running two profiles in one application
Global config assumes one profile per process. When an application collects on more than one โ say
a tenant context and an admin context sharing the same workers โ pass the profile to Parapos
instead, and nothing has to be written to global config (writes that would otherwise leak from one
request into the next under Octane or a queue worker):
$parapos = new Parapos([ 'apiKey' => '...', 'secretKey' => '...', 'model' => \App\Models\Landlord\LandlordCardPayment::class, 'response_url' => 'landlord/parapos/response/{hash}', 'appUrl' => 'https://admin.example.com', ]);
model, response_url, tenant and appUrl each fall back to config('parapos.*') (and
config('app.url')) when omitted, so an application with a single profile needs no changes.
The 3D callback needs a matching route. Extend HandleResponseAction, override what differs, and
register it wherever you like:
class LandlordParaposResponseController extends \MedyaT\Parapos\Http\HandleResponseAction { protected function model(): string { return \App\Models\Landlord\LandlordCardPayment::class; } } Route::post('landlord/parapos/response/{hash}', LandlordParaposResponseController::class);
Set 'register_routes' => false if you would rather register every callback route yourself.
๐งน Keep a modern codebase with Pint:
composer lint
โ Run refactors using Rector
composer refacto
โ๏ธ Run static analysis using PHPStan:
composer test:types
โ Run unit tests using PEST
composer test:unit
๐ Run the entire test suite:
composer test