Cielo.Recurrency (Cielo v0.1.8) View Source

This module centralize all calls about recurrent payments.

Link to this section Summary

Functions

Create a recurrent payment data.

Deactivate a recurrent payment transaction

Reactivate a recurrent payment transaction

Update a recurrent payment amount

Update a recurrent payment charge day

Update a recurrent payment end date.

Update a recurrent payment interval,

Update a recurrent payment with next charge date, this call change the next date of charge but, mantain other payment dates same the original transaction.

Update a recurrent payment data.

Link to this section Types

Specs

http_response() :: {:error, any()} | {:error, any(), any()} | {:ok, any()}

Link to this section Functions

Specs

create_payment(map()) :: http_response()

Create a recurrent payment data.

Examples

iex(1)> Cielo.Recurrency.create_payment(valid_params)
{:ok, success_map}

iex(2)> Cielo.Recurrency.create_payment(invalid_params)
{:error, :bad_request, [%{code: 313, message: "Recurrent Payment not found"}]}

iex(2)> Cielo.Recurrency.create_payment(invalid_params)
{:error, %{
  errors: [...]
}}
Link to this function

deactivate(recurrent_payment_id)

View Source

Specs

deactivate(binary()) :: http_response()

Deactivate a recurrent payment transaction

Examples

iex(1)> Cielo.Recurrency.deactivate("26e5da86-d975-4e2f-aa25-862b5a43e9f4")
{:ok, :deactivated}

iex(2)> Cielo.Recurrency.deactivate("26e5da86-d975-4e2f-aa25-862b5a44e8f6")
{:error, :bad_request, [%{code: 313, message: "Recurrent Payment not found"}]}

iex(3)> Cielo.Recurrency.deactivate(100)
{:error, :invalid_guid}
Link to this function

reactivate(recurrent_payment_id)

View Source

Specs

reactivate(binary()) :: http_response()

Reactivate a recurrent payment transaction

Examples

iex(1)> Cielo.Recurrency.reactivate("26e5da86-d975-4e2f-aa25-862b5a43e9f4")
{:ok, :reactivated}

iex(2)> Cielo.Recurrency.reactivate("26e5da86-d975-4e2f-aa25-862b5a44e8f6")
{:error, :bad_request, [%{code: 313, message: "Recurrent Payment not found"}]}

iex(3)> Cielo.Recurrency.reactivate(100)
{:error, :invalid_guid}
Link to this function

update_amount(recurrent_payment_id, amount)

View Source

Specs

update_amount(binary(), non_neg_integer()) :: http_response()

Update a recurrent payment amount

Examples

iex(1)> Cielo.Recurrency.update_amount("26e5da86-d975-4e2f-aa25-862b5a43e9f4", 1000)
{:ok, :updated}

iex(2)> Cielo.Recurrency.update_amount("26e5da86-d975-4e2f-aa25-862b5a44e8f6", 100)
{:error, :bad_request, [%{code: 313, message: "Recurrent Payment not found"}]}

iex(3)> Cielo.Recurrency.update_amount("26e5da86-d975-4e2f-aa25-862b5a43e9f4", %{amount: 100})
{:error, :invalid_parameters}

iex(4)> Cielo.Recurrency.update_amount("1000", 100)
{:error, :invalid_guid}
Link to this function

update_charge_day(recurrent_payment_id, charge_day)

View Source

Specs

update_charge_day(binary(), non_neg_integer()) :: http_response()

Update a recurrent payment charge day

Examples

iex(1)> Cielo.Recurrency.update_charge_day("26e5da86-d975-4e2f-aa25-862b5a43e9f4", 15)
{:ok, :updated}

iex(2)> Cielo.Recurrency.update_charge_day("26e5da86-d975-4e2f-aa25-862b5a44e8f6", 15)
{:error, :bad_request, [%{code: 313, message: "Recurrent Payment not found"}]}

iex(3)> Cielo.Recurrency.update_charge_day("26e5da86-d975-4e2f-aa25-862b5a43e9f4", 40)
{:error, :bad_request, [%{code: 317, message: "Invalid Recurrency Day"}]}

iex(4)> Cielo.Recurrency.update_charge_day("862b5a43e9f4", 15)
{:ok, :invalid_guid}

iex(5)> Cielo.Recurrency.update_charge_day("862b5a43e9f4", -15)
{:ok, :invalid_parameters}
Link to this function

update_end_date(recurrent_payment_id, new_date)

View Source

Specs

update_end_date(binary(), binary()) :: http_response()

Update a recurrent payment end date.

The date informed needs be ISO8601 format.

