Skip to content

Commit 3830ad4

Browse files
committed
Add method to validate credentials
1 parent 6cd994a commit 3830ad4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/BuilderAbstract.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ public function __construct($merchant_id)
2323

2424
public static abstract function getPreviousOrders($customerID);
2525

26-
public static function integerPrice($price)
26+
public static function integerPrice(int $price)
2727
{
28-
return intval(round(self::$centsPerWhole * (float) $price));
28+
return is_numeric($price)?
29+
intval(round(self::$centsPerWhole * (float) $price)):
30+
0;
2931
}
3032

3133
protected static function dateOrBlank($date)

src/Client.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ public function __construct($user = null, $password = null, $endpoint = null, $d
3838
$this->_user_agent = Helper::notNull(self::$user_agent, 'cURL php ' . phpversion());
3939
}
4040

41+
public function isValidAuth()
42+
{
43+
$this->initCurl($this->_endpoint . '/orders');
44+
curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'GET');
45+
$this->sendRequest();
46+
return $this->status != 401;
47+
}
48+
4149
public function startSolicitation($order)
4250
{
4351
if ( ! $this->qualifyForSolicitation($order) && ! $this->_debug) {

0 commit comments

Comments
 (0)