Skip to content

coingecko/moolah-ruby

Repository files navigation

Build Status

Moolah::Ruby

Wrapper API for Moolah's Transaction API (v2)

Installation

Add this line to your application's Gemfile:

gem 'moolah-ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install moolah-ruby

Usage

Configuration:

require 'moolah'

Moolah.configure do |config|
  config.api_key = ENV['API_KEY']
  config.api_secret = ENV['API_SECRET'] # necessary for IPN response
  # config.endpoint = "https://api.moolah.io" # endpoint must not contain paths, "/v2" is included in API calls
end

Create a transaction:

moolah_client = Moolah::Client.new

# No IPN Response
response = moolah_client.create_transaction(coin: "bitcoin", currency: "USD", amount: "20", product: "Coingecko Pro")

# IPN Response
response = moolah_client.create_transaction(coin: "bitcoin", currency: "USD", amount: "20", product: "Coingecko Pro", ipn: "www.example.com/processed_payment", ipn_extra: "{ user_id: 1 }")

response[:status] # "success"
response[:guid] # "1234-1234-1234-1234"
response[:address] # "abcdefghijklmnopqrstuvwxyz"
# etc.

Query a transaction:

query_result = moolah_client.query_transaction(guid:"1234-1234-1234-1234")

query_result[:status] # "success"
query_result[:transaction][:tx][:coin] # "bitcoin"
# etc.

API Doc

Complete API documentation available at https://moolah.io/dashboard/merchant/api

Contributing

  1. Fork it ( https://github.com/coingecko/moolah-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Ruby wrapper for the Moolah.io Transaction API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages