Skip to content

Refunds

Create refunds to return funds to a customer's payment method. Refunds are always associated with a specific payment.

Partial and Full Refunds

You can issue a full refund for the entire payment amount, or a partial refund for a lesser amount. Multiple partial refunds can be issued against the same payment, as long as the total refunded does not exceed the original payment amount. The amount_refunded field on the payment tracks the cumulative refunded amount.

QR Ph Payments

QR Ph (qrph) payments do not support refunds. See Payment Methods — Refund Support for details.

Create a Refund

php
use LegionHQ\LaravelPayrex\Facades\Payrex;

$refund = Payrex::refunds()->create([
    'payment_id' => 'pay_xxxxx', // Required
    'amount' => 10000,                                        // Required. cents
    'reason' => 'others',                                     // Required
]);
php
use LegionHQ\LaravelPayrex\Enums\RefundReason;
use LegionHQ\LaravelPayrex\Facades\Payrex;

$refund = Payrex::refunds()->create([
    'payment_id' => 'pay_xxxxx',
    'amount' => 10000,
    'reason' => RefundReason::Others->value,
    'remarks' => 'The customer is disappointed about item XYZ.',
]);
php
use LegionHQ\LaravelPayrex\Enums\RefundReason;
use LegionHQ\LaravelPayrex\Facades\Payrex;

$refund = Payrex::refunds()->create([
    'payment_id' => 'pay_xxxxx',
    'amount' => 10000,
    'reason' => RefundReason::RequestedByCustomer->value,
    'metadata' => [
        'ticket_id' => 'SUP-001',
        'agent' => 'admin@example.com',
    ],
]);

Returns a Refund resource.

Example Response:

json
{
    "id": "re_xxxxx",
    "resource": "refund",
    "amount": 10000,
    "status": "succeeded",
    "currency": "PHP",
    "description": "",
    "reason": "others",
    "remarks": "The customer is disappointed about item XYZ.",
    "livemode": false,
    "metadata": null,
    "payment_id": "pay_xxxxx",
    "created_at": 1700407880,
    "updated_at": 1700407880
}

Parameters

ParameterTypeRequiredDescription
payment_idstringYesPayment to refund (pay_ prefix)
amountintegerYesRefund amount in cents
reasonstringYesRefund reason (see below)
currencystringNoDefaults to config PAYREX_CURRENCY. Note: the PayRex API requires this field, but the package sends your configured default automatically.
descriptionstringNoReference text
remarksstringNoVisible in the PayRex dashboard
metadataobjectNoKey-value pairs

Available Reasons

A reason is required when creating a refund. Use the RefundReason enum for type safety:

EnumValue
RefundReason::Fraudulentfraudulent
RefundReason::RequestedByCustomerrequested_by_customer
RefundReason::ProductOutOfStockproduct_out_of_stock
RefundReason::ServiceNotProvidedservice_not_provided
RefundReason::ProductWasDamagedproduct_was_damaged
RefundReason::ServiceMisalignedservice_misaligned
RefundReason::WrongProductReceivedwrong_product_received
RefundReason::Othersothers

Update a Refund

Update a refund's metadata:

php
use LegionHQ\LaravelPayrex\Facades\Payrex;

$refund = Payrex::refunds()->update('re_xxxxx', [
    'metadata' => ['ticket_id' => 'SUP-001', 'resolved' => 'true'],
]);

Returns a Refund resource.

Example Response:

json
{
    "id": "re_xxxxx",
    "resource": "refund",
    "amount": 10000,
    "status": "succeeded",
    "currency": "PHP",
    "description": "",
    "reason": "others",
    "remarks": "The customer is disappointed about item XYZ.",
    "livemode": false,
    "metadata": {
        "ticket_id": "SUP-001",
        "resolved": "true"
    },
    "payment_id": "pay_xxxxx",
    "created_at": 1700407880,
    "updated_at": 1700407900
}

Refund Resource

FieldTypeDescription
idstringUnique identifier (re_ prefix)
resourcestringAlways refund
amountintegerRefund amount in cents
currencystringThree-letter ISO currency code
statusstringSee RefundStatus
payment_idstringAssociated payment ID
reasonstringRefund reason
descriptionstringReference text
remarksstring|nullDashboard notes
metadataobject|nullKey-value pairs
livemodebooleanLive or test mode
created_atintegerUnix timestamp
updated_atintegerUnix timestamp

Refund Statuses

StatusDescription
succeededThe refund was processed successfully and funds have been returned to the customer.
pendingThe refund is being processed. Some refunds may require additional processing time depending on the payment method. Listen for the refund.updated webhook to get the final status.
failedThe refund could not be processed. This may occur if the payment method is no longer valid or the issuer declined the refund.

Property Access

Response field names above are shown in snake_case (matching the raw API response). In PHP, access them as camelCase typed properties on the DTO — e.g., payment_id becomes $refund->paymentId. See Response Data for details.

Further Reading

Released under the MIT License.