payum / offline
The Payum extension. Payments settled outside an online PSP: cash, bank transfer, store credit.
Requires
- payum/core: 2.0.x-dev
Requires (Dev)
- php-http/guzzle7-adapter: ^1.0
- phpunit/phpunit: ^9.5
- symfony/phpunit-bridge: ^8.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- 2.x-dev
- 2.0.0-alpha1
- 1.7.x-dev
- 1.7.7
- 1.7.6
- 1.7.5
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.0
- 1.6.x-dev
- 1.6.3
- 1.6.1
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.1
- 1.3.7
- 1.3.0
- 1.2.0
- 1.1.4
- 1.0.0.x-dev
- 1.0.0
- 1.0.0-BETA1
- 0.15.x-dev
- 0.15.1
- 0.14.x-dev
- 0.14.0
- 0.13.x-dev
- 0.13.0
- 0.12.x-dev
- 0.12.0
- 0.11.x-dev
- 0.11.0
- 0.10.x-dev
- 0.10.0
- 0.9.x-dev
- 0.9.0
- 0.8.x-dev
- 0.8.0
- 0.7.x-dev
- 0.7.0
- 0.6.x-dev
- 0.6.0
- dev-fix-subtree-split-action
- dev-1.0.0-BETA1
This package is auto-updated.
Last update: 2026-11-09 11:34:12 UTC
README
Payum is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider:
Offline
Payments that are settled outside an online payment provider: cash, cheque, bank transfer, store credit. No external API is called. The gateway records each operation in the payment's details and reports its status.
Register it
Register the gateway once for each payment method you offer:
<?php use Payum\Core\PayumBuilder; use Payum\Offline\OfflineConfig; $payum = (new PayumBuilder()) ->addDefaultStorages() ->registerGateway('cash', new OfflineConfig()) ->registerGateway('bank_transfer', new OfflineConfig(paid: false)) ->getPayum();
A captured payment is paid at once unless the config says paid: false. Then it stays pending until you
set its paid detail to true and capture it again. A paid detail set on the payment before the capture
always wins.
It answers capture, authorize, refund (also partial), cancel, sync and payout.
Replace a handler
Give your own handler for an operation that has to do more, such as taking the amount off a customer's store credit. It replaces the gateway's handler for that command on this registration only:
<?php use Payum\Core\Command\CaptureCommand; use Payum\Core\Handler\CaptureHandlerInterface; use Payum\Core\Handler\Context; use Payum\Core\Result\CaptureResult; use Payum\Core\Result\Failure; use Payum\Core\Result\FailureReason; final class StoreCreditCaptureHandler implements CaptureHandlerInterface { public function __construct(private readonly StoreCreditLedger $ledger) { } public function handle(CaptureCommand $command, Context $context): CaptureResult { $payment = $context->payment(); if (! $this->ledger->withdraw($payment->getClientId(), $context->amount())) { return CaptureResult::failed(new Failure(FailureReason::InsufficientFunds)); } return CaptureResult::captured(); } } $payum = (new PayumBuilder()) ->addDefaultStorages() ->addGlobalService(StoreCreditLedger::class, $ledger) ->registerGateway('store_credit', new OfflineConfig(handlers: [StoreCreditCaptureHandler::class])) ->getPayum();
A class name is autowired, with services registered by addGlobalService(). You can pass an instance
instead. The status your handler returns is written to the payment's status detail, so the other
operations see it.
Extend it
OfflineConfig and OfflineGateway can be extended. A StoreCreditConfig extends OfflineConfig passes its
handlers to the parent constructor and can add settings of its own. A StoreCreditGateway extends OfflineGateway gives the method its own name, logo and handler list. Point the config's
getGatewayClass() at it and the gateway's configClass() at the config. See the
Offline docs for an example.
Resources
License
Offline is released under the MIT License.