PHPackages                             konekt/payum-otp-hungary - 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. konekt/payum-otp-hungary

ActiveLibrary[Payment Processing](/categories/payments)

konekt/payum-otp-hungary
========================

Custom Payum Gateway for SimplePay Hungary via Legacy OTP Bank integration

1.1.1(5y ago)41732MITPHP

Since Mar 29Pushed 5y ago4 watchersCompare

[ Source](https://github.com/artkonekt/payum-otp-hungary)[ Packagist](https://packagist.org/packages/konekt/payum-otp-hungary)[ RSS](/packages/konekt-payum-otp-hungary/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

Payum Gateway for SimplePay Hungary via the Legacy OTP Integration
==================================================================

[](#payum-gateway-for-simplepay-hungary-via-the-legacy-otp-integration)

[![Packagist Stable Version](https://camo.githubusercontent.com/1c799dddda0c636bbee42053ae49186fb139638d8b6ce15d57bb196ae6eadcbf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6f6e656b742f706179756d2d6f74702d68756e676172792e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/konekt/payum-otp-hungary)[![OTP SDK v5](https://camo.githubusercontent.com/ac4b394b51cad161de85e31f5a8eeb996c138d7e432a38f58af8c5a76bb61106/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4f545025323053444b2d76352d3532616533302e7376673f7374796c653d666c61742d737175617265)](http://simplepartner.hu/download.php?target=webshop5)[![SimplePay Compatible](https://camo.githubusercontent.com/ba3500ede3637cb185a96d1fc2ccbd4c512aa3aec08a4c9abba3184ba70b127c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53696d706c655061792d636f6d70617469626c652d3230633466342e7376673f7374796c653d666c61742d737175617265)](http://simplepartner.hu/download.php?target=otpvposen)

> The OTP based payment method has been deprecated by the bank, use SimplePay instead!

> It works with OTP SDK v5 despite the names and references to v4.

Consists of a standard payum gateway library with which you can make online payments through OTP Bank Hungary. It also provides basic integration with [Symfony](http://symfony.com/) and [Sylius](http://sylius.org/).

Disclaimer: the library for now provides only simple offsite (haromszereplos) payment for a single shop (no multishop support). Feel free to contribute or ask for support if you need further functionality.

Architecture
------------

[](#architecture)

The library builds on top of OTP's official SDK. It hides some of the library's inconveniences, like having to edit a configuration file, no autoloading, messy warnings/notices and no support for PHP7. The official SDK's logging features work as they provide it.

You will have to download the SDK [from OTP's site](https://www.otpbank.hu/portal/hu/Kartyaelfogadas/Webshop) in order to be able to use the library.

SDK
---

[](#sdk)

After you downloaded the SDK (currently a ZIP file named Webshop\_4.0) you will find the needed php library in the zip on the following path: `kliensek/php/otpwebshop`. This is the library that is used and you have to put it in a place accessible to your web server. From now on we will call the full path where you have the library `SDK_DIR`.

Because the SDK has no proper versioning, to check if it is the same code that this library is building on you will have to generate the checksum of the library like this (assuming you're on Unix):

```
find SDK_DIR/ -type f -name "*.php" -exec md5sum {} + | awk '{print $1}' | sort | md5sum1

```

The tested library has a checksum of 5a57d623e8da3541c8b8d6fd3848862c. If you have another one it means the SDK code has changed. If something is not working as expected this can be a reason for that.

Using the standalone library
----------------------------

[](#using-the-standalone-library)

You will have to implement actions as described in the [Payum documentation](https://github.com/Payum/Payum/blob/master/src/Payum/Core/Resources/docs/scripts/index.md). In the `examples` folder you will find working scripts which can help you.

### Configuration

[](#configuration)

You will find the parameters you will have to configure in `examples/params.dist`.

- sdk\_dir: The full path to the SDK (as described above). Mandatory.
- sandbox: Can be true or false, if it is true, you don't need to provide the secret\_key and pos\_id. Default: true.
- pos\_id: Your shop ID given to you by OTP. Mandatory when not in sandbox mode.
- secret\_key: The full path to the secret key file belonging to the shop id given to you by OTP. Mandatory when not in sandbox mode.
- transactionid\_prefix: For each payment the library generates a unique ID, you can specify any prefix to it here. It should be no more than 10 characters and should be alphanumeric.

In addition you can configure the log dirs where the SDK will log the transactions. You will find the details in the SDK official documentation about each directory.

Using the library with Sylius
-----------------------------

[](#using-the-library-with-sylius)

You will have to register the action which converts the Sylius models into the gateway's data as a service.

```
app.payum.otp.action.convert:
    class: Konekt\PayumOtp\Bridge\Sylius\ConvertPaymentToOtpAction
```

You also can define another service where you can control the payment note (shopMegjegyzes) sent to OTP. If you do this you have to implement \\Konekt\\PayumOtp\\Bridge\\Sylius\\PaymentNoteProviderInterface in your app and define it as a service, then inject it to the converter. In this case the above definition looks like:

```
app.payum.otp.note_provider:
    class: AppBundle\MyNoteProvider #this class implements \Konekt\PayumOtp\Bridge\Sylius\PaymentNoteProviderInterface
    public: false

app.payum.otp.action.convert:
    class: Konekt\PayumOtp\Bridge\Sylius\ConvertPaymentToOtpAction
    arguments:
        - @app.payum.otp.note_provider
```

To register the custom payum library into your app, you should add the following to your AppBundle:

```
$extension = $container->getExtension('payum');
$extension->addGatewayFactory(new Konekt\PayumOtp\Bridge\Symfony\OtpHungaryOffsiteGatewayFactory());
```

Then you will have to configure the payum bundle to know about the new custom library like this:

```
payum:
    gateways:
        otp_hungary_offsite:
            otp_hungary_offsite:
                sandbox: %payum.otp.is_sandbox%
                secret_key: %payum.otp.secret_key%
                sdk_dir: %payum.otp.sdk_dir%
                pos_id: %payum.otp.pos_id%
                transactionid_prefix: %payum.otp.transactionid_prefix%
                actions:
                    - app.payum.otp.action.convert
                extensions:
                    - app.payum.otp.extension.error_notifier
```

You can define the parameters in your `parameters.yml` (recommended). For the meaning of the parameters see the Configuration section above. Note: even if you are in sandbox mode you will have to provide a value for secret\_key and pos\_id, but in this case it doesn't matter what you provide there (this is a technical depth for now).

### Error handling

[](#error-handling)

You also have the possibility to handle the transaction errors in a decoupled way. For example you want to get an email if any transaction fails by reasons such as wrong amount sent or the private key was rejected etc. In this case you will have to register the library's event notifier extension class as a service:

```
app.payum.otp.extension.error_notifier:
    class:  Konekt\PayumOtp\Bridge\Symfony\ErrorNotifierExtension
    arguments:
        - @event_dispatcher
```

Then you will have to write a listener in your app and define it as a service. Implement `MyOtpListener` which sends an email if an error occurs:

```
