This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
forked from thephpleague/omnipay-braintree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from theiconic/feature/add-search-by-order-id-r…
…equest Add search by order id request
- Loading branch information
Showing
5 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "omnipay/braintree", | ||
"name": "theiconic/omnipay-braintree", | ||
"type": "library", | ||
"description": "Braintree gateway for Omnipay payment processing library", | ||
"keywords": [ | ||
|
@@ -11,22 +11,8 @@ | |
"braintree", | ||
"purchase" | ||
], | ||
"homepage": "https://github.com/thephpleague/omnipay-braintree", | ||
"homepage": "https://github.com/theiconic/omnipay-braintree", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Kayla Daniels", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Barry vd. Heuvel", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Omnipay Contributors", | ||
"homepage": "https://github.com/thephpleague/omnipay-braintree/contributors" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { "Omnipay\\Braintree\\" : "src/" } | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Omnipay\Braintree\Message; | ||
|
||
use Braintree\TransactionSearch; | ||
use Omnipay\Common\Message\ResponseInterface; | ||
|
||
class SearchRequest extends AbstractRequest | ||
{ | ||
/** | ||
* Authorize Request | ||
* | ||
* @method Response send() | ||
*/ | ||
public function getData() | ||
{ | ||
$this->validate('purchaseOrderNumber'); | ||
|
||
return array( | ||
'purchaseOrderNumber' => $this->getPurchaseOrderNumber(), | ||
); | ||
} | ||
|
||
/** | ||
* Send the request with specified data | ||
* | ||
* @param mixed $data The data to send | ||
* @return ResponseInterface | ||
*/ | ||
public function sendData($data) | ||
{ | ||
$response = $this->braintree->transaction()->search([ | ||
TransactionSearch::orderId()->is($data['purchaseOrderNumber']), | ||
]); | ||
|
||
$transactions = []; | ||
foreach($response as $transaction) { | ||
$transactions[] = $transaction; | ||
} | ||
|
||
return $this->createResponse($transactions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Omnipay\Braintree\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
class SearchRequestTest extends TestCase | ||
{ | ||
/** | ||
* @var SearchRequest | ||
*/ | ||
private $request; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new SearchRequest($this->getHttpClient(), $this->getHttpRequest(), \Braintree_Configuration::gateway()); | ||
$this->request->initialize( | ||
array( | ||
'purchaseOrderNumber' => '2187588535', | ||
) | ||
); | ||
} | ||
|
||
public function testGetData() | ||
{ | ||
$data = $this->request->getData(); | ||
|
||
$this->assertSame('2187588535', $data['purchaseOrderNumber']); | ||
} | ||
} |