Skip to content

Commit

Permalink
Add Invoice reissue (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
XaosSintez committed Aug 21, 2019
1 parent b4e838e commit cc59cbe
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Security - in case of vulnerabilities.
- [x] Added new property to `Website`: `organizationId`
- [x] Added `AlternativeInstrument`, `Customer Timeline`
- [x] Added `description` field to `ValuesList`
- [x] Added `reissue` method to `InvoiceService`
- [x] Added `dueTime` to `InvoiceService::issue()`

### Deprecated
- [x] Deprecated `Transaction` entity method: `getPaymentCardId`
Expand Down
33 changes: 31 additions & 2 deletions src/Services/InvoiceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,41 @@ public function abandon($invoiceId)
/**
* @param string $invoiceId
* @param string $issuedTime
* @param string|null $dueTime
*
* @return Invoice
*/
public function issue($invoiceId, $issuedTime)
public function issue($invoiceId, $issuedTime, $dueTime = null)
{
return $this->client()->post(['issuedTime' => $issuedTime], 'invoices/{invoiceId}/issue', ['invoiceId' => $invoiceId]);
return $this->client()->post(
[
'issuedTime' => $issuedTime,
'dueTime' => $dueTime,
],
'invoices/{invoiceId}/issue',
[
'invoiceId' => $invoiceId,
]
);
}

/**
* @param string $invoiceId
* @param string|null $dueTime
*
* @return Invoice
*/
public function reissue($invoiceId, $dueTime = null)
{
return $this->client()->post(
[
'dueTime' => $dueTime,
],
'invoices/{invoiceId}/reissue',
[
'invoiceId' => $invoiceId,
]
);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/Api/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ public function invoiceService()
$result = $service->abandon('dummy');
$this->assertInstanceOf(Entities\Invoice::class, $result);

$result = $service->issue('dummy', date('Y-m-d H:i:s'));
$result = $service->issue('dummy', date('Y-m-d H:i:s'), date('Y-m-d H:i:s'));
$this->assertInstanceOf(Entities\Invoice::class, $result);

$result = $service->reissue('dummy', date('Y-m-d H:i:s'));
$this->assertInstanceOf(Entities\Invoice::class, $result);
}

Expand Down

0 comments on commit cc59cbe

Please sign in to comment.