Skip to content

Commit 8e770c5

Browse files
authored
docs: document the enums and use them in the examples (#2)
The enums shipped in 0.2.0 with no mention in the README, and the config examples still passed bare strings. Every snippet here was compiled or run before landing.
1 parent 918c84d commit 8e770c5

4 files changed

Lines changed: 41 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.2.1
4+
5+
- The README documents the enums and uses them in its examples, instead of the bare strings it
6+
still showed.
7+
38
## 0.2.0
49

510
- Enums for the values the API uses: `Status`, `CardStatus`, `InvoiceStatus`, `B2BStatus`,

‎README.md‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Most methods return a `Response`. Read known fields as attributes, anything else
9292

9393
```python
9494
r = client.get_status("te0000000001")
95-
r.status # "success"
95+
r.status # "success", compares equal to Status.SUCCESS
9696
r.ok # True
9797
r.get("rrn") # bank reference number
9898
r.raw # the full response dict
@@ -101,6 +101,39 @@ r.raw # the full response dict
101101
`create_payment`, `reserve`, `create_split_payment` and the other checkout methods return
102102
`redirect_url`. `get_installment_plans` returns a list and `list_wallets` returns a dict.
103103

104+
## Enums
105+
106+
Every value the API uses has an enum. They come from the sandbox's own definitions, so they match
107+
what production sends. Members are `str` subclasses, so they go over the wire unchanged and
108+
compare equal to the raw value; a plain string still works anywhere an enum is accepted.
109+
110+
```python
111+
from epoint import CardStatus, Currency, EpointClient, Language, Status
112+
113+
client = EpointClient.from_env(language=Language.EN, currency=Currency.USD)
114+
115+
status = client.get_status(transaction)
116+
if status.status == Status.SUCCESS:
117+
fulfil(order_id)
118+
```
119+
120+
| Enum | Values |
121+
|---|---|
122+
| `Status` | new, success, failed, error, returned, server_error |
123+
| `CardStatus` | new, active, pending, rejected, expired, session_expired |
124+
| `InvoiceStatus` | waiting_for_payment, paid, canceled |
125+
| `B2BStatus` | PENDING, PROCESSING, SUCCESS, FAILED |
126+
| `OperationCode` | 001 card registration, 100 payment, 200 registration with payment |
127+
| `Language` | az, en, ru |
128+
| `Currency` | AZN, USD, EUR, RUB |
129+
130+
Currency is not uniform across the API. Checkout takes all four, but split, pre-auth, refund,
131+
reverse, payout and wallet take AZN and nothing else. `SUPPORTED_CURRENCIES` and `AZN_ONLY` hold
132+
those two sets.
133+
134+
`SETTLED_STATUSES` is what `ok` checks, and `USABLE_CARD_STATUSES` is the set a card has to be in
135+
before you can charge it.
136+
104137
## Methods
105138

106139
| Group | Methods |

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "epoint"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
description = "Python client for the epoint.az payment gateway"
55
readme = "README.md"
66
requires-python = ">=3.10"

‎src/epoint/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .errors import EpointError, GatewayError, SignatureError, TransportError
2020
from .models import Callback, Response
2121

22-
__version__ = "0.2.0"
22+
__version__ = "0.2.1"
2323

2424
__all__ = [
2525
"AZN_ONLY",

0 commit comments

Comments
 (0)