Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Commit 320ab30

Browse files
Merge pull request #13 from WilliamOtieno/develop
finalized docs
2 parents 78be423 + 9cd36a2 commit 320ab30

File tree

9 files changed

+82
-9
lines changed

9 files changed

+82
-9
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
### python-flutterwave
2+
23
- This lib aims to be the middleman between `Flutterwave API` and a python backend. Ergo, it directly makes the API requests to FW and returns the necessary info to the backend.
4+
35
- One should thoroughly go through the [official docs here](https://developer.flutterwave.com/reference/introduction) in order to have a meaningful insight on how to use the params provided by the functions in the lib.
6+
47
- The lib will also follow the same project structure as the official docs for ease of use and consistency.
58

69
- NB: Set `FW_SECRET_KEY` environnment variable obtained from the dashboard.
7-
## Quick Example.
810

9-
```python
10-
from python_flutterwave.charge import initiate_apple_pay_charge, validate_charge
11+
- Full package documentation can be accessed from [here](https://python-flutterwave.readthedocs.io/en/latest/)
1112

12-
details = initiate_apple_pay_charge(tx_ref="your_unique_ref", amount=20, email="johndoe@example.com", currency="USD")
13-
print(details)
14-
validation_details = validate_charge(flw_ref="qwerty", otp="123456")
15-
print(validation_details)
16-
```
1713

18-
- More contributors needed, refer to [the contribution gude](/CONTRIBUTING.md)
14+
- More contributors needed, refer to [the contribution gude](/CONTRIBUTING.md)

docs/.DS_Store

-6 KB
Binary file not shown.

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
extensions = ["sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.autodoc"]
2323

24+
autodoc_decorators = True
25+
2426
templates_path = ["_templates"]
2527
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
2628

python_flutterwave/charge/bank.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def initiate_bank_charge(
2020
2121
Args:
2222
tx_ref (int): This is a unique reference peculiar to the transaction being carried out.
23+
2324
amount (int): This is the amount to be charged for the transaction.
25+
2426
email (str): The customer's email address.
2527
2628
Returns:
@@ -53,7 +55,9 @@ def initiate_nigeria_bank_charge(
5355
5456
Args:
5557
tx_ref (int): This is a unique reference peculiar to the transaction being carried out.
58+
5659
amount (int): This is the amount to be charged for the transaction.
60+
5761
email (str): The customer's email address.
5862
5963
Returns:
@@ -84,9 +88,13 @@ def initiate_uk_eu_bank_charge(
8488
8589
Args:
8690
tx_ref (int): Unique reference peculiar to the transaction.
91+
8792
amount (int): Amount to be charged for the transaction.
93+
8894
email (str): The customer's email address.
95+
8996
phone_number (str): Phone number linked to the customer's bank account or mobile money account
97+
9098
is_token_io (int):
9199
92100
Returns:
@@ -123,9 +131,13 @@ def initiate_ach_bank_charge(
123131
124132
Args:
125133
tx_ref (int): Unique reference peculiar to the transaction.
134+
126135
amount (int): Amount to be charged for the transaction.
136+
127137
email (str): The customer's email address.
138+
128139
phone_number (str): Phone number linked to the customer's bank account or mobile money account
140+
129141
currency (str): Currency to charge in. Expected values are ZAR for ZA ACH and USD for US ACH.
130142
131143
Returns:

python_flutterwave/charge/card.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ def initiate_card_charge(
2424
2525
Args:
2626
tx_ref (int): This is a unique reference peculiar to the transaction being carried out.
27+
2728
amount (int): This is the amount to be charged for the transaction.
29+
2830
email (str): The customer's email address.
31+
2932
card_number (int): The customer's card.
33+
3034
cvv (int): Card CVV.
35+
3136
expiry_month (int): Card expiry month
37+
3238
expiry_year (int): Card expiry year
3339
3440
Returns:

python_flutterwave/charge/mobile.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ def initiate_mpesa_charge(
1818
1919
Args:
2020
tx_ref (int): Unique reference peculiar to the transaction.
21+
2122
amount (int): Amount to be charged for the transaction.
23+
2224
email (str): The customer's email address.
25+
2326
phone_number (str): Phone number linked to the customer's bank account or mobile money account
2427
2528
Returns:
@@ -52,9 +55,13 @@ def initiate_ghana_mobile_charge(
5255
5356
Args:
5457
tx_ref (int): Unique reference peculiar to the transaction.
58+
5559
amount (int): Amount to be charged for the transaction.
60+
5661
email (str): The customer's email address.
62+
5763
phone_number (str): Phone number linked to the customer's bank account or mobile money account
64+
5865
network (str): Mobile money network provider (MTN, VODAFONE, TIGO)
5966
6067
Returns:
@@ -91,8 +98,11 @@ def initiate_uganda_mobile_charge(
9198
9299
Args:
93100
tx_ref (int): Unique reference peculiar to the transaction.
101+
94102
amount (int): Amount to be charged for the transaction.
103+
95104
email (str): The customer's email address.
105+
96106
phone_number (str): Phone number linked to the customer's bank account or mobile money account
97107
98108
Returns:
@@ -130,10 +140,15 @@ def initiate_franco_mobile_charge(
130140
131141
Args:
132142
tx_ref (int): Unique reference peculiar to the transaction.
143+
133144
amount (int): Amount to be charged for the transaction.
145+
134146
email (str): The customer's email address.
147+
135148
phone_number (str): Phone number linked to the customer's bank account or mobile money account
149+
136150
currency (str): Currency to charge in.
151+
137152
franco_country_code (str): Country code (BF, CI, CM, SN)
138153
139154
Returns:
@@ -170,8 +185,11 @@ def initiate_tanzania_mobile_charge(
170185
171186
Args:
172187
tx_ref (int): Unique reference peculiar to the transaction.
188+
173189
amount (int): Amount to be charged for the transaction.
190+
174191
email (str): The customer's email address.
192+
175193
phone_number (str): Phone number linked to the customer's bank account or mobile money account
176194
177195
Returns:
@@ -204,9 +222,13 @@ def initiate_rwanda_mobile_charge(
204222
205223
Args:
206224
tx_ref (int): Unique reference peculiar to the transaction.
225+
207226
amount (int): Amount to be charged for the transaction.
227+
208228
email (str): The customer's email address.
229+
209230
phone_number (str): Phone number linked to the customer's bank account or mobile money account
231+
210232
order_id (str): Unique ref for the mobilemoney transaction to be provided by the merchant
211233
212234
Returns:
@@ -243,8 +265,11 @@ def initiate_zambia_mobile_charge(
243265
244266
Args:
245267
tx_ref (int): Unique reference peculiar to the transaction.
268+
246269
amount (int): Amount to be charged for the transaction.
270+
247271
email (str): The customer's email address.
272+
248273
phone_number (str): Phone number linked to the customer's bank account or mobile money account
249274
250275
Returns:
@@ -281,9 +306,13 @@ def initiate_ussd_charge(
281306
282307
Args:
283308
tx_ref (int): Unique reference peculiar to the transaction.
309+
284310
amount (int): Amount to be charged for the transaction.
311+
285312
email (str): The customer's email address.
313+
286314
account_bank (str): Bank numeric code. It can be gotten from the banks endpoint.
315+
287316
phone_number (str): Phone number linked to the customer's bank account or mobile money account
288317
289318
Returns:
@@ -320,8 +349,11 @@ def initiate_apple_pay_charge(
320349
321350
Args:
322351
tx_ref (int): Unique reference peculiar to the transaction.
352+
323353
amount (int): Amount to be charged for the transaction.
354+
324355
email (str): The customer's email address.
356+
325357
currency (str): Currency to charge in.
326358
327359
Returns:
@@ -356,8 +388,11 @@ def initiate_google_pay_charge(
356388
357389
Args:
358390
tx_ref (int): Unique reference peculiar to the transaction.
391+
359392
amount (int): Amount to be charged for the transaction.
393+
360394
email (str): The customer's email address.
395+
361396
currency (str): Currency to charge in.
362397
363398
Returns:
@@ -391,7 +426,9 @@ def initiate_enaira_charge(
391426
392427
Args:
393428
tx_ref (int): This is a unique reference peculiar to the transaction being carried out.
429+
394430
amount (int): This is the amount to be charged for the transaction.
431+
395432
email (str): The customer's email address.
396433
397434
Returns:
@@ -424,7 +461,9 @@ def initiate_fawry_pay_charge(
424461
425462
Args:
426463
tx_ref (int): This is a unique reference peculiar to the transaction being carried out.
464+
427465
amount (int): This is the amount to be charged for the transaction.
466+
428467
email (str): The customer's email address.
429468
430469
Returns:
@@ -459,9 +498,13 @@ def initiate_paypal_charge(
459498
460499
Args:
461500
tx_ref (int): Unique reference peculiar to the transaction.
501+
462502
amount (int): Amount to be charged for the transaction.
503+
463504
email (str): The customer's email address.
505+
464506
currency (str): Currency to charge in.
507+
465508
Returns:
466509
dict: Response Details
467510
"""

python_flutterwave/charge/validation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def validate_charge(otp: str, flw_ref: str) -> dict:
1313
1414
Args:
1515
flw_ref (str): Reference returned in the initiate charge call as `data.flw_ref`
16+
1617
otp (str): Random number of at least 6 characters sent to customers phone number.
1718
1819
Returns:

python_flutterwave/decorators.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import os
22
import requests
3+
from functools import wraps
34
from .exceptions import TokenException, FlutterwaveAPIException
45

56

67
token = os.environ.get("FW_SECRET_KEY")
78

89

910
def require_token(func):
11+
"""Ascertain existence of the auth token"""
12+
@wraps(func)
1013
def wrapper(*args, **kwargs):
1114
if token == "" or token is None:
1215
raise TokenException(token=token, message="Authentication token absent")
@@ -16,6 +19,8 @@ def wrapper(*args, **kwargs):
1619

1720

1821
def handle_api_exceptions(func):
22+
"""Raise exceptions whenever necessary"""
23+
@wraps(func)
1924
@require_token
2025
def wrapper(*args, **kwargs):
2126
try:

python_flutterwave/tokenization/tokenized_charge.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ def initiate_tokenized_charge(
1717
1818
Args:
1919
tx_ref (int): Unique reference peculiar to the transaction.
20+
2021
amount (int): Amount to be charged for the transaction.
22+
2123
email (str): The customer's email address.
24+
2225
currency (str): Currency to be used
26+
2327
token (str): Card token returned from the transaction verification endpoint as data.card.token
2428
2529
Returns:
@@ -58,6 +62,7 @@ def initiate_bulk_tokenized_charges(
5862
5963
Args:
6064
retry_strategy: RetryStrategy
65+
6166
bulk_data: list[ChargeData]
6267
6368
Returns:
@@ -141,8 +146,11 @@ def update_card_token(email: str, full_name: str, phone_number: str, token: str)
141146
142147
Args:
143148
email (str): The customer's email address.
149+
144150
full_name (str): The customer's email address.
151+
145152
phone_number (str): Customer's phone number.
153+
146154
token (str): Card token returned from the transaction verification endpoint as data.card.token
147155
148156
Returns:

0 commit comments

Comments
 (0)