Giter Site home page Giter Site logo

moneris-elixir's Introduction

MonerisElixir

Unofficial Elixir client for processing payments through Moneris.

Installation

def deps do
  [
    {:moreris, git: "https://github.com/tiagopog/moneris-elixir.git"}
  ]
end

Usage

Example of Pre-Authorization + Completion with CVD

##
# 1. Set up the gateway infomation:
##

iex> gateway = Moneris.Gateway.new(:development, "{{username}}", "{{api_key}}")
%Moneris.Gateway{
  url: "https://esqa.moneris.com/gateway2/servlet/MpgRequest",
  store_id: "{{username}}",
  api_token: "{{api_key}}"
}

##
# 2. Pre-authorize the payment:
##

iex> Moneris.preauth(gateway, order, card)
{:ok,
 %Moneris.Response{
   order_id: "e7e4a53245084998b5f7fa8155ffde10",
   amount: 1001,
   transaction_number: "10-0_482",
   reference_number: "660188080010010130",
   message: "Approved",
   code: 0,
   cvd: "1M",
   avs: "",
   cvd_verified: false,
   address_verified: false,
   zipcode_verified: false,
   success: true
 }}

##
# 3. Update the order with some data from pre-authorization step:
##

iex> order = %Moneris.Order{order | transaction_number: "10-0_482", reference_number: "660188080010010130"}
%Moneris.Order{
  order_id: "e7e4a53245084998b5f7fa8155ffde10",
  amount: 1001,
  crypt_type: 7,
  cust_id: "ecom-order-num-5",
  transaction_number: "10-0_482",
  reference_number: "660188080010010130"
}

##
# 4. Capture the payment:
##

iex> Moneris.capture(gateway, order)
{:ok,
 %Moneris.Response{
   order_id: "e7e4a53245084998b5f7fa8155ffde10",
   amount: 1001,
   transaction_number: "11-1_482",
   reference_number: "660188080010010140",
   message: "Approved",
   code: 0,
   cvd: "",
   avs: "",
   cvd_verified: false,
   address_verified: false,
   zipcode_verified: false,
   success: true
 }}

moneris-elixir's People

Contributors

tiagopog avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

juliandicks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.