{"id":24460900,"url":"https://github.com/holyketzer/pscb_integration","last_synced_at":"2026-04-27T17:05:33.406Z","repository":{"id":56889472,"uuid":"88671209","full_name":"holyketzer/pscb_integration","owner":"holyketzer","description":"PSCB bank payment service integration / Интеграция с ПСКБ-эквайрингом","archived":false,"fork":false,"pushed_at":"2019-04-01T07:24:52.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-18T05:57:58.839Z","etag":null,"topics":["acquiring","payment-gateway","payment-integration","pscb","pscb-bank","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/holyketzer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-18T21:14:36.000Z","updated_at":"2019-04-01T07:24:09.000Z","dependencies_parsed_at":"2022-08-21T00:50:20.176Z","dependency_job_id":null,"html_url":"https://github.com/holyketzer/pscb_integration","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/holyketzer/pscb_integration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyketzer%2Fpscb_integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyketzer%2Fpscb_integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyketzer%2Fpscb_integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyketzer%2Fpscb_integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/holyketzer","download_url":"https://codeload.github.com/holyketzer/pscb_integration/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyketzer%2Fpscb_integration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32345899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acquiring","payment-gateway","payment-integration","pscb","pscb-bank","rails","ruby"],"created_at":"2025-01-21T04:15:54.658Z","updated_at":"2026-04-27T17:05:33.370Z","avatar_url":"https://github.com/holyketzer.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/pscb_integration.svg)](https://badge.fury.io/rb/pscb_integration)\n[![Build Status](https://travis-ci.org/holyketzer/pscb_integration.svg?branch=master)](https://travis-ci.org/holyketzer/pscb_integration)\n[![Code Climate](https://codeclimate.com/github/holyketzer/pscb_integration/badges/gpa.svg)](https://codeclimate.com/github/holyketzer/pscb_integration)\n[![Test Coverage](https://codeclimate.com/github/holyketzer/pscb_integration/badges/coverage.svg)](https://codeclimate.com/github/holyketzer/pscb_integration/coverage)\n\n# PSCB Integration\n\nPSCB bank payment service integration (trade acquiring). \n\nOfficial documentation http://docs.pscb.ru/oos/\n\nOffer https://pscb.ru/corp/services/payment_service/platezhi-v-internete/.\n\n## Disclamer\n\nStay awhile and listen. Are you sure that you need this stuff?\n\n### Pro:\n\n* 3% fee for Visa/MasterCard payments\n\n### Cons:\n\n* During 1.5 years of our expirience PSCB lost all client's reccurent bingings twice. We lost a lot of revenue because of this.\n* **Very slow** personal account web site, it takes tens of seconds to load a page.\n* API looks not solid and have a lack of consistency, it has several ways to return errors in response \n* PSCB send demo environment payment callbacks to your production server, and if you don't handle them, they send you email like 'We have got invalid response for our HTTP-callbacks', so they can't completely split demo and production environments\n\n### Your choise\n\nIt's up to you. Probably Yandex.Kassa will be better option, its [API](https://tech.yandex.ru/money/doc/payment-solution/shop-config/intro-docpage/) looks much more solid and reliable (it's Yandex anyway) but it has higher fee 3.5% on [base plan](https://kassa.yandex.ru/fees) for bank cards. But if you revenue more than 1 million RUB per month then only 2.8%. I suppose the choice is obvious here.\n\n\n## Installation\n\nI see you decided to try. Good luck and best wishes.\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'pscb_integration'\n```\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\n### Configuration\n\nConfigure it in `\u003cyou app folder\u003e/config/initializers/pscb.rb` with:\n\n```ruby\nPscbIntegration.setup do |config|\n  config.host = 'https://oos.pscb.ru'\n  config.market_place = '\u003cyour market place id\u003e'\n  config.secret_key = '\u003cyour secret key\u003e'\n  config.demo_secret_key = '\u003cyour secret key for demo env\u003e'\n  config.confirm_payment_callback = PaymentService.method(:confirm_pscb_payment_callback)\nend\n```\n\nIf your application didn't setup `PscbIntegration` configuration with `setup` block then `PscbIntegration::ConfigurationError` will be raised during first attempt to call of any method.\n\n### Handling payment status notification\n\nMount engine in your `routes.rb` file as you wish, e.g.:\n\n```ruby\nnamespace :integration_api do\n  mount PscbIntegration::Engine =\u003e '/'\nend\n```\n\nImplement callback function assigned to `confirm_pscb_payment_callback`:\n\nArguments:\n`payment` - hash with payment details from PSCB:\n\n|Property          | Description|\n|------------------|-------------------------------------|\n|`orderId`         | Unique order id generated by merchant|\n|`showOrderId`     | Not uniqe order id generated by merchant to show it to customer|\n|`paymentId`       | Order id generated by PSCB|\n|`account`         | Customer id on merchant side|\n|`marketPlace`     | Merchant id on PSCB side|\n|`paymentMethod`   | Payment method|\n|`state`           | [Payment state](http://docs.pscb.ru/oos/api.html#api-dopolnitelnyh-vozmozhnostej-merchanta-sostoyaniya-platezha)|\n|`stateDate`       | Date of last state changing ISO8601|\n|`amount`          | Order amount|\n|`recurrencyToken` | Recurrency token|\n\n`is_demo` - if `true` then payment is from demo environment else from production.\n\nCallback should return `true` if you system accepts and confirms payment, and `false` (`nil`) in case of rejecting. Example:\n\n```ruby\ndef confirm_pscb_payment_callback(payment, is_demo)\n  if (order = OrderModel.find_by(uid: payment['orderId']))\n    # Some state machine transition\n    order.apply_status(payment['state'])\n  end\nend\n```\n\n### Build payment url\n\n[PSCB API documentation](http://docs.pscb.ru/oos/api.html#api-pskb-onlajn-dlya-merchantov-api-platezhnoj-stranicy)\n\n```ruby\nclient = PscbIntegration::Client.new\n\nurl = client.build_payment_url(\n  nonce: SecureRandom.hex(5), # Salt to avoid replay attack\n  customerAccount: user.id, # Some user id\n  customerRating: 5, # Customer rating \n  customerEmail: user.email, # Customer email\n  customerPhone: user.phone, # Customer phone\n  orderId: '123456', # Unique order id\n  details: 'Some paymnet', # Payment details comment\n  amount: 500, # Amount in RUB\n  paymentMethod: 'ac', # Payment menthod\n  recurrentable: true, # Payment can be repeated by merchant\n  data: {\n    debug: 1, # show debug info in customer browser \n  }\n)\n```\n\n### Pull order status\n\n[PSCB API documentation](http://docs.pscb.ru/oos/api.html#api-dopolnitelnyh-vozmozhnostej-merchanta-zapros-sostoyaniya-platezha)\n\n`Client` methods return result in [Either monad](https://github.com/bolshakov/fear#either-documentation) for helping handling errors on different level. Thank you [@bolshakov](https://github.com/bolshakov).\n\nHow it works:\n\n* `Right` result means success\n* `Left` result means PSCB returns some conscious error which can require special handling on our side.\n* any exception means unexpected error (e.g. timeout, network) that we don't know how to handle, and probably best option is to log it and try again later.\n\nLearn more about [Either monad usage](https://github.com/bolshakov/fear#either-documentation). Example:\n\n```ruby\nclient = PscbIntegration::Client.new\n\nres = client.pull_order_status(order.id)\n\nres.reduce(\n  # Left result is handled here\n  # @param error - PscbIntegration::BaseApiError\n  -\u003e(error) {\n    # Some special error handling e.g.\n    if error.unknown_payment?\n      # Do something special\n    end\n  },\n\n  # Right result is handled here\n  # @param payment - payment hash from PSCB\n  -\u003e(payment) { \n    # Update order status\n  }\n)\n```\n\n### Recurring payment\n\n[PSCB API documentation](http://docs.pscb.ru/oos/api.html#api-dopolnitelnyh-vozmozhnostej-merchanta-iniciaciya-povtornoj-oplaty)\n\nBefore this call you customer should successefully paid order with `recurrentable` flag. In callback or through status pulling `recurrency_token` will be returned.\n\n```ruby\nclient = PscbIntegration::Client.new\n\nres = client.recurring_payment(\n    prev_order_uid: prev_order.id, # Previous recurrentable order id\n    new_order_uid: new_order.id, # New order id\n    token: recurrency_token, # Recurrency token from previous order \n    amount: 300, # Amount in RUB\n)\n\nres.reduce(\n  -\u003e(error) { },\n  -\u003e(payment) { },\n)\n```\n\n### Refund order\n\n[PSCB API documentation](http://docs.pscb.ru/oos/api.html#api-dopolnitelnyh-vozmozhnostej-merchanta-vozvrat-po-platezhu)\n\n```ruby\nclient = PscbIntegration::Client.new\n\nres = client.refund_order(order.id)\n\nres.reduce(\n  -\u003e(error) { },\n  -\u003e(payment) { },\n)\n```\n\n## Development\n\nAfter 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.\n\nTo 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).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/holyketzer/pscb_integration.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyketzer%2Fpscb_integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fholyketzer%2Fpscb_integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyketzer%2Fpscb_integration/lists"}