PHPackages                             webgriffe/lib-monetaweb2 - 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. webgriffe/lib-monetaweb2

ActiveLibrary[Payment Processing](/categories/payments)

webgriffe/lib-monetaweb2
========================

Webgriffe Setefi MonetaWeb 2.0 PHP library

1.0.0(7y ago)119.2k2MITPHP

Since Sep 29Pushed 7y ago1 watchersCompare

[ Source](https://github.com/webgriffe/lib-monetaweb2)[ Packagist](https://packagist.org/packages/webgriffe/lib-monetaweb2)[ RSS](/packages/webgriffe-lib-monetaweb2/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (7)Used By (0)

Webgriffe MonetaWeb 2.0 PHP library
===================================

[](#webgriffe-monetaweb-20-php-library)

[![Run Status](https://camo.githubusercontent.com/7fa9a433f1218c7fec93c81a2e740de948cb69dc15ee8b0270d5fa59e7abac53/68747470733a2f2f7472617669732d63692e6f72672f7765626772696666652f6c69622d6d6f6e657461776562322e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/webgriffe/lib-monetaweb2.svg?branch=master)

This library provides a complete integration for the XML Hosted 3DSecure protocol of Setefi MonetaWeb 2.0 payment gateway. It was developed following the technical documentation provided by Setefi released in July 2017.

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

[](#installation)

In order to use this library, first of all import it using composer:

```
composer require webgriffe/lib-monetaweb2

```

Usage
-----

[](#usage)

### Payment initialization

[](#payment-initialization)

You can generate a payment initialization URL using the `GatewayClient` class:

```
$gatewayClient = new Webgriffe\LibMonetaWebDue\Api\GatewayClient();
$getPaymentPageInfo = $gatewayClient->getPaymentPageInfo(
    'https://ecommerce.keyclient.it/ecomm/ecomm/DispatcherServlet',
    '99999999',
    '99999999',
    1428.7,
    'EUR',
    'ITA',
    'http://www.merchant.it/notify/',
    'http://www.merchant.it/error/',
    'TRCK0001',
    'Descrizione',
    'Nome Cognome',
    'nome@dominio.com',
    'Campo Personalizzabile'
);

```

The `getPaymentPageInfo` method returns a `GatewayPageInfo` value object that encapsulates 3 values:

- Payment ID, unique ID of the payment session
- Security Token, an hash that should be compared to the one returned in the response of the notify request (server-to-server notification, of which we talk below)
- Hosted Page URL, the URL to which the user must be redirected in order to perform the payment

### Server to server notification

[](#server-to-server-notification)

Once that you redirected the user to the `Hosted Page URL` a server-to-server notification will be perfomed by MonetaWebDue to one of the 2 urls that you specified when you called `getPaymentPageInfo`. In the example of the payment initialization the user will be redirected to `http://www.merchant.it/notify/` in case of successful operation and to `http://www.merchant.it/error/` otherwise.

You can handle this request by using the `handleNotify` method of the `GatewayClient` class:

```
$gatewayClient = new Webgriffe\LibMonetaWebDue\Api\GatewayClient();
...
// $psrRequest must be an instance of an object that implements the \Psr\Http\Message\RequestInterface
$paymentResult = $gatewayClient->handleNotify($psrRequest);

```

The result of the `handleNotify` method could be a `PaymentResultInfo` object or a `PaymentResultErrorInfo`:

- The former object is returned when the notify request comunicates that the payment was handled successfully (this does not means that the payment was successful!). The properties of this object are mapped 1to1 with the successful notify response parameters, so refer to the payment gateway's integration documentation for more details about them.
- Instead, the latter object is returned when the notify request comunicates an error. This means that something went unexpectedly wrong during the payment. This has nothing to do with, for example, a "canceled" order: cases like this are not unexpected and so they generates a PaymentResultInfo object (as explained above). Even the properties of this object are mapped 1to1 with the parameters of the "faulty notify response", so refer to the payment gateway's integration documentation for more details about them.

The Security Token is a value that is comunicated by Setefi both in the payment initialization response and the server to server notification. You should compare them to be ensure the integrity of the payment. In order to do this, the `GatewayClient` class has a method called `verifySecurityToken` that accepts the initialization's security token and the payment result info (returned by the handle notify) as parameters and returns a boolean:

```
$gatewayClient = new Webgriffe\LibMonetaWebDue\Api\GatewayClient();
...
$match = $gatewayClient->verifySecurityToken($storedSecurityToken, $paymentResult);

```

So an example of a real implementation for the server to server notification could be this:

```
$gatewayClient = new Webgriffe\LibMonetaWebDue\Api\GatewayClient();
...
$paymentResult = $gatewayClient->handleNotify($psrRequest);
if ($paymentResult instanceof PaymentResultErrorInfo) {
    ..
} else {
    /** @var PaymentResultInfo $paymentResult */
    if (!$paymentResult->isCanceled()) { // the security token is not returned if the payment was canceled
        if (!$gatewayClient->verifySecurityToken($storedSecurityToken, $paymentResult)) {
            // error
            ..
        }
    }
    ..
}

```

Contributing
------------

[](#contributing)

Fork this repository, make your changes and submit a pull request. Please run the tests and the coding standards checks before submitting a pull request. You can do it with:

```
vendor/bin/phpspec run
vendor/bin/phpcs --standard=PSR2 src/

```

License
-------

[](#license)

This library is under the MIT license. See the complete license in the LICENSE file.

Credits
-------

[](#credits)

Developed by [Webgriffe®](http://www.webgriffe.com/).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~94 days

Total

5

Last Release

2776d ago

Major Versions

0.2.1 → 1.0.02018-10-11

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/11092003742f6168d050e4b68b4af410ced03e91d86559140694388ec1704197?d=identicon)[azambon](/maintainers/azambon)

---

Top Contributors

[![azambon](https://avatars.githubusercontent.com/u/2920227?v=4)](https://github.com/azambon "azambon (39 commits)")[![LucaGallinari](https://avatars.githubusercontent.com/u/5822554?v=4)](https://github.com/LucaGallinari "LucaGallinari (28 commits)")[![fabianaromagnoli](https://avatars.githubusercontent.com/u/23638004?v=4)](https://github.com/fabianaromagnoli "fabianaromagnoli (12 commits)")

---

Tags

monetawebmonetaweb2paymentpayment-gatewaypaymentgatewaysetefiwebgriffe

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/webgriffe-lib-monetaweb2/health.svg)

```
[![Health](https://phpackages.com/badges/webgriffe-lib-monetaweb2/health.svg)](https://phpackages.com/packages/webgriffe-lib-monetaweb2)
```

###  Alternatives

[imdhemy/google-play-billing

Google Play Billing

491.3M5](/packages/imdhemy-google-play-billing)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[contica/facturador-electronico-cr

Un facturador de código libre para integrar facturación electrónica en Costa Rica a un proyecto PHP

2128.8k](/packages/contica-facturador-electronico-cr)[mrprompt/cielo

Integration with Cielo gateway.

481.9k1](/packages/mrprompt-cielo)[messagecloud/gateway-php

A PHP library to help you integrate the MessageCloud Gateway.

137.2k](/packages/messagecloud-gateway-php)

PHPackages © 2026

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