PHP code example of teodoriu / omnipay-mobilpay

1. Go to this page and download the library: Download teodoriu/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/ */

    

teodoriu / omnipay-mobilpay example snippets


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

$response = $gateway->purchase([
    'language' => 'en',
    'amount'     => '10.00',
    'currency'   => 'EUR',
    'orderId'    => 1,
    'confirmUrl' => 'http://example.com/ipn',
    'returnUrl'  => 'http://www.google.com',
    'details'    => 'Test payment',
    'testMode'   => true,
    'params'     => [
        'selected_package' => 1
    ],
    'billingAddress' => [
                'type'           => 'person',
                'firstName'      => 'first_name',
                'lastName'       => 'last_name',
                'email'          => 'email',
                'mobilePhone'    => 'phone',
                'address'        => 'address',
                'fiscalNumber'   => null,
                'identityNumber' => null,
                'country'        => 'Romania',
                'county'         => null,
                'bank'           => null,
                'iban'           => null,
                'city'           => 'Bucharest',
                'zipCode'        => '10000',
            ]
])->send();

$response->redirect();

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

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

switch($response->getMessage())
{
    case 'confirmed_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "pending"

        break;
    case 'paid_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "pending"

        break;
    case 'paid': // transaction is pending authorization. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "open/preauthorized"

        break;
    case 'confirmed': // transaction is finalized, the money have been captured from the customer's account

        //update DB, SET status = "confirmed/captured"

        break;
    case 'canceled': // transaction is canceled

        //update DB, SET status = "canceled"

        break;
    case 'credit': // transaction has been refunded

        //update DB, SET status = "refunded"

        break;
}