yandex-money-sdk 0.9.5 → 0.10.0

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: a851ab68dc492d080c3b3e46be4c8c6c36a0d030
4
- data.tar.gz: 6a29bb11b69a450ca37edab75f4b40f6eb841e11
3
+ metadata.gz: 9bc4a805a893ffedcd0df89f8d383e287b051aee
4
+ data.tar.gz: 2ba73b073817413e27467427250095bc03f5d1aa
5
5
  SHA512:
6
- metadata.gz: 1a2814f372471fadee105d949d82a3932810443033563d1c6d5f92ab6393995283aef858389e933dcb38e90d8b77c5a12fea5db9e01ad9c58db06685c805415c
7
- data.tar.gz: f096c4534b1066da1af352d6e18f6ba3a6fbbadbbe6f7470bffb6c13fa8157ce1aae55b361680be903fd356e3b57986d7f351ebbdd8c25d56fa8201beacf5cec
6
+ metadata.gz: c3758f7f3286616aa274f679c33f4f2c134c86f08577f6d334cf29a8e228c07e944a9fe9f1b6f8bf4ce5578dfbd173e60fd58c4de7dc7d3d40cb78ae4e60e6c0
7
+ data.tar.gz: 2c8da222474426e5ff251027832fa791e097794191f2dfb30cc603c4074040caaae0ff40a83ed82ac313a115a33501c688abdcf07acc3492df5b1552b545c1f4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.10.0 (September 20, 2014)
2
+
3
+ Exceptions now is divided by classes, now it lives in `lib/yandex_money/exceptions.rb` for details.
4
+
1
5
  # 0.9.5 (September 14, 2014)
2
6
 
3
7
  Changed API for initialization and `obtain_token` method. Now secret key only needed in `obtain_token` method.
