0.0
No commit activity in last 3 years
No release in over 3 years
Yandex Kassa API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0

Runtime

 Project Readme

Code Climate

YandexKassa

Simple API wrapper for [YandexKassa] (https://kassa.yandex.ru). Official API documentaton here

Installation

Add this line to your application's Gemfile:

gem 'yandex_kassa'

And then execute:

$ bundle

Or install it yourself as:

$ gem install yandex_kassa

Usage

First of all configure gem.

require "yandex_kassa"

YandexKassa.configure do |config|
  # API end url given by Yandex
  config.url = "https://bo-demo02.yamoney.ru:9094/webservice/deposition/api"
  #path to you *.cer generated by Yandex on your request
  config.cert = "123123.cer"
  #path to your private key
  config.key = "private.key"
  #path to deposit *.cer generated by Yandex
  config.deposit = "deposit.cer"
  #passphare for *.key file, omit if you don't need
  config.passphrase = "passphrase"
end

Doc for Deposition requests

testDeposition:

#enable std loggin for Rest client
RestClient.log = 'stdout'

#create api instance
api = YandexKassa.create

#send test deposition request
test_deposition_params = {
  dst_account: "410011234567", amount: "10.00", currency: 10643,
  agent_id: "123123", contract: "Fun stuff", client_order_id: 1, request_dt: Time.now.iso8601
}

data = api.test_deposition(test_deposition_params)
# => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<testDepositionResponse clientOrderId=\"1\" status=\"3\" error=\"41\" processedDT=\"2016-03-23T12:52:53.087+03:00\" identification=\"anonymous\" />\r\n"

#or equally
data = api.test_deposition do |request|
    request.dst_account = 410011234567
    request.amount = 10.00
    request.currency = 10643
    request.contract = "Fun stuff"
    request.dst_account = 410011234567
    request.client_order_id = 1
    request.request_dt = Time.now.iso8601
  end
# => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<testDepositionResponse clientOrderId=\"1\" status=\"3\" error=\"41\" processedDT=\"2016-03-23T12:52:53.087+03:00\" identification=\"anonymous\" />\r\n"

makeDeposition:

#send make deposition request
payment_params = { "skr_destinationCardSynonim" => "b0af887ae9ad01fe01ca65df7cff19a7b5fcbf9b_scn",
                   "pdr_firstName" => "Владимир",
                   "pdr_middleName" => "Владимирович",
                   "pdr_docNumber" => "4002109067",
                   "pdr_postcode" => "194044",
                   "pdr_country" => "643",
                   "pdr_city" => "Москва",
                   "pdr_adress" => "ул. Какая-то",
                   "pdr_birthDate" => "24.05.1987",
                   "pdr_birthplace" => "Новосибирск",
                   "pdr_docIssueYear" => "1999",
                   "pdr_docIssueMonth" => "7",
                   "pdr_docIssueDay" => "30",
                   "pdr_docIssuedBy" => "ТП",
                   "pof_offerAccepted" => 1,
                   "smsPhoneNumber" => "79653457676"
                  }

make_deposition_params = {
  dst_account: "410011234567", amount: "10.00", currency: 10643,
  agent_id: "123123", contract: "Fun stuff", client_order_id: 1, request_dt: Time.now.iso8601,
  payment_params: payment_params
}

data = api.make_deposition(make_deposition_params)
# => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<makeDepositionResponse clientOrderId=\"1\" status=\"3\" error=\"41\" processedDT=\"2016-03-23T12:52:53.087+03:00\" identification=\"anonymous\" />\r\n"

#or equally
data = api.make_deposition do |request|
    request.dst_account = 410011234567
    request.amount = 10.00
    request.currency = 10643
    request.contract = "Fun stuff"
    request.dst_account = 410011234567
    request.client_order_id = 1
    request.request_dt = Time.now.iso8601
    set_payment_params payment_params
  end
# => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<makeDepositionResponse clientOrderId=\"1\" status=\"3\" error=\"41\" processedDT=\"2016-03-23T12:52:53.087+03:00\" identification=\"anonymous\" />\r\n"

Balance:

balance_params = { dst_account: "410011234567", agent_id: "123123",client_order_id: 1 }
api.balance(balance_params)
# => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<balanceResponse clientOrderId=\"1\" status=\"0\" processedDT=\"2016-03-24T14:15:43.484+03:00\" balance=\"-8320.00\" />\r\n"

Getting card_synonym:

url = "https://demo-scrat.yamoney.ru/gates/card/storeCard"
error_url = "https://example.com/error_url"
success_url = "https://example.com/success_url"
demo_card_number = "4444444444444448"

store_card = YandexKassa::StoreCard.new(
  url: url,
  error_url: error_url,
  success_url: success_url,
  response_format: "json",
  destination_card_number: demo_card_number
)

response = store_card.request
# => "{\"storeCard\":{\"reason\":\"success\",\"skr_destinationCardCountryCode\":\"616\",\"skr_destinationCardSynonim\":\"mob64asbX5okWsURXB8QoYwYSwwZ.SC.201603\",\"skr_destinationCardType\":\"Visa\",\"skr_destinationCardPanmask\":\"444444******4448\"}}"

##Integration Following gists may be useful:

Yandex Kassa Card payment test

Yandex Kassa different accounts test

License

The gem is available as open source under the terms of the MIT License.