Download the PHP package xpiston/monetico without Composer

On this page you can find all versions of the php package xpiston/monetico. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package monetico

# ๐Ÿ’ณ Monetico for PHP **Monetico Paiement, without the folklore.** Sealed payment forms, verified notifications, capture and refund โ€” for Laravel, Symfony, or no framework at all. [![PHP](https://img.shields.io/badge/PHP-8.2%20%E2%86%92%208.5-777BB4?logo=php&logoColor=white)](https://php.net) [![Laravel](https://img.shields.io/badge/Laravel-12%20%7C%2013-FF2D20?logo=laravel&logoColor=white)](https://laravel.com) [![Symfony](https://img.shields.io/badge/Symfony-6.4%20%7C%207-000000?logo=symfony&logoColor=white)](https://symfony.com) [![Tests](https://img.shields.io/badge/tests-444%20passing-22C55E)](#-tests) [![PHPStan](https://img.shields.io/badge/PHPStan-max-2563EB)](#-tests) [![License](https://img.shields.io/badge/license-MIT-blue)](#license)

Monetico Paiement is the card payment platform of Crรฉdit Mutuel and CIC โ€” the gateway a great many French shops are handed when they open a merchant account, and one that has to be integrated by hand: a sealed HTML form, a server-to-server notification to answer within fifteen seconds, and two more services for collecting and refunding.

This package does those four things and nothing else. It has no opinion about your orders, writes nothing to your database, and reaches the network only when you ask it to collect or refund money.

Every class in src/ is commented with why it does what it does, not what it does. The protocol has a dozen details that look like trivia until a payment fails at nine on a Saturday morning, and they are written down next to the code that handles them.

โœจ What's inside

๐Ÿš€ Quick start

Monetico gives you three things when the contract is signed: a terminal number (TPE, 7 characters), a security key (40 hexadecimal characters) and a company code (societe). They are different in the sandbox and in production โ€” all three of them.

1. Send the customer to the payment page

$form->toInputs() gives you the hidden fields alone, for a template that wants to own the <form> element. $form->toUrl() gives you the URL for the iframe integration.

2. Answer the notification

The platform posts the result of every attempt to a URL you give it when the contract is set up โ€” not to your return URLs, which are only where the customer's browser lands.

Three things that are not obvious and are not negotiable:

3. Collect the money, and send it back

Deferred, partial and pre-authorised payments are not collected until you ask.

These two call the platform over HTTPS, so they need a PSR-18 client. Pass one to the constructor, or let php-http/discovery find the one your application already has:

Rendering a form and verifying a notification need no HTTP client at all, which is why the constructor does not ask for one.

๐Ÿงฐ Laravel

The service provider is discovered automatically. Set three values:

Register the route, and take it out of CSRF protection โ€” the platform is not a browser and carries no token:

A 419 here is invisible from the shop's side: the platform retries once, emails the merchant, and the payment sits unrecorded.

NotificationRequest::fields() is not decoration. $request->all() merges the query string into the body, so a notification route reached with ?utm_source=x would put a field the platform never sealed into the string the seal is computed over โ€” and every payment would fail verification with nothing in the logs to say why.

php artisan vendor:publish --tag=monetico-config writes the config file, with the reasoning for each option in it.

Laravel 12 and 13 are in the test matrix. The bridge touches nothing newer than ServiceProvider, Request and Response, so it works on 11 as well - but 11 is not tested, because Composer now refuses to install any 11.x release: they are all covered by security advisories.

๐Ÿงฐ Symfony

Monetico and NotificationVerifier are then autowired like anything else, and the PSR-18 client is taken from the container as soon as symfony/http-client is installed.

The notification route has to be reachable without a session and without authentication โ€” if a firewall covers the path, give it security: false.

๐Ÿ” The seal, in one page

Every message in both directions carries a MAC: 40 hexadecimal characters, HMAC-SHA1 per RFC 2104, keyed with the merchant's security key.

The key is text, the HMAC needs bytes. Monetico hands over 40 hexadecimal characters; the documentation calls the 20-byte form the operational representation. Hashing with the 40-character text produces a perfectly well-formed seal that the platform rejects every single time, with an error message that blames your form.

The string is built, not formatted. Sorted name=value pairs joined by *, in byte order โ€” digits, then upper case, then lower case, so TPE comes before date. PHP's ksort() defaults to SORT_REGULAR, which compares two numeric-looking keys as numbers; this sorts bytes.

