mangopay 3.0.25 → 3.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +30 -28
  3. data/.rspec +2 -2
  4. data/.travis.yml +13 -4
  5. data/Gemfile +2 -2
  6. data/LICENSE +20 -20
  7. data/README.md +126 -126
  8. data/bin/mangopay +9 -9
  9. data/lib/generators/mangopay/install_generator.rb +60 -60
  10. data/lib/generators/templates/mangopay.rb.erb +5 -5
  11. data/lib/mangopay.rb +228 -225
  12. data/lib/mangopay/authorization_token.rb +88 -88
  13. data/lib/mangopay/bank_account.rb +38 -38
  14. data/lib/mangopay/bankingaliases.rb +29 -0
  15. data/lib/mangopay/bankingaliases_iban.rb +16 -0
  16. data/lib/mangopay/card.rb +8 -8
  17. data/lib/mangopay/card_registration.rb +9 -9
  18. data/lib/mangopay/client.rb +74 -74
  19. data/lib/mangopay/dispute.rb +130 -130
  20. data/lib/mangopay/errors.rb +61 -61
  21. data/lib/mangopay/event.rb +18 -18
  22. data/lib/mangopay/filter_parameters.rb +46 -46
  23. data/lib/mangopay/hook.rb +9 -9
  24. data/lib/mangopay/http_calls.rb +85 -85
  25. data/lib/mangopay/json.rb +14 -14
  26. data/lib/mangopay/kyc_document.rb +70 -70
  27. data/lib/mangopay/legal_user.rb +15 -15
  28. data/lib/mangopay/mandate.rb +32 -32
  29. data/lib/mangopay/natural_user.rb +14 -14
  30. data/lib/mangopay/pay_in.rb +96 -85
  31. data/lib/mangopay/pay_out.rb +14 -14
  32. data/lib/mangopay/pre_authorization.rb +13 -13
  33. data/lib/mangopay/refund.rb +7 -7
  34. data/lib/mangopay/report.rb +17 -17
  35. data/lib/mangopay/resource.rb +21 -21
  36. data/lib/mangopay/transaction.rb +24 -24
  37. data/lib/mangopay/transfer.rb +9 -9
  38. data/lib/mangopay/user.rb +43 -43
  39. data/lib/mangopay/version.rb +3 -3
  40. data/lib/mangopay/wallet.rb +17 -17
  41. data/mangopay.gemspec +30 -30
  42. data/spec/mangopay/authorization_token_spec.rb +70 -70
  43. data/spec/mangopay/bank_account_spec.rb +97 -97
  44. data/spec/mangopay/bankingaliases_spec.rb +29 -0
  45. data/spec/mangopay/card_registration_spec.rb +73 -73
  46. data/spec/mangopay/client_spec.rb +110 -110
  47. data/spec/mangopay/configuration_spec.rb +95 -95
  48. data/spec/mangopay/dispute_spec.rb +262 -262
  49. data/spec/mangopay/event_spec.rb +31 -31
  50. data/spec/mangopay/fetch_filters_spec.rb +63 -63
  51. data/spec/mangopay/hook_spec.rb +37 -37
  52. data/spec/mangopay/idempotency_spec.rb +41 -41
  53. data/spec/mangopay/kyc_document_spec.rb +103 -103
  54. data/spec/mangopay/log_requests_filter_spec.rb +25 -25
  55. data/spec/mangopay/mandate_spec.rb +92 -92
  56. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
  57. data/spec/mangopay/payin_card_direct_spec.rb +68 -68
  58. data/spec/mangopay/payin_card_web_spec.rb +47 -38
  59. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
  60. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
  61. data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
  62. data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
  63. data/spec/mangopay/payout_bankwire_spec.rb +54 -54
  64. data/spec/mangopay/preauthorization_spec.rb +42 -42
  65. data/spec/mangopay/refund_spec.rb +21 -21
  66. data/spec/mangopay/report_spec.rb +39 -39
  67. data/spec/mangopay/shared_resources.rb +397 -381
  68. data/spec/mangopay/transaction_spec.rb +54 -54
  69. data/spec/mangopay/transfer_spec.rb +69 -69
  70. data/spec/mangopay/user_spec.rb +137 -137
  71. data/spec/mangopay/wallet_spec.rb +80 -80
  72. data/spec/spec_helper.rb +31 -31
  73. metadata +7 -6
  74. data/lib/mangopay/temp.rb +0 -74
  75. data/spec/mangopay/temp_paymentcard_spec.rb +0 -31
