mangopay4-ruby-sdk 3.44.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.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby_cd.yml +34 -0
  3. data/.github/workflows/ruby_ci.yml +30 -0
  4. data/.gitignore +30 -0
  5. data/.rspec +3 -0
  6. data/CHANGELOG.md +640 -0
  7. data/Gemfile +2 -0
  8. data/LICENSE +20 -0
  9. data/README.md +162 -0
  10. data/Rakefile +5 -0
  11. data/bin/mangopay +9 -0
  12. data/lib/generators/mangopay/install_generator.rb +60 -0
  13. data/lib/generators/templates/mangopay.rb.erb +5 -0
  14. data/lib/mangopay/acquiring.rb +56 -0
  15. data/lib/mangopay/authorization_token.rb +89 -0
  16. data/lib/mangopay/bank_account.rb +49 -0
  17. data/lib/mangopay/bankingaliases.rb +29 -0
  18. data/lib/mangopay/bankingaliases_iban.rb +16 -0
  19. data/lib/mangopay/card.rb +54 -0
  20. data/lib/mangopay/card_registration.rb +9 -0
  21. data/lib/mangopay/client.rb +94 -0
  22. data/lib/mangopay/conversion.rb +49 -0
  23. data/lib/mangopay/deposit.rb +36 -0
  24. data/lib/mangopay/dispute.rb +152 -0
  25. data/lib/mangopay/errors.rb +66 -0
  26. data/lib/mangopay/event.rb +18 -0
  27. data/lib/mangopay/filter_parameters.rb +56 -0
  28. data/lib/mangopay/hook.rb +9 -0
  29. data/lib/mangopay/http_calls.rb +88 -0
  30. data/lib/mangopay/identity_verification.rb +16 -0
  31. data/lib/mangopay/json.rb +14 -0
  32. data/lib/mangopay/kyc_document.rb +83 -0
  33. data/lib/mangopay/legal_user.rb +21 -0
  34. data/lib/mangopay/legal_user_sca.rb +25 -0
  35. data/lib/mangopay/mandate.rb +42 -0
  36. data/lib/mangopay/natural_user.rb +20 -0
  37. data/lib/mangopay/natural_user_sca.rb +25 -0
  38. data/lib/mangopay/pay_in.rb +415 -0
  39. data/lib/mangopay/pay_out.rb +41 -0
  40. data/lib/mangopay/payment_method_metadata.rb +13 -0
  41. data/lib/mangopay/pre_authorization.rb +17 -0
  42. data/lib/mangopay/recipient.rb +35 -0
  43. data/lib/mangopay/refund.rb +19 -0
  44. data/lib/mangopay/regulatory.rb +22 -0
  45. data/lib/mangopay/report.rb +24 -0
  46. data/lib/mangopay/report_v2.rb +21 -0
  47. data/lib/mangopay/resource.rb +21 -0
  48. data/lib/mangopay/settlement.rb +21 -0
  49. data/lib/mangopay/transaction.rb +24 -0
  50. data/lib/mangopay/transfer.rb +20 -0
  51. data/lib/mangopay/ubo.rb +26 -0
  52. data/lib/mangopay/ubo_declaration.rb +32 -0
  53. data/lib/mangopay/user.rb +100 -0
  54. data/lib/mangopay/version.rb +3 -0
  55. data/lib/mangopay/virtual_account.rb +44 -0
  56. data/lib/mangopay/wallet.rb +17 -0
  57. data/lib/mangopay.rb +456 -0
  58. data/mangopay.gemspec +30 -0
  59. data/spec/mangopay/acquiring_spec.rb +176 -0
  60. data/spec/mangopay/authorization_token_spec.rb +70 -0
  61. data/spec/mangopay/bank_account_spec.rb +105 -0
  62. data/spec/mangopay/bankingaliases_spec.rb +29 -0
  63. data/spec/mangopay/card_registration_spec.rb +123 -0
  64. data/spec/mangopay/client_spec.png +0 -0
  65. data/spec/mangopay/client_spec.rb +213 -0
  66. data/spec/mangopay/configuration_spec.rb +249 -0
  67. data/spec/mangopay/conversion_spec.rb +96 -0
  68. data/spec/mangopay/deposit_spec.rb +107 -0
  69. data/spec/mangopay/dispute_spec.png +0 -0
  70. data/spec/mangopay/dispute_spec.rb +294 -0
  71. data/spec/mangopay/event_spec.rb +33 -0
  72. data/spec/mangopay/fetch_filters_spec.rb +63 -0
  73. data/spec/mangopay/hook_spec.rb +37 -0
  74. data/spec/mangopay/idempotency_spec.rb +41 -0
  75. data/spec/mangopay/identity_verification_spec.rb +47 -0
  76. data/spec/mangopay/kyc_document_spec.png +0 -0
  77. data/spec/mangopay/kyc_document_spec.rb +118 -0
  78. data/spec/mangopay/log_requests_filter_spec.rb +26 -0
  79. data/spec/mangopay/mandate_spec.rb +99 -0
  80. data/spec/mangopay/payin_applepay_direct_spec.rb +21 -0
  81. data/spec/mangopay/payin_bancontact_web_spec.rb +30 -0
  82. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -0
  83. data/spec/mangopay/payin_bankwire_external_instruction_spec.rb +104 -0
  84. data/spec/mangopay/payin_bizum_web_spec.rb +54 -0
  85. data/spec/mangopay/payin_blik_web_spec.rb +41 -0
  86. data/spec/mangopay/payin_card_direct_spec.rb +69 -0
  87. data/spec/mangopay/payin_card_web_spec.rb +64 -0
  88. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -0
  89. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -0
  90. data/spec/mangopay/payin_giropay_web_spec.rb +30 -0
  91. data/spec/mangopay/payin_googlepay_direct_spec.rb +21 -0
  92. data/spec/mangopay/payin_ideal_web_spec.rb +30 -0
  93. data/spec/mangopay/payin_intent_spec.rb +151 -0
  94. data/spec/mangopay/payin_klarna_web_spec.rb +32 -0
  95. data/spec/mangopay/payin_mbway_web_spec.rb +32 -0
  96. data/spec/mangopay/payin_multibanco_web_spec.rb +31 -0
  97. data/spec/mangopay/payin_paybybank_web_spec.rb +56 -0
  98. data/spec/mangopay/payin_payconiq_web_spec.rb +31 -0
  99. data/spec/mangopay/payin_paypal_web_spec.rb +113 -0
  100. data/spec/mangopay/payin_preauthorized_direct_spec.rb +118 -0
  101. data/spec/mangopay/payin_satispay_web_spec.rb +32 -0
  102. data/spec/mangopay/payin_swish_web_spec.rb +30 -0
  103. data/spec/mangopay/payin_twint_web_spec.rb +30 -0
  104. data/spec/mangopay/payment_method_metadata_spec.rb +15 -0
  105. data/spec/mangopay/payout_bankwire_spec.rb +93 -0
  106. data/spec/mangopay/preauthorization_spec.rb +51 -0
  107. data/spec/mangopay/recipient_spec.rb +134 -0
  108. data/spec/mangopay/recurring_payin_spec.rb +222 -0
  109. data/spec/mangopay/refund_spec.rb +34 -0
  110. data/spec/mangopay/regulatory_spec.rb +26 -0
  111. data/spec/mangopay/report_spec.rb +40 -0
  112. data/spec/mangopay/report_v2_spec.rb +117 -0
  113. data/spec/mangopay/report_wallets_spec.rb +40 -0
  114. data/spec/mangopay/settlement_sample.csv +8 -0
  115. data/spec/mangopay/settlement_spec.rb +38 -0
  116. data/spec/mangopay/shared_resources.rb +1380 -0
  117. data/spec/mangopay/transaction_spec.rb +59 -0
  118. data/spec/mangopay/transfer_spec.rb +77 -0
  119. data/spec/mangopay/ubo_declaration_spec.rb +44 -0
  120. data/spec/mangopay/ubo_spec.rb +39 -0
  121. data/spec/mangopay/user_spec.rb +444 -0
  122. data/spec/mangopay/virtual_account_spec.rb +52 -0
  123. data/spec/mangopay/wallet_spec.rb +100 -0
  124. data/spec/spec_helper.rb +31 -0
  125. data/spec/tmp/.keep +0 -0
  126. metadata +280 -0
