Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions fintoc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from fintoc.managers import (
AccountsManager,
ChargesManager,
CheckoutSessionsManager,
InvoicesManager,
LinksManager,
PaymentIntentsManager,
Expand Down Expand Up @@ -41,6 +42,9 @@ def __init__(self, api_key, api_version=None, jws_private_key=None):
jws_private_key=jws_private_key,
)
self.charges = ChargesManager("/v1/charges", self._client)
self.checkout_sessions = CheckoutSessionsManager(
"/v1/checkout_sessions", self._client
)
self.links = LinksManager("/v1/links", self._client)
self.payment_intents = PaymentIntentsManager(
"/v1/payment_intents", self._client
Expand Down
1 change: 1 addition & 0 deletions fintoc/managers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .accounts_manager import AccountsManager
from .charges_manager import ChargesManager
from .checkout_sessions_manager import CheckoutSessionsManager
from .invoices_manager import InvoicesManager
from .links_manager import LinksManager
from .movements_manager import MovementsManager
Expand Down
15 changes: 15 additions & 0 deletions fintoc/managers/checkout_sessions_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Module to hold the checkout sessions manager."""

from fintoc.mixins import ManagerMixin


class CheckoutSessionsManager(ManagerMixin):
"""Represents a checkout sessions manager."""

resource = "checkout_session"
methods = ["create", "get", "expire"]

def _expire(self, identifier, **kwargs):
"""Expire a checkout session."""
path = f"{self._build_path(**kwargs)}/{identifier}/expire"
return self._create(path_=path, **kwargs)
1 change: 1 addition & 0 deletions fintoc/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .account import Account
from .balance import Balance
from .charge import Charge
from .checkout_session import CheckoutSession
from .generic_fintoc_resource import GenericFintocResource
from .income import Income
from .institution import Institution
Expand Down
7 changes: 7 additions & 0 deletions fintoc/resources/checkout_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Module to hold the CheckoutSession resource."""

from fintoc.mixins import ResourceMixin


class CheckoutSession(ResourceMixin):
"""Represents a Fintoc CheckoutSession."""
2 changes: 1 addition & 1 deletion fintoc/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Module to hold the version utilities."""

version_info = (2, 7, 0)
version_info = (2, 8, 0)
__version__ = ".".join([str(x) for x in version_info])
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fintoc"
version = "2.7.0"
version = "2.8.0"
description = "The official Python client for the Fintoc API."
authors = ["Daniel Leal <daniel@fintoc.com>", "Nebil Kawas <nebil@uc.cl>"]
maintainers = ["Daniel Leal <daniel@fintoc.com>"]
Expand Down
36 changes: 36 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,42 @@ def test_v2_simulate_receive_transfer(self):
assert transfer.json.currency == currency
assert transfer.json.account_number_id == account_number_id

def test_checkout_session_create(self):
"""Test creating a checkout session."""
checkout_session_data = {
"amount": 5000,
"currency": "CLP",
"success_url": "https://example.com/success",
"cancel_url": "https://example.com/cancel",
}

checkout_session = self.fintoc.checkout_sessions.create(**checkout_session_data)

assert checkout_session.method == "post"
assert checkout_session.url == "v1/checkout_sessions"
assert checkout_session.json.amount == checkout_session_data["amount"]
assert checkout_session.json.currency == checkout_session_data["currency"]
assert checkout_session.json.success_url == checkout_session_data["success_url"]
assert checkout_session.json.cancel_url == checkout_session_data["cancel_url"]

def test_checkout_session_get(self):
"""Test getting a specific checkout session."""
checkout_session_id = "test_checkout_session_id"

checkout_session = self.fintoc.checkout_sessions.get(checkout_session_id)

assert checkout_session.method == "get"
assert checkout_session.url == f"v1/checkout_sessions/{checkout_session_id}"

def test_checkout_session_expire(self):
"""Test expiring a checkout session."""
checkout_session_id = "test_checkout_session_id"

result = self.fintoc.checkout_sessions.expire(checkout_session_id)

assert result.method == "post"
assert result.url == f"v1/checkout_sessions/{checkout_session_id}/expire"


if __name__ == "__main__":
pytest.main()