Ruby wrapper for PAYMILL API forked by dkd's paymill-ruby
- If you are not familiar with PAYMILL, start with the documentation.
- Install the latest release.
- Check the API reference.
- Check the specification examples.
- Take a look at the change log for recent updates and improvements.
Add this line to your application's Gemfile:
gem 'paymill', git: 'git://github.com/paymill/paymill-ruby.git'And then execute:
$ bundle
The paymill gem is tested on Ruby 1.9.3, 2.0.0, 2.1.0, 2.1.3 and 2.1.5. It requires ruby version 1.9.3+
Initialize the library by providing your api key:
Paymill.api_key = '<YOUR PRIVATE API KEY>'or by reading it from the envirounment variables
Paymill.api_key = ENV['PAYMILL_API_TEST_KEY']Creating via factory method create, which expects an optional hash as arguments. If some of the required attributes are missing the method will throw ArgumentError.
With a hash of optional arguments:
client = Paymill::Client.create( email: 'john.rambo@qaiware.com', description: 'Main caracter in First Blood' )Without mandatory arguments:
client = Paymill::Client.createYou can retrieve an object by using the find method with an object id:
client = Paymill::Client.find( 'client_b54ff8b3811e06c02e14' )or with the instance itself:
client = Paymill::Client.find( client )Update is done by modifying the instance variables of the object. The object itself provides accessor methods only for properties which can be updated.
client = Paymill::Client.find( 'client_b54ff8b3811e06c02e14' )
client.email = 'john.rambo.2@qaiware.com'
client.description = 'Main caracter in First Blood II'
client.updateYou may delete objects by calling the its instance method delete. The delete method will return nil when the given object is removed successfully.
client = Paymill::Client.find( 'client_b54ff8b3811e06c02e14' )
client.deleteTo retrieve a list you may simply use the all class method
clients = Paymill::Client.allYou may provide filter, order, offset and count parameters to list method
clients = Paymill::Client.all( order: [:email, :created_at_desc], count: 30, offset: 10, filters: [email: 'john.rambo@qaiware.com', created_at: "#{4.days.ago.to_i}-#{2.days.ago.to_i}"] )When you want to update the offer and to apply the new changes to its subscriptions you can pass an additional parameter update_subscriptions set to true to its instance method update
offer = Offer.find( 'offer_b54ff8b3811e06c02e14' )
offer.amount = 1000
offer.update( update_subscriptions: true )To delete an offer and its corresponding subscriptions call
offer = Offer.find( 'offer_b54ff8b3811e06c02e14' )
offer.delete_with_subscriptions()To delete an offer but leave its corresponding subscriptions call
offer = Offer.find( 'offer_b54ff8b3811e06c02e14' )
offer.delete_without_subscriptionsTo delete an offer and its corresponding subscriptions you can call the instance method delete with an argument remove_with_subscriptions set to true
offer = Offer.find( 'offer_b54ff8b3811e06c02e14' )
offer.delete( remove_with_subscriptions: true )To create a refund you have to pass a transaction, which you want to be refunded.
transaction = Transaction.create( token: '098f6bcd4621d373cade4e832627b4f6', amount: 990, currency: 'EUR' )
refund = Refund.create( transaction, amount: 100 )- Fork it ( https://github.com/paymill/paymill-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Setup the project (
bundle install) - Setup PAYMILL's test key in your environment (
export PAYMILL_API_TEST_KEY="<YOUR_TEST_KEY>") - Run all the tests (
rspec .)or a subset from them (rspec ./spec/paymill/models/client_spec.rb) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
