PHPackages                             birkof/netopia-mobilpay - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. birkof/netopia-mobilpay

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

birkof/netopia-mobilpay
=======================

Mirroring MobilePay library with composer PSR-4 autoloading capability.

v4.0.0(2mo ago)590.2k↓65.9%51MITPHPPHP &gt;=8.3

Since Jul 23Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/birkof/netopia-mobilpay)[ Packagist](https://packagist.org/packages/birkof/netopia-mobilpay)[ RSS](/packages/birkof-netopia-mobilpay/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)Dependencies (2)Versions (14)Used By (1)

NETOPIA Payments API
====================

[](#netopia-payments-api)

Mirroring the [MobilPay](https://github.com/mobilpay/PHP_CARD) library with Composer PSR-4 autoloading.

Requirements
------------

[](#requirements)

- PHP `>= 8.3`
- `ext-openssl`

> **OpenSSL 3 note.** OpenSSL 3.0 removed RC4 from the default provider. The library detects this and seals payloads with `aes-256-cbc` instead, which requires an **initialization vector (IV)**. The cipher and IV must be relayed to the gateway and back from the IPN — see the wiring below. On OpenSSL &lt; 3 the legacy `RC4` cipher is used and no IV is produced (`getIv()` returns `null`).

Install
-------

[](#install)

```
composer require birkof/netopia-mobilpay
```

Sending a payment request
-------------------------

[](#sending-a-payment-request)

```
use Mobilpay\Payment\Request\Card;
use Mobilpay\Payment\Invoice;

$request = new Card();
$request->signature  = 'YOUR-NETOPIA-SIGNATURE';
$request->orderId    = 'ORDER-123';
$request->confirmUrl = 'https://example.com/ipn';     // IPN endpoint (server-to-server)
$request->returnUrl  = 'https://example.com/return';  // browser redirect

$invoice = new Invoice();
$invoice->currency = 'RON';
$invoice->amount   = '49.99';
$invoice->details  = 'Order #123';
$request->invoice  = $invoice;

// Seal the request with NETOPIA's public certificate.
$request->encrypt('/path/to/sandbox.YOUR-SIGNATURE.public.cer');
```

### Posting to the gateway (cipher + IV)

[](#posting-to-the-gateway-cipher--iv)

`encrypt()` exposes the sealed envelope through four getters. **All four must be posted** so the gateway can open the envelope:

```
$endpoint = 'http://sandboxsecure.mobilpay.ro'; // live: https://secure.mobilpay.ro

$fields = [
    'env_key' => $request->getEnvKey(),
    'data'    => $request->getEncData(),
    'cipher'  => $request->getCipher(), // e.g. "aes-256-cbc" (or "RC4" on OpenSSL < 3)
    'iv'      => $request->getIv(),     // base64 IV; null when the cipher is a stream cipher
];
?>
