Junex.Client (Junex v0.1.0) View Source

Main Module! Defines all possible functions to call Juno API

Link to this section Summary

Functions

Returns the latest charge status

Returns a new client to perform other requests!

Creates and return a new charge

Creates and returns a new Payment

Return you current balance!

Return a card_info map to use on Junex.Client.get_payment_info/2

Return a new charge_billing_info map to be used on Junex.Client.create_charges/4

Retuns a charge_info map with installments == 1 to be used on Junex.Client.create_charges/4

Returns a charge_info map to be used on Junex.Client.create_charges/2

Returns a payment_billing_info map to use on Junex.Client.get_payment_info/2

Returns a payment_info map to be used on Junex.Client.create_payment/3

List all possible banks for Juno transfers

Link to this section Types

Specs

card_info() :: %{creditCardHash: String.t()}

Specs

charge_billing_info() :: %{
  name: String.t(),
  document: String.t(),
  email: String.t(),
  phone: String.t()
}

Specs

charge_info() :: %{
  description: String.t(),
  installments: integer(),
  amount: float(),
  paymentTypes: String.t()
}
Link to this type

payment_billing_info()

View Source

Specs

payment_billing_info() :: %{
  email: String.t(),
  address: %{
    street: String.t(),
    number: integer(),
    complement: String.t(),
    city: String.t(),
    state: String.t(),
    postCode: String.t()
  }
}

Specs

payment_info() :: %{
  chargeId: String.t(),
  billing: payment_billing_info(),
  creditCardDetails: card_info()
}

Specs

total_charge_info() :: %{
  description: String.t(),
  installments: integer(),
  totalAmount: float(),
  paymentTypes: String.t()
}

Link to this section Functions

Link to this function

check_charge_status(client, charge_id, mode)

View Source

Specs

check_charge_status(
  %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()},
  String.t(),
  atom()
) :: {:ok, map()}

Returns the latest charge status

Parameters

  • client: Got from Junex.Client.create/2
  • charge_id: One of results do Junex.Client.create_charges/4
  • mode: :prod | :sandbox
Link to this function

create(access_token, resource_token)

View Source

Specs

create(String.t(), String.t()) ::
  {:ok, %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}}

Returns a new client to perform other requests!

Params

  • access_token: Got from Junex.Auth.get_access_token
  • resource_token: You can generate one on your Juno's account, is the "Private Token"

Examples

iex> Junex.Client.create("access_token", "resource_token")

Link to this function

create_charges(client, charge_info, billing, mode)

View Source

Specs

create_charges(
  %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()},
  total_charge_info() | charge_info(),
  charge_billing_info(),
  atom()
) :: {:ok, map()} | {:error, atom() | String.t() | {atom(), atom()}}

Creates and return a new charge

Parameters

  • client: Got from Junex.Client.create/2
  • charge_info: Build mannualy or generated with Junex.Client.get_charge_info/3 or /4
  • billing: Build mannualy or generated with Junex.Client.get_charge_billing_info/4
  • mode: :prod | :sandbox
Link to this function

create_payment(client, payment_info, mode)

View Source

Specs

create_payment(
  %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()},
  payment_info(),
  atom()
) :: {:ok, map()} | {:error, atom() | String.t() | {atom(), atom()}}

Creates and returns a new Payment

Parameters

  • client: Got from Junex.Client.create/2
  • payment_info: Build mannualy or got from Junex.Client.get_payment_info/3
  • mode: :prod | :sandbox
Link to this function

get_balance(client, mode)

View Source

Specs

get_balance(
  %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()},
  atom()
) :: {:ok, map()} | {:error, atom()}

Return you current balance!

Parameters

  • client: Get from Junex.Client.create/2
  • mode: :prod | :sandbox

Examples

iex> Junex.Client.getbalance(client, :sandbox) {:ok, %{"links" => , "balance" => , "transferableBalance" => , "withheldBalance" => _}}

Link to this function

get_card_info(card_hash)

View Source

Specs

get_card_info(String.t()) :: card_info()

Return a card_info map to use on Junex.Client.get_payment_info/2

Link to this function

get_charge_billing_info(name, doc, email, phone)

View Source

Specs

get_charge_billing_info(String.t(), String.t(), String.t(), String.t()) ::
  charge_billing_info()

Return a new charge_billing_info map to be used on Junex.Client.create_charges/4

Link to this function

get_charge_info(description, payment_type, amount)

View Source

Specs

get_charge_info(String.t(), String.t(), float()) :: charge_info()

Retuns a charge_info map with installments == 1 to be used on Junex.Client.create_charges/4

Link to this function

get_charge_info(description, installments, payment_type, amount)

View Source

Specs

get_charge_info(String.t(), integer(), String.t(), float()) ::
  total_charge_info()

Returns a charge_info map to be used on Junex.Client.create_charges/2

Link to this function

get_payment_billing_info(email, street, st_number, compl, city, state, post_code)

View Source

Specs

get_payment_billing_info(
  String.t(),
  String.t(),
  integer(),
  String.t(),
  String.t(),
  String.t(),
  String.t()
) :: payment_billing_info()

Returns a payment_billing_info map to use on Junex.Client.get_payment_info/2

Link to this function

get_payment_info(charge_id, card_info, payment_billing_info)

View Source

Specs

get_payment_info(String.t(), card_info(), payment_billing_info()) ::
  payment_info()

Returns a payment_info map to be used on Junex.Client.create_payment/3

Parameters

  • charge_id: Result of one entries of Junex.Client.create_charges/4
  • card_info: Build mannualy or got from Junex.Client.get_card_info/1
  • payment_billing_info: Build mannually or got from Junex.Client.get_payment_billing_info/7
Link to this function

list_banks(client, mode)

View Source

Specs

list_banks(
  %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()},
  atom()
) :: {:ok, [map()]} | {:error, atom() | String.t() | {atom(), atom()}}

List all possible banks for Juno transfers

Parameters

  • client: from Junex.Client.create/2
  • mode: :prod | :sandbox

Examples

iex> Junex.Client.list_banks(client, :sandbox) {:ok, [%{"name" => "", "number" => ""}]}