Skip to content

Akmalsaiful/omise-ruby

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Omise Ruby Client

Maintainability GitHub Actions status Gem

Installation

Add the following to your Gemfile and run bundle install to install via RubyGems:

gem 'omise'

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

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

Requirements

Tested on Ruby 2.5 and above

Configuration

First configure your secret key:

require "omise"

Omise.api_key = "skey_test_xxxxxxxxxxxxxxxxxxx"

After you have implemented Omise.js on your frontend you can charge the card by passing the token generated by Omise.js 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 omise.co/docs.

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).

Omise.api_version = "2019-05-29"

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

Logging

To enable logging you can set Omise.logger with a Ruby logger. All HTTP requests and responses will be logged.

To disable logging, just configure Omise.logger to nil. Default is disabled.

An example configuring Rails logger:

Omise.logger = Rails.logger

Development

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

About

Omise Ruby Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%