For a notification, every field counts. The documentation is firm: all parameters sent by our server, even the ones unknown or unused by your server. So AlphabeticalSeal owns no list of field names, and it is important that it never does โ€” because the sandbox adds a field with a random name and random content to every notification, for the stated purpose of proving that merchants handle parameters they have never seen.

There are two algorithms in production. Monetico changed the calculation, and it seals a notification the way the order was created โ€” so an instalment plan taken before your migration still calls back, months later, sealed the old way. Both are accepted by default; SealVerifier::strict() turns the old one off once nothing can still report in.

Escape last. The documentation says to HTML-encode the fields immediately after the MAC calculation. Seal Rue de l&#x27;ร‰glise instead of Rue de l'ร‰glise and every payment from an address with an apostrophe fails while the rest work. PaymentRequest::fields() returns raw values; PaymentForm escapes them on the way out, once.

And a seal is compared with hash_equals, case-insensitively โ€” the platform documents the seal it sends in upper case and the one it expects in lower.

๐Ÿงฑ How it's built

Decisions visible in the code

โœ… Tests

PHP 8.2 or later and Composer, and nothing else:

No network, no database, no browser: the suite runs in under half a second.

Three groups are worth describing, because they are the ones that would catch a mistake in this package rather than restate it:

Against the documentation, not against itself. Monetico prints the exact string to hash for an immediate payment, for a split payment and for the older notification calculation. Those three strings are in the tests, byte for byte, and the canonical string is compared to them. The HMAC itself is checked against RFC 2202's published vectors, so the key derivation and the hash are verified by numbers somebody else published.

Against a fake platform, in both directions. tests/Support/FakePlatform seals a notification the way Monetico would. A test that only asserts "a wrong seal is refused" proves nothing โ€” an implementation that refuses everything passes it. The pair that means something is: a notification sealed exactly as the platform seals it is accepted, and the same notification with one byte changed is not. The fake also does what the sandbox does and adds a field with a random name, which is the test this library exists to pass.

Against the real frameworks. The Laravel bridge is tested in a Laravel application booted by Testbench, and the Symfony bundle by compiling a real Symfony container. Both earned their keep immediately: the bundle had a service definition that threw on every application that installed it, and a unit test would not have noticed.

The historical key transformation gets a test of its own. The official PHP kit ran the key through a routine that patched up its last two characters; this package is a plain hex2bin, and the suite proves the two agree โ€” exhaustively over every pair of characters the routine can touch, and over random keys โ€” rather than asking you to take the docblock's word for it.

๐Ÿค” Why another package?

There is one other PHP SDK for Monetico, dansmaculotte/monetico-php, and it deserves credit: it is MIT, it has been there for years, and plenty of shops have been paid through it. It is also written for PHP 7.2, its last release is from June 2024, and the three things below were run on PHP 8.5 against version 2.0.11 rather than read off its source:

A notification carrying the random field the sandbox adds to every payment fails verification (validate() returns false)
A Conecs meal voucher โ€” brand=CO, which the documentation lists throws brand value is invalid: CO before the seal is even checked
Constructing the client, and building any form three deprecation notices, one of them (${var} in strings) for syntax removed in PHP 9

The first is the one that matters: the seal is recomputed from a hardcoded list of field names, so any field Monetico adds โ€” and it adds one on purpose, in the sandbox, to catch exactly this โ€” makes a good payment look forged. The seals are also compared with === rather than hash_equals.

Beyond that, this package exists because the parts above the seal are where the afternoons go: the amount arithmetic a capture has to satisfy, the two incompatible rule sets for a reference, the three meanings of cdr, the timezone, the acknowledgement that depends on the seal and not the payment, and framework wiring that does not quietly put a query parameter into a signature.

โš ๏ธ Not included

๐Ÿ“š The documentation this was built from

Where the documentation contradicts itself, the code says so and the tests pin the behaviour: the notification date appears in three different formats across three pages (all three are read), and the English edition translates the names of the return-URL fields in its field table while its own HTML examples keep url_retour_ok and url_retour_err (which are the ones sent).

License

MIT.


All versions of monetico with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-hash Version *
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package xpiston/monetico contains the following files

Loading the files please wait ...