PHPackages                             italiamultimedia/xpay - 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. italiamultimedia/xpay

ActiveLibrary

italiamultimedia/xpay
=====================

A PHP component/library.

v1.1.0(3mo ago)0169MITPHPPHP ^8.4

Since Nov 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/italiamultimedia/xpay)[ Packagist](https://packagist.org/packages/italiamultimedia/xpay)[ Docs](https://github.com/italiamultimedia/xpay)[ RSS](/packages/italiamultimedia-xpay/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (20)Versions (12)Used By (0)

italiamultimedia/xpay
=====================

[](#italiamultimediaxpay)

An XPay (Nexi) implementation.

Currently implemented functionality:

- [Pagamento semplice](https://ecommerce.nexi.it/specifiche-tecniche/codicebase.html)
- [Pagamento ricorrente](https://ecommerce.nexi.it/specifiche-tecniche/pagamentoricorrente/introduzione.html)

---

Pagamento semplice
------------------

[](#pagamento-semplice)

### Extend class `AbstractSimplePaymentService`

[](#extend-class-abstractsimplepaymentservice)

- implement `SimplePaymentServiceInterface`:
    - `createCancelUrl`;
    - `createNotificationUrl`;
    - `createReturnUrl`;

```
final class SimplePaymentService extends AbstractSimplePaymentService implements SimplePaymentServiceInterface
{
    protected function createCancelUrl(string $orderId): string
    {
        ...
    }

    protected function createNotificationUrl(string $orderId): string
    {
        ...
    }

    protected function createReturnUrl(string $orderId): string
    {
        ...
    }
}
```

### Extend class `AbstractRequestInputService`

[](#extend-class-abstractrequestinputservice)

- optionally implement your own validation rules;

```
final class RequestInputService extends AbstractRequestInputService implements RequestInputServiceInterface
{
    public const KEY_LANGUAGE = 'lang';

    public const KEY_ORDER_ID = 'orderId';

    protected function getValidationRule(string $key): string
    {
        return match ($key) {
            self::KEY_ORDER_ID => '/^[a-f0-9]{42}$/',
            default => parent::getValidationRule($key),
        };
    }

    protected function validateInput(string $key, string $value): bool
    {
        if ($key === self::KEY_LANGUAGE) {
            return $this->validateLanguageCode($value);
        }

        return parent::validateInput($key, $value);
    }

    private function validateLanguageCode(string $value): bool
    {
        if (!in_array($value, ['en', 'it'], true)) {
            throw new UnexpectedValueException('Invalid data.');
        }

        return true;
    }
}
```

### Payment request

[](#payment-request)

- [Avvio pagamento](https://ecommerce.nexi.it/specifiche-tecniche/codicebase.html)

```

        ...

            document.getElementById('payment_form').submit();

```

### Return page

[](#return-page)

```
// Validate order (get info from storage)
...

/**
 * Special situation: "mac" can be missing from the request.
 * Eg. try to pay already paid transaction.
 * In that situation we don't want to have a transaction error, however we also can not trust the request.
 * Simply do not process transaction.
 */
$processTransaction = true;
try {
    // Try to get mac
    $requestInputService->getValidatedString(RequestInput::MAC);
} catch (OutOfBoundsException) {
    $processTransaction = false;
}

if ($processTransaction) {
    // Validate transaction. Uses input data (_GET or _POST).
    $requestInputService->validateInputMac();

    // Store transaction result.
    ...
}

// Redirect back to website.
...
```

---

Pagamento ricorrente
--------------------

[](#pagamento-ricorrente)

### Extend class `AbstractRecurringPaymentService`

[](#extend-class-abstractrecurringpaymentservice)

- implement `RecurringPaymentServiceInterface`:
    - `createCancelUrl`;
    - `createNotificationUrl`;
        - `createReturnUrl`;

```
final class RecurringPaymentService extends AbstractRecurringPaymentService implements RecurringPaymentServiceInterface
{
    protected function createCancelUrl(string $orderId): string
    {
        ...
    }

    protected function createNotificationUrl(string $orderId): string
    {
        ...
    }

    protected function createReturnUrl(string $orderId): string
    {
        ...
    }
}
```

### Extend class `AbstractRequestInputService`

[](#extend-class-abstractrequestinputservice-1)

- optionally implement your own validation rules;
- see the same section in "Pagamento semplice"

### First payment: Payment request

[](#first-payment-payment-request)

- [Primo pagamento](https://ecommerce.nexi.it/specifiche-tecniche/pagamentoricorrente/primopagamento.html)

```

        ...

            document.getElementById('payment_form').submit();

```

### First payment: Return page

[](#first-payment-return-page)

- see the same section in "Pagamento semplice"

### Subsequent payments

[](#subsequent-payments)

- [Pagamenti successivi](https://ecommerce.nexi.it/specifiche-tecniche/pagamentoricorrente/pagamentisuccessivi.html)
- Use `SubsequentPaymentService`, method `executeSubsequentPayment(string $numeroContratto, float $orderTotal, string $scadenza): AbstractResponseData`.
- Can also use `SubsequentPaymentService`.`getResponse`, returns `Psr\Http\Message\ResponseInterface` if run after `executeSubsequentPayment`, null otherwise.
- Check if the result is `PositiveResponseData` or `NegativeResponseData` and act accordingly.

---

Development
-----------

[](#development)

```
# Lint
composer check:lint && \
# Code style
composer check:phpcs && \
# PHPStan
composer check:phpstan && \
# Phan
composer check:phan && \
# PHPMD
composer check:phpmd && \
# Psalm
composer check:psalm
```

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance80

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 98.2% 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

Every ~79 days

Recently: every ~110 days

Total

11

Last Release

106d ago

Major Versions

v0.4.0 → v1.0.02025-02-16

PHP version history (3 changes)v0.0.1PHP ^8.2

v0.0.4PHP ^8.3

v1.0.0PHP ^8.4

### Community

Maintainers

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

---

Top Contributors

[![ariademur](https://avatars.githubusercontent.com/u/34913107?v=4)](https://github.com/ariademur "ariademur (55 commits)")[![punkrock34](https://avatars.githubusercontent.com/u/52674665?v=4)](https://github.com/punkrock34 "punkrock34 (1 commits)")

---

Tags

nexixpayitaliamultimedia

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/italiamultimedia-xpay/health.svg)

```
[![Health](https://phpackages.com/badges/italiamultimedia-xpay/health.svg)](https://phpackages.com/packages/italiamultimedia-xpay)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[aporat/store-receipt-validator

PHP receipt validator for Apple App Store and Amazon Appstore

6503.9M9](/packages/aporat-store-receipt-validator)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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