soapy_yandex 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0296c3817f37f08fc6ee1117c60abd08d524005f
4
- data.tar.gz: 95092eb556a1b33ebdd7042697df324f8e8087fa
3
+ metadata.gz: 931e5150e67cea989c45589e62cf305df9c28dd2
4
+ data.tar.gz: a1984827b6a208d0fb832b4c88eaa77241117901
5
5
  SHA512:
6
- metadata.gz: 9630150a755b8deebda113eb3230c0d253db9eddc9f341afba169b3dbc74df32714449220ce073fd36477514982c96824211137633051c7e21daa5f70261fc17
7
- data.tar.gz: b3d451deed45910d0733d8259d5a65a6d53f774fa62237ce327790d04b384e0350bcb4fb69ad5971fd413b982ed08c0d8fb16be6838309ae1038f17f5d93872f
6
+ metadata.gz: 9f2a5fc6dd97a997aa553b1872b8c7caec8f34dbf02e11200340442e1021db4c933bc7ed47177e01aeea3753180e1627e811a90bd208066bafacd824a3df5579
7
+ data.tar.gz: 8a7e4a9a0a6ba47129ff8e9d23c59f80805d5f4a92aed80faacd03e88405a44f903bb6787def1b66da6d587ce8f051d2b3085fa7a828dd88eb986d0e189096cf
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,11 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-06-29 18:51:22 +0200 using RuboCop version 0.39.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Metrics/AbcSize:
11
+ Max: 16
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.2
1
+ 2.2.4
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  gemspec
data/Rakefile CHANGED
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/gem_tasks'
2
3
  require 'rubocop-ci'
