Skip to main content
The ApiRefunds class provides methods to retrieve refund transactions. Refunds are created through the PayIn or PayOut objects.

Methods

Get

Get a refund object by ID.
public function Get($refundId)
refundId
string
required
The unique identifier of the refund
Returns: \MangoPay\Refund - The Refund object Example:
$refund = $api->Refunds->Get('refund_123456');
To create refunds, use ApiPayIns->CreateRefund() for pay-in refunds. Refunds for payouts are created through the payout endpoints.

Refund Entity

The Refund entity represents a refund transaction.

Properties

Id
string
The unique identifier of the refund
CreationDate
int
Unix timestamp of when the refund was created
Tag
string
Custom data for your use
AuthorId
string
required
The user ID who initiated the refund
CreditedUserId
string
The user ID being credited by the refund
DebitedWalletId
string
The ID of the wallet being debited for the refund
CreditedWalletId
string
The ID of the wallet being credited by the refund
DebitedFunds
\MangoPay\Money
required
The amount debited for the refund
CreditedFunds
\MangoPay\Money
The amount credited by the refund (DebitedFunds - Fees)
Fees
\MangoPay\Money
required
The fees for the refund transaction
Status
string
The status of the refund: CREATED, SUCCEEDED, FAILED
ResultCode
string
The result code of the refund
ResultMessage
string
The result message explaining the result code
ExecutionDate
int
Unix timestamp of when the refund was executed
Type
string
The transaction type: PAYOUT or TRANSFER
Nature
string
The transaction nature: REFUND
InitialTransactionId
string
required
The ID of the initial transaction being refunded
InitialTransactionType
string
required
The type of the initial transaction: PAYIN, PAYOUT, TRANSFER
RefundReason
\MangoPay\RefundReasonDetails
Contains information about the reason for the refund
Reference
string
Custom reference for the refund
StatementDescriptor
string
A description that appears on the bank statement

Usage Example

Refunds are typically created through the parent transaction:
// Create a refund for a pay-in
$refund = new \MangoPay\Refund();
$refund->AuthorId = $userId;
$refund->DebitedFunds = new \MangoPay\Money();
$refund->DebitedFunds->Currency = 'EUR';
$refund->DebitedFunds->Amount = 500;
$refund->Fees = new \MangoPay\Money();
$refund->Fees->Currency = 'EUR';
$refund->Fees->Amount = 5;

// Create the refund
$result = $api->PayIns->CreateRefund('payin_123456', $refund);

// Later, retrieve the refund
$retrievedRefund = $api->Refunds->Get($result->Id);

Build docs developers (and LLMs) love