Generate invoice numbers via the transaction call as a 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 Sage Pay support for Omnipay.
Omnipay is installed via Composer. To install, simply add it
to your composer.json
file:
{
"require": {
"seymourlabs/omnipay-invoice": "~1.0"
}
}
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
// Create a gateway for the Invoice Gateway
// (routes to GatewayFactory::create)
$gateway = \Omnipay\Omnipay::create('Invoice');
// Initialise the gateway
$gateway->initialize([
'testMode' => true, // Test mode prepends "TEST:" into the invoice number
]);
// Do an authorize transaction on the gateway
$transaction = $gateway->authorize([
'amount' => '10.00',
'currency' => 'GBP',
]);
// optional prefix assignment
$transaction->setPrefix('ABC');
$response = $transaction->send();
if ($response->isSuccessful()) {
echo "Authorize transaction was successful!\n";
$sale_id = $response->getTransactionReference();
echo "Transaction reference = " . $sale_id . "\n";
}