Paystack :dollar::dollar:

A library for working with Paystack in Elixir with out of the box support for telemetry events.

Elixir CICoverage StatusHex.pm

Comprehensive documentation available on HexDocs

Requirements

This package requires Elixir v1.12+

Installation

Add the following to your mix.exs file

  {:paystack, "~> 0.6.0"}

Then run mix deps.get to pull in the package

Configuration

Add the following to your config.exs or runtime.exs file

config :paystack, secret_key: System.get_env("PAYSTACK_SECRET_KEY")

Your environment variable does not have to be PAYSTACK_SECRET_KEY, as the package only depends on the config key.

### Usage This package returns responses in the format of {:ok, Paystack.Response{}} | {:error, any}. This means a successful request would look like this;

  iex> Paystack.Transaction.initialize(%{ email: "customer@email.com", amount: "20000" })
  
  {:ok,
    %Paystack.Response{
    data: %{
      "access_code" => "0peioxfhpn",
      "authorization_url" => "https://checkout.paystack.com/0peioxfhpn",
      "reference" => "7PVGX8MEk85tgeEpVDtD"
    },
    message: "Authorization URL created",
    meta: nil,
    status_code: 200,
    success: true
  }}

An unsuccessful response would look like this;

  iex> Paystack.Transaction.initialize(%{ email: "customer@email.com", amount: "20000" })
  
  {:ok,
    %Paystack.Response{
      data: nil,
      message: "Invalid key",
      meta: nil,
      status_code: 401,
      success: false
    }}

while an unexpected response would look like this.

  iex> Paystack.Transaction.initialize(%{ email: "customer@email.com", amount: "20000" })
  
  {:error, :nxdomain}

## Telemetry This library executes the following telemetry events:

Happy coding!

Testing

Run mix test

License

MIT

TODO