Cielo.Consultation (Cielo v0.1.8) View Source

This module makes all consultations call in Cielo API

Reference API:

Link to this section Summary

Functions

Consult bin card for extra informations about card.

Wrap a consultation of a payment by merchant_order_id, if not found a payments with this merchant_order_id, an error tuple will be returned.

Consult one payment by paymentID.

Consult one recurrent payment by paymentID.

Consult ZeroAuth for validate card and holder.

Link to this section Functions

Specs

bin(binary()) :: {:error, any(), list()} | {:error, any()} | {:ok, map()}

Consult bin card for extra informations about card.

Example

iex(1)> Cielo.Consultation.bin("538965")
{:ok,
  %{
    card_type: "Débito",
    corporate_card: false,
    foreign_card: true,
    issuer: "Bradesco",
    issuer_code: "237",
    provider: "MASTERCARD",
    status: "00"
  }
}
Link to this function

merchant_order(merchant_order_id)

View Source

Specs

merchant_order(binary()) ::
  {:error, any(), list()} | {:error, any()} | {:ok, map()}

Wrap a consultation of a payment by merchant_order_id, if not found a payments with this merchant_order_id, an error tuple will be returned.

The payload of response have a :payment key with valeu as a list, eg.:

Examples

iex(1)> Cielo.Consultation.merchant_order("2014111703")
{:ok,
%{
payments: [
  %{
    payment_id: "37d2dcc6-6397-4d40-8066-2539397cfa8c",
    receveid_date: "2020-10-02T20:46:22.033"
  },
  %{
    payment_id: "9b446419-32c3-4feb-aab4-54768767c1a0",
    receveid_date: "2020-10-04T15:14:04.93"
  }
]
}

iex(2)> Cielo.Consultation.merchant_order("0000000000")
{:error, :not_found}

Specs

payment(binary()) :: {:error, any(), list()} | {:error, any()} | {:ok, map()}

Consult one payment by paymentID.

Example

iex(1)> Cielo.Consultation.payment("37d2dcc6-6397-4d40-8066-2539397cfa8c")
{:ok,
  %{
    customer: %{address: %{}, name: "Comprador crédito simples"},
    merchant_order_id: "2014111703",
    payment: %{
      amount: 15700,
      authenticate: false,
      ...
    }
  }
}
Link to this function

recurrent_payment(recurrent_payment_id)

View Source

Specs

recurrent_payment(binary()) ::
  {:error, any(), list()} | {:error, any()} | {:ok, map()}

Consult one recurrent payment by paymentID.

Example

iex(1)> Cielo.Consultation.recurrent_payment("8814cc0e-3658-42bc-8820-52b7439e668a")
{:ok,
  %{
    customer: %{address: %{}, name: "Comprador crédito simples"},
    merchant_order_id: "2014111703",
    payment: %{
      amount: 15700,
      authenticate: false,
      ...
    }
  }
}

Specs

zero_auth(map()) :: {:error, any(), list()} | {:error, any()} | {:ok, map()}

Consult ZeroAuth for validate card and holder.

Example

iex(1)> attrs = %{
  brand: "Visa",
  card_number: "1234123412341231",
  card_on_file: %{reason: "Recurring", usage: "First"},
  expiration_date: "12/2021",
  holder: "Alexsander Rosa",
  save_card: "false",
  security_code: "123"
}
iex(2)> Cielo.Consultation.zero_auth(attrs)
{:ok,
  %{
    valid: true,
    return_code: "00",
    return_message: "Transacao autorizada",
    issuer_transaction_id: "580027442382078"
  }
}