PHP code example of morcano / omnipay-nmi

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

    

morcano / omnipay-nmi example snippets


$gateway = Omnipay::create('NMI_DirectPost');
$gateway->setUsername('demo');
$gateway->setPassword('password');

$request = $gateway->purchase([
    'amount' => $amount,
    'card' => [
        'number' => '4111111111111111',
        'expiryMonth' => '10',
        'expiryYear' => '25',
        'cvv' => '111'
    ],
    ...
])->send();

if ($response->isSuccessful()) {
    // payment was successful: update database
    dump($response);
} else {
    // payment failed: display message to customer
    dump('Error: ' . $response->getMessage());
}