The official Ruby library for the UniBee Billing API. It provides a simple way to integrate subscriptions, invoices, payments, users, plans, and more into your Ruby application.
- API reference — UniBee API overview and dashboard
- OpenAPI spec — full endpoint definition
Add the gem to your application:
# Gemfile
gem 'unibee'Then run:
bundle installOr install the gem directly:
gem install unibee- Ruby 2.7+
Configure the client with your merchant credentials (from the UniBee Dashboard):
require 'unibee'
# Default host is https://api.unibee.top
Unibee.configure do |config|
config.api_key['Authorization'] = 'your_merchant_api_key'
endList subscriptions:
api = Unibee::SubscriptionApi.new
response = api.subscription_list_get
# => subscription list responseGet a single invoice:
api = Unibee::InvoiceApi.new
invoice = api.invoice_detail_get(invoice_id)List plans:
api = Unibee::PlanApi.new
plans = api.plan_list_getCreate a checkout session:
api = Unibee::CheckoutSetupApi.new
req = Unibee::UnibeeApiMerchantCheckoutSetupReq.new(
plan_id: plan_id,
user_id: user_id,
success_url: 'https://yoursite.com/success',
cancel_url: 'https://yoursite.com/cancel'
)
result = api.checkout_setup_post(req)You can pass options to a single request instead of using the global config:
api = Unibee::MerchantApi.new
api.merchant_detail_get(Unibee::ApiClient.new(Unibee.configure))Or build a dedicated client:
config = Unibee::Configuration.new
config.api_key['Authorization'] = 'another_key'
config.host = 'https://api.unibee.top'
client = Unibee::ApiClient.new(config)
api = Unibee::SubscriptionApi.new(client)
api.subscription_list_getbegin
api.invoice_detail_get(invoice_id)
rescue Unibee::ApiError => e
puts "HTTP status: #{e.code}"
puts "Response: #{e.response_body}"
end| Option | Description | Default |
|---|---|---|
host |
API base URL | https://api.unibee.top |
api_key |
Auth header key/value | — |
scheme |
http or https |
https |
timeout |
Request timeout (sec) | — |
Unibee.configure do |config|
config.host = 'https://api.unibee.top'
config.api_key['Authorization'] = 'Bearer your_key'
config.debugging = false
endMIT. See LICENSE for details.