data/YMchain.pem ADDED
@@ -0,0 +1,49 @@
1
+ subject=/DC=ru/DC=yamoney/CN=NBCO YM Int
2
+ issuer=/C=RU/L=Moscow/O=Yandex.Money/CN=NBCO YM Root
3
+ -----BEGIN CERTIFICATE-----
4
+ MIIDqjCCApKgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBMMQswCQYDVQQGEwJSVTEP
5
+ MA0GA1UEBxMGTW9zY293MRUwEwYDVQQKEwxZYW5kZXguTW9uZXkxFTATBgNVBAMT
6
+ DE5CQ08gWU0gUm9vdDAeFw0xNTEwMjcxNTEyMDBaFw0yNTEwMjcxNTEwMDBaMEMx
7
+ EjAQBgoJkiaJk/IsZAEZFgJydTEXMBUGCgmSJomT8ixkARkWB3lhbW9uZXkxFDAS
8
+ BgNVBAMTC05CQ08gWU0gSW50MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
9
+ AQEA328FsVfkHjZ+HQV6ZJ7gsG13ag9kdqDT8B6MvskxPJ13qGdjrsUTLA+5RHta
10
+ awcy8DPfpG6SQeI2mM2Sg8kMPktpfqXV9WBlxwiKqX7gIT3dBoGb6GHkKYEiT/id
11
+ N6EdzYNfV1rD7j/dg7y0Fxn8kMzCbku2NoYiSgrCbQzjqTwOTtM4gurxaXIVb5bP
12
+ eGD1vs5JsF6EyWpRUxLrNXP8CZDB9tLiqrT7xLuG1mB9WSefPDQzOcSP0ukBU3aa
13
+ y8JbwJtkfj9BjrhnLGRJp4YoHGyASvOkq5XwVz1gqyn/QaAxTDycfQfBGNmL0Re1
14
+ kx9ODEkmyDnwHDY+C/fTDxDpIQIDAQABo4GfMIGcMA8GA1UdEwEB/wQFMAMBAf8w
15
+ HQYDVR0OBBYEFCZ6yXTNavz4zpfikZ6lP428m4bSMAsGA1UdDwQEAwIBBjAwBgNV
16
+ HR8EKTAnMCWgI6Ahhh9odHRwOi8vY3Jscy55YW1vbmV5LnJ1L3ltY2EuY3JsMBAG
17
+ CSsGAQQBgjcVAQQDAgEAMBkGCSsGAQQBgjcUAgQMHgoAUwB1AGIAQwBBMA0GCSqG
18
+ SIb3DQEBCwUAA4IBAQAQv8HlZQBpv4v09JpwzLgWYsWvRbuglZN8AQXgHO19CFmi
19
+ jwPMgkhFnJ/Qv33grhmTMK8Qx51VFZpJ/WZMmrlT7LR9E49j1QZhCba9K4jdv/1w
20
+ Nnri6cTfcINrVw7V7aBuZmEfx7/9bsCTa1gddi6AAHMM8/9yhmTsQmjuRUg1tmt/
21
+ KoRmc27ga4NY2uclWDep3cIi020/87jXgIhAm68CU+/qy70EtueSvs4/vifdj3LN
22
+ 5H3RPuc7Oay093G+s7BKTuq2ftoCtr0BKXIYp18kBb9trEp6yge3kSDZBZiIuHx6
23
+ Ur7/7nPKw3vGz1v/r+W416f7pMox2UpfPlHrQ7Ox
24
+ -----END CERTIFICATE-----
25
+
26
+ subject=/C=RU/L=Moscow/O=Yandex.Money/CN=NBCO YM Root
27
+ issuer=/C=RU/L=Moscow/O=Yandex.Money/CN=NBCO YM Root
28
+ -----BEGIN CERTIFICATE-----
29
+ MIIDhDCCAmygAwIBAgIBATANBgkqhkiG9w0BAQsFADBMMQswCQYDVQQGEwJSVTEP
30
+ MA0GA1UEBxMGTW9zY293MRUwEwYDVQQKEwxZYW5kZXguTW9uZXkxFTATBgNVBAMT
31
+ DE5CQ08gWU0gUm9vdDAeFw0xNTEwMjcxNTEwMDBaFw0yNTEwMjcxNTEwMDBaMEwx
32
+ CzAJBgNVBAYTAlJVMQ8wDQYDVQQHEwZNb3Njb3cxFTATBgNVBAoTDFlhbmRleC5N
33
+ b25leTEVMBMGA1UEAxMMTkJDTyBZTSBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOC
34
+ AQ8AMIIBCgKCAQEAzZ/d+4ohJafRq73KtWXBGh78hFIl1hcVU4TtylTiR66x+HYh
35
+ Y6VVQclhhcOsLMfzjOx/8d7HkbnI5gNnJmCej9ns0yDhZHQtHBuTe+7y7zNQtQF/
36
+ Xe1YQrIxcDZun33X6VW2kag2A/6p2m28P6RIms4lbqU/8y74r7m6nSfNW1atL6D4
37
+ p2AR7qz07/p7aIy2nfB0K4C7QKAguQcXPGHH9BgI10+FtpzAi2KYSmvlMHjcdpcs
38
+ IBWACQVyrd0/payDHQBS4M2Ecmnr+2+EpSt/eg8QiIiGVy+99PxFqFYuLx/XtuH3
39
+ a6xwMZCRMjciRKy9JT2BQhJte2UeAlDpW2ICNQIDAQABo3EwbzAPBgNVHRMBAf8E
40
+ BTADAQH/MB0GA1UdDgQWBBTSTaqjsJgBMV8CiKVDdayytLdmqTALBgNVHQ8EBAMC
41
+ AQYwMAYDVR0fBCkwJzAloCOgIYYfaHR0cDovL2NybHMueWFtb25leS5ydS95bWNh
42
+ LmNybDANBgkqhkiG9w0BAQsFAAOCAQEAB9e+pde82S+mAvTkHHxmEBA5uHCToBKp
43
+ R653iU5NlM8CEyTTzXSdwl4HowoQM5cIDJA6i9cRtnDDGL04AxAflcsV4eGytqKj
44
+ GeNBT/+8fuDxcekAwJ4pJvZS/ginxDOs3LLNeRcdPP0mUDT8XKrpRKwat44+PWDo
45
+ gpU/mhG6p7Qjejf+hHsR3/ionjXPOT0qoo3N8ez0OU6GL/zdx7YMSZbffITYTAeY
46
+ 0WR/zoXEFonWIAr4weK+j9Z8l8MCoZ19Cg8ORKfrqmf2b9HmrO8+4wUj4vQJX4cl
47
+ us7t6n1GJvWrnaU1vi3rULZAqm+i+RSHnfFZhvE0mKIDdAyOzlVQYg==
48
+ -----END CERTIFICATE-----
49
+
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyYandex
2
3
  class Client
3
4
  def initialize(opts)
