Skip to content

Commit ffef3fb

Browse files
committed
fix(docs): correct PaymentResponse field access in documentation
Fixed incorrect access pattern for payment.ecommerce_id throughout documentation. The correct path is payment.data.ecommerce_id since PaymentResponse contains a nested PaymentData object. - Updated all documentation examples to use payment.data.ecommerce_id - Fixed 37 instances across 7 documentation files - Prevents AttributeError when users follow the documentation examples This ensures users correctly access the ecommerce_id field from the PaymentResponse object returned by create_payment().
1 parent c1580a0 commit ffef3fb

File tree

8 files changed

+43
-42
lines changed

8 files changed

+43
-42
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# ATH Móvil Unofficial Python Library
22

3-
[![PyPI version](https://badge.fury.io/py/athm.svg)](https://badge.fury.io/py/athm)
3+
![PyPI - Version](https://img.shields.io/pypi/v/athm)
44
[![Python Versions](https://img.shields.io/pypi/pyversions/athm.svg)](https://pypi.org/project/athm/)
5+
[![Read the Docs](https://img.shields.io/readthedocs/athm-python)](https://athm-python.readthedocs.io/en/latest/)
56
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
67
[![Tests](https://github.com/django-athm/athm-python/actions/workflows/test.yml/badge.svg)](https://github.com/django-athm/athm-python/actions/workflows/test.yml)
78

@@ -54,10 +55,10 @@ payment = client.create_payment(
5455
],
5556
)
5657

57-
confirmed = client.wait_for_confirmation(payment.ecommerce_id)
58+
confirmed = client.wait_for_confirmation(payment.data.ecommerce_id)
5859

5960
if confirmed:
60-
result = client.authorize_payment(payment.ecommerce_id)
61+
result = client.authorize_payment(payment.data.ecommerce_id)
6162
print(f"Payment completed: {result.data.reference_number}")
6263
```
6364

@@ -118,7 +119,7 @@ with ATHMovilClient(public_token="token") as client:
118119
## Development
119120

120121
```bash
121-
git clone https://github.com/yourusername/athm-python.git
122+
git clone https://github.com/django-athm/athm-python.git
122123
cd athm-python
123124
uv sync --all-extras --dev
124125
uv run pytest
@@ -127,8 +128,8 @@ uv run pytest
127128
### Code Quality
128129

129130
```bash
130-
uv run ruff format athm tests
131-
uv run ruff check athm tests --fix
131+
uv run ruff format
132+
uv run ruff check
132133
uv run mypy athm
133134
```
134135

docs/advanced.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ with ATHMovilClient(public_token="...") as client:
111111
tax="0.00"
112112
)
113113

114-
confirmed = client.wait_for_confirmation(payment.ecommerce_id)
115-
result = client.authorize_payment(payment.ecommerce_id)
114+
confirmed = client.wait_for_confirmation(payment.data.ecommerce_id)
115+
result = client.authorize_payment(payment.data.ecommerce_id)
116116

117117
print(f"Reference: {result.data.reference_number}")
118118

@@ -186,7 +186,7 @@ payment = client.create_payment(...) # Uses 30s timeout
186186

187187
# Longer wait for confirmation
188188
confirmed = client.wait_for_confirmation(
189-
payment.ecommerce_id,
189+
payment.data.ecommerce_id,
190190
polling_interval=2.0,
191191
max_attempts=300 # 10 minutes (300 * 2s)
192192
)

docs/api-reference.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ Response from creating a payment.
278278
```python
279279
payment = client.create_payment(...)
280280

281-
print(payment.ecommerce_id) # Payment ID
282-
print(payment.auth_token) # Authorization token
283-
print(payment.expires_in) # Expiry timestamp
281+
print(payment.data.ecommerce_id) # Payment ID
282+
print(payment.data.auth_token) # Authorization token
283+
print(payment.data.expires_in) # Expiry timestamp
284284
```
285285

286286
**Fields:**
@@ -562,13 +562,13 @@ payment = client.create_payment(
562562
)
563563

564564
# Check status
565-
status = client.find_payment(payment.ecommerce_id)
565+
status = client.find_payment(payment.data.ecommerce_id)
566566

567567
# Wait for confirmation
568-
confirmed = client.wait_for_confirmation(payment.ecommerce_id)
568+
confirmed = client.wait_for_confirmation(payment.data.ecommerce_id)
569569

570570
# Authorize
571-
result = client.authorize_payment(payment.ecommerce_id)
571+
result = client.authorize_payment(payment.data.ecommerce_id)
572572

573573
# Refund (requires private_token)
574574
refund = client.refund_payment(

docs/errors.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def create_payment_with_retry(
308308
subtotal=amount,
309309
tax="0.00"
310310
)
311-
return payment.ecommerce_id
311+
return payment.data.ecommerce_id
312312

313313
except ValidationError as e:
314314
# Invalid data - don't retry, fix input
@@ -461,7 +461,7 @@ try:
461461
subtotal="50.00",
462462
tax="0.00"
463463
)
464-
logger.info(f"Payment created: {payment.ecommerce_id}")
464+
logger.info(f"Payment created: {payment.data.ecommerce_id}")
465465

466466
except ATHMovilError as e:
467467
# Log error safely
@@ -487,7 +487,7 @@ try:
487487
payment = client.create_payment(...)
488488
logger.info(
489489
"payment_created",
490-
ecommerce_id=payment.ecommerce_id,
490+
ecommerce_id=payment.data.ecommerce_id,
491491
amount="50.00"
492492
)
493493
except ATHMovilError as e:

docs/guide.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ payment = client.create_payment(
5151
}]
5252
)
5353

54-
print(f"Payment created: {payment.ecommerce_id}")
54+
print(f"Payment created: {payment.data.ecommerce_id}")
5555
print("Customer will receive a push notification")
5656
```
5757

@@ -68,14 +68,14 @@ The customer needs to open their ATH Móvil app and approve the payment:
6868
# Option 1: Automatic polling (recommended)
6969
try:
7070
confirmed = client.wait_for_confirmation(
71-
payment.ecommerce_id,
71+
payment.data.ecommerce_id,
7272
polling_interval=2.0, # Check every 2 seconds
7373
max_attempts=150 # 5 minutes max (150 * 2s)
7474
)
7575
print("Customer confirmed!")
7676
except TimeoutError:
7777
print("Customer didn't confirm in time")
78-
client.cancel_payment(payment.ecommerce_id)
78+
client.cancel_payment(payment.data.ecommerce_id)
7979
```
8080

8181
```python
@@ -86,7 +86,7 @@ max_wait = 300 # 5 minutes
8686
elapsed = 0
8787

8888
while elapsed < max_wait:
89-
status = client.find_payment(payment.ecommerce_id)
89+
status = client.find_payment(payment.data.ecommerce_id)
9090

9191
if status.data.status == "CONFIRM":
9292
print("Customer confirmed!")
@@ -118,7 +118,7 @@ Once confirmed, you must authorize to finalize:
118118

119119
```python
120120
# Authorize completes the payment
121-
result = client.authorize_payment(payment.ecommerce_id)
121+
result = client.authorize_payment(payment.data.ecommerce_id)
122122

123123
print(f"Payment completed!")
124124
print(f"Reference number: {result.data.reference_number}")
@@ -166,17 +166,17 @@ try:
166166
# Wait for confirmation
167167
try:
168168
confirmed = client.wait_for_confirmation(
169-
payment.ecommerce_id,
169+
payment.data.ecommerce_id,
170170
max_attempts=150
171171
)
172172
except TimeoutError:
173173
# Customer didn't confirm, clean up
174-
client.cancel_payment(payment.ecommerce_id)
174+
client.cancel_payment(payment.data.ecommerce_id)
175175
print("Payment cancelled due to timeout")
176176
return
177177

178178
# Authorize
179-
result = client.authorize_payment(payment.ecommerce_id)
179+
result = client.authorize_payment(payment.data.ecommerce_id)
180180
print(f"Success! Reference: {result.data.reference_number}")
181181

182182
except ValidationError as e:
@@ -221,23 +221,23 @@ def process_payment(amount: str, phone: str, order_id: str) -> str | None:
221221
],
222222
)
223223

224-
print(f"Payment created: {payment.ecommerce_id}")
224+
print(f"Payment created: {payment.data.ecommerce_id}")
225225
print(f"Waiting for customer {phone} to confirm...")
226226

227227
# 2. Wait for customer confirmation (5 minute timeout)
228228
try:
229229
client.wait_for_confirmation(
230-
payment.ecommerce_id,
230+
payment.data.ecommerce_id,
231231
polling_interval=2.0,
232232
max_attempts=150 # 5 minutes
233233
)
234234
except TimeoutError:
235235
print("Customer didn't confirm in time, cancelling...")
236-
client.cancel_payment(payment.ecommerce_id)
236+
client.cancel_payment(payment.data.ecommerce_id)
237237
return None
238238

239239
# 3. Authorize payment
240-
result = client.authorize_payment(payment.ecommerce_id)
240+
result = client.authorize_payment(payment.data.ecommerce_id)
241241

242242
print(f"Payment completed!")
243243
print(f" Reference: {result.data.reference_number}")
@@ -321,12 +321,12 @@ If the customer provides a different phone number:
321321
```python
322322
# After payment creation, before confirmation
323323
client.update_phone_number(
324-
ecommerce_id=payment.ecommerce_id,
324+
ecommerce_id=payment.data.ecommerce_id,
325325
phone_number="7875559999"
326326
)
327327

328328
# Now wait for confirmation on the new number
329-
client.wait_for_confirmation(payment.ecommerce_id)
329+
client.wait_for_confirmation(payment.data.ecommerce_id)
330330
```
331331

332332
## Common Patterns
@@ -339,15 +339,15 @@ If you don't want to poll, implement a customer redirect:
339339
# 1. Create payment
340340
payment = client.create_payment(...)
341341

342-
# 2. Show customer a page with payment.ecommerce_id
342+
# 2. Show customer a page with payment.data.ecommerce_id
343343
# Customer opens ATH Móvil app and confirms
344344

345345
# 3. Customer returns to your site, you check status
346-
status = client.find_payment(payment.ecommerce_id)
346+
status = client.find_payment(payment.data.ecommerce_id)
347347

348348
if status.data.status == "CONFIRM":
349349
# Authorize it
350-
result = client.authorize_payment(payment.ecommerce_id)
350+
result = client.authorize_payment(payment.data.ecommerce_id)
351351
```
352352

353353
### Pattern: Background Job
@@ -357,8 +357,8 @@ For async frameworks:
357357
```python
358358
# In request handler
359359
payment = client.create_payment(...)
360-
enqueue_job("check_payment", payment.ecommerce_id)
361-
return {"payment_id": payment.ecommerce_id}
360+
enqueue_job("check_payment", payment.data.ecommerce_id)
361+
return {"payment_id": payment.data.ecommerce_id}
362362

363363
# In background worker
364364
def check_payment(ecommerce_id):

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ payment = client.create_payment(
3838
)
3939

4040
# Wait for customer to confirm on their phone
41-
confirmed = client.wait_for_confirmation(payment.ecommerce_id)
41+
confirmed = client.wait_for_confirmation(payment.data.ecommerce_id)
4242

4343
# Authorize the payment
44-
result = client.authorize_payment(payment.ecommerce_id)
44+
result = client.authorize_payment(payment.data.ecommerce_id)
4545
print(f"Payment completed! Reference: {result.data.reference_number}")
4646
```
4747

docs/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ try:
146146
tax="0.00",
147147
metadata1="Installation Test"
148148
)
149-
print(f"Success! Payment ID: {payment.ecommerce_id}")
149+
print(f"Success! Payment ID: {payment.data.ecommerce_id}")
150150

151151
# Cancel the test payment
152-
client.cancel_payment(payment.ecommerce_id)
152+
client.cancel_payment(payment.data.ecommerce_id)
153153
print("Test payment cancelled")
154154

155155
except Exception as e:

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)