Skip to content

Commit

Permalink
adding support for ACH transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
zburke committed Jul 28, 2016
1 parent da247b6 commit 6f5b1cc
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,10 @@ public function purchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\BluePay\Message\SaleRequest', $parameters);
}


public function achPurchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\BluePay\Message\AchSaleRequest', $parameters);
}
}
16 changes: 16 additions & 0 deletions src/Message/AchSaleRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Omnipay\BluePay\Message;

/**
* BluePay ACH Sale Request
*/
class AchSaleRequest extends AbstractRequest
{
protected $action = 'SALE';

public function getData()
{
return array_merge($this->getBaseData(), $this->getBillingData());
}
}
20 changes: 20 additions & 0 deletions tests/GatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,24 @@ public function testPurchaseFailure()
$this->assertFalse($response->isSuccessful());
$this->assertSame('CARD ACCOUNT NOT VALID', $response->getMessage());
}

public function testAchPurchaseSuccess()
{
$this->setMockHttpResponse('AchSaleSuccess.txt');

$response = $this->gateway->achPurchase($this->purchaseOptions)->send();

$this->assertTrue($response->isSuccessful());
$this->assertSame('100346171008', $response->getTransactionReference());
}

public function testAchPurchaseFailure()
{
$this->setMockHttpResponse('AchSaleFailure.txt');

$response = $this->gateway->achPurchase($this->purchaseOptions)->send();

$this->assertFalse($response->isSuccessful());
$this->assertSame('SECURITY ERROR', $response->getMessage());
}
}
27 changes: 27 additions & 0 deletions tests/Message/AchSaleRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Omnipay\BluePay\Message;

use Omnipay\Tests\TestCase;

class AchSaleRequestTest extends TestCase
{
public function setUp()
{
$this->request = new AchSaleRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'clientIp' => '10.0.0.1',
'amount' => '11.00',
'customerId' => 'cust-id',
)
);
}

public function testGetData()
{
$data = $this->request->getData();

$this->assertSame('SALE', $data['TRANS_TYPE']);
}
}
11 changes: 11 additions & 0 deletions tests/Mock/AchSaleFailure.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HTTP/1.1 400 Error
Server: cloudflare-nginx
Date: Sun, 06 Mar 2016 02:42:23 GMT
Content-Type: text/html; charset=iso-8859-1
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
CF-RAY: 27f2743ff2fc0165-ORD

STATUS=E&MESSAGE=SECURITY%20ERROR&
12 changes: 12 additions & 0 deletions tests/Mock/AchSaleSuccess.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Sun, 06 Mar 2016 02:41:59 GMT
Content-Type: text/html; charset=ISO-8859-1
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d5dab2121d5b42dfeb69b23ca9dfe271a1457232118; expires=Mon, 06-Mar-17 02:41:58 GMT; path=/; domain=.bluepay.com; HttpOnly
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
CF-RAY: 27f273a4a9842604-ORD

TRANS_ID=100346171008&STATUS=1&MESSAGE=App%20ACH%20Sale&TRANS_TYPE=SALE

0 comments on commit 6f5b1cc

Please sign in to comment.