Skip to content

Commit

Permalink
switch
Browse files Browse the repository at this point in the history
  • Loading branch information
shesek committed Jan 14, 2018
1 parent 145258d commit 0a707b9
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions client.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,16 @@ public function fetchAll() {
public function wait($invoice_id, $timeout) {
$res = $this->api->get('/invoice/' . urlencode($invoice_id) . '/wait?timeout=' . (int)$timeout);

// 402 Payment Required: timeout reached without payment, invoice is still payable
if ($res->info->http_code === 402)
return null;
// 410 Gone: invoice expired and can not longer be paid
else if ($res->info->http_code === 410)
return false;
// 200 OK: invoice is paid, returns the updated invoice
else if ($res->info->http_code === 200)
return $res->decode_response();
else
throw new Exception('invalid response');
switch ($res->info->http_code) {
// 200 OK: invoice is paid, return the updated invoice
case 200: return $res->decode_response();
// 402 Payment Required: timeout reached without payment, invoice is still payable
case 402: return null;
// 410 Gone: invoice expired and can not longer be paid
case 410: return false;

default: throw new Error('unknown status code ' . $res->info->http_code);
}
}

/**
Expand Down

0 comments on commit 0a707b9

Please sign in to comment.