PHP code example of digistorm / omnipay-mpgs

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

    

digistorm / omnipay-mpgs example snippets



use Omnipay\Omnipay;
use Omnipay\Common\CreditCard;

// Create a gateway for the Mpgs Gateway
// (routes to GatewayFactory::create)
/* @var \Omnipay\Mpgs\Gateway $gateway */
$gateway = Omnipay::create('Mpgs');

$gateway->setTestMode(true);
$gateway->setEndpointBase('https://test-gateway.mastercard.com');
$gateway->setMerchantId('merchantIdValue');
$gateway->setPassword('passwordValue');


// Charge using a card
/* @var \Omnipay\Mpgs\Message\PurchaseResponse $response */
$response = $gateway->purchase([
    'card' => new CreditCard([
        'number' => '5111111111111118',
        'cvv' => '100',
        'expiryMonth' => '05',
        'expiryYear' => '2021',
        'firstName' => 'John',
        'lastName' => 'Doe',
    ]),
    'amount' => '50.00',
    'currency' => 'AUD',
    'description' => 'Merchant Reference',
])->send();