ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - aviabird/gringotts: A complete payment library for Elixir and Phoenix Framework
A complete payment library for Elixir and Phoenix Framework - aviabird/gringotts
Visit Site

GitHub - aviabird/gringotts: A complete payment library for Elixir and Phoenix Framework

GitHub - aviabird/gringotts: A complete payment library for Elixir and Phoenix Framework

Gringotts offers a simple and unified API to access dozens of different payment gateways with very different APIs, response schemas, documentation and jargon.

The project started out as a fork of commerce_billing and the notable differences are:

  1. No GenServer process to act as a "payment worker".
  2. Consistent docs and good amount of tests.
  3. Support many more payment gateways.

Installation

From hex.pm

Add gringotts to the list of dependencies of your application.

# your mix.exs

def deps do
  [
    {:gringotts, "~> 1.1"},
    # ex_money provides an excellent Money library, and integrates
    # out-of-the-box with Gringotts
    {:ex_money, ">= 2.6.0"}
  ]
end

Usage

This simple example demonstrates how a purchase can be made using a sample credit card using the MONEI gateway.

One must "register" their account with gringotts ie, put all the authentication details in the Application config. Usually via config/config.exs

# config/config.exs

config :gringotts, Gringotts.Gateways.Monei,
    userId: "your_secret_user_id",
    password: "your_secret_password",
    entityId: "your_secret_channel_id"

Copy and paste this code in a module or an IEx session, or use this handy .iex.exs for all the bindings.

alias Gringotts.Gateways.Monei
alias Gringotts.CreditCard

# a fake sample card that will work now because the Gateway is by default
# in "test" mode.

card = %CreditCard{
  first_name: "Harry",
  last_name: "Potter",
  number: "4200000000000000",
  year: 2099, month: 12,
  verification_code:  "123",
  brand: "VISA"
}

# a sum of $42
amount = Money.new(42, :USD)

case Gringotts.purchase(Monei, amount, card) do
  {:ok,    %{id: id}} ->
    IO.puts("Payment authorized, reference token: '#{id}'")

  {:error, %{status_code: error, raw: raw_response}} ->
    IO.puts("Error: #{error}\nRaw:\n#{raw_response}")
end

On the Gringotts.Money protocol and money representation

All financial applications must take proper care when representing money in their system. Using simple floating values might lead to losses in the real world due to various reasons.

Most payment gateways are strict about the formatting of the amount in the request, hence we cannot render arbitrary floating amounts like $4.99999. Moreover, such amounts might mean something to your application but they don't have any value in the real world (since you can't charge someone for a fraction of a US cent).

Your application must round such amounts before invoking Gringotts and manage any remainders sensibly yourself.

Gringotts may perform rounding using the half-even strategy, but it will discard remainders if any.

Supported "Money" libraries

Gringotts does not ship with any library to work with monies. You are free to choose any monie library you wish, as long as they implement the Gringotts.Money for their type!

That said, we recommend [ex_money][ex_money] (above v2.6.0) to represent monies. You just have to add it in your deps().

Supported Gateways

Gateway PCI compliance purchase authorize capture void refund (card) store (card) unstore
Authorize.Net mandatory
CAMS mandatory
MONEI mandatory
PAYMILL optional
Stripe optional
TREXLE mandatory

Road Map

Apart from supporting more and more gateways, we also keep a somewhat detailed plan for the future on our wiki.

FAQ

1. What's with the name? "Gringotts"?

Gringotts has a nice ring to it. Also this.

License

MIT

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory