mangopay 3.0.25.pre.alpha.pre.20 → 3.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +28 -28
  3. data/.rspec +2 -2
  4. data/.travis.yml +4 -13
  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 +225 -225
  12. data/lib/mangopay/authorization_token.rb +88 -88
  13. data/lib/mangopay/bank_account.rb +38 -38
  14. data/lib/mangopay/card.rb +8 -8
  15. data/lib/mangopay/card_registration.rb +9 -9
  16. data/lib/mangopay/client.rb +74 -74
  17. data/lib/mangopay/dispute.rb +130 -130
  18. data/lib/mangopay/errors.rb +61 -61
  19. data/lib/mangopay/event.rb +18 -18
  20. data/lib/mangopay/filter_parameters.rb +46 -46
  21. data/lib/mangopay/hook.rb +9 -9
  22. data/lib/mangopay/http_calls.rb +85 -85
  23. data/lib/mangopay/json.rb +14 -14
  24. data/lib/mangopay/kyc_document.rb +70 -70
  25. data/lib/mangopay/legal_user.rb +15 -15
  26. data/lib/mangopay/mandate.rb +32 -32
  27. data/lib/mangopay/natural_user.rb +14 -14
  28. data/lib/mangopay/pay_in.rb +85 -85
  29. data/lib/mangopay/pay_out.rb +14 -14
  30. data/lib/mangopay/pre_authorization.rb +13 -13
  31. data/lib/mangopay/refund.rb +7 -7
  32. data/lib/mangopay/report.rb +17 -17
  33. data/lib/mangopay/resource.rb +21 -21
  34. data/lib/mangopay/temp.rb +74 -74
  35. data/lib/mangopay/transaction.rb +24 -24
  36. data/lib/mangopay/transfer.rb +9 -9
  37. data/lib/mangopay/user.rb +43 -43
  38. data/lib/mangopay/version.rb +3 -3
  39. data/lib/mangopay/wallet.rb +17 -17
  40. data/mangopay.gemspec +30 -31
  41. data/spec/mangopay/authorization_token_spec.rb +70 -70
  42. data/spec/mangopay/bank_account_spec.rb +97 -97
  43. data/spec/mangopay/card_registration_spec.rb +73 -73
  44. data/spec/mangopay/client_spec.rb +110 -110
  45. data/spec/mangopay/configuration_spec.rb +95 -95
  46. data/spec/mangopay/dispute_spec.rb +262 -262
  47. data/spec/mangopay/event_spec.rb +31 -31
  48. data/spec/mangopay/fetch_filters_spec.rb +63 -63
  49. data/spec/mangopay/hook_spec.rb +37 -37
  50. data/spec/mangopay/idempotency_spec.rb +41 -41
  51. data/spec/mangopay/kyc_document_spec.rb +103 -103
  52. data/spec/mangopay/log_requests_filter_spec.rb +25 -25
  53. data/spec/mangopay/mandate_spec.rb +92 -92
  54. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
  55. data/spec/mangopay/payin_card_direct_spec.rb +68 -68
  56. data/spec/mangopay/payin_card_web_spec.rb +38 -38
  57. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
  58. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
  59. data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
  60. data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
  61. data/spec/mangopay/payout_bankwire_spec.rb +54 -54
  62. data/spec/mangopay/preauthorization_spec.rb +42 -42
  63. data/spec/mangopay/refund_spec.rb +21 -21
  64. data/spec/mangopay/report_spec.rb +39 -39
  65. data/spec/mangopay/shared_resources.rb +381 -381
  66. data/spec/mangopay/temp_paymentcard_spec.rb +31 -31
  67. data/spec/mangopay/transaction_spec.rb +54 -54
  68. data/spec/mangopay/transfer_spec.rb +69 -69
  69. data/spec/mangopay/user_spec.rb +137 -137
  70. data/spec/mangopay/wallet_spec.rb +80 -80
  71. data/spec/spec_helper.rb +31 -31
  72. metadata +5 -5
