PHP code example of gentor / omnipay-mobilpay

1. Go to this page and download the library: Download gentor/omnipay-mobilpay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gentor / omnipay-mobilpay example snippets


$gateway = Omnipay::create('MobilPay');
$gateway->setMerchantId('1234-5678-9012-3456-7890');
$gateway->setPublicKey('/path/to/public.cer');

$response = $gateway->purchase([
    'amount'     => '10.00',
    'currency'   => 'RON',
    'orderId'    => 1,
    'confirmUrl' => 'http://example.com/ipn',
    'returnUrl'  => 'http://www.google.com',
    'details'    => 'Test payment',
    'testMode'   => true,
    'params'     => [
        'selected_package' => 1
    ]
])->send();

$response->redirect();

$gateway = Omnipay::create('MobilPay');
$gateway->privateKeyPath('/path/to/private.key');

$response = $gateway->completePurchase($_POST)->send();
$response->sendResponse();

if ($response->isSuccessful()) {
    return STATUS_COMPLETED;
}

if ($response->isCancelled()) {
    return STATUS_CANCELED;
}

if ($response->isPending()) {
    return STATUS_PENDING;
}

if ($response->isRefunded()) {
    return STATUS_REFUNDED;
}