data/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  [![Build Status](https://travis-ci.org/yandex-money/yandex-money-sdk-ruby.svg)](https://travis-ci.org/yandex-money/yandex-money-sdk-ruby)
4
4
  [![Coverage Status](https://img.shields.io/coveralls/yandex-money/yandex-money-sdk-ruby.svg)](https://coveralls.io/r/yandex-money/yandex-money-sdk-ruby)
5
5
  [![Code Climate](https://codeclimate.com/github/yandex-money/yandex-money-sdk-ruby/badges/gpa.svg)](https://codeclimate.com/github/yandex-money/yandex-money-sdk-ruby)
6
+ [![Gem Version](https://badge.fury.io/rb/yandex-money-sdk.svg)](http://badge.fury.io/rb/yandex-money-sdk)
7
+ [![Dependency Status](https://gemnasium.com/yandex-money/yandex-money-sdk-ruby.svg)](https://gemnasium.com/yandex-money/yandex-money-sdk-ruby)
6
8
 
7
9
  Ruby gem for Yandex Money API usage.
8
10
 
@@ -98,6 +100,7 @@ Required permissions: `operation-history`.
98
100
  ```ruby
99
101
  api.operation_history
100
102
  #<OpenStruct next_record="30", operations=[{"operation_id"=>"462449992116028008", "title"=>"Возврат средств от:", "amount"=>1.0, "direction"=>"in", "datetime"=>"2014-08-27T10:19:52Z", "status"=>"success", "type"=>"deposition"}, ..., {"pattern_id"=>"p2p", "operation_id"=>"460970888534110007", "title"=>"Перевод на счет 410011700000000", "amount"=>3.02, "direction"=>"out", "datetime"=>"2014-08-10T07:28:15Z", "status"=>"success", "type"=>"outgoing-transfer"}]>
103
+
101
104
  # you could pass params:
102
105
  api.operation_history(records: 1)
103
106
  #<OpenStruct next_record="1", operations=[{"pattern_id"=>"p2p", "operation_id"=>"463947376678019004", "title"=>"Перевод от 410011285000000", "amount"=>0.99, "direction"=>"in", "datetime"=>"2014-09-13T18:16:16Z", "status"=>"refused", "type"=>"incoming-transfer-protected"}]>
@@ -118,8 +121,8 @@ If operation doesn't exist, exception will be raised:
118
121
 
119
122
  ```ruby
120
123
  api.operation_details "unknown"
121
- # RuntimeError:
122
- # Illegal param operation id
124
+ # YandexMoney::ApiError:
125
+ # Illegal param operation id
123
126
  ```
124
127
 
125
128
  If scope is insufficient, expcetion will be raised:
@@ -127,8 +130,8 @@ If scope is insufficient, expcetion will be raised:
127
130
  ```ruby
128
131
  api = YandexMoney::Api.new(token: TOKEN)
129
132
  api.operation_details(OPERATION_ID)
130
- # RuntimeError:
131
- # Insufficient Scope
133
+ # YandexMoney::InsufficientScopeError:
134
+ # YandexMoney::InsufficientScopeError
132
135
  ```
133
136
 
134
137
  ### Payments from the Yandex.Money wallet
@@ -182,7 +185,7 @@ Required token permissions: `incoming-transfers`.
182
185
  api.incoming_transfer_accept "463937708331015004", "0208"
183
186
  # true
184
187
  api.incoming_transfer_accept "463937708331015004", "WRONG"
185
- # RuntimeError:
188
+ # YandexMoney::ApiError:
186
189
  # Illegal param protection code, attemps available: 2
187
190
  ```
188
191
 
@@ -197,7 +200,7 @@ Required token permissions: `incoming-transfers`.
197
200
  api.incoming_transfer_reject "463947376678019004"
198
201
  # true
199
202
  api.incoming_transfer_reject ""
200
- # RuntimeError:
203
+ # YandexMoney::ApiError:
201
204
  # Illegal param operation id
202
205
  ```
203
206
 
@@ -247,6 +250,10 @@ The recommended retry mode is determined by the `next_retry` response field (by
247
250
  #<OpenStruct status="ext_auth_required", acs_params={"cps_context_id"=>"31323039373...93134623165", "paymentType"=>"FC"}, acs_uri="https://m.sp-money.yandex.ru/internal/public-api/to-payment-type">
248
251
  ```
249
252
 
253
+ ## Running tests
254
+
255
+ Just run it with `rake` command.
256
+
250
257
  ## Caveats
251
258
 
252
259
  This library is very unstable. Pull requests welcome!
@@ -1,4 +1,5 @@
1
1
  require "yandex_money/api/version"
2
+ require "yandex_money/exceptions"
2
3
  require "httparty"
3
4
  require "uri"
4
5
  require "ostruct"
@@ -34,7 +35,7 @@ module YandexMoney
34
35
 
35
36
  # obtains and saves token from code
36
37
  def obtain_token(client_secret = nil)
37
- raise "Authorization code not provided" if code == nil
38
+ raise YandexMoney::FieldNotSetError.new(:code) if @code == nil
38
39
  uri = "/oauth/token"
39
40
  options = {
40
41
  code: @code,
@@ -50,40 +51,22 @@ module YandexMoney
50
51
  # obtains account info
51
52
  def account_info
52
53
  check_token
53
- uri = "/api/account-info"
54
- OpenStruct.new self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
55
- "Authorization" => "Bearer #{@token}",
56
- "Content-Type" => "application/x-www-form-urlencoded"
57
- }).parsed_response
54
+ OpenStruct.new send_request("/api/account-info").parsed_response
58
55
  end
59
56
 
60
57
  # obtains operation history
61
58
  def operation_history(options=nil)
62
59
  check_token
63
- uri = "/api/operation-history"
64
- OpenStruct.new self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
65
- "Authorization" => "Bearer #{@token}",
66
- "Content-Type" => "application/x-www-form-urlencoded"
67
- }, body: options).parsed_response
60
+ OpenStruct.new send_request("/api/operation-history", options).parsed_response
68
61
  end
69
62
 
70
63
  # obtains operation details
71
64
  def operation_details(operation_id)
72
65
  check_token
73
- raise "Provide operation_id" if operation_id == nil
74
- uri = "/api/operation-details"
75
- request = self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
76
- "Authorization" => "Bearer #{@token}",
77
- "Content-Type" => "application/x-www-form-urlencoded"
78
- }, body: {
79
- operation_id: operation_id
80
- })
81
-
82
- raise "Insufficient Scope" if request.response.code == "403"
83
-
66
+ request = send_request("/api/operation-details", operation_id: operation_id)
84
67
  details = OpenStruct.new request.parsed_response
85
68
  if details.error
86
- raise details.error.gsub(/_/, " ").capitalize
69
+ raise YandexMoney::ApiError.new details.error
87
70
  else
88
71
  details
89
72
  end
@@ -92,18 +75,12 @@ module YandexMoney
92
75
  # basic request payment method
93
76
  def request_payment(options)
94
77
  check_token
95
- uri = "/api/request-payment"
96
- response = OpenStruct.new with_http_retries {
97
- request = self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
98
- "Authorization" => "Bearer #{@token}",
99
- "Content-Type" => "application/x-www-form-urlencoded"
100
- }, body: options)
101
-
102
- raise "Insufficient Scope" if request.response.code == "403"
103
- request.parsed_response
104
- }
78
+ response = with_http_retries do
79
+ request = send_request("/api/request-payment", options)
80
+ OpenStruct.new request.parsed_response
81
+ end
105
82
  if response.error
106
- raise response.error.gsub(/_/, " ").capitalize
83
+ raise YandexMoney::ApiError.new response.error
107
84
  else
108
85
  response
109
86
  end
@@ -112,33 +89,20 @@ module YandexMoney
112
89
  # basic process payment method
113
90
  def process_payment(options)
114
91
  check_token
115
- uri = "/api/process-payment"
116
- request = self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
117
- "Authorization" => "Bearer #{@token}",
118
- "Content-Type" => "application/x-www-form-urlencoded"
119
- }, body: options)
120
-
121
- raise "Insufficient Scope" if request.response.code == "403"
122
-
92
+ request = send_request("/api/process-payment", options)
123
93
  response = OpenStruct.new request.parsed_response
124
94
 
125
95
  if response.error
126
- raise response.error.gsub(/_/, " ").capitalize
96
+ raise YandexMoney::ApiError.new response.error
127
97
  else
128
98
  response
129
99
  end
130
100
  end
131
101
 
132
102
  def get_instance_id
133
- uri = "/api/instance-id"
134
- request = self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
135
- "Content-Type" => "application/x-www-form-urlencoded"
136
- }, body: {
137
- client_id: @client_id
138
- })
139
-
103
+ request = send_request("/api/instance-id", client_id: @client_id)
140
104
  if request["status"] == "refused"
