Handles Refund resource endpoints.
Endpoints
- POST /v1/refunds - Create refund
- GET /v1/refunds/:id - Retrieve refund
- POST /v1/refunds/:id - Update refund
- GET /v1/refunds - List refunds
Note: Refunds cannot be deleted (immutable resource).
Refund Object
%{
id: "re_...",
object: "refund",
created: 1234567890,
amount: 2000, # in cents ($20.00)
charge: "ch_...",
currency: "usd",
status: "succeeded",
reason: "requested_by_customer",
metadata: %{},
# ... other fields
}
Summary
Functions
Creates a new refund.
Lists all refunds with pagination.
Retrieves a refund by ID.
Updates a refund.
Functions
@spec create(Plug.Conn.t()) :: Plug.Conn.t()
Creates a new refund.
Required Parameters
- charge - Charge ID to refund
Optional Parameters
- amount - Amount in cents to refund (if not provided, refunds full charge)
- reason - Reason for refund: "duplicate", "fraudulent", "requested_by_customer"
- metadata - Key-value metadata
@spec list(Plug.Conn.t()) :: Plug.Conn.t()
Lists all refunds with pagination.
Parameters
- limit - Number of items (default: 10, max: 100)
- starting_after - Cursor for pagination
- ending_before - Reverse cursor
- charge - Filter by charge ID
- status - Filter by status (succeeded, pending, failed)
@spec retrieve(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Retrieves a refund by ID.
@spec update(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Updates a refund.
Note: Refunds can only have limited fields updated.
Updatable Fields
- metadata