yandex-money-client 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +8 -0
  5. data/.yardopts +1 -0
  6. data/CHANGELOG.md +43 -0
  7. data/Gemfile +11 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +159 -0
  10. data/Rakefile +7 -0
  11. data/lib/yandex_money/api.rb +10 -0
  12. data/lib/yandex_money/api/version.rb +5 -0
  13. data/lib/yandex_money/client.rb +56 -0
  14. data/lib/yandex_money/config.rb +26 -0
  15. data/lib/yandex_money/exceptions.rb +71 -0
  16. data/lib/yandex_money/external_payment.rb +81 -0
  17. data/lib/yandex_money/wallet.rb +215 -0
  18. data/spec/account_info_spec.rb +64 -0
  19. data/spec/auth_spec.rb +35 -0
  20. data/spec/cards_spec.rb +55 -0
  21. data/spec/config_spec.rb +50 -0
  22. data/spec/exceptions_spec.rb +55 -0
  23. data/spec/fixtures/vcr_cassettes/accept_incoming_transfer_with_protection_code.yml +40 -0
  24. data/spec/fixtures/vcr_cassettes/accept_incoming_transfer_with_protection_code_with_wrong_code.yml +40 -0
  25. data/spec/fixtures/vcr_cassettes/get_account_info.yml +40 -0
  26. data/spec/fixtures/vcr_cassettes/get_instance_id_fail.yml +38 -0
  27. data/spec/fixtures/vcr_cassettes/get_instance_id_success.yml +38 -0
  28. data/spec/fixtures/vcr_cassettes/get_operation_details.yml +233 -0
  29. data/spec/fixtures/vcr_cassettes/get_operation_history.yml +186 -0
  30. data/spec/fixtures/vcr_cassettes/get_operation_history_with_params.yml +46 -0
  31. data/spec/fixtures/vcr_cassettes/get_token_from_authorization_code.yml +48 -0
  32. data/spec/fixtures/vcr_cassettes/get_wrong_operation_details.yml +40 -0
  33. data/spec/fixtures/vcr_cassettes/init_without_client_secret.yml +843 -0
  34. data/spec/fixtures/vcr_cassettes/initialize_with_token.yml +40 -0
  35. data/spec/fixtures/vcr_cassettes/insufficient_scope_error.yml +40 -0
  36. data/spec/fixtures/vcr_cassettes/invalid_request_error.yml +40 -0
  37. data/spec/fixtures/vcr_cassettes/process_external_payment.yml +114 -0
  38. data/spec/fixtures/vcr_cassettes/process_payment_to_an_account_with_failure.yml +41 -0
  39. data/spec/fixtures/vcr_cassettes/reject_payment.yml +40 -0
  40. data/spec/fixtures/vcr_cassettes/reject_payment_fail.yml +40 -0
  41. data/spec/fixtures/vcr_cassettes/request_external_payment.yml +79 -0
  42. data/spec/fixtures/vcr_cassettes/request_payment_to_an_account_with_failure.yml +41 -0
  43. data/spec/fixtures/vcr_cassettes/success_process_payment_to_an_account.yml +40 -0
  44. data/spec/fixtures/vcr_cassettes/success_request_payment_to_an_account.yml +41 -0
  45. data/spec/fixtures/vcr_cassettes/unauthorized_error.yml +41 -0
  46. data/spec/fixtures/vcr_cassettes/unauthorized_exception.yml +41 -0
  47. data/spec/logger_spec.rb +1 -0
  48. data/spec/payments_spec.rb +80 -0
  49. data/spec/spec_helper.rb +27 -0
  50. data/spec/support/constants.example.rb +13 -0
  51. data/yandex-money-client.gemspec +31 -0
  52. metadata +269 -0
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://money.yandex.ru/api/account-info
6
+ body:
7
+ encoding: UTF-8
8
+ string: recurse_over_arrays=true
9
+ headers:
10
+ Authorization:
11
+ - Bearer <ACCESS_TOKEN>
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Mon, 10 Nov 2014 19:24:27 GMT
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Content-Length:
26
+ - '281'
27
+ Connection:
28
+ - keep-alive
29
+ Keep-Alive:
30
+ - timeout=120
31
+ Vary:
32
+ - Accept-Encoding
33
+ Cache-Control:
34
+ - no-cache
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"account":"<WALLET_NUMBER>","balance":6.88,"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"}'
38
+ http_version:
39
+ recorded_at: Mon, 10 Nov 2014 19:24:29 GMT
40
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://money.yandex.ru/api/request-payment
6
+ body:
7
+ encoding: UTF-8
8
+ string: pattern_id=p2p&to=example%40example.com&amount=5
9
+ headers:
10
+ Authorization:
11
+ - Bearer <ACCESS_TOKEN>
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 403
17
+ message: Forbidden
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Fri, 21 Nov 2014 07:38:43 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="insufficient_scope"
35
+ body:
36
+ encoding: UTF-8
37
+ string: ''
38
+ http_version:
39
+ recorded_at: Fri, 21 Nov 2014 07:38:45 GMT
40
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://money.yandex.ru/api/request-payment
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - Bearer WRONG TOKEN
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 400
17
+ message: Bad Request
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Fri, 21 Nov 2014 07:21:50 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_request"
35
+ body:
36
+ encoding: UTF-8
37
+ string: ''
38
+ http_version:
39
+ recorded_at: Fri, 21 Nov 2014 07:21:52 GMT
40
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,114 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://money.yandex.ru/api/instance-id
6
+ body:
7
+ encoding: UTF-8
8
+ string: client_id=<CLIENT_ID>
9
+ headers:
10
+ Content-Type:
11
+ - application/x-www-form-urlencoded
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Mon, 10 Nov 2014 19:24:27 GMT
21
+ Content-Type:
22
+ - application/json;charset=UTF-8
23
+ Content-Length:
24
+ - '101'
25
+ Connection:
26
+ - keep-alive
27
+ Keep-Alive:
28
+ - timeout=120
29
+ Vary:
30
+ - Accept-Encoding
31
+ Cache-Control:
32
+ - no-cache
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"status":"success","instance_id":"kGBM/H4/SOoHbHK0OM3h6i4iBSQWnIqUxeNMQmBb2vQPPQpwHcSkQGBmqpRCiPLy"}'
36
+ http_version:
37
+ recorded_at: Mon, 10 Nov 2014 19:24:29 GMT
38
+ - request:
39
+ method: post
40
+ uri: https://money.yandex.ru/api/request-external-payment
41
+ body:
42
+ encoding: UTF-8
43
+ string: pattern_id=p2p&to=410011285611534&amount_due=1.00&message=test&instance_id=kGBM%2FH4%2FSOoHbHK0OM3h6i4iBSQWnIqUxeNMQmBb2vQPPQpwHcSkQGBmqpRCiPLy
44
+ headers:
45
+ Content-Type:
46
+ - application/x-www-form-urlencoded
47
+ response:
48
+ status:
49
+ code: 200
50
+ message: OK
51
+ headers:
52
+ Server:
53
+ - nginx
54
+ Date:
55
+ - Mon, 10 Nov 2014 19:24:27 GMT
56
+ Content-Type:
57
+ - application/json;charset=UTF-8
58
+ Content-Length:
59
+ - '251'
60
+ Connection:
61
+ - keep-alive
62
+ Keep-Alive:
63
+ - timeout=120
64
+ Vary:
65
+ - Accept-Encoding
66
+ Cache-Control:
67
+ - no-cache
68
+ body:
69
+ encoding: ASCII-8BIT
70
+ string: !binary |-
71
+ eyJzdGF0dXMiOiJzdWNjZXNzIiwidGl0bGUiOiLQn9C10YDQtdCy0L7QtCDQ
72
+ vdCwINGB0YfQtdGCIDQxMDAxMTI4NTYxMTUzNCIsImNvbnRyYWN0X2Ftb3Vu
73
+ dCI6MS4wMiwibW9uZXlfc291cmNlIjp7InBheW1lbnQtY2FyZCI6e319LCJy
74
+ ZXF1ZXN0X2lkIjoiMzEzMzMwMzYzMzM0MzQzOTMwMzM1ZjYyNjM2NDM5MzYz
75
+ OTMzMzMzODM3MzE2MTMzMzEzMzM3MzMzMTM3MzUzMDMyMzkzMzYyMzQzNDY0
76
+ MzU2MjMyMzEzODM2NjQzNzMzMzgzODM0In0=
77
+ http_version:
78
+ recorded_at: Mon, 10 Nov 2014 19:24:29 GMT
79
+ - request:
80
+ method: post
81
+ uri: https://money.yandex.ru/api/process-external-payment
82
+ body:
83
+ encoding: UTF-8
84
+ string: request_id=313330363334343930335f62636439363933333837316133313337333137353032393362343464356232313836643733383834&ext_auth_success_uri=http%3A%2F%2F127.0.0.1%3A4567%2Fsuccess&ext_auth_fail_uri=http%3A%2F%2F127.0.0.1%3A4567%2Ffail&instance_id=kGBM%2FH4%2FSOoHbHK0OM3h6i4iBSQWnIqUxeNMQmBb2vQPPQpwHcSkQGBmqpRCiPLy
85
+ headers:
86
+ Content-Type:
87
+ - application/x-www-form-urlencoded
88
+ response:
89
+ status:
90
+ code: 200
91
+ message: OK
92
+ headers:
93
+ Server:
94
+ - nginx
95
+ Date:
96
+ - Mon, 10 Nov 2014 19:24:27 GMT
97
+ Content-Type:
98
+ - application/json;charset=UTF-8
99
+ Content-Length:
100
+ - '263'
101
+ Connection:
102
+ - keep-alive
103
+ Keep-Alive:
104
+ - timeout=120
105
+ Vary:
106
+ - Accept-Encoding
107
+ Cache-Control:
108
+ - no-cache
109
+ body:
110
+ encoding: UTF-8
111
+ string: '{"status":"ext_auth_required","acs_uri":"https://m.sp-money.yandex.ru/internal/public-api/to-payment-type","acs_params":{"cps_context_id":"313330363334343930335f62636439363933333837316133313337333137353032393362343464356232313836643733383834","paymentType":"FC"}}'
112
+ http_version:
113
+ recorded_at: Mon, 10 Nov 2014 19:24:29 GMT
114
+ 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/process-payment
6
+ body:
7
+ encoding: UTF-8
8
+ string: test_payment=true&test_result=success
9
+ headers:
10
+ Authorization:
11
+ - Bearer <ACCESS_TOKEN>
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Mon, 10 Nov 2014 19:24:28 GMT
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Content-Length:
26
+ - '141'
27
+ Connection:
28
+ - keep-alive
29
+ Keep-Alive:
30
+ - timeout=120
31
+ Vary:
32
+ - Accept-Encoding
33
+ Cache-Control:
34
+ - no-cache
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"status":"refused","error":"contract_not_found","error_description":"expected
38
+ request_id = ''test-p2p'' or ''test-shop''","test_payment":"true"}'
39
+ http_version:
40
+ recorded_at: Mon, 10 Nov 2014 19:24:30 GMT
41
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://money.yandex.ru/api/incoming-transfer-reject
6
+ body:
7
+ encoding: UTF-8
8
+ string: operation_id=463947376678019004
9
+ headers:
10
+ Authorization:
11
+ - Bearer <ACCESS_TOKEN>
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Mon, 10 Nov 2014 19:24:28 GMT
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Content-Length:
26
+ - '20'
27
+ Connection:
28
+ - keep-alive
29
+ Keep-Alive:
30
+ - timeout=120
31
+ Vary:
32
+ - Accept-Encoding
33
+ Cache-Control:
34
+ - no-cache
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"status":"success"}'
38
+ http_version:
39
+ recorded_at: Mon, 10 Nov 2014 19:24:30 GMT
40
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://money.yandex.ru/api/incoming-transfer-reject
6
+ body:
7
+ encoding: UTF-8
8
+ string: operation_id=
9
+ headers:
10
+ Authorization:
11
+ - Bearer <ACCESS_TOKEN>
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Mon, 10 Nov 2014 19:24:28 GMT
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Content-Length:
26
+ - '57'
27
+ Connection:
28
+ - keep-alive
29
+ Keep-Alive:
30
+ - timeout=120
31
+ Vary:
32
+ - Accept-Encoding
33
+ Cache-Control:
34
+ - no-cache
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"status":"refused","error":"illegal_param_operation_id"}'
38
+ http_version:
39
+ recorded_at: Mon, 10 Nov 2014 19:24:30 GMT
40
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,79 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://money.yandex.ru/api/instance-id
6
+ body:
7
+ encoding: UTF-8
8
+ string: client_id=<CLIENT_ID>
9
+ headers:
10
+ Content-Type:
11
+ - application/x-www-form-urlencoded
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Mon, 10 Nov 2014 19:24:27 GMT
21
+ Content-Type:
22
+ - application/json;charset=UTF-8
23
+ Content-Length:
24
+ - '101'
25
+ Connection:
26
+ - keep-alive
27
+ Keep-Alive:
28
+ - timeout=120
29
+ Vary:
30
+ - Accept-Encoding
31
+ Cache-Control:
32
+ - no-cache
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"status":"success","instance_id":"6hayxm04FRD5BAcLnbBqeY/ikYmUJKuvYuCCbGqQ5Nd4epIdnhtRmaebGxWqH7jO"}'
36
+ http_version:
37
+ recorded_at: Mon, 10 Nov 2014 19:24:29 GMT
38
+ - request:
39
+ method: post
40
+ uri: https://money.yandex.ru/api/request-external-payment
41
+ body:
42
+ encoding: UTF-8
43
+ string: pattern_id=p2p&to=410011285611534&amount_due=1.00&message=test&instance_id=6hayxm04FRD5BAcLnbBqeY%2FikYmUJKuvYuCCbGqQ5Nd4epIdnhtRmaebGxWqH7jO
44
+ headers:
45
+ Content-Type:
46
+ - application/x-www-form-urlencoded
47
+ response:
48
+ status:
49
+ code: 200
50
+ message: OK
51
+ headers:
52
+ Server:
53
+ - nginx
54
+ Date:
55
+ - Mon, 10 Nov 2014 19:24:27 GMT
56
+ Content-Type:
57
+ - application/json;charset=UTF-8
58
+ Content-Length:
59
+ - '251'
60
+ Connection:
61
+ - keep-alive
62
+ Keep-Alive:
63
+ - timeout=120
64
+ Vary:
65
+ - Accept-Encoding
66
+ Cache-Control:
67
+ - no-cache
68
+ body:
69
+ encoding: ASCII-8BIT
70
+ string: !binary |-
71
+ eyJzdGF0dXMiOiJzdWNjZXNzIiwidGl0bGUiOiLQn9C10YDQtdCy0L7QtCDQ
72
+ vdCwINGB0YfQtdGCIDQxMDAxMTI4NTYxMTUzNCIsImNvbnRyYWN0X2Ftb3Vu
73
+ dCI6MS4wMiwicmVxdWVzdF9pZCI6IjMxMzMzMDM2MzMzNDM0MzkzMDMwNWY2
74
+ NjM0MzM2NTY2MzczOTYxMzAzNzYyNjU2NjMwMzUzMTM0NjEzMTM2NjYzNjM3
75
+ Mzg2MzM1MzMzOTYzMzEzMzY1NjUzMzYyMzQzMzM2NjEzMyIsIm1vbmV5X3Nv
76
+ dXJjZSI6eyJwYXltZW50LWNhcmQiOnt9fX0=
77
+ http_version:
78
+ recorded_at: Mon, 10 Nov 2014 19:24:29 GMT
79
+ 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/request-payment
6
+ body:
7
+ encoding: UTF-8
8
+ string: pattern_id=p2p&to=410011161616877&test_payment=true&test_result=success
9
+ headers:
10
+ Authorization:
11
+ - Bearer <ACCESS_TOKEN>
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Mon, 10 Nov 2014 19:24:28 GMT
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Content-Length:
26
+ - '148'
27
+ Connection:
28
+ - keep-alive
29
+ Keep-Alive:
30
+ - timeout=120
31
+ Vary:
32
+ - Accept-Encoding
33
+ Cache-Control:
34
+ - no-cache
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"status":"refused","error":"illegal_params","error_description":"At
38
+ least one parameter of amount or amount_due is expected","test_payment":"true"}'
39
+ http_version:
40
+ recorded_at: Mon, 10 Nov 2014 19:24:30 GMT
41
+ recorded_with: VCR 2.9.3