141
- raise request["error"].gsub(/_/, " ").capitalize
105
+ raise YandexMoney::ApiError.new request["error"]
142
106
  else
143
107
  request["instance_id"]
144
108
  end
@@ -154,36 +118,20 @@ module YandexMoney
154
118
  else
155
119
  request_body = { operation_id: operation_id }
156
120
  end
157
- request = self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
158
- "Authorization" => "Bearer #{@token}",
159
- "Content-Type" => "application/x-www-form-urlencoded"
160
- }, body: request_body)
121
+ request = send_request("/api/incoming-transfer-accept", request_body)
161
122
 
162
- raise "Insufficient Scope" if request.response.code == "403"
163
123
  if request["status"] == "refused"
164
- if request["protection_code_attempts_available"]
165
- attemps = ", attemps available: #{request["protection_code_attempts_available"]}"
166
- else
167
- attemps = ""
168
- end
169
- raise "#{request["error"].gsub(/_/, " ").capitalize}#{attemps}"
124
+ raise YandexMoney::AcceptTransferError.new request["error"], request["protection_code_attempts_available"]
170
125
  else
171
126
  true
172
127
  end
173
128
  end
174
129
 
175
130
  def incoming_transfer_reject(operation_id)
176
- uri = "/api/incoming-transfer-reject"
177
- request = self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
178
- "Authorization" => "Bearer #{@token}",
179
- "Content-Type" => "application/x-www-form-urlencoded"
180
- }, body: {
181
- operation_id: operation_id
182
- })
131
+ request = send_request("/api/incoming-transfer-reject", operation_id: operation_id)
183
132
 
