54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Omnipay\CardSave;
|
|
|
|
use Omnipay\Common\CreditCard;
|
|
use Omnipay\Tests\GatewayTestCase;
|
|
|
|
class GatewayTest extends GatewayTestCase
|
|
{
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest());
|
|
|
|
$this->options = array(
|
|
'amount' => '10.00',
|
|
'returnUrl' => 'https://www.example.com/return',
|
|
'card' => new CreditCard(array(
|
|
'firstName' => 'Example',
|
|
'lastName' => 'User',
|
|
'number' => '4111111111111111',
|
|
'expiryMonth' => '12',
|
|
'expiryYear' => '2016',
|
|
'cvv' => '123',
|
|
'issueNumber' => '5',
|
|
'startMonth' => '4',
|
|
'startYear' => '2013',
|
|
)),
|
|
);
|
|
}
|
|
|
|
public function testPurchase()
|
|
{
|
|
$this->setMockHttpResponse('PurchaseSuccess.txt');
|
|
|
|
$response = $this->gateway->purchase($this->options)->send();
|
|
|
|
$this->assertInstanceOf('\Omnipay\CardSave\Message\Response', $response);
|
|
$this->assertTrue($response->isSuccessful());
|
|
$this->assertEquals('130215141054377801316798', $response->getTransactionReference());
|
|
}
|
|
|
|
public function testPurchaseError()
|
|
{
|
|
$this->setMockHttpResponse('PurchaseFailure.txt');
|
|
|
|
$response = $this->gateway->purchase($this->options)->send();
|
|
|
|
$this->assertFalse($response->isSuccessful());
|
|
$this->assertSame('Input variable errors', $response->getMessage());
|
|
}
|
|
}
|