Skip to content

Commit

Permalink
Merge pull request #7 from jtgrimes/feature-void-transaction
Browse files Browse the repository at this point in the history
void transaction
  • Loading branch information
greydnls committed Nov 3, 2015
2 parents 9d86e34 + e1f29e2 commit 1d5963f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Message/VoidRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Omnipay\Payflow\Message;

/**
* Payflow Void Request
*/
class VoidRequest extends AuthorizeRequest
{
protected $action = 'V';

/**
* Void prevents transactions from being settled.
*
* @return array ... the data Payflow needs to void a transaction
* @throws \Omnipay\Common\Exception\InvalidRequestException
*/
public function getData()
{
$this->validate('transactionReference');

$data = $this->getBaseData();
$data['ORIGID'] = $this->getTransactionReference();

return $data;
}
}
5 changes: 5 additions & 0 deletions src/ProGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ public function refund(array $parameters = array())
{
return $this->createRequest('\Omnipay\Payflow\Message\RefundRequest', $parameters);
}

public function void(array $parameters = array())
{
return $this->createRequest('\Omnipay\Payflow\Message\VoidRequest', $parameters);
}
}
14 changes: 14 additions & 0 deletions tests/ProGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,18 @@ public function testRefund()
$this->assertTrue($response->isSuccessful());
$this->assertEquals('A10A6AE7042E', $response->getTransactionReference());
}

public function testVoid()
{
$options = array(
'transactionReference' => 'abc123',
);

$this->setMockHttpResponse('PurchaseSuccess.txt');

$response = $this->gateway->void($options)->send();

$this->assertTrue($response->isSuccessful());
$this->assertEquals('A10A6AE7042E', $response->getTransactionReference());
}
}

0 comments on commit 1d5963f

Please sign in to comment.