184
- raise "Insufficient Scope" if request.response.code == "403"
185
133
  if request["status"] == "refused"
186
- raise "#{request["error"].gsub(/_/, " ").capitalize}"
134
+ raise YandexMoney::ApiError.new request["error"]
187
135
  else
188
136
  true
189
137
  end
@@ -191,13 +139,9 @@ module YandexMoney
191
139
 
192
140
  def request_external_payment(payment_options)
193
141
  payment_options[:instance_id] ||= @instance_id
194
- uri = "/api/request-external-payment"
195
- request = self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
196
- "Content-Type" => "application/x-www-form-urlencoded"
197
- }, body: payment_options)
198
- raise "Insufficient Scope" if request.response.code == "403"
142
+ request = send_request("/api/request-external-payment", payment_options)
199
143
  if request["status"] == "refused"
200
- raise "#{request["error"].gsub(/_/, " ").capitalize}"
144
+ raise YandexMoney::ApiError.new request["error"]
201
145
  else
202
146
  OpenStruct.new request.parsed_response
203
147
  end
@@ -205,15 +149,12 @@ module YandexMoney
205
149
 
206
150
  def process_external_payment(payment_options)
207
151
  payment_options[:instance_id] ||= @instance_id
208
- uri = "/api/process-external-payment"
209
- request = self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
210
- "Content-Type" => "application/x-www-form-urlencoded"
211
- }, body: payment_options)
212
- raise "Insufficient Scope" if request.response.code == "403"
152
+ request = send_request("/api/process-external-payment", payment_options)
153
+
213
154
  if request["status"] == "refused"
214
- raise "#{request["error"].gsub(/_/, " ").capitalize}"
155
+ raise YandexMoney::ApiError.new request["error"]
215
156
  elsif request["status"] == "in_progress"
216
- raise "in progress", request["next_retry"]
157
+ raise YandexMoney::ExternalPaymentProgressError.new request["error"], request["next_retry"]
217
158
  else
218
159
  OpenStruct.new request.parsed_response
219
160
  end
@@ -221,6 +162,19 @@ module YandexMoney
221
162
 
222
163
  private
223
164
 
165
+ def send_request(uri, options = nil)
166
+ request = self.class.post(uri, base_uri: "https://money.yandex.ru", headers: {
167
+ "Authorization" => "Bearer #{@token}",
168
+ "Content-Type" => "application/x-www-form-urlencoded"
169
+ }, body: options)
170
+
171
+ case request.response.code
172
+ when "403" then raise YandexMoney::InsufficientScopeError
173
+ when "401" then raise YandexMoney::UnauthorizedError.new request["www-authenticate"]
174
+ else request
175
+ end
176
+ end
177
+
224
178
  # Retry when errors
225
179
  def with_http_retries(&block)
226
180
  begin
@@ -232,7 +186,7 @@ module YandexMoney
232
186
  end
233
187
 
234
188
  def check_token
235
- raise "Token not provided" unless @token
189
+ raise YandexMoney::FieldNotSetError.new(:token) unless @token
236
190
  end
237
191
 
238
192
  def send_authorize_request(options)
@@ -1,5 +1,5 @@
1
1
  module YandexMoney
