From e2859c4b91215776eb7592e602f94daf71c04c1b Mon Sep 17 00:00:00 2001 From: Daniel Leal Date: Thu, 9 Dec 2021 15:42:34 -0300 Subject: [PATCH 1/4] feat: add the payment intent resource --- fintoc/resources/__init__.py | 1 + fintoc/resources/payment_intent.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 fintoc/resources/payment_intent.py diff --git a/fintoc/resources/__init__.py b/fintoc/resources/__init__.py index 7ff12ff..9434d24 100644 --- a/fintoc/resources/__init__.py +++ b/fintoc/resources/__init__.py @@ -11,6 +11,7 @@ from .link import Link from .movement import Movement from .other_taxes import OtherTaxes +from .payment_intent import PaymentIntent from .refresh_intent import RefreshIntent from .services_invoice import ServicesInvoice from .subscription import Subscription diff --git a/fintoc/resources/payment_intent.py b/fintoc/resources/payment_intent.py new file mode 100644 index 0000000..c5148d0 --- /dev/null +++ b/fintoc/resources/payment_intent.py @@ -0,0 +1,13 @@ +"""Module to hold the PaymentIntent resource.""" + +from fintoc.mixins import ResourceMixin + + +class PaymentIntent(ResourceMixin): + + """Represents a Fintoc Payment Intent.""" + + mappings = { + "recipient_account": "transfer_account", + "sender_account": "transfer_account", + } From 9e83a07ed7d37e9ee333cd56312e5bfea49e46cf Mon Sep 17 00:00:00 2001 From: Daniel Leal Date: Thu, 9 Dec 2021 15:47:57 -0300 Subject: [PATCH 2/4] feat: add the payment intents manager --- fintoc/managers/__init__.py | 1 + fintoc/managers/payment_intents_manager.py | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 fintoc/managers/payment_intents_manager.py diff --git a/fintoc/managers/__init__.py b/fintoc/managers/__init__.py index eb852f1..d20e276 100644 --- a/fintoc/managers/__init__.py +++ b/fintoc/managers/__init__.py @@ -4,6 +4,7 @@ from .invoices_manager import InvoicesManager from .links_manager import LinksManager from .movements_manager import MovementsManager +from .payment_intents_manager import PaymentIntentsManager from .refresh_intents_manager import RefreshIntentsManager from .subscriptions_manager import SubscriptionsManager from .tax_returns_manager import TaxRetunsManager diff --git a/fintoc/managers/payment_intents_manager.py b/fintoc/managers/payment_intents_manager.py new file mode 100644 index 0000000..e8ca92b --- /dev/null +++ b/fintoc/managers/payment_intents_manager.py @@ -0,0 +1,11 @@ +"""Module to hold the payment_intents manager.""" + +from fintoc.mixins import ManagerMixin + + +class PaymentIntentsManager(ManagerMixin): + + """Represents a payment_intents manager.""" + + resource = "payment_intent" + methods = ["all", "get", "create"] From c7dd08877ae829827fd946aba195337da25526b7 Mon Sep 17 00:00:00 2001 From: Daniel Leal Date: Thu, 9 Dec 2021 16:04:33 -0300 Subject: [PATCH 3/4] feat: integrate the payment intents functionality --- fintoc/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fintoc/core.py b/fintoc/core.py index 7f5ddf7..94e91d7 100644 --- a/fintoc/core.py +++ b/fintoc/core.py @@ -4,7 +4,7 @@ from fintoc.client import Client from fintoc.constants import API_BASE_URL, API_VERSION -from fintoc.managers import LinksManager, WebhookEndpointsManager +from fintoc.managers import LinksManager, PaymentIntentsManager, WebhookEndpointsManager from fintoc.version import __version__ @@ -19,6 +19,7 @@ def __init__(self, api_key): user_agent=f"fintoc-python/{__version__}", ) self.links = LinksManager("/links", self._client) + self.payment_intents = PaymentIntentsManager("/payment_intents", self._client) self.webhook_endpoints = WebhookEndpointsManager( "/webhook_endpoints", self._client ) From 44895d920572701ec599ebbebb7ed0a196cd3ae4 Mon Sep 17 00:00:00 2001 From: Daniel Leal Date: Thu, 9 Dec 2021 16:07:59 -0300 Subject: [PATCH 4/4] docs: add the payment intents functionality to the README.md file --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 522bbdb..761081e 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ from fintoc import Fintoc fintoc_client = Fintoc("your_api_key") ``` -This gives us access to a bunch of operations already. The object created using this _snippet_ contains two [managers](#managers): `links` and `webhook_endpoints`. +This gives us access to a bunch of operations already. The object created using this _snippet_ contains three [managers](#managers): `links`, `payment_intents` and `webhook_endpoints`. #### The `webhook_endpoints` manager @@ -232,6 +232,44 @@ webhook_endpoint = fintoc_client.webhook_endpoints.get("we_8anqVLlBC8ROodem") print(webhook_endpoint.id) # we_8anqVLlBC8ROodem ``` +#### The `payment_intents` manager + +Available methods: `all`, `get`, `create`. + +Payment intents allow you to start a payment using Fintoc! Start by creating a new payment intent: + +```python +payment_intent = fintoc_client.payment_intents.create( + currency="CLP", + amount=5990, + recipient_account={ + "holder_id": "111111111", + "number": "123123123", + "type": "checking_account", + "institution_id": "cl_banco_de_chile", + } +) + +print(payment_intent.id) # pi_BO381oEATXonG6bj +print(payment_intent.widget_token) # pi_BO381oEATXonG6bj_sec_a4xK32BanKWYn +``` + +Notice that the success of this payment intent will be notified through a Webhook. Now, let's list every payment intent we have: + +```python +for payment_intent in fintoc_client.payment_intents.all(): + print(payment_intent.id) +``` + +If you see a payment intent you want to use, just use the `get` method! + +```python +payment_intent = fintoc_client.payment_intents.get("pi_BO381oEATXonG6bj") + +print(payment_intent.id) # pi_BO381oEATXonG6bj +print(payment_intent.status) # succeeded +``` + #### The `links` manager Available methods: `all`, `get`, `update`, `delete`. @@ -320,7 +358,8 @@ If you see a refresh intent you want to use, just use the `get` method! ```python refresh_intent = link.refresh_intents.get("ri_5A94DVCJ7xNM3MEo") -print(refresh_intent.id) # ri_5A94DVCJ7xNM3MEo +print(refresh_intent.id) # ri_5A94DVCJ7xNM3MEo +print(refresh_intent.status) # succeeded ``` #### The `accounts` manager