Apruve v0.1.0 Apruve.Order View Source

Module for Apruve orders.

Link to this section Summary

Functions

Get all orders. Optionally only ones matching a certain merchant_order_id

Convert a JSON string to an Order struct or list of Order structs

Get an order by the Apruve order id

Link to this section Types

Link to this type order_id() View Source
order_id() :: String.t()
Link to this type t() View Source
t() :: %Apruve.Order{
  accepts_payment_terms: term(),
  accepts_payments_via: term(),
  amount_cents: term(),
  created_at: term(),
  currency: term(),
  default_payment_method: term(),
  expire_at: term(),
  final_state_at: term(),
  finalize_on_create: term(),
  id: term(),
  invoice_on_create: term(),
  links: term(),
  merchant_id: term(),
  merchant_order_id: term(),
  order_items: term(),
  payment_term: term(),
  payment_terms: term(),
  secure_hash: term(),
  shipping_cents: term(),
  shopper_id: term(),
  status: term(),
  tax_cents: term(),
  updated_at: term()
}

Link to this section Functions

Link to this function all(merchant_order_id \\ nil, p_client_config \\ :from_app_config) View Source

Get all orders. Optionally only ones matching a certain merchant_order_id.

A merchant order id is the order id used by the merchant.

Results can be limited to the first 25 orders by the server side API.

Link to this function create(order, p_client_config \\ :from_app_config) View Source
create(t(), Apruve.ClientConfig.t() | :from_app_config) ::
  {:ok, t()} | {:error, any()}

Create an order.

Link to this function from_json(json_string) View Source
from_json(String.t()) ::
  {:ok, t()} | {:ok, [t()]} | {:error, :could_not_make_struct_from_json}

Convert a JSON string to an Order struct or list of Order structs.

Link to this function get(order_id, p_client_config \\ :from_app_config) View Source
get(order_id(), Apruve.ClientConfig.t() | :from_app_config) ::
  {:ok, Apruve.Order.t()} | {:error, any()}

Get an order by the Apruve order id.

iex> {:ok, order} = Apruve.Order.get("719101ae45b8fab4fb542ed65b455635", test_config())
iex> order.id
"02b263350ba2a8f59b0d6e00645cc251"
Link to this function secure_hash_for_order_and_api_key(order, api_key_or_conf) View Source
secure_hash_for_order_and_api_key(
  t(),
  String.t() | Apruve.ClientConfig.t() | :from_app_config
) :: String.t()

Calculates the secure hash.

Takes an order and one of: an API key, an Apruve.ClientConfig struct or :from_app_config

See https://docs.apruve.com/docs/merchant-integration-tutorial-1 for more details.

Link to this function to_json(order) View Source
to_json(%Apruve.Order{
  accepts_payment_terms: term(),
  accepts_payments_via: term(),
  amount_cents: term(),
  created_at: term(),
  currency: term(),
  default_payment_method: term(),
  expire_at: term(),
  final_state_at: term(),
  finalize_on_create: term(),
  id: term(),
  invoice_on_create: term(),
  links: term(),
  merchant_id: term(),
  merchant_order_id: term(),
  order_items: term(),
  payment_term: term(),
  payment_terms: term(),
  secure_hash: term(),
  shipping_cents: term(),
  shopper_id: term(),
  status: term(),
  tax_cents: term(),
  updated_at: term()
}) :: {:ok, String.t()} | {:error, any()}