2
2
  class Api
3
- VERSION = "0.9.5"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
@@ -0,0 +1,61 @@
1
+ module YandexMoney
2
+ class Error < StandardError; end
3
+
4
+ class InsufficientScopeError < Error; end
5
+
6
+ class UnauthorizedError < Error
7
+ def initialize(error)
8
+ @err = error
9
+ end
10
+
11
+ def message
12
+ @err
13
+ end
14
+ end
15
+
16
+ class FieldNotSetError < Error
17
+ def initialize(field)
18
+ @field = field
19
+ end
20
+
21
+ def message
22
+ "Field '#{@field}' not set!"
23
+ end
24
+ end
25
+
26
+ class ApiError < Error
27
+ def initialize(msg)
28
+ @msg = msg
29
+ end
30
+
31
+ def message
32
+ @msg.gsub(/_/, " ").capitalize
33
+ end
34
+ end
35
+
36
+ class AcceptTransferError < ApiError
37
+ def initialize(msg, attemps = nil)
38
+ @msg = msg
39
+ @attemps = attemps
40
+ end
41
+
42
+ def message
43
+ if @attemps
44
+ super + ", attemps available: #{@attemps}"
45
+ else
46
+ super
47
+ end
48
+ end
49
+ end
50
+
51
+ class ExternalPaymentProgressError < ApiError
52
+ def initialize(msg, next_retry)
53
+ @msg = msg
54
+ @next_retry = next_retry
55
+ end
56
+
57
+ def message
58
+ super + ", next_retry: #{@next_retry}"
59
+ end
60
+ end
61
+ end
@@ -45,9 +45,18 @@ describe "get account info" do
45
45
  end
46
46
  end
47
47
 
48
+ it "raise unauthorized exception when wrong token" do
49
+ VCR.use_cassette "unauthorized exception" do
50
+ @api = YandexMoney::Api.new(
51
+ token: "wrong"
52
+ )
53
+ expect { @api.operation_details "462449992116028008" }.to raise_error YandexMoney::UnauthorizedError
54
+ end
55
+ end
56
+
48
57
  it "should raise exception if operation_id is wrong" do
49
58
  VCR.use_cassette "get wrong operation details" do
50
- expect { @api.operation_details "unknown" }.to raise_error "Illegal param operation id"
59
+ expect { @api.operation_details "unknown" }.to raise_error YandexMoney::ApiError
51
60
  end
52
61
  end
53
62
  end
data/spec/auth_spec.rb CHANGED
@@ -54,4 +54,9 @@ describe "Application authorization flow" do
54
54
  expect(api.account_info.account).to eq("41001565326286")
55
55
  end
56
56
  end
57
+
58
+ it "should raise exception while trying to obtain token without code" do
59
+ api = YandexMoney::Api.new(client_id: CLIENT_ID)
60
+ expect { api.obtain_token }.to raise_error YandexMoney::FieldNotSetError
61
+ end
57
62
  end
data/spec/cards_spec.rb CHANGED
@@ -10,7 +10,7 @@ describe "Payments from bank cards without authorization" do
10
10
  @api = YandexMoney::Api.new(
11
11
  client_id: nil
12
12
  )
13
- expect { @api.get_instance_id }.to raise_exception("Illegal param client id")
13
+ expect { @api.get_instance_id }.to raise_error YandexMoney::ApiError
14
14
  end
15
15
  end