@@ -1,14 +1,14 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/users/natural-users/
4
- class NaturalUser < User
5
-
6
- def self.url(id = nil)
7
- if id
8
- "#{MangoPay.api_path}/users/natural/#{CGI.escape(id.to_s)}"
9
- else
10
- "#{MangoPay.api_path}/users/natural"
11
- end
12
- end
13
- end
14
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/users/natural-users/
4
+ class NaturalUser < User
5
+
6
+ def self.url(id = nil)
7
+ if id
8
+ "#{MangoPay.api_path}/users/natural/#{CGI.escape(id.to_s)}"
9
+ else
10
+ "#{MangoPay.api_path}/users/natural"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,85 +1,96 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/payins/
4
- class PayIn < Resource
5
- include HTTPCalls::Fetch
6
- include HTTPCalls::Refund
7
-
8
- module Card
9
-
10
- # See http://docs.mangopay.com/api-references/payins/payins-card-web/
11
- class Web < Resource
12
- include HTTPCalls::Create
13
- def self.url(*)
14
- "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
15
- end
16
- end
17
-
18
- # See http://docs.mangopay.com/api-references/payins/payindirectcard/
19
- class Direct < Resource
20
- include HTTPCalls::Create
21
- def self.url(*)
22
- "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
23
- end
24
- end
25
-
26
- end
27
-
28
- module PreAuthorized
29
-
30
- # See http://docs.mangopay.com/api-references/payins/preauthorized-payin/
31
- class Direct < Resource
32
- include HTTPCalls::Create
33
- def self.url(*)
34
- "#{MangoPay.api_path}/payins/preauthorized/direct"
35
- end
36
- end
37
-
38
- end
39
-
40
- module BankWire
41
-
42
- # See http://docs.mangopay.com/api-references/payins/payinbankwire/
43
- class Direct < Resource
44
- include HTTPCalls::Create
45
- def self.url(*)
46
- "#{MangoPay.api_path}/payins/bankwire/direct"
47
- end
48
- end
49
-
50
- end
51
-
52
- module DirectDebit
53
-
54
- # See http://docs.mangopay.com/api-references/payins/direct-debit-pay-in-web/
55
- class Web < Resource
56
- include HTTPCalls::Create
57
- def self.url(*)
58
- "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
59
- end
60
- end
61
-
62
- # See https://docs.mangopay.com/api-references/payins/direct-debit-pay-in-direct/
63
- class Direct < Resource
64
- include HTTPCalls::Create
65
- def self.url(*)
66
- "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
67
- end
68
- end
69
-
70
- end
71
-
72
- module PayPal
73
-
74
- # See https://docs.mangopay.com/api-references/payins/paypal-payin/
75
- class Web < Resource
76
- include HTTPCalls::Create
77
- def self.url(*)
78
- "#{MangoPay.api_path}/payins/paypal/#{CGI.escape(class_name.downcase)}"
79
- end
80
- end
81
-
82
- end
83
-
84
- end
85
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/payins/
4
+ class PayIn < Resource
5
+ include HTTPCalls::Fetch
6
+ include HTTPCalls::Refund
7
+
8
+ module Card
9
+
10
+ # See http://docs.mangopay.com/api-references/payins/payins-card-web/
11
+ class Web < Resource
12
+ include HTTPCalls::Create
13
+ def self.url(*)
14
+ "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
15
+ end
16
+
17
+ def self.extended(pay_in_id)
18
+ MangoPay.request(:get, extended_url(pay_in_id), {}, {})
19
+ end
20
+
21
+ # See https://docs.mangopay.com/endpoints/v2.01/payins#e847_view-card-details-for-a-payin-web
22
+ # example: data = MangoPay::PayIn::Card::Web.extended(12639078)
23
+ def self.extended_url(pay_in_id)
24
+ escaped_pay_in_id = CGI.escape(pay_in_id.to_s)
25
+ "#{MangoPay.api_path}/payins/card/web/#{escaped_pay_in_id}/extended"
26
+ end
27
+ end
28
+
29
+ # See http://docs.mangopay.com/api-references/payins/payindirectcard/
30
+ class Direct < Resource
31
+ include HTTPCalls::Create
32
+ def self.url(*)
33
+ "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+ module PreAuthorized
40
+
41
+ # See http://docs.mangopay.com/api-references/payins/preauthorized-payin/
42
+ class Direct < Resource
43
+ include HTTPCalls::Create
44
+ def self.url(*)
45
+ "#{MangoPay.api_path}/payins/preauthorized/direct"
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ module BankWire
52
+
53
+ # See http://docs.mangopay.com/api-references/payins/payinbankwire/
54
+ class Direct < Resource
55
+ include HTTPCalls::Create
56
+ def self.url(*)
57
+ "#{MangoPay.api_path}/payins/bankwire/direct"
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ module DirectDebit
64
+
65
+ # See http://docs.mangopay.com/api-references/payins/direct-debit-pay-in-web/
66
+ class Web < Resource
67
+ include HTTPCalls::Create
68
+ def self.url(*)
69
+ "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
70
+ end
71
+ end
72
+
73
+ # See https://docs.mangopay.com/api-references/payins/direct-debit-pay-in-direct/
74
+ class Direct < Resource
75
+ include HTTPCalls::Create
76
+ def self.url(*)
77
+ "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
78
+ end
79
+ end
80
+
81
+ end
82
+
83
+ module PayPal
84
+
85
+ # See https://docs.mangopay.com/api-references/payins/paypal-payin/
86
+ class Web < Resource
87
+ include HTTPCalls::Create
88
+ def self.url(*)
89
+ "#{MangoPay.api_path}/payins/paypal/#{CGI.escape(class_name.downcase)}"
90
+ end
91
+ end
92
+
93
+ end
94
+
95
+ end
96
+ end
@@ -1,14 +1,14 @@
1
- module MangoPay
2
- class PayOut < Resource
3
- include HTTPCalls::Fetch
4
-
5
- # See http://docs.mangopay.com/api-references/pay-out-bank-wire/
6
- class BankWire < Resource
7
- include HTTPCalls::Create
8
-
9
- def self.url(*)
10
- "#{MangoPay.api_path}/payouts/bankwire"
11
- end
12
- end
13
- end
14
- end
1
+ module MangoPay
2
+ class PayOut < Resource
3
+ include HTTPCalls::Fetch
4
+
5
+ # See http://docs.mangopay.com/api-references/pay-out-bank-wire/
6
+ class BankWire < Resource
7
+ include HTTPCalls::Create
8
+
9
+ def self.url(*)
10
+ "#{MangoPay.api_path}/payouts/bankwire"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,13 +1,13 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/payins/preauthorized-payin/
4
- class PreAuthorization < Resource
5
- include HTTPCalls::Update
6
- include HTTPCalls::Fetch
7
-
8
- def self.create(params, idempotency_key = nil)
9
- MangoPay.request(:post, "#{url}/card/direct", params, {}, idempotency_key)
10
- end
11
-
12
- end
13
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/payins/preauthorized-payin/
4
+ class PreAuthorization < Resource
5
+ include HTTPCalls::Update
6
+ include HTTPCalls::Fetch
7
+
8
+ def self.create(params, idempotency_key = nil)
9
+ MangoPay.request(:post, "#{url}/card/direct", params, {}, idempotency_key)
10
+ end
11
+
12
+ end
13
+ end
@@ -1,7 +1,7 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/refund/
4
- class Refund < Resource
5
- include HTTPCalls::Fetch
6
- end
7
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/refund/
4
+ class Refund < Resource
5
+ include HTTPCalls::Fetch
6
+ end
7
+ end
@@ -1,17 +1,17 @@
1
- module MangoPay
2
-
3
- # See https://docs.mangopay.com/endpoints/v2.01/reporting
4
- class Report < Resource
5
- include HTTPCalls::Fetch
6
-
7
- class << self
8
-
9
- # +params+: hash; see https://docs.mangopay.com/endpoints/v2.01/reporting#e825_create-a-transaction-report
10
- def create(params, idempotency_key = nil)
11
- url = url() + '/transactions/'
12
- MangoPay.request(:post, url, params, {}, idempotency_key)
13
- end
14
-
15
- end
16
- end
17
- end
1
+ module MangoPay
2
+
3
+ # See https://docs.mangopay.com/endpoints/v2.01/reporting
4
+ class Report < Resource
5
+ include HTTPCalls::Fetch
6
+
7
+ class << self
8
+
9
+ # +params+: hash; see https://docs.mangopay.com/endpoints/v2.01/reporting#e825_create-a-transaction-report
10
+ def create(params, idempotency_key = nil)
11
+ url = url() + '/transactions/'
12
+ MangoPay.request(:post, url, params, {}, idempotency_key)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -1,21 +1,21 @@
1
- module MangoPay
2
- # @abstract
3
- class Resource
4
- class << self
5
- def class_name
6
- name.split('::').last
7
- end
8
-
9
- def url(id = nil)
10
- if self == Resource
11
- raise NotImplementedError.new('Resource is an abstract class. Do not use it directly.')
12
- end
13
- if id
14
- "#{MangoPay.api_path}/#{CGI.escape(class_name.downcase)}s/#{CGI.escape(id.to_s)}"
15
- else
16
- "#{MangoPay.api_path}/#{CGI.escape(class_name.downcase)}s"
17
- end
18
- end
19
- end
20
- end
21
- end
1
+ module MangoPay
2
+ # @abstract
3
+ class Resource
4
+ class << self
5
+ def class_name
6
+ name.split('::').last
7
+ end
8
+
9
+ def url(id = nil)
10
+ if self == Resource
11
+ raise NotImplementedError.new('Resource is an abstract class. Do not use it directly.')
12
+ end
13
+ if id
14
+ "#{MangoPay.api_path}/#{CGI.escape(class_name.downcase)}s/#{CGI.escape(id.to_s)}"
15
+ else
16
+ "#{MangoPay.api_path}/#{CGI.escape(class_name.downcase)}s"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,24 +1,24 @@
1
- module MangoPay
2
- class Transaction < Resource
3
- class << self
4
- # Fetches list of transactions belonging to the given +wallet_id+.
5
- # See also transactions for user: MangoPay::User#transactions
6
- #
7
- # Optional +filters+ is a hash accepting following keys:
8
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
9
- # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
10
- # - +Type+: TransactionType {PAYIN, PAYOUT, TRANSFER}
11
- # - +Nature+: TransactionNature {NORMAL, REFUND, REPUDIATION}
12
- # - +BeforeDate+ (timestamp): filters transactions with CreationDate _before_ this date
13
- # - +AfterDate+ (timestamp): filters transactions with CreationDate _after_ this date
14
- # See https://docs.mangopay.com/api-references/sort-lists/
15
- def fetch(wallet_id, filters={})
16
- MangoPay.request(:get, url(wallet_id), {}, filters)
17
- end
18
-
19
- def url(wallet_id)
20
- "#{MangoPay.api_path}/wallets/#{CGI.escape(wallet_id.to_s)}/transactions"
21
- end
22
- end
23
- end
24
- end
1
+ module MangoPay
2
+ class Transaction < Resource
3
+ class << self
4
+ # Fetches list of transactions belonging to the given +wallet_id+.
5
+ # See also transactions for user: MangoPay::User#transactions
6
+ #
7
+ # Optional +filters+ is a hash accepting following keys:
8
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
9
+ # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
10
+ # - +Type+: TransactionType {PAYIN, PAYOUT, TRANSFER}
11
+ # - +Nature+: TransactionNature {NORMAL, REFUND, REPUDIATION}
12
+ # - +BeforeDate+ (timestamp): filters transactions with CreationDate _before_ this date
13
+ # - +AfterDate+ (timestamp): filters transactions with CreationDate _after_ this date
14
+ # See https://docs.mangopay.com/api-references/sort-lists/
15
+ def fetch(wallet_id, filters={})
16
+ MangoPay.request(:get, url(wallet_id), {}, filters)
17
+ end
18
+
19
+ def url(wallet_id)
20
+ "#{MangoPay.api_path}/wallets/#{CGI.escape(wallet_id.to_s)}/transactions"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,9 +1,9 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/transfers/
4
- class Transfer < Resource
5
- include HTTPCalls::Create
6
- include HTTPCalls::Fetch
7
- include HTTPCalls::Refund
8
- end
9
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/transfers/
4
+ class Transfer < Resource
5
+ include HTTPCalls::Create
6
+ include HTTPCalls::Fetch
7
+ include HTTPCalls::Refund
8
+ end
9
+ end
data/lib/mangopay/user.rb CHANGED
@@ -1,43 +1,43 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/users/
4
- # See also children classes:
5
- # - MangoPay::NaturalUser
6
- # - MangoPay::LegalUser
7
- class User < Resource
8
- include HTTPCalls::Create
9
- include HTTPCalls::Update
10
- include HTTPCalls::Fetch
11
- class << self
12
- # Fetches list of wallets belonging to the given +user_id+.
13
- # Optional +filters+ is a hash accepting following keys:
14
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
15
- def wallets(user_id, filters={})
16
- MangoPay.request(:get, url(user_id) + '/wallets', {}, filters)
17
- end
18
-
19
- # Fetches list of bank accounts belonging to the given +user_id+.
20
- # Optional +filters+ is a hash accepting following keys:
21
- # - +page+, +per_page+, +sort+: pagination and sorting params
22
- # (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
23
- def bank_accounts(user_id, filters={})
24
- MangoPay.request(:get, url(user_id) + '/bankaccounts', {}, filters)
25
- end
26
-
27
- # Fetches list of cards belonging to the given +user_id+.
28
- # Optional +filters+ is a hash accepting following keys:
29
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
30
- def cards(user_id, filters={})
31
- MangoPay.request(:get, url(user_id) + '/cards', {}, filters)
32
- end
33
-
34
- # Fetches list of transactions belonging to the given +user_id+.
35
- # Optional +filters+ is a hash accepting following keys:
36
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
37
- # - other keys specific for transactions filtering (see MangoPay::Transaction#fetch)
38
- def transactions(user_id, filters={})
39
- MangoPay.request(:get, url(user_id) + '/transactions', {}, filters)
40
- end
41
- end
42
- end
43
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/users/
4
+ # See also children classes:
5
+ # - MangoPay::NaturalUser
6
+ # - MangoPay::LegalUser
7
+ class User < Resource
8
+ include HTTPCalls::Create
9
+ include HTTPCalls::Update
10
+ include HTTPCalls::Fetch
11
+ class << self
12
+ # Fetches list of wallets belonging to the given +user_id+.
13
+ # Optional +filters+ is a hash accepting following keys:
14
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
15
+ def wallets(user_id, filters={})
16
+ MangoPay.request(:get, url(user_id) + '/wallets', {}, filters)
17
+ end
18
+
19
+ # Fetches list of bank accounts belonging to the given +user_id+.
20
+ # Optional +filters+ is a hash accepting following keys:
21
+ # - +page+, +per_page+, +sort+: pagination and sorting params
22
+ # (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
23
+ def bank_accounts(user_id, filters={})
24
+ MangoPay.request(:get, url(user_id) + '/bankaccounts', {}, filters)
25
+ end
26
+
27
+ # Fetches list of cards belonging to the given +user_id+.
28
+ # Optional +filters+ is a hash accepting following keys:
29
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
30
+ def cards(user_id, filters={})
31
+ MangoPay.request(:get, url(user_id) + '/cards', {}, filters)
32
+ end
33
+
34
+ # Fetches list of transactions belonging to the given +user_id+.
35
+ # Optional +filters+ is a hash accepting following keys:
36
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
37
+ # - other keys specific for transactions filtering (see MangoPay::Transaction#fetch)
38
+ def transactions(user_id, filters={})
39
+ MangoPay.request(:get, url(user_id) + '/transactions', {}, filters)
40
+ end
41
+ end
42
+ end
43
+ end