Skip to content

Commit cb464ec

Browse files
committed
init client with merchant_id
1 parent 7f8a2b4 commit cb464ec

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To use the library, import it and create a client instance:
1616
```python
1717
from sentoo import Sentoo
1818

19-
sentoo = Sentoo(token='your_token')
19+
sentoo = Sentoo(token='your_token', merchant_id='your_merchant_id')
2020
```
2121
## Documentation
2222

@@ -27,7 +27,6 @@ The Sentoo client provides the following methods:
2727
```python
2828
# Create a new transaction
2929
response = sentoo.transaction_create(
30-
sentoo_merchant="your_merchant_id",
3130
sentoo_amount=1000, # Amount in cents
3231
sentoo_description="Payment description",
3332
sentoo_currency="ANG", # Supported: ANG, AWG, USD, EUR, XCD
@@ -45,7 +44,6 @@ response = sentoo.transaction_create(
4544
```python
4645
# Cancel an existing transaction
4746
response = sentoo.transaction_cancel(
48-
merchant_id="your_merchant_id",
4947
transaction_id="transaction_id"
5048
)
5149
```
@@ -55,7 +53,6 @@ response = sentoo.transaction_cancel(
5553
```python
5654
# Check the status of a transaction
5755
response = sentoo.transaction_status(
58-
merchant_id="your_merchant_id",
5956
transaction_id="transaction_id"
6057
)
6158
```
@@ -65,7 +62,6 @@ response = sentoo.transaction_status(
6562
```python
6663
# Get available payment processors for a transaction
6764
response = sentoo.transaction_processors(
68-
merchant_id="your_merchant_id",
6965
transaction_id="transaction_id"
7066
)
7167
```

src/sentoo/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import importlib.metadata
2+
23
from .client import Sentoo
34

45
try:

src/sentoo/client.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from typing import Any, TypedDict, Literal
2-
from typing import Optional
1+
from typing import Any, Literal, Optional, TypedDict
2+
33
import httpx
44

55

@@ -44,16 +44,18 @@ class Sentoo:
4444
A client for interacting with the Sentoo payment processing API.
4545
"""
4646

47-
def __init__(self, token: str, sandbox: bool = False) -> None:
47+
def __init__(self, token: str, merchant_id: str, sandbox: bool = False) -> None:
4848
"""
4949
Initialize Sentoo API client
5050
5151
Args:
5252
token (str): Your Sentoo API secret token
53+
merchant_id (str): Your Sentoo merchant identifier
5354
sandbox (bool): Whether to use sandbox environment. Defaults to False.
5455
"""
5556
self._token = token
5657
self._sandbox = sandbox
58+
self._merchant_id = merchant_id
5759
self._base_url = get_base_url(self._sandbox)
5860
self._headers = {"X-SENTOO-SECRET": self._token}
5961

@@ -82,44 +84,41 @@ def transaction_create(self, **kwargs: CreateTransactionKwargs) -> dict[str, Any
8284
url = self._url("/transactions/new")
8385
return httpx.post(url, headers=self._headers, json=kwargs)
8486

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]:
8688
"""
8789
Cancel an existing transaction
8890
8991
Args:
90-
merchant_id (str): The merchant identifier
9192
transaction_id (str): The transaction identifier to cancel
9293
9394
Returns:
9495
dict[str, Any]: API response containing cancellation result
9596
"""
96-
url = self._url(f"/payment/cancel/{merchant_id}/{transaction_id}")
97+
url = self._url(f"/payment/cancel/{self._merchant_id}/{transaction_id}")
9798
return httpx.post(url, headers=self._headers)
9899

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]:
100101
"""
101102
Check the status of a transaction
102103
103104
Args:
104-
merchant_id (str): The merchant identifier
105105
transaction_id (str): The transaction identifier to check
106106
107107
Returns:
108108
dict[str, Any]: API response containing transaction status
109109
"""
110-
url = self._url(f"/payment/status/{merchant_id}/{transaction_id}")
110+
url = self._url(f"/payment/status/{self._merchant_id}/{transaction_id}")
111111
return httpx.get(url, headers=self._headers)
112112

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]:
114114
"""
115115
Get available payment processors for a transaction
116116
117117
Args:
118-
merchant_id (str): The merchant identifier
119118
transaction_id (str): The transaction identifier
120119
121120
Returns:
122121
dict[str, Any]: API response containing available payment methods
123122
"""
124-
url = self._url(f"/payment/methods/{merchant_id}/{transaction_id}")
123+
url = self._url(f"/payment/methods/{self._merchant_id}/{transaction_id}")
125124
return httpx.get(url, headers=self._headers)

0 commit comments

Comments
 (0)