CloudPayments ruby client
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib Merge pull request #17 from numbata/master Oct 19, 2017
spec Add Issuer to transaction and callback payload Sep 5, 2017
.gitignore First commit Dec 25, 2014
.rspec
.travis.yml Update Travis config Feb 17, 2017
Gemfile Add frozen_string_literal comment Aug 3, 2017
LICENSE.txt First commit Dec 25, 2014
README.md Update README.md Dec 25, 2017
Rakefile Add frozen_string_literal comment Aug 3, 2017
cloud_payments.gemspec Add frozen_string_literal comment Aug 3, 2017
config.ru Add frozen_string_literal comment Aug 3, 2017

README.md

Attention!!!

I am not able to maintain this repo anymore. I have no real projects which use this gem, so I do not understand the needs. I cannot test your changes in production env. So it would be nice if someone would take the care of this gem.

Я больше не в состоянии поддерживать этот гем. У меня нет реальных проектов которые его используют, поэтому я не понимаю потребности которые возникают у пользователей. Я не могу его обновлять добавляя новые фичи и проверять закрытые баги на продакшене. Было бы здорово если бы кто-то забрал его к себе и заботился о нем (если есть такая потребность)

CloudPayments

CloudPayments ruby client (http://cloudpayments.eu/Docs/Integration)

Build Status

Installation

Add this line to your application's Gemfile:

gem 'cloud_payments'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cloud_payments

Usage

Configuration

CloudPayments.configure do |c|
  c.host = 'http://localhost:3000'    # By default, it is https://api.cloudpayments.ru
  c.public_key = ''
  c.secret_key = ''
  c.log = false                       # By default. it is true
  c.logger = Logger.new('/dev/null')  # By default, it writes logs to stdout
  c.raise_banking_errors = true       # By default, it is not raising banking errors
end

Test method

CloudPayments.client.ping
# => true

Cryptogram-based payments

transaction = CloudPayments.client.payments.cards.charge(
  amount: 120,
  currency: 'RUB',
  ip_address: request.remote_ip,
  name: params[:name],
  card_cryptogram_packet: params[:card_cryptogram_packet]
)
# => {:metadata=>nil,
# :id=>12345,
# :amount=>120,
# :currency=>"RUB",
# :currency_code=>0,
# :invoice_id=>"1234567",
# :account_id=>"user_x",
# :email=>nil,
# :description=>"Payment for goods on example.com",
# :created_at=>#<DateTime: 2014-08-09T11:49:41+00:00 ((2456879j,42581s,0n),+0s,2299161j)>,
# :authorized_at=>#<DateTime: 2014-08-09T11:49:42+00:00 ((2456879j,42582s,0n),+0s,2299161j)>,
# :confirmed_at=>#<DateTime: 2014-08-09T11:49:42+00:00 ((2456879j,42582s,0n),+0s,2299161j)>,
# :auth_code=>"123456",
# :test_mode=>true,
# :ip_address=>"195.91.194.13",
# :ip_country=>"RU",
# :ip_city=>"Ufa",
# :ip_region=>"Bashkortostan Republic",
# :ip_district=>"Volga Federal District",
# :ip_lat=>54.7355,
# :ip_lng=>55.991982,
# :card_first_six=>"411111",
# :card_last_four=>"1111",
# :card_type=>"Visa",
# :card_type_code=>0,
# :issuer=>"Sberbank of Russia",
# :issuer_bank_country=>"RU",
# :status=>"Completed",
# :status_code=>3,
# :reason=>"Approved",
# :reason_code=>0,
# :card_holder_message=>"Payment successful",
# :name=>"CARDHOLDER NAME",
# :token=>"a4e67841-abb0-42de-a364-d1d8f9f4b3c0"}
transaction.class
# => CloudPayments::Transaction
transaction.token
# => "a4e67841-abb0-42de-a364-d1d8f9f4b3c0"

Webhooks

if CloudPayments.webhooks.data_valid?(payload, hmac_token)
  event = CloudPayments.webhooks.on_recurrent(payload)
  # or
  event = CloudPayments.webhooks.on_pay(payload)
  # or
  event = CloudPayments.webhooks.on_fail(payload)
end

with capturing of an exception

rescue_from CloudPayments::Webhooks::HMACError, :handle_hmac_error

before_action -> { CloudPayments.webhooks.validate_data!(payload, hmac_token) }

def pay
  event = CloudPayments.webhooks.on_pay(payload)
  # ...
end

def fail
  event = CloudPayments.webhooks.on_fail(payload)
  # ...
end

def recurrent
  event = CloudPayments.webhooks.on_recurrent(payload)
  # ...
end

Contributing

  1. Fork it ( https://github.com/undr/cloud_payments/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