pinxs v2.0.0 PINXS.Charges.Charge View Source
The Charge module provides functions for working wtih charges.
Required Fields
When creating a charge, the following fields are required.
- description
- amount
- ip_address
and one of
- card
- card_token
- customer_token
Error handling
All requests return tagged tuples in the form {:ok, result}
or {:error, %PINXS.Error{}}
Link to this section Summary
Functions
Captures a previously authorized charge
Creates a new charge and returns its details
Retrieves a single charge
Retrieves a paginated list of charges
Retrieves a specific pages of charges
Retrieve charges based on search criteria
Link to this section Types
t() :: %PINXS.Charges.Charge{ amount: nil | integer(), amount_refunded: nil | integer(), authorisation_expired: nil | boolean(), capture: nil | boolean(), captured: nil | boolean(), card: nil | PINXS.Cards.Card.t(), card_token: nil | String.t(), currency: String.t(), customer_token: nil | String.t(), description: String.t(), email: String.t(), ip_address: String.t(), merchant_entitlement: nil | integer(), metadata: nil | map(), refund_pending: nil | boolean(), settlement_currency: nil | String.t(), token: nil | String.t(), total_fees: nil | integer(), transfer: nil | list() }
Link to this section Functions
capture(PINXS.Charges.Charge.t(), PINXS.t()) :: {:ok, PINXS.Charges.Charge.t()} | {:error, PINXS.Error.t()}
Captures a previously authorized charge
capture(PINXS.Charges.Charge.t(), map(), PINXS.t()) :: {:ok, PINXS.Charges.Charge.t()} | {:error, PINXS.Error.t()}
create(PINXS.Charges.Charge.t(), PINXS.t()) :: {:ok, PINXS.Charges.Charge.t()} | {:error, PINXS.Error.t()}
Creates a new charge and returns its details
The Charge
struct must have one of the following fields, card
, card_token
or customer_token
get(String.t(), PINXS.t()) :: {:ok, PINXS.Charges.Charge.t()} | {:error, PINXS.Error.t()}
Retrieves a single charge
get_all(PINXS.t()) :: {:ok, [PINXS.Charges.Charge.t()]} | {:error, PINXS.Error.t()}
Retrieves a paginated list of charges
get_all(integer(), PINXS.t()) :: {:ok, [PINXS.Charges.Charge.t()]} | {:error, PINXS.Error.t()}
Retrieves a specific pages of charges
search(map(), PINXS.t()) :: {:ok, [PINXS.Charges.Charge.t()]} | {:error, PINXS.Error.t()}
Retrieve charges based on search criteria
Search options
%{
query: "",
start_date: "YYYY/MM/DD", # 2013/01/01
end_date: "YYYY/MM/DD", # 2013/12/25
sort: "", # field to sort by, default `created_at`
direction: 1 # 1 or -1
}