ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - 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
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 - swelham/cashier
Visit Site

GitHub - 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

GitHub - 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

Cashier

Build Status Deps Status Hex Version Join the chat at https://gitter.im/swelham/cashier Open Source Helpers

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

defp deps do
  {:cashier, "~> 0.2.0"}
end

Make sure the cashier application gets started

def application do
  [applications: [:cashier]]
end

Config options

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: "<paypal_client_id>",
  client_secret: "<paypal_client_secret>"

Cashier request examples

alias Cashier.Address
alias Cashier.PaymentCard

address = %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("<capture_id>", 19.45, [final_capture: true]) do
    {:ok, result}     -> IO.inspect result
    {:error, reason}  -> IO.inspect reason
end

#Void request
case Cashier.void("<void_id>") do
    {:ok, result}     -> IO.inspect result
    {:error, reason}  -> IO.inspect reason
end

#Refund request
case Cashier.refund("<refund_id>", [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("<card_id>") do
    :ok               -> IO.puts "card unstored"
    {:error, reason}  -> IO.inspect reason
end

Todo

All current todo items are listed on the issues page.

Please add any issues, suggestions or feature requests to this page.

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