Skip to main content

Documentation Index

Fetch the complete documentation index at: https://danestvesllc-2b77d201.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Laravel Polar exposes refund operations directly on the Order model. Issue a full refund, a partial refund, or a targeted refund with a reason, comment, and metadata — without leaving PHP. Under the hood, $order->refund() calls the Polar Refunds API. You can also use the LaravelPolar facade directly when managing refunds outside the context of a single order model instance.
All refunds are irreversible. Double-check the amount and reason before issuing.

Full refund

Call refund() with no arguments to refund the entire remaining unrefunded amount. The reason defaults to customer_request.
$order->refund();
The method calculates the refund amount as $order->amount - $order->refunded_amount, so calling it on a partially refunded order will cover only what remains.

Partial refund

Pass an explicit amount in minor units (cents) to refund only part of the order:
$order->refund(amount: 2500); // refund $25.00

Refund with reason, comment, and metadata

For more detailed refunds — such as those triggered by fraud detection or support tickets — pass any combination of reason, comment, and metadata:
use Polar\Models\Components\RefundReason;

$order->refund(
    amount: 2500,
    reason: RefundReason::Fraudulent,
    comment: 'flagged by risk team',
    metadata: ['ticket' => 'T-42'],
);

Available reasons

Enum valueWhen to use
RefundReason::CustomerRequestCustomer asked for a refund (default)
RefundReason::FraudulentFraudulent transaction or chargeback risk
RefundReason::DuplicateOrder was placed more than once
RefundReason::OtherAny other reason
All refund() calls are irreversible. Verify the amount and reason before issuing a refund, especially when passing custom metadata.

Listing previous refunds

Call refunds() on an order to retrieve a collection of all refunds issued against it:
$refunds = $order->refunds();
// Illuminate\Support\Collection<int, \Polar\Models\Components\Refund>

foreach ($refunds as $refund) {
    echo $refund->amount . ' ' . $refund->reason->value;
}
refunds() returns an empty collection when the order has no polar_id.

Using the facade directly

For admin workflows that operate across multiple orders, use LaravelPolar::createRefund() and LaravelPolar::listRefunds() directly:
use Danestves\LaravelPolar\LaravelPolar;
use Polar\Models\Components;
use Polar\Models\Operations;

// Create a refund for any order by its Polar ID
LaravelPolar::createRefund(new Components\RefundCreate(
    orderId: 'ord_xxx',
    reason: Components\RefundReason::Duplicate,
    amount: 1000,
));

// List all refunds for a given order
$response = LaravelPolar::listRefunds(
    new Operations\RefundsListRequest(orderId: 'ord_xxx'),
);

$refunds = $response->listResourceRefund->items;
$order->refund() and LaravelPolar::createRefund() both call the same Polar endpoint. Use whichever fits your workflow — $order->refund() when you have a model instance, the facade when working with raw order IDs.