Customer resource for Razorpay API.
This module provides functions for working with customers:
- Create, fetch, update, and list customers
- Manage customer details and tokens
Summary
Functions
Lists all customers with optional filters.
Creates a new customer.
Fetches a customer by ID.
Updates a customer.
Types
Functions
@spec all(map()) :: {:ok, [t()]} | {:error, RazorpayEx.Error.t()}
Lists all customers with optional filters.
Parameters
params: Query parameters (count, skip, etc.)
Examples
# List first 10 customers
{:ok, customers} = RazorpayEx.Customer.all(%{count: 10})
@spec create(map()) :: {:ok, t()} | {:error, RazorpayEx.Error.t()}
Creates a new customer.
Parameters
params: Customer parameters (name, email, contact, etc.)
Required Parameters
name: Customer nameemail: Customer emailcontact: Customer contact number
Optional Parameters
gstin: Customer GSTINnotes: Additional notes
Examples
{:ok, customer} = RazorpayEx.Customer.create(%{
name: "John Doe",
email: "john@example.com",
contact: "+919999999999",
notes: %{
customer_since: "2023"
}
})
@spec fetch(String.t()) :: {:ok, t()} | {:error, RazorpayEx.Error.t()}
Fetches a customer by ID.
Parameters
id: Customer ID
Examples
{:ok, customer} = RazorpayEx.Customer.fetch("cust_9A33XWu170gUtm")
@spec update(String.t(), map()) :: {:ok, t()} | {:error, RazorpayEx.Error.t()}
Updates a customer.
Parameters
id: Customer IDparams: Update parameters (name, email, contact, notes, etc.)
Examples
{:ok, customer} = Razorpay.Customer.update("cust_9A33XWu170gUtm", %{
name: "John Updated",
email: "updated@example.com",
notes: %{updated_at: "2024-01-01"}
})