GithubHelp home page GithubHelp logo

omise-sample's Introduction

Omise Elixir Client

Build Status Hex.pm Coverage Status

Omise for Elixir

Installation

First, add omise to your list of dependencies in mix.exs:

def deps do
  [{:omise, "~> 0.6.0"}]
end

Then update your dependencies with:

$ mix deps.get

Configuration

Set the following configuration variables in config/config.exs file:

config :omise,
  public_key: "pkey_test_xxx",
  secret_key: "skey_test_xxx"

Or manually configure at runtime:

Omise.configure(public_key: "pkey_test_xxx", secret_key: "skey_test_xxx")

To configure the HTTP options, you could optionally add :http_options key to the omise configuration. For a full list of the available options, please check HTTPoison documentation.

config :omise,
  http_options: [timeout: 60_000, recv_timeout: 60_000]

Example

charge_params = [amount: 100_00, currency: "thb", card: "tokn_xxx"]

with {:ok, %Omise.Charge{paid: true}} <- Omise.Charge.create(charge_params) do
  # handle success
  IO.puts "Thank you :)"
else
  {:ok, %Omise.Charge{failure_code: failure_code}} ->
    # handle failure

  {:error, %Omise.Error{code: code, message: message}} ->
    # handle error
end

You can also set a per-request key and api version when making an API call:

Omise.Charge.list([], key: "skey_test_xxx", api_version: "2015-11-17")

Omise.Charge.retrieve("chrg_test_4yq7duw15p9hdrjp8oq", key: "skey_test_xxx")

Omise.Charge.create([
  amount: 1000_00,
  currency: "thb",
  customer: "cust_test_xxx"
], key: "skey_test_xxx")

Development

  • Install all dependencies with mix deps.get
  • Run tests with mix test

Documentation

omise-sample's People

Contributors

kanokorn avatar lowks avatar tteerawat avatar

Watchers

 avatar

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.