Testcloud::Billing::Ruby
Connecting to the testCloud Billing API (currently only used internally).
Installation
Add this line to your application's Gemfile:
gem 'testcloud-billing-ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install testcloud-billing-ruby
Usage
Configure the client (e.g. in an initializer):
Testcloud::Billing.setup url: 'http(s)://api.example.com', api_key: 'your_api_key'
Create a Customer (in this case with SEPA direct debit payment):
customer = Testcloud::Billing::Customer.create(
company: "testCloud.de GmbH", # this or 'name' is required
address_line_one: "Boxhagenerstr. 76/78",
zip: "10245",
city: "Berlin",
country: "DE",
email: "[email protected]",
vatid: "DE279558871", # required if in EU but outside DE
locale: "en",
timezone: "Berlin",
payment_method: "sepa_debit",
sepa_data_attributes: {
iban: "DEAVALIDIBAN",
bic: "AVALIDBIC"
}
)
For credit card customers use this:
...
payment_method: "credit_card",
credit_card_data_attributes: { # from Stripe.js
stripe_token: "THESTRIPETOKEN",
last4: "4242",
brand: "visa",
exp_month: "05",
exp_year: "2020",
name: "Name on card", # optional
country: "DE" # optional
}
Billing a customer:
bill = Testcloud::Billing::Bill.create(
customer_id: customer.id,
currency: 'EUR',
month: 5,
year: 2014,
bill_items_attributes: [
{
title: 'A month of service',
price_for_one: 99.25,
quantity: 1,
description: '' # optional
}
]
)
Contributing
- Fork it ( https://github.com/testCloud/testcloud-billing-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request