Download the PHP package jeddsaliba/laravel-apcopay without Composer
On this page you can find all versions of the php package jeddsaliba/laravel-apcopay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeddsaliba/laravel-apcopay
More information about jeddsaliba/laravel-apcopay
Files in jeddsaliba/laravel-apcopay
Package laravel-apcopay
Short Description Laravel integration for ApcoPay payment gateway (hosted page and payment status)
License MIT
Homepage https://github.com/jeddsaliba/laravel-apcopay
Informations about the package laravel-apcopay
Laravel ApcoPay
Laravel integration for the ApcoPay payment gateway: hosted payment page and payment status (GetPayment / PreparePayment).
Requirements
- PHP 8.2+
- Laravel 10.x, 11.x or 12.x
- GuzzleHTTP 7.x
Installation
Publish the config file (optional; defaults are used from the package):
Configuration
Add to your .env:
APCO_PAY_ENV accepts (case-insensitively) production, prod, or live for the live gateway, and local, sandbox, staging, or testing for the sandbox gateway. Any other value throws a RuntimeException at resolution time rather than silently falling back to the sandbox — this is deliberate, since a typo here would otherwise route real transactions to the wrong endpoint without any warning.
username, password, and pid are required. If any are left blank, resolving the service throws a RuntimeException naming the missing config key(s) instead of failing later with an opaque authentication error from ApcoPay.
After publishing the config, you can optionally customize http (e.g. timeout, connect_timeout) for the Guzzle client. Avoid setting verify => false in production — this disables TLS certificate verification for requests that carry your ApcoPay credentials in plaintext.
Retry / backoff configuration
getPaymentWithRetry() blocks synchronously between attempts using an exponential backoff (base_delay_seconds * backoff_multiplier ^ attempt, capped at max_delay_seconds). Configure it via .env or config/apcopay.php:
Because the delay is a real, blocking sleep(), avoid calling getPaymentWithRetry() directly inside a web request with a large retry count — prefer dispatching a queued job that polls instead, so you don't tie up an application worker or risk a load-balancer timeout.
Usage
Inject Jeddsaliba\ApcoPay\Contracts\ApcoPayServiceInterface:
Exceptions: the service throws Jeddsaliba\ApcoPay\Exceptions\ApcoPayException when the HTTP request to ApcoPay fails, when ApcoPay returns a response that isn't valid JSON, and when getPaymentWithRetry() exhausts all retry attempts. It throws \InvalidArgumentException for invalid input (a non-positive $amount, or $retries < 1).
Each request sent to ApcoPay includes a freshly generated MessageId (a UUID) so that retried or duplicated requests can be deduplicated/reconciled on ApcoPay's side.
Note: this package only wraps ApcoPay's synchronous PreparePayment/GetPayment calls. It does not implement or verify any asynchronous payment notification/webhook ApcoPay may send; if your integration relies on that, you'll need to build and secure that endpoint yourself (verify the request against ApcoPay's documented signing/authentication mechanism before trusting it).
Using the Facade
When the package is installed in a Laravel app, you can use the ApcoPay facade:
Testing
Or with PHPUnit directly:
License
The MIT License (MIT). Please see the License File for more information.
All versions of laravel-apcopay with dependencies
guzzlehttp/guzzle Version ^7.0
illuminate/support Version ^10.0|^11.0|^12.0