16
16
 
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  Authorization:
11
- - Bearer 41001565326286.42598500AE42A3672ED59463D02EC424B7CD31B416309A392125FA45E79290F3FCFA2CF178D314A0B396659EEAC938BDF8480229BC55CDFD039E66AFFCF5109B44F306D80B6B88FFEF8E87C2C1199949B5CD43B422BB6C2AD857CB9B0AB0FAF316B864F5870BB19C37B08CAEDDB6642401119F1CE8A1D3C23F54EE145A4933A3
11
+ - Bearer 41001565326286.B93F917A6E44078B5FA04B7089BC213BE925EC52FB06B3E4EC4B2BFD91C8B2DAB75B552224D3B56C59EE3F7FFD0BB9EF3E14D9221F34EFFF2B0D378532A041F230338D28272A574671AB2639761126E2F587F02077005354F906C9A79FEFED6CBB3D5E3EB0DC90B2B6D029837D744613978DDE8AA42F5916BBE524B752E89E20
12
12
  Content-Type:
13
13
  - application/x-www-form-urlencoded
14
14
  response:
@@ -19,11 +19,11 @@ http_interactions:
19
19
  Server:
20
20
  - nginx
21
21
  Date:
22
- - Sat, 30 Aug 2014 13:11:08 GMT
22
+ - Sun, 14 Sep 2014 18:49:12 GMT
23
23
  Content-Type:
24
24
  - application/json;charset=UTF-8
25
25
  Content-Length:
26
- - '282'
26
+ - '281'
27
27
  Connection:
28
28
  - keep-alive
29
29
  Keep-Alive:
@@ -34,7 +34,7 @@ http_interactions:
34
34
  - no-cache
35
35
  body:
36
36
  encoding: UTF-8
37
- string: '{"account":"41001565326286","balance":48.98,"currency":"643","avatar":{"ts":"2012-05-02T17:22:59.000+04:00","url":"https://avatars.yandex.net/get-yamoney-profile/yamoney-profile-56809635-2/normal?1335964979000"},"account_type":"personal","identified":false,"account_status":"named"}'
37
+ string: '{"account":"41001565326286","balance":8.91,"currency":"643","avatar":{"ts":"2012-05-02T17:22:59.000+04:00","url":"https://avatars.yandex.net/get-yamoney-profile/yamoney-profile-56809635-2/normal?1335964979000"},"identified":false,"account_type":"personal","account_status":"named"}'
38
38
  http_version:
39
- recorded_at: Sat, 30 Aug 2014 13:11:08 GMT
40
- recorded_with: VCR 2.6.0
39
+ recorded_at: Sun, 14 Sep 2014 18:49:12 GMT
40
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://money.yandex.ru/api/operation-details
6
+ body:
7
+ encoding: UTF-8
8
+ string: operation_id=462449992116028008
9
+ headers:
10
+ Authorization:
11
+ - Bearer wrong
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 401
17
+ message: Unauthorized
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Sat, 20 Sep 2014 11:20:03 GMT
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Content-Length:
26
+ - '0'
27
+ Connection:
28
+ - keep-alive
29
+ Keep-Alive:
30
+ - timeout=120
31
+ Cache-Control:
32
+ - no-cache
33
+ Www-Authenticate:
34
+ - Bearer error="invalid_token", error_description="The specified access token
35
+ isn't found yet."
36
+ body:
37
+ encoding: UTF-8
38
+ string: ''
39
+ http_version:
40
+ recorded_at: Sat, 20 Sep 2014 11:20:03 GMT
41
+ recorded_with: VCR 2.9.3
@@ -3,15 +3,9 @@ require "spec_helper"
3
3
  describe "Payments from the Yandex.Money wallet" do
4
4
  describe "make payment to an account" do
5
5
  before :all do
