Skip to content

Commit e4b4027

Browse files
committed
Merge pull request #22 from finicprint/master
Addition - add release from escrow
2 parents d8c4f59 + ef0bfcb commit e4b4027

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

src/Gateway.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,15 @@ public function refund(array $parameters = array())
221221
return $this->createRequest('\Omnipay\Braintree\Message\RefundRequest', $parameters);
222222
}
223223

224+
/**
225+
* @param array $parameters
226+
* @return Message\PurchaseRequest
227+
*/
228+
public function releaseFromEscrow(array $parameters = array())
229+
{
230+
return $this->createRequest('\Omnipay\Braintree\Message\ReleaseFromEscrowRequest', $parameters);
231+
}
232+
224233
/**
225234
* @param array $parameters
226235
* @return Message\PurchaseRequest
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Omnipay\Braintree\Message;
4+
5+
use Omnipay\Common\Message\ResponseInterface;
6+
7+
/**
8+
* Authorize Request
9+
*
10+
* @method Response send()
11+
*/
12+
class ReleaseFromEscrowRequest extends AbstractRequest
13+
{
14+
public function getData()
15+
{
16+
$this->validate('transactionId');
17+
18+
return array(
19+
'transactionId' => $this->getTransactionId(),
20+
);
21+
}
22+
23+
/**
24+
* Send the request with specified data
25+
*
26+
* @param mixed $data The data to send
27+
* @return ResponseInterface
28+
*/
29+
public function sendData($data)
30+
{
31+
$response = $this->braintree->transaction()->releaseFromEscrow($data['transactionId']);
32+
33+
return $this->createResponse($response);
34+
}
35+
}

tests/GatewayTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ public function testRefund()
106106
$this->assertSame('10.00', $request->getAmount());
107107
}
108108

109+
public function testReleaseFromEscrow()
110+
{
111+
$request = $this->gateway->releaseFromEscrow(array('transactionId' => 'abc123'));
112+
$this->assertInstanceOf('Omnipay\Braintree\Message\ReleaseFromEscrowRequest', $request);
113+
$this->assertSame('abc123', $request->getTransactionId());
114+
}
115+
109116
public function testVoid()
110117
{
111118
$request = $this->gateway->void();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Omnipay\Braintree\Message;
4+
5+
use Omnipay\Tests\TestCase;
6+
7+
class ReleaseFromEscrowRequestTest extends TestCase
8+
{
9+
/**
10+
* @var ReleaseFromEscrowRequest
11+
*/
12+
private $request;
13+
14+
public function setUp()
15+
{
16+
parent::setUp();
17+
18+
$this->request = new ReleaseFromEscrowRequest($this->getHttpClient(), $this->getHttpRequest(), \Braintree_Configuration::gateway());
19+
$this->request->initialize(
20+
array(
21+
'transactionId' => 'abc123',
22+
)
23+
);
24+
}
25+
26+
public function testGetData()
27+
{
28+
$data = $this->request->getData();
29+
30+
$this->assertSame('abc123', $data['transactionId']);
31+
}
32+
33+
}

0 commit comments

Comments
 (0)