How to implement NMI in Omnipay?

555 Views Asked by At

I used composer to load Ominpay-nmi with all of its required. I get no composer errors but when I run

use Omnipay\Omnipay;
$gatewayObj = Omnipay::create("NMI");

I get the message Fatal error: Uncaught exception 'Omnipay\Common\Exception\RuntimeException' with message 'Class '\Omnipay\NMI\Gateway' not found' in /home/ken/NetBeansProjects/tournament/vendor/omnipay/common/src/Omnipay/Common/GatewayFactory.php on line 105

I tried creating an empty class as suggested in

code as follows:

<?php

namespace Omnipay\myNMIGateway;

class Gateway {
//put your code here
}

Composer code

{
    "name":"x/x",
    "description":"autoload for tournament software",
    "license":"",

    "require": {
        "php": ">=5.3.0",
        "ext-curl": "*",
        "ext-json": "*",
        "paypal/rest-api-sdk-php" : "dev-master",
        "mfauveau/omnipay-nmi": "~2.0",
        "twilio/sdk": "dev-master",
        "mailgun/mailgun-php": "dev-master",
        "components/jqueryui":">=1.11.4",
        "bacon/bacon-qr-code": "dev-master"
    },         

    "autoload":{
        "files":["tournamentConfig.php"],
        "psr-4":{"mts\\classes\\":"classes", 
                 "mts\\classes\\tables\\":"classes/tables/src",
                 "mts\\":"classes\\factories",
                 "mts\\":"classes\\data",
                 "mts\\":"classes\\view",
                 "mts\\":"classes\\keys",
                 "mts\\view\\":"view",
                 "mts\\model\\":"model"
        }
    }
}

Any examples specific for NMI AND Paypal, (that will be my next gateway implementation) would be greatly appreciated.

Thank you

Ken

1

There are 1 best solutions below

2
On

The class file in mfauveau/omnipay-nmi looks like this:

namespace Omnipay\NMI;
use Omnipay\Common\AbstractGateway;
class DirectPostGateway extends AbstractGateway

So to load it you should do this:

$gatewayObj = Omnipay::create("NMI_DirectPost");

The documentation for the PayPal REST gateway is fairly complete, to load that one you should use:

$gatewayObj = Omnipay::create("PayPal_Rest");