Examples

iex(1)> Cielo.Recurrency.update_end_date("26e5da86-d975-4e2f-aa25-862b5a43e9f4", "2020-12-12")
{:ok, :updated}

iex(2)> Cielo.Recurrency.update_end_date("26e5da86-d975-4e2f-aa25-862b5a43e9f4", ~D[2020-12-12])
{:ok, :updated}

iex(3)> Cielo.Recurrency.update_end_date("26e5da86-d975-4e2f-aa25-862b5a44e8f6", 2)
{:error, :bad_request, [%{code: 313, message: "Recurrent Payment not found"}]}

iex(4)> Cielo.Recurrency.update_end_date("862b5a43e9f4", 15)
{:ok, :invalid_guid}

iex(5)> Cielo.Recurrency.update_end_date("26e5da86-d975-4e2f-aa25-862b5a43e9f4", -15)
{:ok, :invalid_parameters}

iex(6)> Cielo.Recurrency.update_end_date("26e5da86-d975-4e2f-aa25-862b5a43e9f4", "2020-15-12")
{:ok, :invalid_date}
Link to this function

update_interval(recurrent_payment_id, interval)

View Source

Specs

update_interval(binary(), non_neg_integer() | atom()) :: http_response()

Update a recurrent payment interval,

You can use atoms for predefined intervals.

Valid intervals:

  • :monthly = 1
  • :bimonthly = 2
  • :quarterly = 3
  • :semi_annual = 6
  • :annual = 12

Examples

iex(1)> Cielo.Recurrency.update_interval("26e5da86-d975-4e2f-aa25-862b5a43e9f4", 2)
{:ok, :updated}

iex(2)> Cielo.Recurrency.update_interval("26e5da86-d975-4e2f-aa25-862b5a43e9f4", :bimonthly)
{:ok, :updated}

iex(3)> Cielo.Recurrency.update_interval("26e5da86-d975-4e2f-aa25-862b5a44e8f6", 2)
{:error, :bad_request, [%{code: 313, message: "Recurrent Payment not found"}]}

iex(4)> Cielo.Recurrency.update_interval("862b5a43e9f4", 15)
{:ok, :invalid_guid}

iex(5)> Cielo.Recurrency.update_interval("862b5a43e9f4", -15)
{:ok, :invalid_parameters}
Link to this function

update_next_charge_date(recurrent_payment_id, new_date)

View Source

Specs

update_next_charge_date(binary(), binary()) :: http_response()

Update a recurrent payment with next charge date, this call change the next date of charge but, mantain other payment dates same the original transaction.

The date informed needs be ISO8601 format.

Examples

iex(1)> Cielo.Recurrency.update_next_charge_date("26e5da86-d975-4e2f-aa25-862b5a43e9f4", "2020-12-12")
{:ok, :updated}

iex(2)> Cielo.Recurrency.update_next_charge_date("26e5da86-d975-4e2f-aa25-862b5a43e9f4", ~D[2020-12-12])
{:ok, :updated}

iex(3)> Cielo.Recurrency.update_next_charge_date("26e5da86-d975-4e2f-aa25-862b5a44e8f6", 2)
{:error, :bad_request, [%{code: 313, message: "Recurrent Payment not found"}]}

iex(4)> Cielo.Recurrency.update_next_charge_date("862b5a43e9f4", 15)
{:ok, :invalid_guid}

iex(5)> Cielo.Recurrency.update_next_charge_date("26e5da86-d975-4e2f-aa25-862b5a43e9f4", -15)
{:ok, :invalid_parameters}

iex(6)> Cielo.Recurrency.update_next_charge_date("26e5da86-d975-4e2f-aa25-862b5a43e9f4", "2020-15-12")
{:ok, :invalid_date}
Link to this function

update_payment_data(recurrent_payment_id, params)

View Source

Specs

update_payment_data(binary(), map()) :: http_response()

Update a recurrent payment data.

Caveats: This changing affects all data of payment json key. Thus, for mantaining previous data, you must inform the fields that will not be changed with the same saved values. For more information read the official documentation here

Examples

iex(1)> Cielo.Recurrency.update_end_date("26e5da86-d975-4e2f-aa25-862b5a43e9f4", %{...})
{:ok, :updated}

iex(2)> Cielo.Recurrency.update_end_date("26e5da86-d975-4e2f-aa25-862b5a44e8f6", %{...})
{:error, :bad_request, [%{code: 313, message: "Recurrent Payment not found"}]}

iex(3)> Cielo.Recurrency.update_end_date("862b5a43e9f4", %{...})
{:ok, :invalid_guid}