PHPackages                             codehouse/payment-invoice-mapper - 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. codehouse/payment-invoice-mapper

ActiveLibrary[Payment Processing](/categories/payments)

codehouse/payment-invoice-mapper
================================

Payment-invoice mapper. The component maps incoming invoices with provided payments from file.

1.7(10y ago)116GNU GPL3PHP

Since Apr 20Pushed 8y agoCompare

[ Source](https://github.com/Shmarkus/PIM)[ Packagist](https://packagist.org/packages/codehouse/payment-invoice-mapper)[ Docs](https://github.com/Shmarkus/PIM)[ RSS](/packages/codehouse-payment-invoice-mapper/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Status
------

[](#status)

[![Build Status](https://camo.githubusercontent.com/71f7a7010bcd6503ec64fa7a1373f47e0448adb4482676a18d2c1a45dbd732c1/68747470733a2f2f7472617669732d63692e6f72672f53686d61726b75732f50494d2e706e67)](https://travis-ci.org/Shmarkus/PIM)[![GitHub version](https://camo.githubusercontent.com/c5a104f888aafe0321b612d2d3aed220096a259d5ed76dd6c611aaca9f70d279/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f73686d61726b75732f70696d2e737667)](https://github.com/Shmarkus/PIM)

When should I use this library?
-------------------------------

[](#when-should-i-use-this-library)

If You have some kind of e-commerce system that manages orders and You need to match bank transactions with the orders to determine whether order has been paid or not, then You'd want to use this library!

How to use
----------

[](#how-to-use)

### Prerequisite

[](#prerequisite)

This library is [Composer](https://getcomposer.org) friendly, so the most convenient way is to get Composer

```
curl -sS https://getcomposer.org/installer | php

```

Get the project from Packagist

```
php composer.phar require codehouse/payment-invoice-mapper

```

Pull the library from the internet

```
php composer.phar update

```

Dont forget to include **vendor/autoload.php** in Your bootstrap script, such as index.php

### Usage

[](#usage)

When the library is loaded, create a entity class that will hold Your invoices from the system so that it will implement **\\Entities\\Invoice** interface (You can access PIM classes via namespaces now, since Composer did all the heavy lifting). When the class is ready, create a function that will retrieve all invoices that have not been paid yet and assign them to Your Invoice object. Since You probably have more than 1 invoice, You have to create ArrayObject of them e.g.

```
$invoices = new ArrayObject();
while ($item = $query->fetch(PDO::FETCH_ASSOC)) {
    $invoices->append(new YourInvoiceObject($item['amount'], $item['invoiceNo'], $item['orderNo'], $item['referenceNo']))
}
```

By this point Your invoices are ready to be mapped, the next step is to get the payments to map with! In this example, I assume, that user uploads a file that contains the payments from the bank. The uploaded file is in **ISO20022** format. For other formats and sources see [Extending](#extending).

In this example, user posts file from a web page, the file HTML name is *import*.

```
$mapper = new \Mappers\MapperImpl();
try {
    $paidInvoices = $mapper->map($invoices, $_FILE['import']['tmp_name'], 'ISO20022');
    updateInvoices($paidInvoices);
} catch (Exception $e) { .. }

function updateInvoices($invoices) {
    //update Your database here
}
```

The mapper function returns **Payments** (see \\Entities\\Payments) that matched with invoices. In order to update Your invoice table, You have to take the return value of *map()* function and update Your table accordingly

Extending
---------

[](#extending)

### Basics

[](#basics)

If You have a special kind of file format, create a new **Parser** to *mapper/src/Parsers*. It has to extend the *\\Parsers\\AbstractParser* class and implement *\\Parsers\\Parser* interface (see examples like \\Parsers\\ISO20022Parser). When Your parser is ready, create new entry to **\\Parsers\\ParserFactoryImpl::getParser()** method to register Your new parser (add new case statement). Now You can use Your new parser by passing Your parser name to map() functions third argument!

### Advanced

[](#advanced)

If the default extractor doesn't cut it for You, You can create new Extractors. This would happen if You need to read data from a webservice or other source than a file. In this case You'd need to create a new **Extractor** that implements *\\Extractors\\Extractor* interface and then register Your new extractor in **\\Extractors\\ExtractorFactoryImpl::getExtractor()**method (add new case statement). The same thing goes for comparison logic. To use other than default comparison method, create new **Comparator** that extends the *\\Comparators\\Comparator* interface and register Your new comparator in **\\Comparators\\ComparatorFactoryImpl::getComparator()** method

Now You can use Your new extractor and comparator when invoking Mapper object like this:

```
$mapper = new \Mappers\MapperImpl('YourComparatorName', 'YourExtractorName');
```

The default comparator is **IPRNo** and extractor is **File**

Component model
---------------

[](#component-model)

[![Component diagram](https://github.com/Shmarkus/PIM/raw/master/doc/Components.png "Component diagram")](https://github.com/Shmarkus/PIM/blob/master/doc/Components.png)

Class diagram
-------------

[](#class-diagram)

[![Class diagram](https://github.com/Shmarkus/PIM/raw/master/doc/System.png "Class diagram")](https://github.com/Shmarkus/PIM/blob/master/doc/System.png)

Sequence diagram
----------------

[](#sequence-diagram)

[![Sequence diagram](https://github.com/Shmarkus/PIM/raw/master/doc/Sequence.png "Sequence diagram")](https://github.com/Shmarkus/PIM/blob/master/doc/Sequence.png)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

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

Total

2

Last Release

3714d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6381245?v=4)[Markus Karileet](/maintainers/shmarkus)[@Shmarkus](https://github.com/Shmarkus)

---

Top Contributors

[![Shmarkus](https://avatars.githubusercontent.com/u/6381245?v=4)](https://github.com/Shmarkus "Shmarkus (3 commits)")

---

Tags

mapperpaymentinvoiceISO20022TeleHansa

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codehouse-payment-invoice-mapper/health.svg)

```
[![Health](https://phpackages.com/badges/codehouse-payment-invoice-mapper/health.svg)](https://phpackages.com/packages/codehouse-payment-invoice-mapper)
```

###  Alternatives

[payum/offline

The Payum extension. It provides Offline payment integration.

303.7M16](/packages/payum-offline)[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.1k](/packages/omalizadeh-laravel-multi-payment)

PHPackages © 2026

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