Vatly
PHP

Refunds

Vatly PHP SDK - Refunds

Refunds allow you to return money to your customers for orders.

The Refund Resource

Below you'll find all properties for the Vatly Refund resource.

Properties

NameTypeDescription
idstringUnique identifier for the refund (refund_...).
resourcestringAlways refund.
statusstringThe refund status (see Refund statuses).
customerIdstringID of the customer who receives the refund.
originalOrderIdstringThe ID of the order being refunded.
orderIdstring | nullThe credit note order ID, null until the refund is processed.
totalMoneyTotal amount including taxes.
subtotalMoneySubtotal amount before taxes.
taxSummaryTaxSummaryCollectionTax breakdown by rate.
linesarrayThe refund lines. Use $refund->lines() for a collection of RefundLine objects.
testmodeboolWhether this is a test refund.
createdAtstringCreation timestamp (ISO 8601).
linksRefundLinksLinks to this refund, the original order, the credit note order (null until there is one) and customerInvoice, the customer-portal page of the refund's credit note (null until the refund is processed). The customerInvoice URL is signed and expires after 72 hours (the customer then sees a page to request a new link).

Create a partial refund

POST /v1/orders/:orderId/refunds

Refund part of an order, line by line.

Required attributes

NameTypeDescription
itemsarrayThe order lines to refund. See Refund items below.

Optional attributes

NameTypeDescription
metadataarrayYour custom metadata.

Refund items

NameTypeRequiredDescription
itemIdstringYesThe ID of the order line to refund.
amountarrayYesAmount to refund for this line before taxes: ['value' => '10.00', 'currency' => 'EUR']. Cannot exceed what is left to refund for the line.
descriptionstring | nullNoCustom description for this refund line.
descriptionAdditionalLinestring | nullNoAdditional description line.
$refund = $vatly->orderRefunds->createForOrderId('order_abc123', [
    'items' => [
        [
            'itemId' => 'order_item_abc123',
            'amount' => ['value' => '10.00', 'currency' => 'EUR'],
            'description' => 'Partial refund',
        ],
    ],
]);

echo $refund->id;
echo $refund->status;

Create a full refund

POST /v1/orders/:orderId/refunds/full

Refund everything that can still be refunded on an order.

Optional attributes

NameTypeDescription
metadataarrayYour custom metadata.
$refund = $vatly->orderRefunds->createFullRefundForOrderId('order_abc123', []);

// Or from an order you already fetched
$refund = $order->fullRefund([]);

Retrieve a refund

GET /v1/refunds/:id

Retrieve a refund by its ID.

$refund = $vatly->refunds->get('refund_abc123');

echo $refund->status;
echo $refund->total->value . ' ' . $refund->total->currency;

List all refunds

GET /v1/refunds

Retrieve a paginated list of all refunds.

Optional attributes

NameTypeDescription
startingAfterstringA cursor for pagination: return the page after this refund ID.
endingBeforestringA cursor for pagination: return the page before this refund ID.
limitintegerThe number of refunds to return (default: 10, max: 100).
$refunds = $vatly->refunds->page();

foreach ($refunds as $refund) {
    echo $refund->id . ': ' . $refund->status;
}

// Pass the cursors and limit in order: startingAfter, endingBefore, limit
$refunds = $vatly->refunds->page('refund_last_id', null, 25);

// One order's refunds (GET /v1/orders/:orderId/refunds)
$refunds = $vatly->orderRefunds->pageForOrderId('order_abc123');

Cancel a refund

DELETE /v1/orders/:orderId/refunds/:refundId

Cancel a refund that has not been processed yet. Once it is processing, cancellation is no longer possible.

$vatly->orderRefunds->cancelRefundForOrderId('order_abc123', 'refund_abc123');

// Or from a refund you already fetched
$refund->cancel();

Refund statuses

StatusDescription
pendingRefund is ready to be sent to the bank
queuedRefund is queued due to a lack of balance
processingRefund is being processed (cancellation is no longer possible)
refundedRefund has been processed successfully
failedRefund failed after processing
canceledRefund was canceled

The Refund object has no status helper methods. Compare $refund->status against the Vatly\API\Types\RefundStatus constants:

use Vatly\API\Types\RefundStatus;

if ($refund->status === RefundStatus::REFUNDED) {
    // The money is on its way back to the customer
}
Copyright © 2026