This repository has been archived by the owner on Oct 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
341c1d3
commit cb3389b
Showing
3 changed files
with
116 additions
and
0 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
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,85 @@ | ||
<?php | ||
namespace Satispay; | ||
|
||
use Satispay\Satispay; | ||
|
||
class Refund { | ||
public static function create($params = null) { | ||
$result = Satispay::request('/online/v1/refunds', 'POST', $params); | ||
$body = $result['body']; | ||
if (!empty($body->code)) { | ||
switch($body->code) { | ||
case 36: | ||
throw new \Exception('Body validation error'); | ||
break; | ||
case 45: | ||
throw new \Exception('Try to create a refund for a Charge not owned by user'); | ||
break; | ||
case 52: | ||
throw new \Exception('Beneficiary validation'); | ||
break; | ||
} | ||
} | ||
return $body; | ||
} | ||
|
||
public static function all($params = null) { | ||
$queryString = ''; | ||
if (!empty($params)) | ||
$queryString = http_build_query($params); | ||
$result = Satispay::request('/online/v1/refunds?'.$queryString); | ||
$body = $result['body']; | ||
if (!empty($body->code)) { | ||
switch($body->code) { | ||
case 45: | ||
throw new \Exception('Try to get a refund of another shop'); | ||
break; | ||
case 52: | ||
throw new \Exception('Beneficiary validation'); | ||
break; | ||
} | ||
} | ||
return $body; | ||
} | ||
|
||
public static function get($id) { | ||
$result = Satispay::request('/online/v1/refunds/'.$id); | ||
$body = $result['body']; | ||
if (!empty($body->code)) { | ||
switch($body->code) { | ||
case 41: | ||
throw new \Exception('Refund does not exist'); | ||
break; | ||
case 45: | ||
throw new \Exception('Try to get a refund of another shop'); | ||
break; | ||
case 52: | ||
throw new \Exception('Shop validation error'); | ||
break; | ||
} | ||
} | ||
return $body; | ||
} | ||
|
||
public static function update($id, $params = null) { | ||
$result = Satispay::request('/online/v1/refunds/'.$id, 'PUT', $params); | ||
$body = $result['body']; | ||
if (!empty($body->code)) { | ||
switch($body->code) { | ||
case 45: | ||
throw new \Exception('Try to update a refund of another user'); | ||
break; | ||
case 52: | ||
throw new \Exception('Beneficiary validation'); | ||
break; | ||
case 36: | ||
throw new \Exception('Body validation error'); | ||
break; | ||
case 41: | ||
throw new \Exception('Refund don’t exist'); | ||
break; | ||
} | ||
} | ||
return $body; | ||
} | ||
} |