fintoc 1.6.0 → 1.7.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +109 -4
- data/fintoc.gemspec +3 -3
- data/lib/fintoc/base_client.rb +6 -4
- data/lib/fintoc/errors.rb +67 -0
- data/lib/fintoc/v1/client/client.rb +80 -0
- data/lib/fintoc/v1/managers/accounts_manager.rb +30 -0
- data/lib/fintoc/v1/managers/charges_manager.rb +48 -0
- data/lib/fintoc/v1/managers/disputes_manager.rb +43 -0
- data/lib/fintoc/v1/managers/institutions_manager.rb +19 -0
- data/lib/fintoc/v1/managers/invoices_manager.rb +30 -0
- data/lib/fintoc/v1/managers/link_intents_manager.rb +25 -0
- data/lib/fintoc/v1/managers/links_manager.rb +17 -0
- data/lib/fintoc/v1/managers/movements_manager.rb +31 -0
- data/lib/fintoc/v1/managers/payment_intents_manager.rb +42 -0
- data/lib/fintoc/v1/managers/payment_links_manager.rb +42 -0
- data/lib/fintoc/v1/managers/payouts_manager.rb +50 -0
- data/lib/fintoc/v1/managers/refresh_intents_manager.rb +39 -0
- data/lib/fintoc/v1/managers/refunds_manager.rb +47 -0
- data/lib/fintoc/v1/managers/subscription_intents_manager.rb +36 -0
- data/lib/fintoc/v1/managers/subscriptions_manager.rb +30 -0
- data/lib/fintoc/v1/managers/tax_returns_manager.rb +30 -0
- data/lib/fintoc/v1/managers/tax_statements_manager.rb +30 -0
- data/lib/fintoc/v1/managers/webhook_endpoints_manager.rb +1 -2
- data/lib/fintoc/v1/resources/account.rb +9 -2
- data/lib/fintoc/v1/resources/charge.rb +39 -0
- data/lib/fintoc/v1/resources/dispute.rb +41 -0
- data/lib/fintoc/v1/resources/dispute_document.rb +30 -0
- data/lib/fintoc/v1/resources/institution.rb +4 -2
- data/lib/fintoc/v1/resources/invoice.rb +43 -0
- data/lib/fintoc/v1/resources/link.rb +2 -2
- data/lib/fintoc/v1/resources/link_intent.rb +39 -0
- data/lib/fintoc/v1/resources/payment_intent.rb +72 -0
- data/lib/fintoc/v1/resources/payment_link.rb +43 -0
- data/lib/fintoc/v1/resources/payout.rb +37 -0
- data/lib/fintoc/v1/resources/refresh_intent.rb +37 -0
- data/lib/fintoc/v1/resources/refund.rb +43 -0
- data/lib/fintoc/v1/resources/subscription.rb +30 -0
- data/lib/fintoc/v1/resources/subscription_intent.rb +39 -0
- data/lib/fintoc/v1/resources/tax_return.rb +33 -0
- data/lib/fintoc/v1/resources/tax_statement.rb +39 -0
- data/lib/fintoc/v1/resources/webhook_endpoint.rb +10 -4
- data/lib/fintoc/v2/client/client.rb +45 -0
- data/lib/fintoc/v2/managers/checkout_sessions_manager.rb +42 -0
- data/lib/fintoc/v2/managers/customers_manager.rb +36 -0
- data/lib/fintoc/v2/managers/entities_manager.rb +6 -0
- data/lib/fintoc/v2/managers/events_manager.rb +30 -0
- data/lib/fintoc/v2/managers/invoice_lines_manager.rb +30 -0
- data/lib/fintoc/v2/managers/invoices_manager.rb +78 -0
- data/lib/fintoc/v2/managers/onboardings_manager.rb +14 -0
- data/lib/fintoc/v2/managers/payment_intents_manager.rb +53 -0
- data/lib/fintoc/v2/managers/payment_methods_manager.rb +68 -0
- data/lib/fintoc/v2/managers/products_manager.rb +42 -0
- data/lib/fintoc/v2/managers/setup_intents_manager.rb +24 -0
- data/lib/fintoc/v2/managers/subscription_items_manager.rb +41 -0
- data/lib/fintoc/v2/managers/subscriptions_manager.rb +54 -0
- data/lib/fintoc/v2/managers/transfers_manager.rb +4 -0
- data/lib/fintoc/v2/resources/checkout_session.rb +81 -0
- data/lib/fintoc/v2/resources/customer.rb +37 -0
- data/lib/fintoc/v2/resources/entity.rb +5 -1
- data/lib/fintoc/v2/resources/event.rb +28 -0
- data/lib/fintoc/v2/resources/invoice.rb +63 -0
- data/lib/fintoc/v2/resources/invoice_line.rb +35 -0
- data/lib/fintoc/v2/resources/payment_intent.rb +68 -0
- data/lib/fintoc/v2/resources/payment_method.rb +37 -0
- data/lib/fintoc/v2/resources/product.rb +32 -0
- data/lib/fintoc/v2/resources/settlement_account.rb +30 -0
- data/lib/fintoc/v2/resources/setup_intent.rb +24 -0
- data/lib/fintoc/v2/resources/subscription.rb +51 -0
- data/lib/fintoc/v2/resources/subscription_item.rb +24 -0
- data/lib/fintoc/version.rb +1 -1
- metadata +54 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 64cdfca14464289a89d38a2693912d7b54791261e25c76851a59b5fd26664b37
|
|
4
|
+
data.tar.gz: '049af1d5371b2a8ec247dcb434299a619b456f069e3db27abb378011748ac2ba'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '089cf2234d2fb65530c6ad3ee1b8e9b7798563db02fb546fdc98bf34220bad5e4d8d62fd48e7100de2286e6684c1daa00baca9bd7db96e48496af481324948ca'
|
|
7
|
+
data.tar.gz: 5572417e3bbf04894ce218ab87c85e58456b46c974b9914a5e8bc58928c1b5d1416799a9f02e1a512e48bc30f5b32f95c0dcab70e1c5f3bff5d299b6f63fd55a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -20,6 +20,7 @@ Do yourself a favor: go grab some ice cubes by installing this refreshing librar
|
|
|
20
20
|
- [Client Architecture](#client-architecture)
|
|
21
21
|
- [**API V1 Client**](#api-v1-client)
|
|
22
22
|
- [**API V2 Client**](#api-v2-client)
|
|
23
|
+
- [**Pagination**](#pagination)
|
|
23
24
|
- [**Backward compatibility**](#backward-compatibility)
|
|
24
25
|
- [Documentation](#documentation)
|
|
25
26
|
- [Examples](#examples)
|
|
@@ -92,7 +93,7 @@ The Fintoc Ruby client is organized into separate clients that mirror the offici
|
|
|
92
93
|
|
|
93
94
|
### **API V1 Client**
|
|
94
95
|
|
|
95
|
-
The API client
|
|
96
|
+
The API V1 client provides access to the Movements, Payments and Webhooks APIs:
|
|
96
97
|
|
|
97
98
|
```ruby
|
|
98
99
|
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
|
@@ -100,15 +101,58 @@ client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
|
|
100
101
|
# Link management
|
|
101
102
|
links = client.v1.links.list
|
|
102
103
|
link = client.v1.links.get('link_token')
|
|
104
|
+
link = client.v1.links.exchange(exchange_token: 'exchange_token')
|
|
105
|
+
client.v1.links.update('link_token', active: false)
|
|
103
106
|
client.v1.links.delete('link_id')
|
|
107
|
+
link_intent = client.v1.link_intents.create(country: 'cl', holder_type: 'business', product: 'movements')
|
|
108
|
+
institutions = client.v1.institutions.list(country: 'cl')
|
|
104
109
|
|
|
105
110
|
# Account access
|
|
106
111
|
account = link.find(id: account_id)
|
|
112
|
+
accounts = client.v1.accounts.list(link_token: 'link_token')
|
|
113
|
+
account = client.v1.accounts.get('account_id', link_token: 'link_token')
|
|
114
|
+
movement = client.v1.movements.get('account_id', 'movement_id', link_token: 'link_token')
|
|
115
|
+
|
|
116
|
+
# Refresh intents
|
|
117
|
+
refresh_intent = client.v1.refresh_intents.create(link_token: 'link_token', refresh_type: 'only_last')
|
|
118
|
+
refresh_intents = client.v1.refresh_intents.list(link_token: 'link_token')
|
|
119
|
+
|
|
120
|
+
# Fiscal data (invoices, tax returns and tax statements) of a link
|
|
121
|
+
invoices = client.v1.invoices.list(link_token: 'link_token', since: '2026-01-01')
|
|
122
|
+
tax_return = client.v1.tax_returns.get('tax_return_id', link_token: 'link_token')
|
|
123
|
+
tax_statements = client.v1.tax_statements.list(link_token: 'link_token')
|
|
124
|
+
|
|
125
|
+
# Payment intents and payment links
|
|
126
|
+
payment_intent = client.v1.payment_intents.create(amount: 1000, currency: 'CLP')
|
|
127
|
+
client.v1.payment_intents.expire('payment_intent_id')
|
|
128
|
+
payment_link = client.v1.payment_links.create(amount: 1000, currency: 'CLP')
|
|
129
|
+
client.v1.payment_links.cancel('payment_link_id')
|
|
130
|
+
|
|
131
|
+
# Subscriptions and charges
|
|
132
|
+
subscription_intent = client.v1.subscription_intents.create(customer_email: 'payer@example.com')
|
|
133
|
+
subscriptions = client.v1.subscriptions.list
|
|
134
|
+
charge = client.v1.charges.create(amount: 1000, currency: 'CLP', subscription_id: 'sub_id')
|
|
135
|
+
client.v1.charges.update('charge_id', amount: 2000)
|
|
136
|
+
client.v1.charges.cancel('charge_id')
|
|
137
|
+
|
|
138
|
+
# Refunds
|
|
139
|
+
refund = client.v1.refunds.create(resource_id: 'pi_id', resource_type: 'payment_intent')
|
|
140
|
+
client.v1.refunds.cancel('refund_id')
|
|
141
|
+
voucher = client.v1.refunds.voucher_url('refund_id') # => { url: '...' }
|
|
142
|
+
|
|
143
|
+
# Payouts. `list_resources` returns payment intents, charges or refunds
|
|
144
|
+
payouts = client.v1.payouts.list(status: 'succeeded')
|
|
145
|
+
resources = client.v1.payouts.list_resources('payout_id', resource_type: 'payment_intent')
|
|
146
|
+
|
|
147
|
+
# Disputes
|
|
148
|
+
disputes = client.v1.disputes.list(status: 'needs_response')
|
|
149
|
+
client.v1.disputes.create_document('dispute_id', file: 'path/to/evidence.pdf')
|
|
150
|
+
client.v1.disputes.submit_for_review('dispute_id')
|
|
107
151
|
```
|
|
108
152
|
|
|
109
153
|
### **API V2 Client**
|
|
110
154
|
|
|
111
|
-
The API V2 client
|
|
155
|
+
The API V2 client provides access to the Transfers, Payments and Billing APIs:
|
|
112
156
|
|
|
113
157
|
```ruby
|
|
114
158
|
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
|
@@ -166,9 +210,64 @@ entity = client.v2.entities.get('entity_id')
|
|
|
166
210
|
onboardings = entity.onboardings.list
|
|
167
211
|
onboarding = entity.onboardings.get('onboarding_id')
|
|
168
212
|
|
|
169
|
-
#
|
|
213
|
+
# Settlement account of an entity
|
|
214
|
+
settlement_account = client.v2.entities.settlement_account('entity_id')
|
|
215
|
+
|
|
216
|
+
# Transfer receipts
|
|
217
|
+
receipt = client.v2.transfers.receipt('transfer_id') # => { download_url: '...', ... }
|
|
218
|
+
|
|
219
|
+
# Customers and payment methods
|
|
220
|
+
customer = client.v2.customers.create(email: 'customer@example.com', name: 'Jon Snow')
|
|
221
|
+
payment_methods = client.v2.payment_methods.list(customer: 'customer_id')
|
|
222
|
+
client.v2.payment_methods.cancel('payment_method_id')
|
|
223
|
+
mandate = client.v2.payment_methods.mandate_document('payment_method_id')
|
|
224
|
+
# Mexican direct debit mandates are sent as multipart. Nested fields are sent in
|
|
225
|
+
# bracket notation and consent documents accept a path or an IO.
|
|
226
|
+
payment_method = client.v2.payment_methods.create(
|
|
227
|
+
type: 'mx_direct_debit',
|
|
228
|
+
customer: 'customer_id',
|
|
229
|
+
mx_direct_debit: {
|
|
230
|
+
account_number: '000000000000000000',
|
|
231
|
+
account_type: 'clabe',
|
|
232
|
+
interval: 'month',
|
|
233
|
+
max_amount: 100000,
|
|
234
|
+
consent_documents: {
|
|
235
|
+
contract: 'contract.pdf', selfie: 'selfie.jpg', id_front: 'front.jpg', id_back: 'back.jpg'
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
# Payment intents, checkout sessions and setup intents
|
|
241
|
+
payment_intent = client.v2.payment_intents.create(
|
|
242
|
+
amount: 5000, currency: 'CLP', payment_method: 'payment_method_id'
|
|
243
|
+
)
|
|
244
|
+
client.v2.payment_intents.cancel('payment_intent_id')
|
|
245
|
+
eligibility = client.v2.payment_intents.check_eligibility(
|
|
246
|
+
amount: 5000, currency: 'CLP', sender_account: { institution_id: 'cl_banco_de_chile' }
|
|
247
|
+
)
|
|
248
|
+
checkout_session = client.v2.checkout_sessions.create(currency: 'CLP', flow: 'payment', amount: 5000)
|
|
249
|
+
client.v2.checkout_sessions.expire('checkout_session_id')
|
|
250
|
+
setup_intent = client.v2.setup_intents.get('setup_intent_id')
|
|
251
|
+
|
|
252
|
+
# Products, subscriptions and invoices
|
|
253
|
+
product = client.v2.products.create(name: 'Gym membership')
|
|
254
|
+
subscription = client.v2.subscriptions.create(customer: 'customer_id', items: [{...}])
|
|
255
|
+
subscription.subscription_items.create(price_data: {...}, quantity: 1)
|
|
256
|
+
client.v2.subscriptions.cancel('subscription_id')
|
|
257
|
+
invoice = client.v2.invoices.create(customer: 'customer_id', lines: [{...}])
|
|
258
|
+
client.v2.invoices.finalize('invoice_id')
|
|
259
|
+
client.v2.invoices.pay('invoice_id', external_payment: true)
|
|
260
|
+
invoice.invoice_lines.update('invoice_line_id', quantity: 2)
|
|
261
|
+
|
|
262
|
+
# Events
|
|
263
|
+
events = client.v2.events.list(type: 'payment_intent.succeeded')
|
|
264
|
+
event = client.v2.events.get('event_id')
|
|
170
265
|
```
|
|
171
266
|
|
|
267
|
+
### **Pagination**
|
|
268
|
+
|
|
269
|
+
Manager `list` methods (`client.v1.*`, `client.v2.*`) return a single page. Pass the pagination params to fetch the next one: `page` and `per_page` in V1, and `limit` and `starting_after` in V2.
|
|
270
|
+
|
|
172
271
|
### **Backward compatibility**
|
|
173
272
|
|
|
174
273
|
The methods of the previous `Fintoc::Client` class implementation are kept for backward compatibility purposes.
|
|
@@ -184,7 +283,7 @@ account = client.get_account('link_token', 'account_id')
|
|
|
184
283
|
|
|
185
284
|
## Documentation
|
|
186
285
|
|
|
187
|
-
This client
|
|
286
|
+
This client covers the public `v1` and `v2` endpoints of the Fintoc API. For complete information about the API, head to the [docs](https://docs.fintoc.com/reference).
|
|
188
287
|
|
|
189
288
|
## Examples
|
|
190
289
|
|
|
@@ -518,6 +617,12 @@ entity.onboardings.upload_legal_representative_document(
|
|
|
518
617
|
'onboarding_id', 'legal_representative_id', 'identification', file: 'path/to/file.pdf'
|
|
519
618
|
)
|
|
520
619
|
|
|
620
|
+
# Add another document to a slot that accepts several documents (multipart).
|
|
621
|
+
entity.onboardings.append_document('onboarding_id', 'slot_key', file: 'path/to/file.pdf')
|
|
622
|
+
|
|
623
|
+
# Delete a document from a slot.
|
|
624
|
+
entity.onboardings.delete_document('onboarding_id', 'slot_key', 'document_id')
|
|
625
|
+
|
|
521
626
|
# Submit the onboarding for review.
|
|
522
627
|
onboarding = entity.onboardings.submit('onboarding_id')
|
|
523
628
|
```
|
data/fintoc.gemspec
CHANGED
|
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
19
19
|
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
|
20
20
|
|
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
21
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
-
`git ls-files -z`.split("\x0").reject
|
|
22
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
23
|
+
f.match(%r{\A(?:(?:test|spec|features|\.agents|\.claude)/|(?:AGENTS|CLAUDE)\.md\z)})
|
|
24
|
+
end
|
|
25
25
|
end
|
|
26
26
|
spec.bindir = 'exe'
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
data/lib/fintoc/base_client.rb
CHANGED
|
@@ -137,6 +137,8 @@ module Fintoc
|
|
|
137
137
|
|
|
138
138
|
def build_form(form)
|
|
139
139
|
form.transform_values do |value|
|
|
140
|
+
next value if value.is_a?(HTTP::FormData::Part)
|
|
141
|
+
|
|
140
142
|
file?(value) ? HTTP::FormData::File.new(value) : value
|
|
141
143
|
end
|
|
142
144
|
end
|
|
@@ -150,12 +152,12 @@ module Fintoc
|
|
|
150
152
|
end
|
|
151
153
|
|
|
152
154
|
def error_class(snake_code)
|
|
153
|
-
pascal_klass_name = Utils.snake_to_pascal(snake_code)
|
|
154
|
-
# this conditional klass_name is to handle InternalServerError custom error class
|
|
155
|
-
# without this the error class name would be like InternalServerErrorError (^-^)
|
|
155
|
+
pascal_klass_name = Utils.snake_to_pascal(snake_code.to_s)
|
|
156
156
|
klass =
|
|
157
157
|
pascal_klass_name.end_with?('Error') ? pascal_klass_name : "#{pascal_klass_name}Error"
|
|
158
|
-
|
|
158
|
+
Fintoc::Errors.const_get(klass, false)
|
|
159
|
+
rescue NameError
|
|
160
|
+
Fintoc::Errors::FintocError
|
|
159
161
|
end
|
|
160
162
|
|
|
161
163
|
# rubocop:disable Layout/LineLength
|
data/lib/fintoc/errors.rb
CHANGED
|
@@ -69,6 +69,21 @@ module Fintoc
|
|
|
69
69
|
class InvalidTransfersError < FintocError; end
|
|
70
70
|
class InvalidTransfersSizeError < FintocError; end
|
|
71
71
|
class InvalidDescriptionSizeError < FintocError; end
|
|
72
|
+
class InvalidBillingCycleAnchorError < FintocError; end
|
|
73
|
+
class InvalidCountryCodeError < FintocError; end
|
|
74
|
+
class InvalidEmailError < FintocError; end
|
|
75
|
+
class InvalidInvoiceStatusError < FintocError; end
|
|
76
|
+
class InvalidMetadataError < FintocError; end
|
|
77
|
+
class InvalidPeriodError < FintocError; end
|
|
78
|
+
class InvalidReferenceIdFormatError < FintocError; end
|
|
79
|
+
class InvalidRefundToGetVoucherError < FintocError; end
|
|
80
|
+
class InvalidRutError < FintocError; end
|
|
81
|
+
class InvalidShareholderStructureError < FintocError; end
|
|
82
|
+
class InvalidWebhookEventTypeError < FintocError; end
|
|
83
|
+
class MinimumAmountError < FintocError; end
|
|
84
|
+
class MutuallyExclusiveParamsError < FintocError; end
|
|
85
|
+
class NotSupportedRefundableResourceTypeError < FintocError; end
|
|
86
|
+
class SplitSumMismatchError < FintocError; end
|
|
72
87
|
|
|
73
88
|
# 401 Unauthorized Errors
|
|
74
89
|
class AuthenticationError < FintocError; end
|
|
@@ -106,11 +121,14 @@ module Fintoc
|
|
|
106
121
|
class MissingAllowedCidrBlocksError < FintocError; end
|
|
107
122
|
class AllowedCidrBlocksDoesNotContainIpError < FintocError; end
|
|
108
123
|
class RecipientBlockedAccountError < FintocError; end
|
|
124
|
+
class InvalidAccountVerificationError < FintocError; end
|
|
125
|
+
class PaymentMethodNotRefundableError < FintocError; end
|
|
109
126
|
|
|
110
127
|
# 404 Not Found Errors
|
|
111
128
|
class MissingResourceError < FintocError; end
|
|
112
129
|
class InvalidUrlError < FintocError; end
|
|
113
130
|
class OrganizationWithoutEntitiesError < FintocError; end
|
|
131
|
+
class ResourceNotFoundError < FintocError; end
|
|
114
132
|
|
|
115
133
|
# 405 Method Not Allowed Errors
|
|
116
134
|
class OperationNotAllowedError < FintocError; end
|
|
@@ -128,6 +146,23 @@ module Fintoc
|
|
|
128
146
|
class AccountNumberLimitReachedError < FintocError; end
|
|
129
147
|
class AccountCannotBeBlockedError < FintocError; end
|
|
130
148
|
class InvalidSenderAccountsError < FintocError; end
|
|
149
|
+
class AccountNumberCouldNotBeAssignedError < FintocError; end
|
|
150
|
+
class AccountNumberTakenError < FintocError; end
|
|
151
|
+
class BlockedAccountNumberError < FintocError; end
|
|
152
|
+
class ConflictedRequestError < FintocError; end
|
|
153
|
+
class DisputeDeadlineExceededError < FintocError; end
|
|
154
|
+
class DisputeNotOpenForDocumentsError < FintocError; end
|
|
155
|
+
class DuplicateRecipientError < FintocError; end
|
|
156
|
+
class EntityHolderIdAlreadyExistsForOrganizationError < FintocError; end
|
|
157
|
+
class InvalidEmptySubscriptionError < FintocError; end
|
|
158
|
+
class InvoiceNotEditableError < FintocError; end
|
|
159
|
+
class InvoiceNotFinalizableError < FintocError; end
|
|
160
|
+
class InvoiceNotMarkableUncollectibleError < FintocError; end
|
|
161
|
+
class NoDocumentsToSubmitError < FintocError; end
|
|
162
|
+
class PaymentMethodNonCancelableError < FintocError; end
|
|
163
|
+
class PaymentNonCancelableError < FintocError; end
|
|
164
|
+
class PaymentNonExpirableError < FintocError; end
|
|
165
|
+
class SubscriptionNotEditableError < FintocError; end
|
|
131
166
|
|
|
132
167
|
# 422 Unprocessable Entity Errors
|
|
133
168
|
class InvalidOtpCodeError < FintocError; end
|
|
@@ -145,6 +180,38 @@ module Fintoc
|
|
|
145
180
|
class RefreshIntentInProgressError < FintocError; end
|
|
146
181
|
class RejectedRefreshIntentError < FintocError; end
|
|
147
182
|
class SenderBlockedAccountError < FintocError; end
|
|
183
|
+
class AmountOutOfRangeError < FintocError; end
|
|
184
|
+
class CountryNotSupportedError < FintocError; end
|
|
185
|
+
class DirectDebitSuspendedError < FintocError; end
|
|
186
|
+
class FileTooLargeError < FintocError; end
|
|
187
|
+
class FileTooSmallError < FintocError; end
|
|
188
|
+
class InvalidAccountForDirectDebitError < FintocError; end
|
|
189
|
+
class InvalidPaymentMethodStateError < FintocError; end
|
|
190
|
+
class InvoiceHasPendingPaymentError < FintocError; end
|
|
191
|
+
class InvoiceNotPayableError < FintocError; end
|
|
192
|
+
class InvoiceNotVoidableError < FintocError; end
|
|
193
|
+
class LegalRepresentativeRequiredError < FintocError; end
|
|
194
|
+
class MerchantChargeLimitExceededError < FintocError; end
|
|
195
|
+
class MerchantVolumeLimitExceededError < FintocError; end
|
|
196
|
+
class NotOneDayCompanyError < FintocError; end
|
|
197
|
+
class OnboardingImmutableError < FintocError; end
|
|
198
|
+
class OnboardingNotAvailableError < FintocError; end
|
|
199
|
+
class OrganizationWithoutOperationalRootEntityError < FintocError; end
|
|
200
|
+
class PaymentCancellationNotSupportedError < FintocError; end
|
|
201
|
+
class PaymentMethodInactiveError < FintocError; end
|
|
202
|
+
class PaymentMethodTypeNotAvailableError < FintocError; end
|
|
203
|
+
class PaymentMethodTypeNotSupportedError < FintocError; end
|
|
204
|
+
class PaymentMethodUnavailableError < FintocError; end
|
|
205
|
+
class RecipientAccountNotAllowedError < FintocError; end
|
|
206
|
+
class RequiredDocumentMissingError < FintocError; end
|
|
207
|
+
class RootEntityNotSupportedViaApiError < FintocError; end
|
|
208
|
+
class ShareholderDocumentNotRequiredError < FintocError; end
|
|
209
|
+
class SingleFileDocumentSlotError < FintocError; end
|
|
210
|
+
class SubscriptionCanceledError < FintocError; end
|
|
211
|
+
class UnknownDocumentSlotError < FintocError; end
|
|
212
|
+
class UnsupportedContentTypeError < FintocError; end
|
|
213
|
+
class UnsupportedInstitutionError < FintocError; end
|
|
214
|
+
class UnsupportedPaymentTypeError < FintocError; end
|
|
148
215
|
|
|
149
216
|
# 429 Too Many Requests Errors
|
|
150
217
|
class RateLimitExceededError < FintocError; end
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
require 'fintoc/base_client'
|
|
2
2
|
require 'fintoc/v1/managers/links_manager'
|
|
3
3
|
require 'fintoc/v1/managers/webhook_endpoints_manager'
|
|
4
|
+
require 'fintoc/v1/managers/accounts_manager'
|
|
5
|
+
require 'fintoc/v1/managers/movements_manager'
|
|
6
|
+
require 'fintoc/v1/managers/institutions_manager'
|
|
7
|
+
require 'fintoc/v1/managers/link_intents_manager'
|
|
8
|
+
require 'fintoc/v1/managers/refresh_intents_manager'
|
|
9
|
+
require 'fintoc/v1/managers/tax_returns_manager'
|
|
10
|
+
require 'fintoc/v1/managers/tax_statements_manager'
|
|
11
|
+
require 'fintoc/v1/managers/invoices_manager'
|
|
12
|
+
require 'fintoc/v1/managers/payment_intents_manager'
|
|
13
|
+
require 'fintoc/v1/managers/payment_links_manager'
|
|
14
|
+
require 'fintoc/v1/managers/subscription_intents_manager'
|
|
15
|
+
require 'fintoc/v1/managers/subscriptions_manager'
|
|
16
|
+
require 'fintoc/v1/managers/charges_manager'
|
|
17
|
+
require 'fintoc/v1/managers/refunds_manager'
|
|
18
|
+
require 'fintoc/v1/managers/payouts_manager'
|
|
19
|
+
require 'fintoc/v1/managers/disputes_manager'
|
|
4
20
|
|
|
5
21
|
module Fintoc
|
|
6
22
|
module V1
|
|
@@ -12,6 +28,70 @@ module Fintoc
|
|
|
12
28
|
def webhook_endpoints
|
|
13
29
|
@webhook_endpoints ||= Managers::WebhookEndpointsManager.new(self)
|
|
14
30
|
end
|
|
31
|
+
|
|
32
|
+
def accounts
|
|
33
|
+
@accounts ||= Managers::AccountsManager.new(self)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def movements
|
|
37
|
+
@movements ||= Managers::MovementsManager.new(self)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def institutions
|
|
41
|
+
@institutions ||= Managers::InstitutionsManager.new(self)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def link_intents
|
|
45
|
+
@link_intents ||= Managers::LinkIntentsManager.new(self)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def refresh_intents
|
|
49
|
+
@refresh_intents ||= Managers::RefreshIntentsManager.new(self)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def tax_returns
|
|
53
|
+
@tax_returns ||= Managers::TaxReturnsManager.new(self)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def tax_statements
|
|
57
|
+
@tax_statements ||= Managers::TaxStatementsManager.new(self)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def invoices
|
|
61
|
+
@invoices ||= Managers::InvoicesManager.new(self)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def payment_intents
|
|
65
|
+
@payment_intents ||= Managers::PaymentIntentsManager.new(self)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def payment_links
|
|
69
|
+
@payment_links ||= Managers::PaymentLinksManager.new(self)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def subscription_intents
|
|
73
|
+
@subscription_intents ||= Managers::SubscriptionIntentsManager.new(self)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def subscriptions
|
|
77
|
+
@subscriptions ||= Managers::SubscriptionsManager.new(self)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def charges
|
|
81
|
+
@charges ||= Managers::ChargesManager.new(self)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def refunds
|
|
85
|
+
@refunds ||= Managers::RefundsManager.new(self)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def payouts
|
|
89
|
+
@payouts ||= Managers::PayoutsManager.new(self)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def disputes
|
|
93
|
+
@disputes ||= Managers::DisputesManager.new(self)
|
|
94
|
+
end
|
|
15
95
|
end
|
|
16
96
|
end
|
|
17
97
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'fintoc/v1/resources/account'
|
|
2
|
+
|
|
3
|
+
module Fintoc
|
|
4
|
+
module V1
|
|
5
|
+
module Managers
|
|
6
|
+
class AccountsManager
|
|
7
|
+
def initialize(client)
|
|
8
|
+
@client = client
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list(link_token:, **params)
|
|
12
|
+
@client.get(version: :v1).call('accounts', link_token:, **params).map do |data|
|
|
13
|
+
build_account(data, link_token)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get(account_id, link_token:)
|
|
18
|
+
data = @client.get(version: :v1).call("accounts/#{account_id}", link_token:)
|
|
19
|
+
build_account(data, link_token)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def build_account(data, link_token)
|
|
25
|
+
Fintoc::V1::Account.new(**data, link_token:, client: @client)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require 'fintoc/v1/resources/charge'
|
|
2
|
+
|
|
3
|
+
module Fintoc
|
|
4
|
+
module V1
|
|
5
|
+
module Managers
|
|
6
|
+
class ChargesManager
|
|
7
|
+
def initialize(client)
|
|
8
|
+
@client = client
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def create(amount:, currency:, subscription_id:, idempotency_key: nil, **params)
|
|
12
|
+
data = @client.post(version: :v1, idempotency_key:)
|
|
13
|
+
.call('charges', amount:, currency:, subscription_id:, **params)
|
|
14
|
+
build_charge(data)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def list(**params)
|
|
18
|
+
@client.get(version: :v1).call('charges', **params).map do |data|
|
|
19
|
+
build_charge(data)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get(charge_id)
|
|
24
|
+
data = @client.get(version: :v1).call("charges/#{charge_id}")
|
|
25
|
+
build_charge(data)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def update(charge_id, idempotency_key: nil, **params)
|
|
29
|
+
data = @client.patch(version: :v1, idempotency_key:)
|
|
30
|
+
.call("charges/#{charge_id}", **params)
|
|
31
|
+
build_charge(data)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def cancel(charge_id, idempotency_key: nil)
|
|
35
|
+
data = @client.post(version: :v1, idempotency_key:)
|
|
36
|
+
.call("charges/#{charge_id}/cancel")
|
|
37
|
+
build_charge(data)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def build_charge(data)
|
|
43
|
+
Fintoc::V1::Charge.new(**data)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'fintoc/v1/resources/dispute'
|
|
2
|
+
require 'fintoc/v1/resources/dispute_document'
|
|
3
|
+
|
|
4
|
+
module Fintoc
|
|
5
|
+
module V1
|
|
6
|
+
module Managers
|
|
7
|
+
class DisputesManager
|
|
8
|
+
def initialize(client)
|
|
9
|
+
@client = client
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def list(**params)
|
|
13
|
+
@client.get(version: :v1).call('disputes', **params).map do |data|
|
|
14
|
+
build_dispute(data)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(dispute_id)
|
|
19
|
+
data = @client.get(version: :v1).call("disputes/#{dispute_id}")
|
|
20
|
+
build_dispute(data)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def submit_for_review(dispute_id, idempotency_key: nil)
|
|
24
|
+
data = @client.post(version: :v1, idempotency_key:)
|
|
25
|
+
.call("disputes/#{dispute_id}/submit_for_review")
|
|
26
|
+
build_dispute(data)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create_document(dispute_id, file:, idempotency_key: nil)
|
|
30
|
+
data = @client.post(version: :v1, idempotency_key:)
|
|
31
|
+
.call("disputes/#{dispute_id}/documents", form: { file: })
|
|
32
|
+
Fintoc::V1::DisputeDocument.new(**data)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def build_dispute(data)
|
|
38
|
+
Fintoc::V1::Dispute.new(**data)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'fintoc/v1/resources/institution'
|
|
2
|
+
|
|
3
|
+
module Fintoc
|
|
4
|
+
module V1
|
|
5
|
+
module Managers
|
|
6
|
+
class InstitutionsManager
|
|
7
|
+
def initialize(client)
|
|
8
|
+
@client = client
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list(**params)
|
|
12
|
+
@client.get(version: :v1).call('institutions', **params).map do |data|
|
|
13
|
+
Fintoc::V1::Institution.new(**data)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'fintoc/v1/resources/invoice'
|
|
2
|
+
|
|
3
|
+
module Fintoc
|
|
4
|
+
module V1
|
|
5
|
+
module Managers
|
|
6
|
+
class InvoicesManager
|
|
7
|
+
def initialize(client)
|
|
8
|
+
@client = client
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list(link_token:, **params)
|
|
12
|
+
@client.get(version: :v1).call('invoices', link_token:, **params).map do |data|
|
|
13
|
+
build_invoice(data)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get(invoice_id, link_token:)
|
|
18
|
+
data = @client.get(version: :v1).call("invoices/#{invoice_id}", link_token:)
|
|
19
|
+
build_invoice(data)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def build_invoice(data)
|
|
25
|
+
Fintoc::V1::Invoice.new(**data)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'fintoc/v1/resources/link_intent'
|
|
2
|
+
|
|
3
|
+
module Fintoc
|
|
4
|
+
module V1
|
|
5
|
+
module Managers
|
|
6
|
+
class LinkIntentsManager
|
|
7
|
+
def initialize(client)
|
|
8
|
+
@client = client
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def create(country:, holder_type:, product:, idempotency_key: nil, **params)
|
|
12
|
+
data = @client.post(version: :v1, idempotency_key:)
|
|
13
|
+
.call('link_intents', country:, holder_type:, product:, **params)
|
|
14
|
+
build_link_intent(data)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def build_link_intent(data)
|
|
20
|
+
Fintoc::V1::LinkIntent.new(**data)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -21,6 +21,15 @@ module Fintoc
|
|
|
21
21
|
_delete_link(link_id)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def update(link_token, idempotency_key: nil, **params)
|
|
25
|
+
data = { **_update_link(link_token, idempotency_key:, **params), link_token: link_token }
|
|
26
|
+
build_link(data)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def exchange(exchange_token:)
|
|
30
|
+
build_link(_exchange_link(exchange_token))
|
|
31
|
+
end
|
|
32
|
+
|
|
24
33
|
private
|
|
25
34
|
|
|
26
35
|
def _get_link(link_token)
|
|
@@ -35,6 +44,14 @@ module Fintoc
|
|
|
35
44
|
@client.delete(version: :v1).call("links/#{link_id}")
|
|
36
45
|
end
|
|
37
46
|
|
|
47
|
+
def _update_link(link_token, idempotency_key: nil, **params)
|
|
48
|
+
@client.patch(version: :v1, idempotency_key:).call("links/#{link_token}", **params)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def _exchange_link(exchange_token)
|
|
52
|
+
@client.get(version: :v1).call('links/exchange', exchange_token:)
|
|
53
|
+
end
|
|
54
|
+
|
|
38
55
|
def build_link(data)
|
|
39
56
|
param = Utils.pick(data, 'link_token')
|
|
40
57
|
@client.default_params.update(param)
|