PHPackages                             jeddsaliba/laravel-apcopay - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. jeddsaliba/laravel-apcopay

ActiveLibrary[Payment Processing](/categories/payments)

jeddsaliba/laravel-apcopay
==========================

Laravel integration for ApcoPay payment gateway (hosted page and payment status)

3.0.0(yesterday)05↑2900%MITPHPPHP ^8.2

Since Jul 31Pushed yesterdayCompare

[ Source](https://github.com/jeddsaliba/laravel-apcopay)[ Packagist](https://packagist.org/packages/jeddsaliba/laravel-apcopay)[ Docs](https://github.com/jeddsaliba/laravel-apcopay)[ RSS](/packages/jeddsaliba-laravel-apcopay/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Laravel ApcoPay
===============

[](#laravel-apcopay)

Laravel integration for the ApcoPay payment gateway: hosted payment page and payment status (GetPayment / PreparePayment).

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10.x, 11.x or 12.x
- GuzzleHTTP 7.x

Installation
------------

[](#installation)

```
composer require jeddsaliba/laravel-apcopay
```

Publish the config file (optional; defaults are used from the package):

```
php artisan vendor:publish --tag=apcopay-config
```

Configuration
-------------

[](#configuration)

Add to your `.env`:

```
APCO_PAY_ENV=local
APCO_PAY_USERNAME=
APCO_PAY_PASSWORD=
APCO_PAY_PID=
APCOPAY_BASE_URL=https://www.apsp.biz/GPG/RESTAPI/api/OnlinePayments
APCOPAY_SANDBOX_BASE_URL=https://www.apsp.biz/GPGTest/RESTAPI/api/OnlinePayments
```

`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

[](#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`:

```
APCO_PAY_RETRY_BASE_DELAY=1
APCO_PAY_RETRY_MAX_DELAY=10
APCO_PAY_RETRY_BACKOFF_MULTIPLIER=2.0
```

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
-----

[](#usage)

Inject `Jeddsaliba\ApcoPay\Contracts\ApcoPayServiceInterface`:

```
use Jeddsaliba\ApcoPay\Contracts\ApcoPayServiceInterface;
use Jeddsaliba\ApcoPay\Enums\PaymentStateFields;

// Get hosted page URL for redirect
$response = $apcoPay->getHostedPage(
    sessionReference: $sessionReference,
    amount: $amount,
    returnUrl: $returnUrl
);
$paymentUrl = $response['paymentURLField'];

// Get payment status
$payment = $apcoPay->getPayment($sessionReference);

// Get payment with retries (e.g. while processing)
$payment = $apcoPay->getPaymentWithRetry($sessionReference, 3);

// Check state
PaymentStateFields::PENDING->value;   // 1
PaymentStateFields::CANCELLED->value; // 2
PaymentStateFields::SUCCESS->value;   // 3
PaymentStateFields::FAILED->value;    // 4
```

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

[](#using-the-facade)

When the package is installed in a Laravel app, you can use the `ApcoPay` facade:

```
use Jeddsaliba\ApcoPay\Facades\ApcoPay;

$response = ApcoPay::getHostedPage($sessionReference, $amount, $returnUrl);
$payment = ApcoPay::getPayment($sessionReference);
$payment = ApcoPay::getPaymentWithRetry($sessionReference, 3); // with retries
```

Testing
-------

[](#testing)

```
composer test
```

Or with PHPUnit directly:

```
./vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT). Please see the [License File](LICENSE) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b559eadc57e518a855212ca3c95827b9ed955c09b143490c82ba11d3e81e63e8?d=identicon)[jeddsaliba](/maintainers/jeddsaliba)

---

Top Contributors

[![jeddsaliba](https://avatars.githubusercontent.com/u/27769176?v=4)](https://github.com/jeddsaliba "jeddsaliba (1 commits)")

---

Tags

laravelpaymentgatewayapcopay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jeddsaliba-laravel-apcopay/health.svg)

```
[![Health](https://phpackages.com/badges/jeddsaliba-laravel-apcopay/health.svg)](https://phpackages.com/packages/jeddsaliba-laravel-apcopay)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.7M3.3k](/packages/craftcms-cms)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4952.7k](/packages/sebdesign-laravel-viva-payments)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

3827.1k](/packages/linkxtr-laravel-qrcode)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
