Giter VIP home page Giter VIP logo

omise-ruby's Introduction

Omise Ruby Client

CodeClimate CircleCI Gem Join the chat at https://gitter.im/omise/omise-ruby

Installation

Installing via rubgems:

gem 'omise'

Or use the cutting-edge version by installing via github:

gem 'omise', github: 'omise/omise-ruby'

Requirements

Requires ruby 1.9.2 or above, the rest-client and json gem.

Configuration

First configure your secret key:

Omise.api_key = "skey_test_xxxxxxxxxxxxxxxxxxx"

If you need to use the Token API you also need to set your public key:

Omise.vault_key = "pkey_test_xxxxxxxxxxxxxxxxxxx"

With this set you'll be able to retrieve tokens or create new ones.

However we recommend using Omise.js to create tokens. When creating a token server side you'll need card data transiting to and from your server and this requires that your organization be PCI compliant.

API version

In case you want to enforce API version the application use, you can specify it by setting the api_version. The version specified by this settings will override the version setting in your account. This is useful if you have multiple environments with different API versions (e.g. development on the latest but production on the older version).

require "omise"
Omise.api_version = "2014-07-27"

It is highly recommended to set this version to the current version you're using.

Quick Start

After you have implemented Omise.js on your frontend you can charge the card by passing the token into the card attribute.

# Charge 1000.00 THB
charge = Omise::Charge.create({
  amount: 1_000_00,
  currency: "thb",
  card: params[:omise_token]
})

if charge.paid
  # handle success
  puts "thanks"
else
  # handle failure
  raise charge.failure_code
end

You can check the complete documentation at docs.omise.co.

Development

The test suite can be run with bundle exec rake test.

omise-ruby's People

Contributors

gitter-badger avatar sirn 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.