pinxs v2.0.3 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.

  • email
  • 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

Link to this type t() View Source
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: nil | String.t(),
  customer_token: nil | String.t(),
  description: nil | String.t(),
  email: nil | String.t(),
  ip_address: nil | 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

Link to this function capture(charge, config) View Source
capture(PINXS.Charges.Charge.t(), PINXS.t()) ::
  {:ok, PINXS.Charges.Charge.t()} | {:error, PINXS.Error.t()}

Captures a previously authorized charge

Link to this function capture(charge, amount, config) View Source
capture(PINXS.Charges.Charge.t(), map(), PINXS.t()) ::
  {:ok, PINXS.Charges.Charge.t()} | {:error, PINXS.Error.t()}
Link to this function create(charge_map, config) View Source
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

Link to this function get(token, config) View Source
get(String.t(), PINXS.t()) ::
  {:ok, PINXS.Charges.Charge.t()} | {:error, PINXS.Error.t()}

Retrieves a single charge

Link to this function get_all(config) View Source
get_all(PINXS.t()) ::
  {:ok, [PINXS.Charges.Charge.t()]} | {:error, PINXS.Error.t()}

Retrieves a paginated list of charges

Link to this function get_all(page, config) View Source
get_all(integer(), PINXS.t()) ::
  {:ok, [PINXS.Charges.Charge.t()]} | {:error, PINXS.Error.t()}

Retrieves a specific pages of charges

Link to this function search(query_map, config) View Source
search(map(), PINXS.t()) :: {:ok, map()} | {: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
}