diff --git a/src/Endpoints/OrderRefundEndpoint.php b/src/Endpoints/OrderRefundEndpoint.php index d50c9e3b..ac4edf3d 100644 --- a/src/Endpoints/OrderRefundEndpoint.php +++ b/src/Endpoints/OrderRefundEndpoint.php @@ -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); + } } diff --git a/src/Resources/Order.php b/src/Resources/Order.php index 349a2c3d..c5989e05 100644 --- a/src/Resources/Order.php +++ b/src/Resources/Order.php @@ -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 @@ -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); } /**