Skip to content
Opennode.co Elixir Client
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
config
lib
test
.credo.exs
.formatter.exs
.gitignore
Dockerfile
LICENSE
README.md
mix.exs
mix.lock

README.md

OpenNodex

Hex version badge Build status badge Code coverage badge

A (very) simple interface to opennode.co - more to come if this gets wings.

Installation

The package can be installed by adding opennodex to your list of dependencies in mix.exs:

def deps do
  [
    {:opennodex, "~> 0.5.0"}
  ]
end

API Documentation is also available at https://hexdocs.pm/opennodex.

Configuration

You can set a default api key and alternative request module via the configuration:

config :opennodex,
  request: OpenNodex.Request,
  api_key: "api_key"

Usage

Create a $99 charge, with callback and success URLs:

OpenNodex.Client.new("[your api_key here]")
|> OpenNodex.create_charge(99, %{currency: "USD", callback_url: "https://example.com/callback", success_url: "https://example.com/success"})

Will return an {:ok, %Charge{id: ...}} upon success or {:error, ...} on failure.

Testing

A MockRequest module has been supplied, and is interchangeable with the default Request module. By configuring the request to use the MockRequest module instead, you can test your app without side-effects or external service dependencies. Also, you can replace the stock request library for your own.

As an example, you can place the following in your config.exs (or config/test.exs) in order to override the request module when tests are run.

config :opennodex,
  request: OpenNodex.MockRequest

TODO

  • Phoenix integration for the callback events.
You can’t perform that action at this time.