@@ -0,0 +1,21 @@
1
+ module MangoPay
2
+
3
+ # See https://docs.mangopay.com/endpoints/v2.01/reporting
4
+ class ReportV2 < Resource
5
+
6
+ class << self
7
+ def create(params, idempotency_key = nil)
8
+ MangoPay.request(:post, "#{MangoPay.api_path}/reporting/reports", params, {}, idempotency_key)
9
+ end
10
+
11
+ def get(id)
12
+ MangoPay.request(:get, "#{MangoPay.api_path}/reporting/reports/#{id}")
13
+ end
14
+
15
+ def get_all(params = nil)
16
+ MangoPay.request(:get, "#{MangoPay.api_path}/reporting/reports", params)
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +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
@@ -0,0 +1,21 @@
1
+ module MangoPay
2
+
3
+ class Settlement < Resource
4
+ class << self
5
+ def upload(file, idempotency_key = nil)
6
+ url = "#{MangoPay.api_path_v3}/payins/intents/settlements"
7
+ MangoPay.request_multipart(:post, url, file, 'settlement_file.csv', idempotency_key)
8
+ end
9
+
10
+ def get(settlement_id)
11
+ url = "#{MangoPay.api_path_v3}/payins/intents/settlements/#{settlement_id}"
12
+ MangoPay.request(:get, url)
13
+ end
14
+
15
+ def update(settlement_id, file, idempotency_key = nil)
16
+ url = "#{MangoPay.api_path_v3}/payins/intents/settlements/#{settlement_id}"
17
+ MangoPay.request_multipart(:put, url, file, 'settlement_file.csv', idempotency_key)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +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={}, headers = nil)
16
+ MangoPay.request(:get, url(wallet_id), {}, filters, headers)
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
@@ -0,0 +1,20 @@
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
+
9
+ # Fetches list of refunds belonging to given +transfer_id+.
10
+ #
11
+ # Optional +filters+ is a hash accepting following keys:
12
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
13
+ # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
14
+ # - +ResultCode+: string representing the transaction result
15
+ def self.refunds(transfer_id, filters = {})
16
+ url = url(transfer_id) + '/refunds'
17
+ MangoPay.request(:get, url, {}, filters)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ module MangoPay
2
+ # Provides API methods for the UBO entity.
3
+ class Ubo < Resource
4
+ class << self
5
+ def url(user_id, ubo_declaration_id, id = nil)
6
+ if id
7
+ "#{MangoPay.api_path}/users/#{user_id}/kyc/ubodeclarations/#{ubo_declaration_id}/ubos/#{id}"
8
+ else
9
+ "#{MangoPay.api_path}/users/#{user_id}/kyc/ubodeclarations/#{ubo_declaration_id}/ubos"
10
+ end
11
+ end
12
+
13
+ def create(user_id, ubo_declaration_id, params, idempotency_key = nil)
14
+ MangoPay.request(:post, url(user_id, ubo_declaration_id), params, {}, idempotency_key)
15
+ end
16
+
17
+ def fetch(user_id, ubo_declaration_id, ubo_id)
18
+ MangoPay.request(:get, url(user_id, ubo_declaration_id, ubo_id))
19
+ end
20
+
21
+ def update(user_id, ubo_declaration_id, ubo_id, params, idempotency_key = nil)
22
+ MangoPay.request(:put, url(user_id, ubo_declaration_id, ubo_id), params, {}, idempotency_key)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ module MangoPay
2
+ # Provides API methods for the UBO declaration entity.
3
+ class UboDeclaration < Resource
4
+ class << self
5
+ def url(user_id, id = nil)
6
+ if id
7
+ "#{MangoPay.api_path}/users/#{user_id}/kyc/ubodeclarations/#{id}"
8
+ else
9
+ "#{MangoPay.api_path}/users/#{user_id}/kyc/ubodeclarations"
10
+ end
11
+ end
12
+
13
+ def create(user_id, idempotency_key = nil)
14
+ MangoPay.request(:post, url(user_id), {}, {}, idempotency_key)
15
+ end
16
+
17
+ # Fetches the Ubo declaration belonging to the given +user_id+ if given, with the given +id+.
18
+ def fetch(user_id, id, idempotency_key = nil)
19
+ url = (user_id) ? url(user_id, id) : "#{MangoPay.api_path}/kyc/ubodeclarations/#{CGI.escape(id.to_s)}"
20
+ MangoPay.request(:get, url, {}, {}, idempotency_key)
21
+ end
22
+
23
+ def update(user_id, id, params = {}, idempotency_key = nil)
24
+ request_params = {
25
+ Status: params['Status'],
26
+ Ubos: params['Ubos']
27
+ }
28
+ MangoPay.request(:put, url(user_id, id), request_params, {}, idempotency_key)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,100 @@
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
+ # - MangoPay::NaturalUserSca
8
+ # - MangoPay::LegalUserSca
9
+ class User < Resource
10
+ include HTTPCalls::Create
11
+ include HTTPCalls::Update
12
+ include HTTPCalls::Fetch
13
+ class << self
14
+ def enroll_sca(user_id, idempotency_key = nil)
15
+ url = "#{MangoPay.api_path}/sca/users/#{user_id}/enrollment"
16
+ MangoPay.request(:post, url, {}, {}, idempotency_key)
17
+ end
18
+
19
+ def manage_consent(user_id, idempotency_key = nil)
20
+ url = "#{MangoPay.api_path}/sca/users/#{user_id}/consent"
21
+ MangoPay.request(:post, url, {}, {}, idempotency_key)
22
+ end
23
+
24
+ # Fetches list of wallets belonging to the given +user_id+.
25
+ # Optional +filters+ is a hash accepting following keys:
26
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
27
+ def wallets(user_id, filters = {})
28
+ MangoPay.request(:get, url(user_id) + '/wallets', {}, filters)
29
+ end
30
+
31
+ # Fetches list of bank accounts belonging to the given +user_id+.
32
+ # Optional +filters+ is a hash accepting following keys:
33
+ # - +page+, +per_page+, +sort+: pagination and sorting params
34
+ # (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
35
+ def bank_accounts(user_id, filters = {})
36
+ MangoPay.request(:get, url(user_id) + '/bankaccounts', {}, filters)
37
+ end
38
+
39
+ # Fetches list of cards belonging to the given +user_id+.
40
+ # Optional +filters+ is a hash accepting following keys:
41
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
42
+ def cards(user_id, filters = {})
43
+ MangoPay.request(:get, url(user_id) + '/cards', {}, filters)
44
+ end
45
+
46
+ # Fetches list of transactions belonging to the given +user_id+.
47
+ # Optional +filters+ is a hash accepting following keys:
48
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
49
+ # - other keys specific for transactions filtering (see MangoPay::Transaction#fetch)
50
+ def transactions(user_id, filters = {})
51
+ MangoPay.request(:get, url(user_id) + '/transactions', {}, filters)
52
+ end
53
+
54
+ # View EMoney belonging to the given +user_id+.
55
+ # Optional +filters+ is a hash accepting following keys:
56
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
57
+ # - other keys specific for transactions filtering (see MangoPay::Transaction#fetch)
58
+ def emoney(user_id, year, month = nil, filters = {})
59
+ if month
60
+ MangoPay.request(:get, url(user_id) + "/emoney/#{year}/#{month}", {}, filters)
61
+ else
62
+ MangoPay.request(:get, url(user_id) + "/emoney/#{year}", {}, filters)
63
+ end
64
+ end
65
+
66
+ # Fetches list of kyc documents belonging to the given +user_id+.
67
+ # Optional +filters+ is a hash accepting following keys:
68
+ # - +page+, +per_page+, +sort+, +BeforeDate+, +AfterDate+, +Status+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
69
+ def kyc_documents(user_id, filters = {})
70
+ MangoPay.request(:get, url(user_id) + '/KYC/documents', {}, filters)
71
+ end
72
+
73
+ # Fetches list of pre-authorizations belonging to the given +user_id+.
74
+ # Optional +filters+ is a hash accepting the following keys:
75
+ # - +page+, +per_page+, +sort+, +Status+, +ResultCode+, +PaymentStatus+: pagination and sorting/filtering params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
76
+ def pre_authorizations(user_id, filters = {})
77
+ MangoPay.request(:get, url(user_id) + '/preauthorizations', {}, filters)
78
+ end
79
+
80
+ # Fetches User Block Status
81
+ def block_status(user_id, filters = {})
82
+ MangoPay.request(:get, url(user_id) + '/blockStatus', {}, filters)
83
+ end
84
+
85
+ # Fetches User Regulatory
86
+ def regulatory(user_id, filters = {})
87
+ MangoPay.request(:get, url(user_id) + '/Regulatory', {}, filters)
88
+ end
89
+
90
+ def fetch_sca(user_id)
91
+ url = "#{MangoPay.api_path}/sca/users/#{user_id}"
92
+ MangoPay.request(:get, url, {}, {})
93
+ end
94
+
95
+ def validate_data_format(params, idempotency_key = nil)
96
+ MangoPay.request(:post, "#{MangoPay.api_path}/users/data-formats/validation", params, {}, idempotency_key)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,3 @@
1
+ module MangoPay
2
+ VERSION = '3.44.0'
3
+ end
@@ -0,0 +1,44 @@
1
+ module MangoPay
2
+
3
+ class VirtualAccount < Resource
4
+ class << self
5
+ # Creates a new virtual account
6
+ def create(wallet_id, params, idempotency_key = nil)
7
+ url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts"
8
+ MangoPay.request(:post, url, params, {}, idempotency_key)
9
+ end
10
+
11
+ # Updates:
12
+ # - irreversibly deactivates a virtual account with +virtual_account_id+
13
+ # see https://docs.mangopay.com/api-reference/virtual-accounts/deactivate-virtual-account
14
+ def deactivate(wallet_id, virtual_account_id, idempotency_key = nil)
15
+ url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts/#{virtual_account_id}"
16
+ MangoPay.request(:put, url, {}, {}, idempotency_key)
17
+ end
18
+
19
+ # Fetches:
20
+ # - view a virtual account with +virtual_account_id+
21
+ # see https://docs.mangopay.com/api-reference/virtual-accounts/view-virtual-account
22
+ def fetch(wallet_id, virtual_account_id)
23
+ url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts/#{virtual_account_id}"
24
+ MangoPay.request(:get, url, {})
25
+ end
26
+
27
+ # Fetches:
28
+ # - view virtual accounts for given +wallet_id+
29
+ # see https://docs.mangopay.com/api-reference/virtual-accounts/list-virtual-accounts-wallet
30
+ def fetch_all(wallet_id, filters = {})
31
+ url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts"
32
+ MangoPay.request(:get, url, {}, filters)
33
+ end
34
+
35
+ # Fetches:
36
+ # Allows to check which account countries and currencies are available
37
+ # see https://docs.mangopay.com/api-reference/virtual-accounts/view-virtual-account-availabilities
38
+ def fetch_availabilities(filters = {})
39
+ url = "#{MangoPay.api_path}/virtual-accounts/availability"
40
+ MangoPay.request(:get, url, {}, filters)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +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 = {}, headers = nil)
14
+ Transaction.fetch(wallet_id, filters, headers)
15
+ end
16
+ end
17
+ end