@@ -10,7 +11,7 @@ module SoapyYandex
10
11
  http_request = HTTParty.post(
11
12
  uri_base + request.api_path,
12
13
  headers: headers,
13
- verify_peer: false,
14
+ ssl_ca_file: ca_file,
14
15
  pem: ssl_cert.to_pem + ssl_key.to_pem,
15
16
  body: sign(request.to_s)
16
17
  )
@@ -24,11 +25,11 @@ module SoapyYandex
24
25
  def extract_response(body)
25
26
  message = OpenSSL::PKCS7.new(body)
26
27
  unless message.verify([remote_cert], empty_cert_store, nil, OpenSSL::PKCS7::NOVERIFY)
27
- fail Error, 'Response signature verification failed'
28
+ raise Error, 'Response signature verification failed'
28
29
  end
29
30
 
30
31
  response = Response.new(message.data)
31
- fail ServerError, response.error_code if response.error?
32
+ raise ServerError, response.error_code if response.error?
32
33
  response
33
34
  end
34
35
 
@@ -52,6 +53,10 @@ module SoapyYandex
52
53
  OpenSSL::PKCS7.sign(ssl_cert, ssl_key, payload, [], OpenSSL::PKCS7::BINARY).to_s
53
54
  end
54
55
 
56
+ def ca_file
57
+ SoapyYandex.root.join('YMchain.pem').to_s
58
+ end
59
+
55
60
  def headers
56
61
  { 'Content-Type' => 'application/pkcs7-mime' }
57
62
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyYandex
2
3
  class Error < ::RuntimeError
3
4
  end
@@ -25,7 +26,7 @@ module SoapyYandex
25
26
  44 => 'Too many transactions in timeframe',
26
27
  45 => 'Not enough funds',
27
28
  46 => 'Amount too small'
28
- }
29
+ }.freeze
29
30
 
30
31
  attr_reader :error_code
31
32
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyYandex
2
3
  class MoneyClient < Client
3
4
  def test_deposition(args)
@@ -31,7 +32,7 @@ module SoapyYandex
31
32
  private
32
33
 
33
34
  def format_amount(args)
34
- fail Error, 'Amount must be a BigDecimal' unless args[:amount].is_a?(BigDecimal)
35
+ raise Error, 'Amount must be a BigDecimal' unless args[:amount].is_a?(BigDecimal)
35
36
  args[:amount] = format('%0.2f', args[:amount])
36
37
  end
37
38
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyYandex
2
3
  class Request
3
4
  attr_reader :api_path
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyYandex
2
3
  class Response
3
4
  attr_reader :xml
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyYandex
2
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
3
4
  end
data/lib/soapy_yandex.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'httparty'
2
3
  require 'openssl'
3
4
  require 'ox'
@@ -13,4 +14,8 @@ require 'soapy_yandex/version'
13
14
  module SoapyYandex
14
15
  CURRENCY_DEMO_RUBLES = 10643
15
16
  CURRENCY_RUBLES = 643
17
+
18
+ def self.root
19
+ Pathname.new(File.expand_path(File.join(__FILE__, '..', '..')))
20
+ end
16
21
  end
data/soapy_yandex.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'soapy_yandex/version'
data/spec/money_spec.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe 'Yandex Money Requests', :vcr do
2
3
  random_mock = 0
3
4
 
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'codeclimate-test-reporter'
2
3
  CodeClimate::TestReporter.start
3
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapy_yandex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ad2games GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-24 00:00:00.000000000 Z
11
+ date: 2016-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ox
@@ -145,11 +145,13 @@ extra_rdoc_files: []
145
145
  files:
146
146
  - ".gitignore"
147
147
  - ".rspec"
148
+ - ".rubocop_todo.yml"
148
149
  - ".ruby-version"
149
150
  - Gemfile
150
151
  - LICENSE.txt
151
152
  - README.md
152
153
  - Rakefile
154
+ - YMchain.pem
153
155
  - circle.yml
154
156
  - lib/soapy_yandex.rb
155
157
  - lib/soapy_yandex/client.rb
@@ -192,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
194
  version: '0'
193
195
  requirements: []
194
196
  rubyforge_project:
195
- rubygems_version: 2.4.8
197
+ rubygems_version: 2.5.1
196
198
  signing_key:
197
199
  specification_version: 4
198
200
  summary: Client library for Yandex Money.