README.md in payture_api-0.1.7 vs README.md in payture_api-0.1.8

- old
+ new

@@ -1,11 +1,9 @@ -# PaytureRuby +# Payture for Ruby -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/payture_ruby`. To experiment with that code, run `bin/console` for an interactive prompt. +Welcome to the Payture for Ruby gem! This gem allows you to integrate Payture into your Ruby application (Rails, etc.) -TODO: Delete this and the text above, and describe your gem - ## Installation Add this line to your application's Gemfile: ```ruby @@ -20,22 +18,116 @@ $ gem install payture_ruby ## Usage -TODO: Write usage instructions here +In your code you will need to require the gem: +```ruby +require 'payture' +``` -## Development +## API -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. +### Payture::Wallet -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). +#### Init +```ruby +HOST = ENV['PAYTURE_HOST'] // i.e. sandbox.payture.com +MERCHANT_ADD = ENV['PAYTURE_ADD'] // VWMerchantExampleAdd +payload = { + OrderId: 'ABC123', + SessionType: 'Block', + VWUserLgn: @user.email, + VWUserPsw: @user.token, + Amount: 100 +} + +wallet = Payture::Wallet.new(HOST) +result = wallet.init(MERCHANT_ADD, payload) +``` + +#### Pay +```ruby +HOST = ENV['PAYTURE_HOST'] // i.e. sandbox.payture.com +MERCHANT_PAY = ENV['PAYTURE_PAY'] // VWMerchantExamplePay + +payload = { + OrderId: 'DCB312', + VWUserLgn: @user.email, + VWUserPsw: @user.token, + Amount: 100 + CardId: @order.card_id +} + +wallet = Payture::Wallet.new(HOST) +result = wallet.pay(MERCHANT_PAY, payload) +``` + +### Payture::User + +#### Register +```ruby +HOST = ENV['PAYTURE_HOST'] // i.e. sandbox.payture.com +MERCHANT_ADD = ENV['PAYTURE_ADD'] // VWMerchantExampleAdd + +payload = { + VWUserLgn: @user.email, + VWUserPsw: @user.token +} + +wallet = Payture::User.new(HOST) +result = wallet.register(MERCHANT_ADD, payload) +``` + +#### Update +```ruby +HOST = ENV['PAYTURE_HOST'] // i.e. sandbox.payture.com +MERCHANT_ADD = ENV['PAYTURE_ADD'] // VWMerchantExampleAdd + +payload = { + VWUserLgn: @user.email, + VWUserPsw: @user.token, + Phone: @user.phone +} + +wallet = Payture::User.new(HOST) +result = wallet.update(MERCHANT_ADD, payload) +``` + +#### Check +```ruby +HOST = ENV['PAYTURE_HOST'] // i.e. sandbox.payture.com +MERCHANT_ADD = ENV['PAYTURE_ADD'] // VWMerchantExampleAdd + +payload = { + VWUserLgn: @user.email, + VWUserPsw: @user.token +} + +wallet = Payture::User.new(HOST) +result = wallet.check(MERCHANT_ADD, payload) +``` + +#### Delete +```ruby +HOST = ENV['PAYTURE_HOST'] // i.e. sandbox.payture.com +MERCHANT_ADD = ENV['PAYTURE_ADD'] // VWMerchantExampleAdd +PASSWORD = ENV['PAYTURE_PASSWORD'] + +payload = { + VWUserLgn: @user.email, + password: PASSWORD +} + +wallet = Payture::User.new(HOST) +result = wallet.delete(MERCHANT_ADD, payload) +``` + ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/payture_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). -