Verifi driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements Verifi support for Omnipay.
Omnipay is installed via Composer. To install, simply add it
to your composer.json
file:
{
"require": {
"pickupman/omnipay-verifi": "~1.0"
}
}
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
The following gateways are provided by this package:
- Verifi
For general usage instructions, please see the main Omnipay repository.
For charging a card you may do the following
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
// Example card data
$card = new Omnipay\Common\CreditCard([
'firstName' => 'John',
'lastName' => 'Doe',
'billingAddress1' => '888 Main',
'billingZip' => '77777',
'billingCity' => 'City',
'billingState' => 'State',
'billingPostcode' => 'Zip',
'number' => '4111111111111111',
'expiryMonth' => '6',
'expiryYear' => '2016',
'cvv' => '123'
]);
$response = $gateway->purchase(
[
'card' => $card,
'amount' => '10.00',
'clientIp' => $_SERVER['REMOTE_ADDR'],
'transactionReference' => '1',
]
)->send();
if ( $response->isSuccessful() ) {
// Continue processing
$transactionID = $response->getTransactionReference();
}
In order to process a refund, you must pass the originating transaction id returned by the gateway
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
$response = $gateway->refund(
[
'amount' => '10.00',
'transactionReference' => 'original transactionid',
]
)->send();
if ( $response->isSuccessful() ) {
// Continue processing
$transactionID = $response->getTransactionReference();
}
To void an existing transaction, you must pass the originating transaction id returned by the gateway
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
$response = $gateway->void(
[
'transactionReference' => 'original transactionid',
]
)->send();
if ( $response->isSuccessful() ) {
// Continue processing
$transactionID = $response->getTransactionReference();
}
You can authorize a credit card to verify funds, and then process the amount later.
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
// Example card data
$card = new Omnipay\Common\CreditCard([
'firstName' => 'John',
'lastName' => 'Doe',
'billingAddress1' => '888 Main',
'billingZip' => '77777',
'billingCity' => 'City',
'billingState' => 'State',
'billingPostcode' => 'Zip',
'number' => '4111111111111111',
'expiryMonth' => '6',
'expiryYear' => '2016',
'cvv' => '123'
]);
$response = $gateway->authorize(
[
'card' => $card,
'amount' => '10.00',
'transactionReference' => 'order id or other unique value',
]
)->send();
if ( $response->isSuccessful() ) {
// Continue processing
$transactionID = $response->getTransactionReference(); // Use this value later to capture
}
Use a capture, to charge a card after retrieving an authorization
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
$response = $gateway->capture(
[
'amount' => '10.00',
'transactionReference' => 'order id or other unique value',
]
)->send();
if ( $response->isSuccessful() ) {
// Continue processing
$transactionID = $response->getTransactionReference(); // Use this value later to capture
}
You can create a custom billing cycle without any plans. You will need to define the amount, and billing intervals. See Verifi documentation for supported values. All API values are supported.
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
// Example card data
$card = new Omnipay\Common\CreditCard([
'firstName' => 'John',
'lastName' => 'Doe',
'billingAddress1' => '888 Main',
'billingZip' => '77777',
'billingCity' => 'City',
'billingState' => 'State',
'billingPostcode' => 'Zip',
'number' => '4111111111111111',
'expiryMonth' => '6',
'expiryYear' => '2016',
'cvv' => '123'
]);
//Create a subscription
$subscription = $gateway->createCustomSubscription([
'start_date' => 'YYYYMMDD', // Defaults to current date if not passed
'plan_id' => 'valid plan id from control panel',
'card' => $card
])->send();
if ( $subscription->isSuccessful() ) {
$subscriptionID = $subscription->getSubscriptionId(); // Save for later
}
You can create a custom billing cycle without any plans. You will need to define the amount, and billing intervals. See Verifi documentation for supported values. All API values are supported.
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
// Example card data
$card = new Omnipay\Common\CreditCard([
'firstName' => 'John',
'lastName' => 'Doe',
'billingAddress1' => '888 Main',
'billingZip' => '77777',
'billingCity' => 'City',
'billingState' => 'State',
'billingPostcode' => 'Zip',
'number' => '4111111111111111',
'expiryMonth' => '6',
'expiryYear' => '2016',
'cvv' => '123'
]);
//Create a subscription
$subscription = $gateway->createCustomSubscription([
'amount' => '25.00',
'month_frequency' => 1, // Billed monthly
'day_of_month' => 1, // on first of the month
'plan_payments' => 0, // indefinitely or cancelled
'card' => $card
])->send();
if ( $subscription->isSuccessful() ) {
$subscriptionID = $subscription->getSubscriptionId(); // Save for later
}
You may delete / cancel a subscription by passing the originating subscription id.
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
$subscription = $gateway->deleteSubscription([
'subscription_id' => 'subscription id here'
])->send();
You may add a customer and their billing information to be saved in your Verifi vault.
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
// Example card data
$card = new Omnipay\Common\CreditCard([
'firstName' => 'John',
'lastName' => 'Doe',
'billingAddress1' => '888 Main',
'billingZip' => '77777',
'billingCity' => 'City',
'billingState' => 'State',
'billingPostcode' => 'Zip',
'number' => '4111111111111111',
'expiryMonth' => '6',
'expiryYear' => '2016',
'cvv' => '123'
]);
$response = $gateway->createCard([
'card' => $card
]);
if ( $response->isSuccessful() ) {
$vaultId = $response->getToken();
}
You can update the billing information for customer by passing the originating transaction id.
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setUsername('username');
$gateway->setPassword('password');
// Example card data
$card = new Omnipay\Common\CreditCard([
'firstName' => 'John',
'lastName' => 'Doe',
'billingAddress1' => '888 Main',
'billingZip' => '77777',
'billingCity' => 'City',
'billingState' => 'State',
'billingPostcode' => 'Zip',
'number' => '4111111111111111',
'expiryMonth' => '6',
'expiryYear' => '2016',
'cvv' => '123'
]);
$subscription = $gateway->updateSubscription([
'subscription_id' => 'subscription id here',
'card' => $card
]);
if ( $subscription->isSuccessful() ) {
$subscriptionID = $subscription->getSubscriptionId();
}
This feature will NOT turn on test mode for your account. Test mode must be enabled or disabled from your Verifi control panel. All transactions processed on a live account will be charged.
If you would like to use the default testing credentials from Verifi, please initialize the gateway with
$gateway = Omnipay\Omnipay::create('Verifi');
$gateway->setTestMode(true); // Automatically sets default testing gateway username and password
Any transactions processed with testMode(true) will not be charged, OR shown in your control panel. This method will automatically apply the testing username and password for the Verifi gateway.
If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.
If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.
If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.