Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swelham/cashier
Cashier is an Elixir library that aims to be an easy to use payment gateway, whilst offering the fault tolerance and scalability benefits of being built on top of Erlang/OTP
https://github.com/swelham/cashier
elixir gateway payment payment-gateway paypal
Last synced: 2 months ago
JSON representation
Cashier is an Elixir library that aims to be an easy to use payment gateway, whilst offering the fault tolerance and scalability benefits of being built on top of Erlang/OTP
- Host: GitHub
- URL: https://github.com/swelham/cashier
- Owner: swelham
- License: mit
- Created: 2016-11-17T10:00:18.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-21T19:27:11.000Z (almost 7 years ago)
- Last Synced: 2024-09-14T16:24:03.960Z (4 months ago)
- Topics: elixir, gateway, payment, payment-gateway, paypal
- Language: Elixir
- Homepage:
- Size: 83 KB
- Stars: 48
- Watchers: 8
- Forks: 10
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Payment gateway offering a common interface into multiple payment providers. (Third Party APIs)
- fucking-awesome-elixir - cashier - Payment gateway offering a common interface into multiple payment providers. (Third Party APIs)
- awesome-elixir - cashier - Payment gateway offering a common interface into multiple payment providers. (Third Party APIs)
README
# Cashier
[![Build Status](https://travis-ci.org/swelham/cashier.svg?branch=master)](https://travis-ci.org/swelham/cashier) [![Deps Status](https://beta.hexfaktor.org/badge/all/github/swelham/cashier.svg?branch=master)](https://beta.hexfaktor.org/github/swelham/cashier) [![Hex Version](https://img.shields.io/hexpm/v/cashier.svg)](https://hex.pm/packages/cashier) [![Join the chat at https://gitter.im/swelham/cashier](https://badges.gitter.im/swelham/cashier.svg)](https://gitter.im/swelham/cashier?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Open Source Helpers](https://www.codetriage.com/swelham/cashier/badges/users.svg)](https://www.codetriage.com/swelham/cashier)Cashier is an Elixir library that aims to be an easy to use payment gateway, whilst offering the fault tolerance and scalability benefits of being built on top of Erlang/OTP
# Usage
The following are basic usage examples on how to use cashier in it's current state. This library is being activily developed and is likely to
change as we move towards the first release.### Setup
Add cashier as a dependency
```elixir
defp deps do
{:cashier, "~> 0.2.0"}
end
```Make sure the cashier application gets started
```elixir
def application do
[applications: [:cashier]]
end
```### Config options
```elixir
use Mix.Config# cashier options
config :cashier, :cashier,
defaults: [
currency: "USD",
gateway: :paypal,
timeout: 20_000 # this option is the OTP timeout setting
],
# this option is passed directly into HTTPoison and can contain any
# of the valid options listed here - https://hexdocs.pm/httpoison/HTTPoison.html#request/5
http: [
recv_timeout: 20_000
]# PayPal specific config
config :cashier, :paypal,
# Please note the PayPal gateway currently only supports the /v1 endpoint
# and this is automattically added for you
url: "https://api.sandbox.paypal.com",
client_id: "",
client_secret: ""
```### Cashier request examples
```elixir
alias Cashier.Address
alias Cashier.PaymentCardaddress = %Address{
line1: "123",
line2: "Main",
city: "New York",
state: "New York",
country_code: "US",
postal_code: "10004"
}card = %PaymentCard{
holder: {"John", "Smith"},
brand: "visa",
number: "4032030901103714",
expiry: {11, 2021},
cvv: "123"
}# Note: The result return type for each request is currently the decoded
# data returned from the payment provider, this will change in the future.# Purchase request
# the card parameter can be either a %PaymentCard or stored card id
case Cashier.purchase(9.99, card, [billing_address: address]) do
{:ok, result} -> IO.inspect result
{:error, reason} -> IO.inspect reason
end# Authorize request
# the card parameter can be either a %PaymentCard or stored card id
case Cashier.authorize(9.99, card, [billing_address: address]) do
{:ok, result} -> IO.inspect result
{:error, reason} -> IO.inspect reason
end# Capture request
case Cashier.capture("", 19.45, [final_capture: true]) do
{:ok, result} -> IO.inspect result
{:error, reason} -> IO.inspect reason
end#Void request
case Cashier.void("") do
{:ok, result} -> IO.inspect result
{:error, reason} -> IO.inspect reason
end#Refund request
case Cashier.refund("", [amount: 9.99]) do
{:ok, result} -> IO.inspect result
{:error, reason} -> IO.inspect reason
end#Store request
case Cashier.store(card, [billing_address: address]) do
{:ok, result} -> IO.inspect result
{:error, reason} -> IO.inspect reason
end#Unstore request
case Cashier.unstore("") do
:ok -> IO.puts "card unstored"
{:error, reason} -> IO.inspect reason
end
```# Todo
All current todo items are listed on the [issues page](https://github.com/swelham/cashier/issues).
Please add any issues, suggestions or feature requests to this page.