Handles Source resource endpoints.
Endpoints
- POST /v1/sources - Create source
- GET /v1/sources/:id - Retrieve source
- POST /v1/sources/:id - Update source
- GET /v1/sources - List sources
Note: Sources cannot be deleted (can only be detached from customers).
Source Object
%{
id: "src_...",
object: "source",
created: 1234567890,
type: "card" | "bank_account" | "sepa_debit" | "alipay" | etc.,
customer: "cus_..." | nil,
status: "pending" | "chargeable" | "consumed" | "canceled" | "failed",
amount: 2000, # Optional, for single-use sources (in cents)
currency: "usd",
metadata: %{},
# ... other fields depending on source type
}
Summary
Functions
Creates a new source.
Lists all sources with pagination and optional customer filter.
Retrieves a source by ID.
Updates a source.
Functions
@spec create(Plug.Conn.t()) :: Plug.Conn.t()
Creates a new source.
Required Parameters
- type - Source type (card, bank_account, sepa_debit, alipay, etc.)
Optional Parameters
- customer - Customer ID to attach source to
- amount - Amount in cents (for single-use sources)
- currency - Three-letter ISO currency code (default: "usd")
- metadata - Key-value metadata
- owner - Owner information (name, email, phone, address)
- statement_descriptor - Descriptor for bank statements
@spec list(Plug.Conn.t()) :: Plug.Conn.t()
Lists all sources with pagination and optional customer filter.
Parameters
- limit - Number of items (default: 10, max: 100)
- starting_after - Cursor for pagination
- ending_before - Reverse cursor
- customer - Filter by customer ID (optional)
@spec retrieve(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Retrieves a source by ID.
@spec update(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Updates a source.
Note: Sources have limited updatable fields.
Updatable Fields
- metadata
- owner
- statement_descriptor