Refund resource for Razorpay API.
This module provides functions for working with refunds:
- Create, fetch, and list refunds
- Process refunds for payments
Summary
Functions
Lists all refunds with optional filters.
Creates a refund for a payment.
Fetches a refund by ID.
Fetches multiple refunds for a payment.
Types
@type t() :: %RazorpayEx.Refund{ acquirer_data: map() | nil, amount: integer() | nil, batch_id: String.t() | nil, created_at: integer() | nil, currency: String.t() | nil, entity: String.t() | nil, id: String.t() | nil, notes: map() | nil, payment_id: String.t() | nil, receipt: String.t() | nil, speed_processed: String.t() | nil, speed_requested: String.t() | nil, status: String.t() | nil }
Functions
@spec all(map()) :: {:ok, [t()]} | {:error, RazorpayEx.Error.t()}
Lists all refunds with optional filters.
Parameters
params: Query parameters (count, skip, payment_id, etc.)
Examples
# List first 10 refunds
{:ok, refunds} = RazorpayEx.Refund.all(%{count: 10})
# List refunds for a specific payment
{:ok, refunds} = RazorpayEx.Refund.all(%{payment_id: "pay_29QQoUBi66xm2f"})
@spec create(String.t(), map()) :: {:ok, t()} | {:error, RazorpayEx.Error.t()}
Creates a refund for a payment.
Parameters
payment_id: Payment IDparams: Refund parameters (amount, notes, etc.)
Required Parameters
amount: Amount to refund (in paise)
Optional Parameters
notes: Additional notesreceipt: Your refund receipt IDspeed: Refund speed ("normal", "optimum")
Examples
# Full refund
{:ok, refund} = RazorpayEx.Refund.create("pay_29QQoUBi66xm2f", %{
amount: 50000
})
# Partial refund with notes
{:ok, refund} = RazorpayEx.Refund.create("pay_29QQoUBi66xm2f", %{
amount: 25000,
notes: %{reason: "Defective product"},
speed: "optimum"
})
@spec fetch(String.t()) :: {:ok, t()} | {:error, RazorpayEx.Error.t()}
Fetches a refund by ID.
Parameters
id: Refund ID
Examples
{:ok, refund} = RazorpayEx.Refund.fetch("rfnd_9A33XWu170gUtm")
@spec for_payment(String.t(), map()) :: {:ok, [t()]} | {:error, RazorpayEx.Error.t()}
Fetches multiple refunds for a payment.
Parameters
payment_id: Payment IDparams: Query parameters
Examples
{:ok, refunds} = RazorpayEx.Refund.for_payment("pay_29QQoUBi66xm2f")