Skip to content

Commit f2a271f

Browse files
committed
Add Disbursements API methods
1 parent ac5534b commit f2a271f

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/Client.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ public function __construct($user = null, $password = null, $endpoint = null, $d
3333
$this->_debug = $debug;
3434
$this->_user = Helper::notNull($user, self::$user);
3535
$this->_password = Helper::notNull($password, self::$password);
36+
$this->_logfile = $logfile;
3637
$url_parts = parse_url(Helper::notNull($endpoint, self::$endpoint));
3738
if (count($url_parts) > 1) {
3839
$this->_endpoint = $url_parts['scheme'] . '://' . $url_parts['host'] . (isset($url_parts['port']) ? ':' . $url_parts['port'] : '');
3940
}
4041
$this->_user_agent = Helper::notNull(self::$user_agent, 'cURL php ' . phpversion());
42+
$this->log(self::class . " created!");
4143
}
4244

4345
public function isValidAuth($merchant = '')
@@ -143,12 +145,27 @@ public function getMerchantPaymentMethods($merchant)
143145

144146
public function getPaymentMethods($uri, $options = array())
145147
{
146-
if (!preg_match('!^https?://!', $uri)) {
147-
$uri = $this->_endpoint . '/orders/' . $uri;
148-
}
149-
$this->initCurl($uri . '/payment_methods' . (count($options) > 0 ? '?' . http_build_query($options) : ''));
148+
$this->initCurl($this->_endpoint . '/merchants/');
150149
curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'GET');
151-
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Accept: text/html'));
150+
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
151+
$this->sendRequest();
152+
$this->dealWithResponse();
153+
curl_close($this->ch);
154+
}
155+
156+
public function getAvailableDisbursements ($merchant) {
157+
$this->initCurl($this->_endpoint . '/merchants/' . $merchant . '/disbursements');
158+
curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'GET');
159+
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
160+
$this->sendRequest();
161+
$this->dealWithResponse();
162+
curl_close($this->ch);
163+
}
164+
165+
public function getDisbursementDetails ($path) {
166+
$this->initCurl($this->_endpoint . $path);
167+
curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'GET');
168+
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
152169
$this->sendRequest();
153170
$this->dealWithResponse();
154171
curl_close($this->ch);

0 commit comments

Comments
 (0)