Giter VIP home page Giter VIP logo

omise-ruby's Introduction

Omise Ruby Library

Maintainability GitHub Actions status Gem

Security Warning

Please do NOT use Omise Ruby library versions less than 0.8.0, as they are outdated and have security vulnerabilities.

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.

API version

To enforce the API version that the application must use, specify it by setting 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 that you are 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, 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.

omise-ruby's People

Contributors

ajzkk avatar anasnaouchi avatar danfowler avatar fred avatar gitter-badger avatar jakyns avatar jonrandy avatar muthuswamyopn avatar prodis avatar rezigned avatar sirn avatar som-m avatar toshihide-tamura avatar varshard avatar zacksiri avatar zentetsukenz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

omise-ruby's Issues

`key` parameter fails to propagate

We toggle between multiple keys but it appears the library is working against us in many cases.

  1. Omise.api_key must be set (I found issue #19 with an identical problem but it was cryptically closed without documenting the solution)
  2. Omise::Charge.retrieve('chrg_xxxxxx', key: 'xxxxxxxx') works, but calling charge.transaction on the result results in a transaction not found error, unless I repeat the key with charge.transaction(key: 'xxxxxxxx')
  3. Omise::List object doesn't retain the key when I paginate with next_page, and this one doesn't even accept the key parameter

Specify timeout options for RestClient::Resource

It would be good to have some default timeout for RestClient::Resource.new

Relatively sensible values could be:

 :open_timeout => 15 # Connection time
 :read_timeout => 60 # Response time

Since a transaction will never be higher than 60 seconds, and connecting to the API should not be longer than 15 seconds.

Pagination attributes being ignored

When querying the list resources, the pagination attributes are not taken into account.

for example, when issuing this list api call:

Omise::Charge.list(from: "2015-04-01", to: "2015-05-01", limit: 2, offset: 1)

Response gives out 20 results, ignore the attributes and date filtering.

<Omise::List:0x007f810c1b9470 
@attributes={
"object"=>"list", 
"from"=>"1970-01-01T00:00:00+00:00", 
"to"=>"2015-05-05T06:09:41+00:00", 
"offset"=>0, 
"limit"=>20, 
"total"=>36,
"data"=>[....]

Fpx

          [install_linux.md](https://github.com/omise/omise-ruby/files/11315441/install_linux.md)

Originally posted by @Akmalsaiful in #52 (comment)

Can't skip settings Omise.api_key

I need to use multi key. So I decided to send key with method option.

When I skip to set Omise.api_key I got error like picture below.
screen shot 2559-12-15 at 10 18 18 pm

It seem like Omise.api_key need to be empty string at least.

Does it Have the other way to skip to set Omise.api_key?

uninitialized constant Omise::Scheduler::WEEKDAY_OF_MONTH

Running this sample code from https://www.omise.co/charge-schedules-api

require "omise"

Omise.secret_api_key = ENV['OMISE_SECRET_KEY']

scheduler = Omise::Charge.schedule({
  customer:    cust_test.id,
  card:        card_test.id,
  amount:      100000,
  description: "Membership fee"
})

schedule = scheduler.every(1).month(on: "2nd_monday")
  .start_date("2022-11-01")
  .end_date("2022-12-31")
  .start

Raises this error:

Traceback (most recent call last):

2: from samples//2014-07-27/charge_schedules/create/create_monthly_by_week.rb:12:in `<main>'
1: from /Users/dan/.rvm/gems/ruby-2.5.1/gems/omise-0.7.1/lib/omise/scheduler.rb:56:in `months'
/Users/dan/.rvm/gems/ruby-2.5.1/gems/omise-0.7.1/lib/omise/scheduler.rb:141:in `month_with_weekday': uninitialized constant Omise::Scheduler::WEEKDAY_OF_MONTH (NameError)

inconsistent outcome

Hi

when Omise::Token.create method is succeed, it returns json
but when failed, it returns text format

so it causes JSON::Parser error on my rspec

JSON::ParserError: 822: unexpected token at '
from /Users/xxxx/.rbenv/versions/2.4.7/lib/ruby/gems/2.4.0/gems/json-1.8.6/lib/json/common.rb:155:in `parse'
```

Please update wiki

I found in wiki to set
Omise.api_key = "skey_test_4xa89ox4z4bcfrikkh2"

but after try out a little bit i found that should use "Omise.vault_key" instead

;D

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.