Skip to content

Commit 1d5963f

Browse files
committed
Merge pull request #7 from jtgrimes/feature-void-transaction
void transaction
2 parents 9d86e34 + e1f29e2 commit 1d5963f

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/Message/VoidRequest.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Omnipay\Payflow\Message;
4+
5+
/**
6+
* Payflow Void Request
7+
*/
8+
class VoidRequest extends AuthorizeRequest
9+
{
10+
protected $action = 'V';
11+
12+
/**
13+
* Void prevents transactions from being settled.
14+
*
15+
* @return array ... the data Payflow needs to void a transaction
16+
* @throws \Omnipay\Common\Exception\InvalidRequestException
17+
*/
18+
public function getData()
19+
{
20+
$this->validate('transactionReference');
21+
22+
$data = $this->getBaseData();
23+
$data['ORIGID'] = $this->getTransactionReference();
24+
25+
return $data;
26+
}
27+
}

src/ProGateway.php

+5
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,9 @@ public function refund(array $parameters = array())
9090
{
9191
return $this->createRequest('\Omnipay\Payflow\Message\RefundRequest', $parameters);
9292
}
93+
94+
public function void(array $parameters = array())
95+
{
96+
return $this->createRequest('\Omnipay\Payflow\Message\VoidRequest', $parameters);
97+
}
9398
}

tests/ProGatewayTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,18 @@ public function testRefund()
9595
$this->assertTrue($response->isSuccessful());
9696
$this->assertEquals('A10A6AE7042E', $response->getTransactionReference());
9797
}
98+
99+
public function testVoid()
100+
{
101+
$options = array(
102+
'transactionReference' => 'abc123',
103+
);
104+
105+
$this->setMockHttpResponse('PurchaseSuccess.txt');
106+
107+
$response = $this->gateway->void($options)->send();
108+
109+
$this->assertTrue($response->isSuccessful());
110+
$this->assertEquals('A10A6AE7042E', $response->getTransactionReference());
111+
}
98112
}

0 commit comments

Comments
 (0)