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. [Payment Processing](/categories/payments)
4. /
5. italiamultimedia/xpay

ActiveLibrary[Payment Processing](/categories/payments)

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

A PHP component/library.

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

Since Nov 21Pushed 5mo 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 yesterday

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

42

—

FairBetter than 88% of packages

Maintenance72

Regular maintenance activity

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

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

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

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[chargebee/chargebee-php

ChargeBee API client implementation for PHP

758.5M9](/packages/chargebee-chargebee-php)

PHPackages © 2026

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