Skip to content

Commit

Permalink
Merge pull request #714 from sandervanhooft/fix_issue_173
Browse files Browse the repository at this point in the history
Fix issue 713
  • Loading branch information
Naoray authored Apr 12, 2024
2 parents d7d09ac + 68cfad4 commit e426af4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
24 changes: 24 additions & 0 deletions src/Endpoints/OrderRefundEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,28 @@ public function createForId($orderId, array $data, array $filters = [])

return parent::rest_create($data, $filters);
}

/**
* @param $orderId
* @param array $parameters
* @return RefundCollection
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function pageForId($orderId, array $parameters = [])
{
$this->parentId = $orderId;

return parent::rest_list(null, null, $parameters);
}

/**
* @param \Mollie\Api\Resources\Order $order
* @param array $parameters
* @return \Mollie\Api\Resources\RefundCollection
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function pageFor(Order $order, array $parameters = [])
{
return $this->pageForId($order->id, $parameters);
}
}
14 changes: 1 addition & 13 deletions src/Resources/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Mollie\Api\Resources;

use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\MollieApiClient;
use Mollie\Api\Types\OrderStatus;

class Order extends BaseResource
Expand Down Expand Up @@ -474,18 +473,7 @@ public function refundAll(array $data = [])
*/
public function refunds()
{
if (! isset($this->_links->refunds->href)) {
return new RefundCollection($this->client, 0, null);
}

$result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->refunds->href);

return ResourceFactory::createCursorResourceCollection(
$this->client,
$result->_embedded->refunds,
Refund::class,
$result->_links
);
return $this->client->orderRefunds->pageFor($this);
}

/**
Expand Down

0 comments on commit e426af4

Please sign in to comment.