Skip to content

Commit

Permalink
Merge pull request #94 from paynl/feature/PLUG-104
Browse files Browse the repository at this point in the history
Refund version updated
  • Loading branch information
woutse authored Mar 13, 2020
2 parents 02e4164 + 6c7d08c commit 70dc7bf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
33 changes: 31 additions & 2 deletions src/Api/Transaction/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ class Refund extends Transaction
{
protected $apiTokenRequired = true;

protected $version = 11;
protected $version = 15;

/**
* @var string the transactionId
*/
private $transactionId;

/**
* @var int the amount in cents
*/
Expand All @@ -33,6 +32,14 @@ class Refund extends Transaction
* @var \DateTime the date the refund should take place
*/
private $processDate;
/**
* @var int (optional) The vat percentage this refund applies to (AfterPay/Focum only)
*/
private $vatPercentage;
/**
* @var int (optional) The currency in which the amount is specified. If no amount is specified, the full amount is refunded and currency is not used. Standard in euro.
*/
private $currency;

/**
* @param string $transactionId
Expand All @@ -42,6 +49,22 @@ public function setTransactionId($transactionId)
$this->transactionId = $transactionId;
}

/**
* @param int|float|null $vatPercentage
*/
public function setVatPercentage($vatPercentage)
{
$this->vatPercentage = $vatPercentage;
}

/**
* @param string $currency
*/
public function setCurrency($currency)
{
$this->currency = $currency;
}

/**
* @param int $amount
*/
Expand Down Expand Up @@ -87,6 +110,12 @@ protected function getData()
if ($this->processDate instanceof \DateTime) {
$this->data['processDate'] = $this->processDate->format('d-m-Y');
}
if (!empty($this->vatPercentage)) {
$this->data['vatPercentage'] = $this->vatPercentage;
}
if (!empty($this->currency)) {
$this->data['currency'] = $this->currency;
}

return parent::getData();
}
Expand Down
12 changes: 11 additions & 1 deletion src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ public static function getForExchange()
* @param int|float|null $amount
* @param string|null $description
* @param \DateTime $processDate
* @param int|float|null $vatPercentage
* @param string $currency
*
* @return Result\Refund
* @throws Error\Api
Expand All @@ -352,7 +354,9 @@ public static function refund(
$transactionId,
$amount = null,
$description = null,
\DateTime $processDate = null
\DateTime $processDate = null,
$vatPercentage = null,
$currency = null
)
{
$api = new Api\Refund();
Expand All @@ -367,6 +371,12 @@ public static function refund(
if ($processDate !== null) {
$api->setProcessDate($processDate);
}
if ($vatPercentage !== null) {
$api->setVatPercentage($vatPercentage);
}
if ($currency !== null) {
$api->setCurrency($currency);
}
$result = $api->doRequest();

return new Result\Refund($result);
Expand Down

0 comments on commit 70dc7bf

Please sign in to comment.