webgriffe / payum-lock-request-extension
A Payum extension providing the ability to lock concurrent requests.
Installs: 9 253
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 6
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- payum/core: ^1.7
- symfony/lock: ^6.0
Requires (Dev)
- pds/skeleton: ^1.0
- php-http/discovery: ^1.19
- phpunit/phpunit: ^9.0 || ^10.0
- symplify/easy-coding-standard: ^12.0
This package is auto-updated.
Last update: 2024-11-27 17:10:42 UTC
README
A Payum extension providing the ability to lock concurrent requests
This extension provides the ability to lock concurrent requests to a Payum gateway (for example when the PSP send both a notify action and a traditional capture action in the same moment). It uses Symfony Lock Component to provide a simple and reliable locking mechanism.
Installation
composer require webgriffe/payum-lock-request-extension
Usage
<?php // Use your preferred \Symfony\Component\Lock\PersistingStoreInterface implementation $persistingStore = new Symfony\Component\Lock\Store\SemaphoreStore(); $lockFactory = new \Symfony\Component\Lock\LockFactory($persistingStore); $lockRequestExtension = new \Webgriffe\PayumLockRequestExtension\LockRequestExtension( $lockFactory, 'my_lock_prefix', // Optional, default value is 'webgriffe_payum_lock_request_extension' 30.0, // Optional, default value is 30.0 true // Optional, default value is true ); /** @var \Payum\Core\Gateway $gateway */ $gateway->addExtension($lockRequestExtension); // here the extension will be called to wrap the execute acton in a lock $gateway->execute(new FooRequest);
Configuration
The extension can be configured with the following options:
- Lock prefix: to ensure lock key is unique, default is
webgriffe_payum_lock_request_extension
. - Lock TTL: the maximum time in seconds that a lock can be hold, default is
30
. - Lock autorelease: release the lock or not when the lock instance is destroyed, default is
true
.