https://github.com/infinitered/elavon-elixir
Native elixir client for USBank Elavon Converge API
https://github.com/infinitered/elavon-elixir
Last synced: 6 months ago
JSON representation
Native elixir client for USBank Elavon Converge API
- Host: GitHub
- URL: https://github.com/infinitered/elavon-elixir
- Owner: infinitered
- License: mit
- Created: 2017-11-27T21:01:14.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-07T23:58:38.000Z (about 8 years ago)
- Last Synced: 2024-10-29T08:41:35.544Z (about 1 year ago)
- Language: Elixir
- Homepage:
- Size: 27.3 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Elavon
[](https://semaphoreci.com/ir/elavon-elixir)
[](https://coveralls.io/github/infinitered/elavon-elixir?branch=master)
A native [USBank Elavon Converge](https://developer.elavon.com/#/home/landing) elixir client. This library only supports a fraction of the full Elavon API, however what is written is production ready.
## Installation
Add `elavon` to your list of dependencies in `mix.exs` and run `mix deps.get`:
```elixir
def deps do
[
{:elavon, "~> 0.1.0"}
]
end
```
## Configuration
After `elavon` is installed, you'll need to add the appropriate configuration:
```
config :elavon,
environment: :sandbox,
transaction_module: Elavon.Transaction.HTTP,
ssl_merchant_id: System.get_env("ELAVON_MERCHANT_ID"),
ssl_user_id: System.get_env("ELAVON_USER_ID"),
ssl_pin: System.get_env("ELAVON_PIN"),
custom_fields: [:Site, :EDate, :SDate]
```
The environment defaults to `:sandbox`, but you'll want to change it to `:production` in your `prod.exs` file.
The transaction module is configurable so that you can create a mock module for testing if necessary. For example:
```
# Create Elavon.Transaction.Mock module
defmodule Elavon.Transaction.Mock do
def sale(params, opts) do
# return a mocked response
end
end
# Update test.exs config file:
config :elavon,
transaction_module: Elavon.Transaction.Mock
```
The custom fields configuration option allows you to specify any custom fields you've defined on your account, which you'd like to be returned as part of the transaction response.
## Usage
The test cards are not listed in the documentation and they may change in future. Here is the current visa test card number:
**VISA**: 4124939999999990
```
params = %{
ssl_card_number: 4124939999999990,
ssl_cvv2cvc2_indicator: 1,
ssl_cvv2cvc2: 123,
ssl_amount: 10.00,
ssl_exp_date: 1220,
ssl_invoice_number: to_string(Enum.take_random(?a..?z, 20))
}
case Elavon.sale(params) do
{:ok, %Elavon.Transaction{} = transaction} -> do_something_with_transaction(transaction)
{:error, %Elavon.Exception{} = error} -> report_error(error)
{:error, %HTTPoison{id: nil, reason: :timeout}} -> handle_timeout()
end
```
## Premium Support
Elavon, as an open source project, is free to use and always will be. [Infinite Red](https://infinite.red) offers premium Elavon support and general web &
mobile app design/development services. Get in touch [here](https://infinite.red/contact) or email us at [hello@infinite.red](mailto:hello@infinite.red).
