8000 Added ability to use sandbox API · dercoder/omnipay-ecopayz@12b7dfb · GitHub
[go: up one dir, main page]

Skip to content

Commit 12b7dfb

Browse files
author
Alexander Shovdra
committed
Added ability to use sandbox API
1 parent 3ce8858 commit 12b7dfb

File tree

5 files changed

+40
-11
lines changed

5 files changed

+40
-11
lines changed

src/Omnipay/Ecopayz/Message/AbstractRequest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111
*/
1212
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
1313
{
14+
/**
15+
* Test Endpoint URL
16+
*
17+
* @var string URL
18+
*/
19+
protected $testEndpoint = 'https://secure.test.ecopayz.com/services/MerchantAPI/MerchantAPIService.asmx';
20+
21+
/**
22+
* Live Endpoint URL
23+
*
24+
* @var string URL
25+
*/
26+
protected $liveEndpoint = 'https://secure.ecopayz.com/services/MerchantAPI/MerchantAPIService.asmx';
27+
1428
/**
1529
* Get the Merchant ID
1630
*
@@ -96,6 +110,16 @@ public function setMerchantAccountNumber($value)
96110
return $this->setParameter('merchantAccountNumber', $value);
97111
}
98112

113+
/**
114+
* Get API endpoint URL
115+
*
116+
* @return string
117+
*/
118+
protected function getEndpoint()
119+
{
120+
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
121+
}
122+
99123
/**
100124
* Get calculated checksum
101125
*

src/Omnipay/Ecopayz/Message/FetchTransactionRequest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
*/
1515
class FetchTransactionRequest extends AbstractRequest
1616
{
17-
protected $endpoint = 'https://secure.ecopayz.com/services/MerchantAPI/MerchantAPIService.asmx';
18-
1917
/**
2018
* Get the data for this request.
2119
*
@@ -114,7 +112,7 @@ public function sendData($data)
114112
'SOAPAction' => 'http://www.ecocard.com/merchantAPI/QueryBySVSTransactionID'
115113
);
116114

117-
$httpRequest = $this->httpClient->createRequest('POST', $this->endpoint, $headers, $data);
115+
$httpRequest = $this->httpClient->createRequest('POST', $this->getEndpoint(), $headers, $data);
118116
$httpResponse = $httpRequest->send();
119117
$xmlResponse = $httpResponse->xml()
120118
->children('http://schemas.xmlsoap.org/soap/envelope/')
@@ -142,7 +140,7 @@ public function sendData($data)
142140
'SOAPAction' => 'http://www.ecocard.com/merchantAPI/QueryByCustomerTransactionID'
143141
);
144142

145-
$httpRequest = $this->httpClient->createRequest('POST', $this->endpoint, $headers, $data);
143+
$httpRequest = $this->httpClient->createRequest('POST', $this->getEndpoint(), $headers, $data);
146144
$httpResponse = $httpRequest->send();
147145
$xmlResponse = $httpResponse->xml()
148146
->children('http://schemas.xmlsoap.org/soap/envelope/')

src/Omnipay/Ecopayz/Message/PayoutRequest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*/
1414
class PayoutRequest extends AbstractRequest
1515
{
16-
protected $endpoint = 'https://secure.ecopayz.com/services/MerchantAPI/MerchantAPIService.asmx';
17-
1816
/**
1917
* Get the Client Account Number
2018
*
@@ -161,7 +159,7 @@ public function sendData($data)
161159
'SOAPAction' => 'http://www.ecocard.com/merchantAPI/Payout'
162160
);
163161

164-
$httpRequest = $this->httpClient->createRequest('POST', $this->endpoint, $headers, $data);
162+
$httpRequest = $this->httpClient->createRequest('POST', $this->getEndpoint(), $headers, $data);
165163
$httpResponse = $httpRequest->send();
166164
$xmlResponse = $httpResponse->xml()
167165
->children('http://schemas.xmlsoap.org/soap/envelope/')

src/Omnipay/Ecopayz/Message/PurchaseResponse.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
*/
1717
class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface
1818
{
19-
protected $endpoint = 'https://secure.ecopayz.com/PrivateArea/WithdrawOnlineTransfer.aspx';
19+
protected $testEndpoint = 'https://secure.test.ecopayz.com/PrivateArea/WithdrawOnlineTransfer.aspx';
20+
protected $liveEndpoint = 'https://secure.ecopayz.com/PrivateArea/WithdrawOnlineTransfer.aspx';
2021

2122
public function __construct(RequestInterface $request, $data)
2223
{
@@ -36,7 +37,7 @@ public function isRedirect()
3637

3738
public function getRedirectUrl()
3839
{
39-
return $this->endpoint . '?' . http_build_query($this->data, '', '&');
40+
return $this->getEndpoint() . '?' . http_build_query($this->data, '', '&');
4041
}
4142

4243
public function getRedirectMethod()
@@ -48,4 +49,9 @@ public function getRedirectData()
4849
{
4950
return null;
5051
}
52+
53+
protected function getEndpoint()
54+
{
55+
return $this->getRequest()->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
56+
}
5157
}

tests/Omnipay/Ecopayz/Message/PurchaseResponseTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<?php
22
namespace Omnipay\Ecopayz\Message;
3-
3+
use Mockery as m;
44
use Omnipay\Tests\TestCase;
55

66
class PurchaseResponseTest extends TestCase
77
{
88
public function testResult()
99
{
10-
$response = new PurchaseResponse($this->getMockRequest(), array(
10+
$request = $this->getMockRequest();
11+
$request->shouldReceive('getTestMode');
12+
13+
$response = new PurchaseResponse($request, array(
1114
'PaymentPageID' => '100',
1215
'MerchantAccountNumber' => '100001',
1316
'CustomerIdAtMerchant' => '1123456789',

0 commit comments

Comments
 (0)
0