6
- VCR.use_cassette "obtain token for making payments to an account" do
7
- @api = YandexMoney::Api.new(
8
- client_id: CLIENT_ID,
9
- redirect_uri: REDIRECT_URI,
10
- scope: 'payment.to-account("410011285611534") incoming-transfers'
11
- )
12
- @api.code = "F0EF348A2AE89F87040E46618C029CB9D6EFC2BFC9254F959D9A629FDD3A4EB6DA067D6422D0E008D098802A0B612F583B72FA9E332C73D21E1F770CBCC6AAF81818859E79AA6018621504572A0B217B7F7456FEE5422AF85D7790C04D51779966700EF8E45B32B4342E411A3E185C3E58B72BBEAAE069D681BCC3D542B3CE1D"
13
- @api.obtain_token
14
- end
6
+ @api = YandexMoney::Api.new(
7
+ token: "41001565326286.F231B646B62994F492C42942769B28211D996082FB0E553BF7D8783D91D6A2FF8CB9C83EA2E7A6A1DC303369916D25A8B60F63E52F6C19784F3F703B54332655CF59964ADFEF6D188F74E912617D7B0954A7BDEF83A683C09DAB35BC189785C3A1E6D0D7168F980875A67962C6119E87A18442E600F0ADB431DD1BCF33C905D3"
8
+ )
15
9
  end
16
10
 
17
11
  it "success request payment" do
@@ -39,7 +33,7 @@ describe "Payments from the Yandex.Money wallet" do
39
33
  test_payment: "true",
40
34
  test_result: "success"
41
35
  )
42
- }.to raise_error "Illegal params"
36
+ }.to raise_error YandexMoney::ApiError
43
37
  end
44
38
  end
45
39
 
@@ -61,7 +55,7 @@ describe "Payments from the Yandex.Money wallet" do
61
55
  test_payment: "true",
62
56
  test_result: "success"
63
57
  )
64
- }.to raise_error "Contract not found"
58
+ }.to raise_error YandexMoney::ApiError
65
59
  end
66
60
  end
67
61
 
@@ -75,7 +69,7 @@ describe "Payments from the Yandex.Money wallet" do
75
69
  VCR.use_cassette "accept incoming transfer with protection code with wrong code" do
76
70
  expect {
77
71
  @api.incoming_transfer_accept("463937921796020004", "6377")
78
- }.to raise_error "Illegal param protection code, attemps available: 2"
72
+ }.to raise_error YandexMoney::AcceptTransferError
79
73
  end
80
74
  end
81
75
 
@@ -89,7 +83,7 @@ describe "Payments from the Yandex.Money wallet" do
89
83
  VCR.use_cassette "reject payment fail" do
90
84
  expect {
91
85
  @api.incoming_transfer_reject("")
92
- }.to raise_error "Illegal param operation id"
86
+ }.to raise_error YandexMoney::ApiError
93
87
  end
94
88
  end
95
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yandex-money-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Maslov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-14 00:00:00.000000000 Z
11
+ date: 2014-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -141,6 +141,7 @@ files:
141
141
  - Rakefile
142
142
  - lib/yandex_money/api.rb
143
143
  - lib/yandex_money/api/version.rb
144
+ - lib/yandex_money/exceptions.rb
144
145
  - spec/account_info_spec.rb
145
146
  - spec/auth_spec.rb
146
147
  - spec/cards_spec.rb
@@ -169,6 +170,7 @@ files:
169
170
  - spec/fixtures/vcr_cassettes/success_process_payment_to_an_account.yml
170
171
  - spec/fixtures/vcr_cassettes/success_request_payment_to_an_account.yml
171
172
  - spec/fixtures/vcr_cassettes/token_with_client_secret.yml
173
+ - spec/fixtures/vcr_cassettes/unauthorized_exception.yml
172
174
  - spec/payments_spec.rb
173
175
  - spec/spec_helper.rb
174
176
  - spec/support/constants.rb
@@ -226,6 +228,7 @@ test_files:
226
228
  - spec/fixtures/vcr_cassettes/success_process_payment_to_an_account.yml
227
229
  - spec/fixtures/vcr_cassettes/success_request_payment_to_an_account.yml
228
230
  - spec/fixtures/vcr_cassettes/token_with_client_secret.yml
231
+ - spec/fixtures/vcr_cassettes/unauthorized_exception.yml
229
232
  - spec/payments_spec.rb
230
233
  - spec/spec_helper.rb
231
234
  - spec/support/constants.rb