wepay-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +118 -0
  7. data/Rakefile +7 -0
  8. data/lib/wepay-api.rb +2 -0
  9. data/lib/wepay.rb +23 -0
  10. data/lib/wepay/api.rb +27 -0
  11. data/lib/wepay/api/account.rb +86 -0
  12. data/lib/wepay/api/base.rb +25 -0
  13. data/lib/wepay/api/checkout.rb +68 -0
  14. data/lib/wepay/api/preapproval.rb +50 -0
  15. data/lib/wepay/api/subscription.rb +50 -0
  16. data/lib/wepay/api/subscription_plan.rb +59 -0
  17. data/lib/wepay/api/withdrawal.rb +41 -0
  18. data/lib/wepay/client.rb +63 -0
  19. data/lib/wepay/client/data.rb +31 -0
  20. data/lib/wepay/client/token.rb +30 -0
  21. data/lib/wepay/configuration.rb +34 -0
  22. data/lib/wepay/error.rb +28 -0
  23. data/lib/wepay/middleware.rb +44 -0
  24. data/lib/wepay/oauth.rb +32 -0
  25. data/lib/wepay/version.rb +3 -0
  26. data/spec/fixtures/vcr_cassettes/Wepay_Middleware/Wepay_Middleware_CheckStatus/raises_a_Wepay_ApiError_with_proper_error_type_message_and_code.yml +35 -0
  27. data/spec/fixtures/vcr_cassettes/wepay_account.yml +38 -0
  28. data/spec/fixtures/vcr_cassettes/wepay_account_add_bank.yml +38 -0
  29. data/spec/fixtures/vcr_cassettes/wepay_account_balance.yml +38 -0
  30. data/spec/fixtures/vcr_cassettes/wepay_account_create.yml +46 -0
  31. data/spec/fixtures/vcr_cassettes/wepay_account_delete.yml +48 -0
  32. data/spec/fixtures/vcr_cassettes/wepay_account_find.yml +43 -0
  33. data/spec/fixtures/vcr_cassettes/wepay_account_get_tax.yml +38 -0
  34. data/spec/fixtures/vcr_cassettes/wepay_account_modify.yml +49 -0
  35. data/spec/fixtures/vcr_cassettes/wepay_account_set_tax.yml +38 -0
  36. data/spec/fixtures/vcr_cassettes/wepay_checkout.yml +40 -0
  37. data/spec/fixtures/vcr_cassettes/wepay_checkout_cancel.yml +38 -0
  38. data/spec/fixtures/vcr_cassettes/wepay_checkout_capture.yml +38 -0
  39. data/spec/fixtures/vcr_cassettes/wepay_checkout_create.yml +38 -0
  40. data/spec/fixtures/vcr_cassettes/wepay_checkout_find.yml +51 -0
  41. data/spec/fixtures/vcr_cassettes/wepay_checkout_modify.yml +40 -0
  42. data/spec/fixtures/vcr_cassettes/wepay_checkout_refund.yml +38 -0
  43. data/spec/fixtures/vcr_cassettes/wepay_preapproval.yml +39 -0
  44. data/spec/fixtures/vcr_cassettes/wepay_preapproval_cancel.yml +38 -0
  45. data/spec/fixtures/vcr_cassettes/wepay_preapproval_create.yml +38 -0
  46. data/spec/fixtures/vcr_cassettes/wepay_preapproval_find.yml +39 -0
  47. data/spec/fixtures/vcr_cassettes/wepay_preapproval_modify.yml +39 -0
  48. data/spec/fixtures/vcr_cassettes/wepay_subscription.yml +38 -0
  49. data/spec/fixtures/vcr_cassettes/wepay_subscription_cancel.yml +36 -0
  50. data/spec/fixtures/vcr_cassettes/wepay_subscription_create.yml +48 -0
  51. data/spec/fixtures/vcr_cassettes/wepay_subscription_find.yml +38 -0
  52. data/spec/fixtures/vcr_cassettes/wepay_subscription_modify.yml +38 -0
  53. data/spec/fixtures/vcr_cassettes/wepay_subscription_plan.yml +39 -0
  54. data/spec/fixtures/vcr_cassettes/wepay_subscription_plan_create.yml +48 -0
  55. data/spec/fixtures/vcr_cassettes/wepay_subscription_plan_delete.yml +48 -0
  56. data/spec/fixtures/vcr_cassettes/wepay_subscription_plan_find.yml +39 -0
  57. data/spec/fixtures/vcr_cassettes/wepay_subscription_plan_get_button.yml +48 -0
  58. data/spec/fixtures/vcr_cassettes/wepay_subscription_plan_modify.yml +49 -0
  59. data/spec/fixtures/vcr_cassettes/wepay_withdrawal.yml +38 -0
  60. data/spec/fixtures/vcr_cassettes/wepay_withdrawal_create.yml +38 -0
  61. data/spec/fixtures/vcr_cassettes/wepay_withdrawal_find.yml +38 -0
  62. data/spec/fixtures/vcr_cassettes/wepay_withdrawal_modify.yml +38 -0
  63. data/spec/settings.yml.example +6 -0
  64. data/spec/spec_helper.rb +12 -0
  65. data/spec/support/matchers.rb +5 -0
  66. data/spec/support/rspec_helper.rb +30 -0
  67. data/spec/support/settings.rb +14 -0
  68. data/spec/support/vcr.rb +17 -0
  69. data/spec/wepay/api/account_spec.rb +110 -0
  70. data/spec/wepay/api/checkout_spec.rb +86 -0
  71. data/spec/wepay/api/preapproval_spec.rb +69 -0
  72. data/spec/wepay/api/subscription_plan_spec.rb +83 -0
  73. data/spec/wepay/api/subscription_spec.rb +65 -0
  74. data/spec/wepay/api/withdrawal_spec.rb +53 -0
  75. data/spec/wepay/api_spec.rb +9 -0
  76. data/spec/wepay/configuration_spec.rb +25 -0
  77. data/spec/wepay/middleware_spec.rb +21 -0
  78. data/spec/wepay/oauth_spec.rb +23 -0
  79. data/wepay-api.gemspec +29 -0
  80. metadata +273 -0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/account
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"account_id":"123456"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Thu, 05 Dec 2013 10:46:19 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ strict-transport-security:
32
+ - max-age=2592000
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"account_id":123456,"name":"Test account","state":"active","description":"abc","account_uri":"https:\/\/stage.wepay.com\/account\/123456","payment_limit":50000,"verification_state":"unverified","type":"personal","auto_withdrawal":false,"create_time":1386239642,"verification_uri":"https:\/\/stage.wepay.com\/api\/account_verify\/123456\/d953f41e"}'
36
+ http_version:
37
+ recorded_at: Thu, 05 Dec 2013 10:46:19 GMT
38
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/account/add_bank
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"account_id":"123456"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Fri, 13 Dec 2013 08:11:12 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ strict-transport-security:
32
+ - max-age=2592000
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"account_id":123456,"add_bank_uri":"https:\/\/stage.wepay.com\/api\/account_add_bank\/123456\/65d2737e"}'
36
+ http_version:
37
+ recorded_at: Fri, 13 Dec 2013 08:11:12 GMT
38
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/account/balance
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"account_id":"123456"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Fri, 13 Dec 2013 08:09:49 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ strict-transport-security:
32
+ - max-age=2592000
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"pending_balance":0,"available_balance":0,"pending_amount":0,"reserved_amount":0,"disputed_amount":0,"currency":"USD"}'
36
+ http_version:
37
+ recorded_at: Fri, 13 Dec 2013 08:09:49 GMT
38
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,46 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/account/create
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"name":"New+Account", "description":"Created by API"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Thu, 05 Dec 2013 10:46:22 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ set-cookie:
32
+ - wepay=28q0mcvp2c90sjn6bn43e7s0t5; path=/; domain=stage.wepay.com; secure; HttpOnly, wepay=28q0mcvp2c90sjn6bn43e7s0t5; path=/; domain=stage.wepay.com; secure; httponly
33
+ expires:
34
+ - Thu, 19 Nov 1981 08:52:00 GMT
35
+ cache-control:
36
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
37
+ pragma:
38
+ - no-cache
39
+ strict-transport-security:
40
+ - max-age=2592000
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"account_id":123456,"account_uri":"https:\/\/stage.wepay.com\/account\/123456"}'
44
+ http_version:
45
+ recorded_at: Thu, 05 Dec 2013 10:46:22 GMT
46
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/account/delete
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"account_id":"123456"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Fri, 13 Dec 2013 08:01:54 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ set-cookie:
32
+ - wepay=u9p97k43btg1qi7j99od7n6s00; path=/; domain=stage.wepay.com; secure;
33
+ HttpOnly, wepay=u9p97k43btg1qi7j99od7n6s00; path=/; domain=stage.wepay.com;
34
+ secure; httponly
35
+ expires:
36
+ - Thu, 19 Nov 1981 08:52:00 GMT
37
+ cache-control:
38
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
39
+ pragma:
40
+ - no-cache
41
+ strict-transport-security:
42
+ - max-age=2592000
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"account_id":123456,"state":"deleted"}'
46
+ http_version:
47
+ recorded_at: Fri, 13 Dec 2013 08:01:55 GMT
48
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/account/find
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Fri, 13 Dec 2013 07:52:42 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ strict-transport-security:
32
+ - max-age=2592000
33
+ body:
34
+ encoding: UTF-8
35
+ string: '[{"account_id":123456,"name":"ABC","state":"active","description":"This
36
+ account was created by ABC","account_uri":"https:\/\/stage.wepay.com\/account\/123456","payment_limit":"50000","verification_state":"unverified","type":"personal","auto_withdrawal":false,"create_time":1386243069,"verification_uri":"https:\/\/stage.wepay.com\/api\/account_verify\/123456\/65d2737e"},{"account_id":1245716361,"name":"Payment
37
+ account for ABC","state":"active","description":"This account was
38
+ created by ABC","account_uri":"https:\/\/stage.wepay.com\/account\/1245716361","payment_limit":"50000","verification_state":"unverified","type":"personal","auto_withdrawal":false,"create_time":1386242810,"verification_uri":"https:\/\/stage.wepay.com\/api\/account_verify\/1245716361\/65d2737e"},{"account_id":2067308492,"name":"New
39
+ Account","state":"active","description":"Created by API","account_uri":"https:\/\/stage.wepay.com\/account\/2067308492","payment_limit":"50000","verification_state":"unverified","type":"personal","auto_withdrawal":false,"create_time":1386240381,"verification_uri":"https:\/\/stage.wepay.com\/api\/account_verify\/2067308492\/65d2737e"},{"account_id":1234567,"name":"Test
40
+ account","state":"active","description":"abc","account_uri":"https:\/\/stage.wepay.com\/account\/1234567","payment_limit":"50000","verification_state":"unverified","type":"personal","auto_withdrawal":false,"create_time":1386239642,"verification_uri":"https:\/\/stage.wepay.com\/api\/account_verify\/1234567\/65d2737e"}]'
41
+ http_version:
42
+ recorded_at: Fri, 13 Dec 2013 07:52:42 GMT
43
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/account/get_tax
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"account_id":123456"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Mon, 16 Dec 2013 03:05:17 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ strict-transport-security:
32
+ - max-age=2592000
33
+ body:
34
+ encoding: UTF-8
35
+ string: '[{"zip":94025,"state":"CA","country":"US","percent":10}]'
36
+ http_version:
37
+ recorded_at: Mon, 16 Dec 2013 03:05:19 GMT
38
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/account/modify
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"account_id":"123456", "name":"New Account Name"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Fri, 13 Dec 2013 07:59:13 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ set-cookie:
32
+ - wepay=1gnrmnud3ajgl9l0fheg14gbj5; path=/; domain=stage.wepay.com; secure;
33
+ HttpOnly, wepay=1gnrmnud3ajgl9l0fheg14gbj5; path=/; domain=stage.wepay.com;
34
+ secure; httponly
35
+ expires:
36
+ - Thu, 19 Nov 1981 08:52:00 GMT
37
+ cache-control:
38
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
39
+ pragma:
40
+ - no-cache
41
+ strict-transport-security:
42
+ - max-age=2592000
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"account_id":123456,"name":"New Account Name","state":"active","description":"This
46
+ account was created by ABC","account_uri":"https:\/\/stage.wepay.com\/account\/123456","payment_limit":"50000","verification_state":"unverified","type":"personal","auto_withdrawal":false,"create_time":1386243069,"verification_uri":"https:\/\/stage.wepay.com\/api\/account_verify\/123456\/65d2737e"}'
47
+ http_version:
48
+ recorded_at: Fri, 13 Dec 2013 07:59:13 GMT
49
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/account/set_tax
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"account_id":"123456","taxes":[{"percent":10,"country":"US","state":"CA","zip":"94025"}]}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Mon, 16 Dec 2013 03:05:15 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ strict-transport-security:
32
+ - max-age=2592000
33
+ body:
34
+ encoding: UTF-8
35
+ string: '[{"zip":94025,"state":"CA","country":"US","percent":10}]'
36
+ http_version:
37
+ recorded_at: Mon, 16 Dec 2013 03:05:18 GMT
38
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/checkout
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"checkout_id":"1234567890"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Wed, 04 Dec 2013 04:08:41 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ strict-transport-security:
32
+ - max-age=2592000
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"checkout_id":1234567890,"account_id":123456,"type":"GOODS","checkout_uri":"https:\/\/stage.wepay.com\/api\/checkout\/1234567890\/541d45b8","short_description":"test
36
+ checkout creation","currency":"USD","amount":10,"fee_payer":"payer","state":"expired","soft_descriptor":"WPY*Descriptor
37
+ ","redirect_uri":"","auto_capture":false,"app_fee":0,"create_time":1386054830,"mode":"regular","amount_refunded":0,"amount_charged_back":0,"tax":0,"dispute_uri":""}'
38
+ http_version:
39
+ recorded_at: Wed, 04 Dec 2013 04:08:42 GMT
40
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://stage.wepayapi.com/v2/checkout/cancel
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"checkout_id":"1234567890", "cancel_reason":"no reason"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Authorization:
13
+ - Bearer access_token
14
+ Content-Type:
15
+ - application/json
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Wed, 04 Dec 2013 05:21:57 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ strict-transport-security:
32
+ - max-age=2592000
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"checkout_id":1234567890,"state":"cancelled"}'
36
+ http_version:
37
+ recorded_at: Wed, 04 Dec 2013 05:21:57 GMT
38
+ recorded_with: VCR 2.8.0