|
1 | | -from typing import Any, TypedDict, Literal |
2 | | -from typing import Optional |
| 1 | +from typing import Any, Literal, Optional, TypedDict |
| 2 | + |
3 | 3 | import httpx |
4 | 4 |
|
5 | 5 |
|
@@ -44,16 +44,18 @@ class Sentoo: |
44 | 44 | A client for interacting with the Sentoo payment processing API. |
45 | 45 | """ |
46 | 46 |
|
47 | | - def __init__(self, token: str, sandbox: bool = False) -> None: |
| 47 | + def __init__(self, token: str, merchant_id: str, sandbox: bool = False) -> None: |
48 | 48 | """ |
49 | 49 | Initialize Sentoo API client |
50 | 50 |
|
51 | 51 | Args: |
52 | 52 | token (str): Your Sentoo API secret token |
| 53 | + merchant_id (str): Your Sentoo merchant identifier |
53 | 54 | sandbox (bool): Whether to use sandbox environment. Defaults to False. |
54 | 55 | """ |
55 | 56 | self._token = token |
56 | 57 | self._sandbox = sandbox |
| 58 | + self._merchant_id = merchant_id |
57 | 59 | self._base_url = get_base_url(self._sandbox) |
58 | 60 | self._headers = {"X-SENTOO-SECRET": self._token} |
59 | 61 |
|
@@ -82,44 +84,41 @@ def transaction_create(self, **kwargs: CreateTransactionKwargs) -> dict[str, Any |
82 | 84 | url = self._url("/transactions/new") |
83 | 85 | return httpx.post(url, headers=self._headers, json=kwargs) |
84 | 86 |
|
85 | | - def transaction_cancel(self, merchant_id: str, transaction_id: str) -> dict[str, Any]: |
| 87 | + def transaction_cancel(self, transaction_id: str) -> dict[str, Any]: |
86 | 88 | """ |
87 | 89 | Cancel an existing transaction |
88 | 90 |
|
89 | 91 | Args: |
90 | | - merchant_id (str): The merchant identifier |
91 | 92 | transaction_id (str): The transaction identifier to cancel |
92 | 93 |
|
93 | 94 | Returns: |
94 | 95 | dict[str, Any]: API response containing cancellation result |
95 | 96 | """ |
96 | | - url = self._url(f"/payment/cancel/{merchant_id}/{transaction_id}") |
| 97 | + url = self._url(f"/payment/cancel/{self._merchant_id}/{transaction_id}") |
97 | 98 | return httpx.post(url, headers=self._headers) |
98 | 99 |
|
99 | | - def transaction_status(self, merchant_id: str, transaction_id: str) -> dict[str, Any]: |
| 100 | + def transaction_status(self, transaction_id: str) -> dict[str, Any]: |
100 | 101 | """ |
101 | 102 | Check the status of a transaction |
102 | 103 |
|
103 | 104 | Args: |
104 | | - merchant_id (str): The merchant identifier |
105 | 105 | transaction_id (str): The transaction identifier to check |
106 | 106 |
|
107 | 107 | Returns: |
108 | 108 | dict[str, Any]: API response containing transaction status |
109 | 109 | """ |
110 | | - url = self._url(f"/payment/status/{merchant_id}/{transaction_id}") |
| 110 | + url = self._url(f"/payment/status/{self._merchant_id}/{transaction_id}") |
111 | 111 | return httpx.get(url, headers=self._headers) |
112 | 112 |
|
113 | | - def transaction_processors(self, merchant_id: str, transaction_id: str) -> dict[str, Any]: |
| 113 | + def transaction_processors(self, transaction_id: str) -> dict[str, Any]: |
114 | 114 | """ |
115 | 115 | Get available payment processors for a transaction |
116 | 116 |
|
117 | 117 | Args: |
118 | | - merchant_id (str): The merchant identifier |
119 | 118 | transaction_id (str): The transaction identifier |
120 | 119 |
|
121 | 120 | Returns: |
122 | 121 | dict[str, Any]: API response containing available payment methods |
123 | 122 | """ |
124 | | - url = self._url(f"/payment/methods/{merchant_id}/{transaction_id}") |
| 123 | + url = self._url(f"/payment/methods/{self._merchant_id}/{transaction_id}") |
125 | 124 | return httpx.get(url, headers=self._headers) |
0 commit comments