• Stars
    star
    475
  • Rank 89,443 (Top 2 %)
  • Language
    Elixir
  • License
    MIT License
  • Created over 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A complete payment library for Elixir and Phoenix Framework

Gringotts Logo

Gringotts is a payment processing library in Elixir integrating various payment gateways, drawing motivation from Shopify's activemerchant gem and commerce_billing. Checkout the demo here.

Build Status Coverage Status Docs coverage Help Contribute to Open Source

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

More Repositories

1

angularspree

angular e-commerce framework for online store
TypeScript
1,674
star
2

yatrum

Yatrum - Share and Discover Travel Stories, Itineraries, Travel Guides built with β™₯️ using Angular 4.0.0
TypeScript
349
star
3

pinterest

PinWork(Pinterest for bloggers) built with ❀️ using Angular2 (4.0.0)
TypeScript
199
star
4

angular-seed

Angular Seed App with Angular 5.0, ngrx/store 4, bootstrap 4, ngrx/effects, immutable.js
TypeScript
84
star
5

angularhunt

Rate & Discuss(coming soon) about open source angular projects.
TypeScript
71
star
6

gringotts_payment

Demo Phoenix app showing gringotts payment library integrations.
Elixir
26
star
7

crowdfunding

Crowdfunding Platform in Angular2
HTML
25
star
8

Yatrum-ios

IOS APP for Yatrum App built with ❀️ using swift-3 with ReSwift, RxSwift observables and backend API available
Swift
20
star
9

pinterest-backend

Pinterest Clone Backend in Phoenix Framework
Elixir
20
star
10

listify

Twitter lists reimagined in an Angular2 application
TypeScript
19
star
11

angularspree-api

API for angular spree frontend
Ruby
18
star
12

yatrum-api

Backend Rails Api for Yatrum app
Ruby
13
star
13

crowdfunding-rails-api

Backend API for crowdfunding repo
Ruby
8
star
14

r-book

Super Cook Recipe Book on Angular2 Built with ngrx/store, effects, Dynamic Forms deployed with store logger
TypeScript
8
star
15

eco_earth

Eco Earth Pledge
JavaScript
5
star
16

gringotts_example

Elixir
5
star
17

tax-app

A simple tax calculator app built in angular2, ngrx/store, Reactive forms etc.
TypeScript
5
star
18

takeapledge_api

Api for Eco Earth built with Phoenix 1.3 @docs https://aviabird.github.io/takeapledge_api
Elixir
4
star
19

howto

company guidelines on all things programming
3
star
20

listify-backend

Ruby
2
star
21

bottle

Elixir
1
star
22

flutter-forum

Flutter form for community
Dart
1
star
23

eventago

CQRS application builder
Go
1
star
24

yt_comment_service

Comment Service in Phoenix
JavaScript
1
star
25

angularhunt-api

Ruby
1
star
26

ngx-carousel

Angular 6+ carousel
TypeScript
1
star