@@ -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
data/lib/mangopay/temp.rb CHANGED
@@ -1,74 +1,74 @@
1
- module MangoPay
2
-
3
- module Temp
4
-
5
- # As part of our migration project to allow users
6
- # to move from v1 to v2 of our API,
7
- # we have added a couple of temporary calls to the v2 API.
8
- #
9
- # They are not documented in normal way, but the calls are related to:
10
- # - registering a card (POST & GET /temp/paymentcards)
11
- # - and doing a web card payin with this card (POST /temp/immediate-payins)
12
- # For the latter, a GET or refunds are done
13
- # via the previously existing resources.
14
- #
15
- # !!! WARNING !!!
16
- # These are TEMPORARY functions and WILL BE REMOVED in the future!
17
- # You should CONTACT SUPPORT TEAM before using these features
18
- # or if you have any questions.
19
- class PaymentCard < Resource
20
-
21
- # POST /temp/paymentcards
22
- #
23
- # Sent data:
24
- # - UserId e.g. "12424242"
25
- # - Tag e.g. "my tag"
26
- # - Culture e.g. "FR"
27
- # - ReturnURL e.g. "http://mysite.com/return"
28
- # - TemplateURL e.g. "http://mysite.com/template"
29
- #
30
- # Received data:
31
- # - UserId e.g. "12424242"
32
- # - Tag e.g. "my tag"
33
- # - Culture e.g. "FR"
34
- # - ReturnURL e.g. "http://mysite.com/return"
35
- # - TemplateURL e.g. "http://mysite.com/template"
36
- # - RedirectURL e.g. "http://payline.com/redirect"
37
- # - Alias e.g. null (but would be e.g. 497010XXXXXX4422 once the user has inputed their info and the card has been successfully registered"
38
- # - Id: "1213131"
39
- # - CreationDate: "13452522657"
40
- include HTTPCalls::Create
41
-
42
- # GET /temp/paymentcards
43
- # Received data: as above
44
- include HTTPCalls::Fetch
45
-
46
- # POST /temp/immediate-payins
47
- #
48
- # Sent data:
49
- # - AuthorId e.g. "121412"
50
- # - CreditUserId e.g. "121412"
51
- # - PaymentCardId e.g. "322311"
52
- # - Tag e.g. "my tag"
53
- # - CreditedWalletId e.g. "123134"
54
- # - DebitedFunds e.g. normal Money object of Currency and Amount
55
- # - Fees e.g. normal Money object of Currency and Amount
56
- #
57
- # Received data:
58
- # Normal card web payin transaction, with the addition of:
59
- # - PaymentCardId e.g. "322311"
60
- def self.immediate_payin(params, idempotency_key = nil)
61
- url = "#{MangoPay.api_path}/temp/immediate-payins"
62
- MangoPay.request(:post, url, params, {}, idempotency_key)
63
- end
64
-
65
- def self.url(id = nil)
66
- if id
67
- "#{MangoPay.api_path}/temp/paymentcards/#{CGI.escape(id.to_s)}"
68
- else
69
- "#{MangoPay.api_path}/temp/paymentcards"
70
- end
71
- end
72
- end
73
- end
74
- end
1
+ module MangoPay
2
+
3
+ module Temp
4
+
5
+ # As part of our migration project to allow users
6
+ # to move from v1 to v2 of our API,
7
+ # we have added a couple of temporary calls to the v2 API.
8
+ #
9
+ # They are not documented in normal way, but the calls are related to:
10
+ # - registering a card (POST & GET /temp/paymentcards)
11
+ # - and doing a web card payin with this card (POST /temp/immediate-payins)
12
+ # For the latter, a GET or refunds are done
13
+ # via the previously existing resources.
14
+ #
15
+ # !!! WARNING !!!
16
+ # These are TEMPORARY functions and WILL BE REMOVED in the future!
17
+ # You should CONTACT SUPPORT TEAM before using these features
18
+ # or if you have any questions.
19
+ class PaymentCard < Resource
20
+
21
+ # POST /temp/paymentcards
22
+ #
23
+ # Sent data:
24
+ # - UserId e.g. "12424242"
25
+ # - Tag e.g. "my tag"
26
+ # - Culture e.g. "FR"
27
+ # - ReturnURL e.g. "http://mysite.com/return"
28
+ # - TemplateURL e.g. "http://mysite.com/template"
29
+ #
30
+ # Received data:
31
+ # - UserId e.g. "12424242"
32
+ # - Tag e.g. "my tag"
33
+ # - Culture e.g. "FR"
34
+ # - ReturnURL e.g. "http://mysite.com/return"
35
+ # - TemplateURL e.g. "http://mysite.com/template"
36
+ # - RedirectURL e.g. "http://payline.com/redirect"
37
+ # - Alias e.g. null (but would be e.g. 497010XXXXXX4422 once the user has inputed their info and the card has been successfully registered"
38
+ # - Id: "1213131"
39
+ # - CreationDate: "13452522657"
40
+ include HTTPCalls::Create
41
+
42
+ # GET /temp/paymentcards
43
+ # Received data: as above
44
+ include HTTPCalls::Fetch
45
+
46
+ # POST /temp/immediate-payins
47
+ #
48
+ # Sent data:
49
+ # - AuthorId e.g. "121412"
50
+ # - CreditUserId e.g. "121412"
51
+ # - PaymentCardId e.g. "322311"
52
+ # - Tag e.g. "my tag"
53
+ # - CreditedWalletId e.g. "123134"
54
+ # - DebitedFunds e.g. normal Money object of Currency and Amount
55
+ # - Fees e.g. normal Money object of Currency and Amount
56
+ #
57
+ # Received data:
58
+ # Normal card web payin transaction, with the addition of:
59
+ # - PaymentCardId e.g. "322311"
60
+ def self.immediate_payin(params, idempotency_key = nil)
61
+ url = "#{MangoPay.api_path}/temp/immediate-payins"
62
+ MangoPay.request(:post, url, params, {}, idempotency_key)
63
+ end
64
+
65
+ def self.url(id = nil)
66
+ if id
67
+ "#{MangoPay.api_path}/temp/paymentcards/#{CGI.escape(id.to_s)}"
68
+ else
69
+ "#{MangoPay.api_path}/temp/paymentcards"
70
+ end
71
+ end
72
+ end
73
+ end
74
+ 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
@@ -1,3 +1,3 @@
1
- module MangoPay
2
- VERSION = '3.0.25'
3
- end
1
+ module MangoPay
2
+ VERSION = '3.0.25'
3
+ end
@@ -1,17 +1,17 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/wallets/
4
- class Wallet < Resource
5
- include HTTPCalls::Create
6
- include HTTPCalls::Update
7
- include HTTPCalls::Fetch
8
-
9
- # Fetches list of transactions belonging to the given +wallet_id+.
10
- # Optional +filters+ is a hash accepting following keys:
11
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
12
- # - other keys specific for transactions filtering (see MangoPay::Transaction.fetch)
13
- def self.transactions(wallet_id, filters = {})
14
- Transaction.fetch(wallet_id, filters)
15
- end
16
- end
17
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/wallets/
4
+ class Wallet < Resource
5
+ include HTTPCalls::Create
6
+ include HTTPCalls::Update
7
+ include HTTPCalls::Fetch
8
+
9
+ # Fetches list of transactions belonging to the given +wallet_id+.
10
+ # Optional +filters+ is a hash accepting following keys:
11
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
12
+ # - other keys specific for transactions filtering (see MangoPay::Transaction.fetch)
13
+ def self.transactions(wallet_id, filters = {})
14
+ Transaction.fetch(wallet_id, filters)
15
+ end
16
+ end
17
+ end