Ruby Client Library for working with Yandex Kassa.
NOTE: current implementation does not support ALL features, and includes only:
- Create Payment
- Get Payment Status
- Receiving Callback From Payment Gate
Add this line to your application's Gemfile:
gem 'kassa'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kassa
Kassa.configure do |config|
config.api_endpoint = 'https://payment.yandex.net/api/v3/'
config.account_id = ENV['ACCOUNT_ID']
config.secret_key = ENV['SECRET_KEY']
config.logger = Logger.new(STDERR)
end
or
client = Kassa::Client.new(
api_endpoint: 'https://payment.yandex.net/api/v3/',
account_id: ENV['ACCOUNT_ID'],
secret_key: ENV['SECRET_KEY'],
logger: Logger.new(STDERR),
)
The last example preferred in case when your work with several merchants.
request = Kassa::Requests::Payment.new.tap do |payment|
payment.amount = { value: 2999, currency: 'RUB' }
payment.confirmation = { type: :redirect, return_url: 'https://example.com' }
end
payment = Kassa.client.create_payment(request, idempotence_key: SecureRandom.uuid)
Kassa.client.payment('some payment id')
First, create a callback application:
KassaWebhooksApp = Kassa::Webhooks::App.new do |notification|
Rails.logger.info(notification)
end
Then mount your callback application:
# config/routes.rb
Rails.application.routes.draw do
mount KassaWebhooksApp, at: '/webhooks/kassa'
end
Setup:
make setup
Run linters:
make lint
Run tests:
make test
Publish gem to nexus:
make publish
Bug reports and pull requests are welcome on GitHub at https://github.com/zabolotnov87/kassa. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Test project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.