PHPackages                             digitsrl/php-wom-connector - 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. [API Development](/categories/api)
4. /
5. digitsrl/php-wom-connector

ActiveLibrary[API Development](/categories/api)

digitsrl/php-wom-connector
==========================

A PHP connector library for the WOM Platform, that allows clients to develop custom Instruments (WOM sources) and Merchants (WOM consumers).

2.0(3y ago)0271MITPHPPHP &gt;=7.0

Since Jul 19Pushed 3y ago2 watchersCompare

[ Source](https://github.com/WOM-Platform/PHP-Connector)[ Packagist](https://packagist.org/packages/digitsrl/php-wom-connector)[ Docs](https://wom.social)[ RSS](/packages/digitsrl-php-wom-connector/feed)WikiDiscussions master Synced 1mo ago

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

PHP Connector for the WOM Platform
==================================

[](#php-connector-for-the-wom-platform)

Setup
-----

[](#setup)

Installation of the PHP WOM Connector is only a [Composer](https://getcomposer.org/) command away:

```
composer require digitsrl/php-wom-connector:dev-master

```

This will automatically install all packages required by the Connector and check compatibility with your setup.

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

[](#configuration)

Check out `/test/example_instrument.php`, `/test/example_pos.php`, and `/test/example_check.php` files for samples of how to use the connector.

It is suggested to set the default timezone to UTC before using the Connector.

```
date_default_timezone_set("UTC");
```

By default, the WOM Connector sets up an internal logger that writes informative messages to `STDERR`, but you can customize the logging handlers using the `Initialize` method (which takes a single handler or an array of Monolog handlers):

```
\WOM\Logger::Initialize(array(
    new \Monolog\Handler\StreamHandler('php://stdout', \Monolog\Logger::DEBUG)
));
```

WOM vouchers can be generated on different domains, with different (and custom) *Registry* installations. By default, the Connector picks the standard *Registry*, which lives on the official `wom.social` domain. You can customize this using the following configuration line:

```
\WOM\Config\Domain::SetDomain('dev.wom.social');
```

When developing your new WOM Platform integration, it can be useful to test on the development domain `dev.wom.social` (contact the WOM development team about this). The POS/Instrument keys and IDs that are used in the test scripts can be freely used on the development domain.

Voucher generation
------------------

[](#voucher-generation)

The process of generating WOMs is pretty straightforward. You just need to be sure to comply with the requirements of the Platform and be registered as a WOM "Instrument".

The very first step is to import the connector library, including the autoload script generated by Composer.

```
require __DIR__ . '/vendor/autoload.php';
```

### Creating an Instrument

[](#creating-an-instrument)

To generate WOMs you need to instantiate an Instrument. To do that, you will need the *Id* and the *Private Key* associated with your Instrument. Note that the second parameter contains the path to the key file (`.pem`).

```
$instrument = new \WOM\Instrument(
    INSTRUMENT_ID,
    INSTRUMENT_PRIVATE_KEY,
    INSTRUMENT_PRIVATE_KEY_PASSWORD
);
```

*Note:* if your key is password-protected, you can optionally pass the password along with the other parameters. Otherwise, pass in `NULL` or an empty string.

### Generating voucher specifications

[](#generating-voucher-specifications)

To request WOMs you need to specify what kind of information you need them to contain. Since multiple vouchers can be requested at once, you need to instantiate an array of voucher specifications.

In this case, we populate the array with just one type of voucher:

```
$vouchers[] = \WOM\Voucher::Create('H', 40.12319, 12.83548, new DateTime('NOW'));
```

In case you need many identical vouchers you can specify their quantity with the additional parameter `count`:

```
$vouchers[] = \WOM\Voucher::Create('H', 40.12319, 12.83548, new DateTime('NOW'), 100);
```

Here we are asking for 100 WOM vouchers.

### Perform the request

[](#perform-the-request)

You are almost done! You just need to actually request the vouchers. If the request is successful the server response will contain the *OTC* and the *Password* which you should present to your users in order to allow them to redeem the WOMs they earned.

```
$values = $instrument->RequestVouchers($vouchers);

$otc = $values['otc'];
$pin = $values['password'];
```

The full example is in `example_instrument.php`.

Payment request generation
--------------------------

[](#payment-request-generation)

The process of generating payments for the WOM Platform is very similar to the voucher generation process: please follow the same setup and autoload steps.

### Creating a Point of Service

[](#creating-a-point-of-service)

Just like when instantiating Instruments, you can instantiate your POS by providing its *Id* and its *Private Key*:

```
$POS = new \WOM\POS(
    POS_ID,
    POS_PRIVATE_KEY,
    POS_PRIVATE_KEY_PASSWORD
);
```

*Note:* just like above, the private key parameter contains the path to the key file. Also, even if POS and Instrument belong to the same entity, they will have different IDs and keys.

### Generating a payment filter

[](#generating-a-payment-filter)

To obtain a payment request you usually only need to specify the amount of WOMs to be paid. However, you may also specify a filter that will be used to select which WOM vouchers are valid for payment and which are not.

Providing a **payment filter** makes you able to choose which kind of vouchers can be used to pay your services. Filters can be comprised of one or more of the following elements:

- *Maximum age:* the maximum amount of days between now and when the vouchers were generated. Vouchers that are older than the set amount of days will not be accepted.
- *Geographical region:* a geogrphical (rectangular) bounding box. Only vouchers earned within the specified area are allowed (notice that the region is specified as a couple of coordinates, *top left* and *bottom right*, both of which are expressed as an array of numbers, latitude and then longitude).
- *Aim:* setting an aim code filters out vouchers that volunteers earned by contributing to other public aims. Note that aim codes are hierarchical, so filtering on ‘H’ will accept any voucher with an aim starting with the same letter (for instance ‘HE’).

All parameters are optional:

```
$filter = \WOM\Filter::Create('H', array(46.0, -17.0), array(12.0, 160.0), 14);
```

In case you want to accept any kind of vouchers as a payment, you still need to provide an empty filter:

```
$filter = \WOM\Filter::Create();
```

### Generating the request

[](#generating-the-request)

You are just a method invocation away from generating a proper payment request. Just call the `RequestVouchers` method as shown below:

```
$values = $POS->RequestPayment(
    100, // Number of WOM vouchers required to perform payment
    'https://myserver.io/confirm/uniquecode123', // Pocket confirmation URL, will be opened by Pocket on payment completion, can be null if Pocket should only display payment confirmation on screen
    $filter, // Filter that determines which vouchers are accepted
    'https://myserver.io/backend/confirm', // Optional Registry confirmation URL, which receives a webhook request from the Registry on payment completion, can be null
    null // Optional boolean indicating whether this is a persistent payment (can be performed multiple times) or not
);

$otc = $values['otc'];
$pin = $values['password'];
```

The full example is in `example_pos.php`.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.1% 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 ~142 days

Total

5

Last Release

1188d ago

Major Versions

1.1.2 → 2.02023-02-06

PHP version history (3 changes)1.0PHP ^5.6.40

1.1PHP &gt;=5.6.40

2.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1719a5e8e2f85874c59dd352ead3038e0c00f3fd6bad958e16be6d8205c6a656?d=identicon)[dlpswr](/maintainers/dlpswr)

![](https://avatars.githubusercontent.com/u/1782445?v=4)[Lorenz Cuno Klopfenstein](/maintainers/LorenzCK)[@LorenzCK](https://github.com/LorenzCK)

---

Top Contributors

[![LorenzCK](https://avatars.githubusercontent.com/u/1782445?v=4)](https://github.com/LorenzCK "LorenzCK (25 commits)")[![xavbeta](https://avatars.githubusercontent.com/u/527052?v=4)](https://github.com/xavbeta "xavbeta (18 commits)")

---

Tags

merchantcreditsdigitvouchersinstrumentWOM

### Embed Badge

![Health badge](/badges/digitsrl-php-wom-connector/health.svg)

```
[![Health](https://phpackages.com/badges/digitsrl-php-wom-connector/health.svg)](https://phpackages.com/packages/digitsrl-php-wom-connector)
```

###  Alternatives

[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M648](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[googleads/googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP

67410.3M25](/packages/googleads-googleads-php-lib)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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