1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90:
<?php
namespace Omnipay\Dummy;
use Omnipay\Common\AbstractGateway;
/**
* Dummy Gateway
*
* This gateway is useful for testing. It simply authorizes any payment made using a valid
* credit card number and expiry.
*
* Any card number which passes the Luhn algorithm and ends in an even number is authorized,
* for example: 4242424242424242
*
* Any card number which passes the Luhn algorithm and ends in an odd number is declined,
* for example: 4111111111111111
*
* ### Example
*
* <code>
* // Create a gateway for the Dummy Gateway
* // (routes to GatewayFactory::create)
* $gateway = Omnipay::create('Dummy');
*
* // Initialise the gateway
* $gateway->initialize(array(
* 'testMode' => true, // Doesn't really matter what you use here.
* ));
*
* // Create a credit card object
* // This card can be used for testing.
* $card = new CreditCard(array(
* 'firstName' => 'Example',
* 'lastName' => 'Customer',
* 'number' => '4242424242424242',
* 'expiryMonth' => '01',
* 'expiryYear' => '2020',
* 'cvv' => '123',
* ));
*
* // Do a purchase transaction on the gateway
* $transaction = $gateway->purchase(array(
* 'amount' => '10.00',
* 'currency' => 'AUD',
* 'card' => $card,
* ));
* $response = $transaction->send();
* if ($response->isSuccessful()) {
* echo "Purchase transaction was successful!\n";
* $sale_id = $response->getTransactionReference();
* echo "Transaction reference = " . $sale_id . "\n";
* }
* </code>
*/
class Gateway extends AbstractGateway
{
public function getName()
{
return 'Dummy';
}
public function getDefaultParameters()
{
return array();
}
/**
* Create an authorize request.
*
* @param array $parameters
* @return \Omnipay\Dummy\Message\AuthorizeRequest
*/
public function authorize(array $parameters = array())
{
return $this->createRequest('\Omnipay\Dummy\Message\AuthorizeRequest', $parameters);
}
/**
* Create a purchase request.
*
* @param array $parameters
* @return \Omnipay\Dummy\Message\AuthorizeRequest
*/
public function purchase(array $parameters = array())
{
return $this->authorize($parameters);
}
}