paga-python 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {paga_python-0.1.0 → paga_python-0.1.1}/PKG-INFO +8 -3
- {paga_python-0.1.0 → paga_python-0.1.1}/README.md +6 -1
- {paga_python-0.1.0 → paga_python-0.1.1}/pyproject.toml +2 -2
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/__init__.py +28 -4
- paga_python-0.1.1/src/paga/actions.py +30 -0
- paga_python-0.1.1/src/paga/airtime.py +150 -0
- paga_python-0.1.1/src/paga/bill_payment.py +203 -0
- paga_python-0.1.1/src/paga/business.py +295 -0
- paga_python-0.1.1/src/paga/checkout.py +67 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/client.py +33 -9
- paga_python-0.1.0/src/paga/checkout.py → paga_python-0.1.1/src/paga/collection.py +108 -34
- paga_python-0.1.1/src/paga/money_transfer.py +391 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/persistent.py +0 -27
- paga_python-0.1.1/src/paga/refunds.py +90 -0
- paga_python-0.1.1/src/paga/status.py +60 -0
- paga_python-0.1.0/src/paga/business.py → paga_python-0.1.1/src/paga/subsidiary.py +14 -420
- paga_python-0.1.0/src/paga/actions.py +0 -246
- paga_python-0.1.0/src/paga/directory.py +0 -523
- {paga_python-0.1.0 → paga_python-0.1.1}/.gitignore +0 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/LICENSE +0 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/auth.py +0 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/codes.py +0 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/customer.py +0 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/direct_debit.py +0 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/exceptions.py +0 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/models.py +0 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/outcome.py +0 -0
- {paga_python-0.1.0 → paga_python-0.1.1}/src/paga/webhooks.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: paga-python
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Unofficial async Python SDK for the Paga Engine API - payments, payouts, wallets and financial operations.
|
|
5
5
|
Project-URL: Homepage, https://github.com/TeamTrustBridge/paga-python
|
|
6
6
|
Project-URL: Documentation, https://github.com/TeamTrustBridge/paga-python#readme
|
|
7
7
|
Project-URL: Repository, https://github.com/TeamTrustBridge/paga-python
|
|
@@ -33,6 +33,11 @@ Description-Content-Type: text/markdown
|
|
|
33
33
|
|
|
34
34
|
**Async Python SDK for the [Paga Engine API](https://developer-docs.paga.com/).**
|
|
35
35
|
|
|
36
|
+
> **This is an unofficial SDK.** It is not built, endorsed, supported or
|
|
37
|
+
> published by Paga. It is community-maintained and follows Paga's published
|
|
38
|
+
> API reference. Paga's own documentation is the source of truth — if this
|
|
39
|
+
> documentation and Paga's disagree, Paga's is right.
|
|
40
|
+
|
|
36
41
|
`paga-python` makes the Paga developer workflow easy for page and integration
|
|
37
42
|
developers building checkout and payment experiences. It wraps the Paga Engine
|
|
38
43
|
API — payments, refunds, money transfers, airtime, bill payments, Direct
|
|
@@ -40,7 +45,7 @@ Debit, subsidiary accounts and business account operations — behind a single,
|
|
|
40
45
|
fully async client.
|
|
41
46
|
|
|
42
47
|
The TypeScript (`paga-ts`) and Rust (`paga-rs`) counterparts live in the same
|
|
43
|
-
|
|
48
|
+
organisation and track the same operation set.
|
|
44
49
|
|
|
45
50
|
## Features
|
|
46
51
|
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
**Async Python SDK for the [Paga Engine API](https://developer-docs.paga.com/).**
|
|
4
4
|
|
|
5
|
+
> **This is an unofficial SDK.** It is not built, endorsed, supported or
|
|
6
|
+
> published by Paga. It is community-maintained and follows Paga's published
|
|
7
|
+
> API reference. Paga's own documentation is the source of truth — if this
|
|
8
|
+
> documentation and Paga's disagree, Paga's is right.
|
|
9
|
+
|
|
5
10
|
`paga-python` makes the Paga developer workflow easy for page and integration
|
|
6
11
|
developers building checkout and payment experiences. It wraps the Paga Engine
|
|
7
12
|
API — payments, refunds, money transfers, airtime, bill payments, Direct
|
|
@@ -9,7 +14,7 @@ Debit, subsidiary accounts and business account operations — behind a single,
|
|
|
9
14
|
fully async client.
|
|
10
15
|
|
|
11
16
|
The TypeScript (`paga-ts`) and Rust (`paga-rs`) counterparts live in the same
|
|
12
|
-
|
|
17
|
+
organisation and track the same operation set.
|
|
13
18
|
|
|
14
19
|
## Features
|
|
15
20
|
|
|
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "paga-python"
|
|
7
|
-
version = "0.1.
|
|
8
|
-
description = "
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Unofficial async Python SDK for the Paga Engine API - payments, payouts, wallets and financial operations."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "GPL-3.0" }
|
|
11
11
|
requires-python = ">=3.9"
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"""Async Python SDK for the Paga Engine API."""
|
|
2
2
|
|
|
3
|
+
from .airtime import AirtimeMixin
|
|
3
4
|
from .auth import PAYMENT_REQUEST_FULL_HASH_FIELDS
|
|
5
|
+
from .bill_payment import BillPaymentMixin
|
|
6
|
+
from .business import BusinessMixin
|
|
7
|
+
from .checkout import CheckoutMixin
|
|
4
8
|
from .client import (
|
|
5
9
|
DEFAULT_CHECKOUT_LIVE_BASE_URL,
|
|
6
10
|
DEFAULT_CHECKOUT_TEST_BASE_URL,
|
|
@@ -16,6 +20,9 @@ from .codes import (
|
|
|
16
20
|
MandateStatusCode,
|
|
17
21
|
PaymentRequestState,
|
|
18
22
|
)
|
|
23
|
+
from .collection import CollectionMixin
|
|
24
|
+
from .customer import CustomerMixin
|
|
25
|
+
from .direct_debit import DirectDebitMixin
|
|
19
26
|
from .exceptions import (
|
|
20
27
|
PagaAPIError,
|
|
21
28
|
PagaAuthenticationError,
|
|
@@ -87,6 +94,11 @@ from .models import (
|
|
|
87
94
|
ValidateMoneyTransferResponse,
|
|
88
95
|
)
|
|
89
96
|
from .outcome import OperationOutcome, classify, is_unknown_outcome
|
|
97
|
+
from .money_transfer import MoneyTransferMixin
|
|
98
|
+
from .persistent import PersistentPaymentAccountMixin
|
|
99
|
+
from .refunds import RefundsMixin
|
|
100
|
+
from .status import StatusMixin
|
|
101
|
+
from .subsidiary import SubsidiaryMixin
|
|
90
102
|
from .webhooks import (
|
|
91
103
|
parse_hash_parameters,
|
|
92
104
|
parse_money_transfer_notification,
|
|
@@ -104,12 +116,15 @@ from .webhooks import (
|
|
|
104
116
|
verify_subsidiary_operation,
|
|
105
117
|
)
|
|
106
118
|
|
|
107
|
-
__version__ = "0.1.
|
|
119
|
+
__version__ = "0.1.1"
|
|
108
120
|
|
|
109
121
|
__all__ = [
|
|
110
122
|
"AccountBalanceResponse",
|
|
123
|
+
"AirtimeMixin",
|
|
111
124
|
"Bank",
|
|
112
125
|
"BanksResponse",
|
|
126
|
+
"BillPaymentMixin",
|
|
127
|
+
"BusinessMixin",
|
|
113
128
|
"BulkMoneyTransferResponse",
|
|
114
129
|
"BulkTransferResult",
|
|
115
130
|
"BusinessErrorCode",
|
|
@@ -117,9 +132,15 @@ __all__ = [
|
|
|
117
132
|
"ChargeMandateStatusData",
|
|
118
133
|
"ChargeMandateStatusResponse",
|
|
119
134
|
"ChargeStatusCode",
|
|
135
|
+
"CheckoutMixin",
|
|
136
|
+
"CheckoutVerifyChargeResponse",
|
|
120
137
|
"CollectBank",
|
|
121
138
|
"CollectBanksResponse",
|
|
139
|
+
"CollectPaymentMethodResult",
|
|
140
|
+
"CollectPaymentRequestResponse",
|
|
122
141
|
"CollectStatusCode",
|
|
142
|
+
"CollectionMixin",
|
|
143
|
+
"CustomerMixin",
|
|
123
144
|
"CustomerResponse",
|
|
124
145
|
"DataBundle",
|
|
125
146
|
"DataBundlesResponse",
|
|
@@ -127,11 +148,9 @@ __all__ = [
|
|
|
127
148
|
"DEFAULT_CHECKOUT_TEST_BASE_URL",
|
|
128
149
|
"DEFAULT_COLLECT_LIVE_BASE_URL",
|
|
129
150
|
"DEFAULT_COLLECT_TEST_BASE_URL",
|
|
130
|
-
"CheckoutVerifyChargeResponse",
|
|
131
|
-
"CollectPaymentMethodResult",
|
|
132
|
-
"CollectPaymentRequestResponse",
|
|
133
151
|
"DepositToBankResponse",
|
|
134
152
|
"DisableMandateResponse",
|
|
153
|
+
"DirectDebitMixin",
|
|
135
154
|
"DirectDebitSessionData",
|
|
136
155
|
"DirectDebitSessionMetadata",
|
|
137
156
|
"DirectDebitSessionResponse",
|
|
@@ -151,6 +170,7 @@ __all__ = [
|
|
|
151
170
|
"MobileOperator",
|
|
152
171
|
"MobileOperatorsResponse",
|
|
153
172
|
"MoneyTransferItem",
|
|
173
|
+
"MoneyTransferMixin",
|
|
154
174
|
"MoneyTransferNotification",
|
|
155
175
|
"MoneyTransferResponse",
|
|
156
176
|
"OnboardMerchantCredentials",
|
|
@@ -169,15 +189,19 @@ __all__ = [
|
|
|
169
189
|
"PaymentRequestState",
|
|
170
190
|
"PaymentStatusData",
|
|
171
191
|
"PaymentStatusResponse",
|
|
192
|
+
"PersistentPaymentAccountMixin",
|
|
172
193
|
"PersistentPaymentAccountResponse",
|
|
173
194
|
"PurchaseResponse",
|
|
174
195
|
"RecentTransaction",
|
|
175
196
|
"RecentTransactionsResponse",
|
|
176
197
|
"RefundResponse",
|
|
177
198
|
"RefundStatusResponse",
|
|
199
|
+
"RefundsMixin",
|
|
200
|
+
"StatusMixin",
|
|
178
201
|
"SubsidiaryAccountResponse",
|
|
179
202
|
"SubsidiaryBalanceResponse",
|
|
180
203
|
"SubsidiaryHistoryResponse",
|
|
204
|
+
"SubsidiaryMixin",
|
|
181
205
|
"SubsidiaryMoneyResponse",
|
|
182
206
|
"SubsidiaryTransferResponse",
|
|
183
207
|
"TransactionHistoryResponse",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Compatibility shim for the old, section-less layout.
|
|
2
|
+
|
|
3
|
+
The operations that used to live here are now split by the section of Paga's
|
|
4
|
+
documentation they belong to:
|
|
5
|
+
|
|
6
|
+
- :mod:`paga.money_transfer` — Money Transfer
|
|
7
|
+
- :mod:`paga.airtime` — Airtime and data
|
|
8
|
+
- :mod:`paga.bill_payment` — Bill payment (VAS)
|
|
9
|
+
- :mod:`paga.refunds` — Refunds
|
|
10
|
+
- :mod:`paga.status` — Check the transaction status
|
|
11
|
+
|
|
12
|
+
This module re-exports them so that ``from paga.actions import ...`` keeps
|
|
13
|
+
working. It will be removed in a future release.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from .airtime import AirtimeMixin
|
|
19
|
+
from .bill_payment import BillPaymentMixin
|
|
20
|
+
from .money_transfer import MoneyTransferMixin
|
|
21
|
+
from .refunds import RefundsMixin
|
|
22
|
+
from .status import StatusMixin
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"AirtimeMixin",
|
|
26
|
+
"BillPaymentMixin",
|
|
27
|
+
"MoneyTransferMixin",
|
|
28
|
+
"RefundsMixin",
|
|
29
|
+
"StatusMixin",
|
|
30
|
+
]
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""Airtime and data purchase operations for the Paga Engine API.
|
|
2
|
+
|
|
3
|
+
Covers the **Make payments → Airtime and data** section of Paga's
|
|
4
|
+
documentation.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any, Dict, Optional
|
|
10
|
+
|
|
11
|
+
from .auth import AIRTIME_HASH_FIELDS, DATA_BUNDLE_HASH_FIELDS, MOBILE_OPERATORS_HASH_FIELDS
|
|
12
|
+
from .models import DataBundlesResponse, MobileOperatorsResponse, PurchaseResponse
|
|
13
|
+
|
|
14
|
+
__all__ = ["AirtimeMixin"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AirtimeMixin:
|
|
18
|
+
"""Airtime and data operations."""
|
|
19
|
+
|
|
20
|
+
async def get_mobile_operators(
|
|
21
|
+
self,
|
|
22
|
+
*,
|
|
23
|
+
reference_number: str,
|
|
24
|
+
locale: Optional[str] = None,
|
|
25
|
+
) -> MobileOperatorsResponse:
|
|
26
|
+
"""List the mobile networks you can top up.
|
|
27
|
+
|
|
28
|
+
Operation: Airtime and data - Get the mobile operator.
|
|
29
|
+
|
|
30
|
+
Send a network's ``mobileOperatorCode`` as ``mobileOperatorPublicId``
|
|
31
|
+
when buying airtime, and as ``operatorPublicId`` when listing data
|
|
32
|
+
bundles. Cache the list.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
reference_number: Your unique reference for this request.
|
|
36
|
+
locale: Optional locale. Paga defaults to the empty string.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
The parsed :class:`MobileOperatorsResponse`.
|
|
40
|
+
"""
|
|
41
|
+
payload: Dict[str, Any] = {"referenceNumber": reference_number}
|
|
42
|
+
if locale is not None:
|
|
43
|
+
payload["locale"] = locale
|
|
44
|
+
|
|
45
|
+
response = await self._request(
|
|
46
|
+
"POST",
|
|
47
|
+
"/getMobileOperators",
|
|
48
|
+
payload,
|
|
49
|
+
use_hash=True,
|
|
50
|
+
use_basic=False,
|
|
51
|
+
base_url=self.business_base_url,
|
|
52
|
+
hash_fields=MOBILE_OPERATORS_HASH_FIELDS,
|
|
53
|
+
raise_on_error=False,
|
|
54
|
+
)
|
|
55
|
+
return MobileOperatorsResponse.model_validate(response.model_dump())
|
|
56
|
+
|
|
57
|
+
async def get_data_bundles(
|
|
58
|
+
self,
|
|
59
|
+
*,
|
|
60
|
+
reference_number: str,
|
|
61
|
+
operator_public_id: str,
|
|
62
|
+
) -> DataBundlesResponse:
|
|
63
|
+
"""List a network's data bundles.
|
|
64
|
+
|
|
65
|
+
Operation: Airtime and data - For data, pick a bundle.
|
|
66
|
+
|
|
67
|
+
Send a bundle's ``serviceId`` as ``mobileOperatorServiceId`` and
|
|
68
|
+
**exactly** its ``servicePrice`` as ``amount`` — the two must match
|
|
69
|
+
byte for byte or Paga rejects the purchase. Bundles rarely change, so
|
|
70
|
+
cache the list and refresh it monthly.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
reference_number: Your unique reference for this request.
|
|
74
|
+
operator_public_id: The operator's ``mobileOperatorCode``.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
The parsed :class:`DataBundlesResponse`.
|
|
78
|
+
"""
|
|
79
|
+
response = await self._request(
|
|
80
|
+
"POST",
|
|
81
|
+
"/getDataBundleByOperator",
|
|
82
|
+
{
|
|
83
|
+
"referenceNumber": reference_number,
|
|
84
|
+
"operatorPublicId": operator_public_id,
|
|
85
|
+
},
|
|
86
|
+
use_hash=True,
|
|
87
|
+
use_basic=False,
|
|
88
|
+
base_url=self.business_base_url,
|
|
89
|
+
hash_fields=DATA_BUNDLE_HASH_FIELDS,
|
|
90
|
+
raise_on_error=False,
|
|
91
|
+
)
|
|
92
|
+
return DataBundlesResponse.model_validate(response.model_dump())
|
|
93
|
+
|
|
94
|
+
async def buy_airtime(
|
|
95
|
+
self,
|
|
96
|
+
*,
|
|
97
|
+
reference_number: str,
|
|
98
|
+
amount: str,
|
|
99
|
+
destination_phone_number: str,
|
|
100
|
+
mobile_operator_public_id: str,
|
|
101
|
+
currency: str = "NGN",
|
|
102
|
+
is_data_bundle: bool = False,
|
|
103
|
+
mobile_operator_service_id: Optional[str] = None,
|
|
104
|
+
is_suppress_recipient_messages: bool = False,
|
|
105
|
+
) -> PurchaseResponse:
|
|
106
|
+
"""Buy airtime or data.
|
|
107
|
+
|
|
108
|
+
Operation: Airtime and data - Buy the airtime or data.
|
|
109
|
+
|
|
110
|
+
Tops up a phone with airtime or data from the business balance. There
|
|
111
|
+
is no callback: decide on ``responseCode``, and check the transaction
|
|
112
|
+
status if needed.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
reference_number: Your unique airtime purchase reference.
|
|
116
|
+
amount: Airtime value, or exactly the bundle's ``servicePrice`` for data.
|
|
117
|
+
destination_phone_number: Phone number to credit.
|
|
118
|
+
mobile_operator_public_id: The network's mobile operator public id.
|
|
119
|
+
currency: Transaction currency. Defaults to ``"NGN"``.
|
|
120
|
+
is_data_bundle: Whether this is a data bundle purchase. Defaults to ``False``.
|
|
121
|
+
mobile_operator_service_id: Data only. The bundle's ``serviceId``.
|
|
122
|
+
is_suppress_recipient_messages: Whether to suppress recipient messages.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
The parsed :class:`PurchaseResponse`.
|
|
126
|
+
"""
|
|
127
|
+
payload: Dict[str, Any] = {
|
|
128
|
+
"referenceNumber": reference_number,
|
|
129
|
+
"amount": amount,
|
|
130
|
+
"destinationPhoneNumber": destination_phone_number,
|
|
131
|
+
"mobileOperatorPublicId": mobile_operator_public_id,
|
|
132
|
+
"currency": currency,
|
|
133
|
+
"isDataBundle": is_data_bundle,
|
|
134
|
+
}
|
|
135
|
+
if mobile_operator_service_id is not None:
|
|
136
|
+
payload["mobileOperatorServiceId"] = mobile_operator_service_id
|
|
137
|
+
if is_suppress_recipient_messages:
|
|
138
|
+
payload["isSuppressRecipientMessages"] = True
|
|
139
|
+
|
|
140
|
+
response = await self._request(
|
|
141
|
+
"POST",
|
|
142
|
+
"/airtimePurchase",
|
|
143
|
+
payload,
|
|
144
|
+
use_hash=True,
|
|
145
|
+
use_basic=False,
|
|
146
|
+
base_url=self.business_base_url,
|
|
147
|
+
hash_fields=AIRTIME_HASH_FIELDS,
|
|
148
|
+
raise_on_error=False,
|
|
149
|
+
)
|
|
150
|
+
return PurchaseResponse.model_validate(response.model_dump())
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"""Bill payment operations for the Paga Engine API.
|
|
2
|
+
|
|
3
|
+
Covers the **Make payments → Bill payment (VAS)** section of Paga's
|
|
4
|
+
documentation.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
from .auth import (
|
|
12
|
+
BILL_PAYMENT_HASH_FIELDS,
|
|
13
|
+
MERCHANT_ACCOUNT_DETAILS_HASH_FIELDS,
|
|
14
|
+
MERCHANT_SERVICES_HASH_FIELDS,
|
|
15
|
+
MERCHANTS_HASH_FIELDS,
|
|
16
|
+
)
|
|
17
|
+
from .models import (
|
|
18
|
+
MerchantAccountDetailsResponse,
|
|
19
|
+
MerchantPaymentResponse,
|
|
20
|
+
MerchantsResponse,
|
|
21
|
+
MerchantServicesResponse,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
__all__ = ["BillPaymentMixin"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class BillPaymentMixin:
|
|
28
|
+
"""Bill payment operations."""
|
|
29
|
+
|
|
30
|
+
async def get_merchants(self, *, reference_number: str) -> MerchantsResponse:
|
|
31
|
+
"""List every biller you can pay.
|
|
32
|
+
|
|
33
|
+
Operation: Bill payment - Find the biller.
|
|
34
|
+
|
|
35
|
+
Lists every biller, with the ``uuid`` you send as ``merchantAccount``.
|
|
36
|
+
Cache the list.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
reference_number: Your unique reference for this request.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
The parsed :class:`MerchantsResponse`.
|
|
43
|
+
"""
|
|
44
|
+
response = await self._request(
|
|
45
|
+
"POST",
|
|
46
|
+
"/getMerchants",
|
|
47
|
+
{"referenceNumber": reference_number},
|
|
48
|
+
use_hash=True,
|
|
49
|
+
use_basic=False,
|
|
50
|
+
base_url=self.business_base_url,
|
|
51
|
+
hash_fields=MERCHANTS_HASH_FIELDS,
|
|
52
|
+
raise_on_error=False,
|
|
53
|
+
)
|
|
54
|
+
return MerchantsResponse.model_validate(response.model_dump())
|
|
55
|
+
|
|
56
|
+
async def get_merchant_services(
|
|
57
|
+
self,
|
|
58
|
+
*,
|
|
59
|
+
reference_number: str,
|
|
60
|
+
merchant_public_id: str,
|
|
61
|
+
) -> MerchantServicesResponse:
|
|
62
|
+
"""List what a biller can be paid for.
|
|
63
|
+
|
|
64
|
+
Operation: Bill payment - Pick the service.
|
|
65
|
+
|
|
66
|
+
No services means any amount is allowed. A service with ``price``
|
|
67
|
+
``0.0`` means the customer chooses the amount. Otherwise pay the
|
|
68
|
+
service's ``price``.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
reference_number: Your unique reference for this request.
|
|
72
|
+
merchant_public_id: The biller's ``uuid``.
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
The parsed :class:`MerchantServicesResponse`.
|
|
76
|
+
"""
|
|
77
|
+
response = await self._request(
|
|
78
|
+
"POST",
|
|
79
|
+
"/getMerchantServices",
|
|
80
|
+
{
|
|
81
|
+
"referenceNumber": reference_number,
|
|
82
|
+
"merchantPublicId": merchant_public_id,
|
|
83
|
+
},
|
|
84
|
+
use_hash=True,
|
|
85
|
+
use_basic=False,
|
|
86
|
+
base_url=self.business_base_url,
|
|
87
|
+
hash_fields=MERCHANT_SERVICES_HASH_FIELDS,
|
|
88
|
+
raise_on_error=False,
|
|
89
|
+
)
|
|
90
|
+
return MerchantServicesResponse.model_validate(response.model_dump())
|
|
91
|
+
|
|
92
|
+
async def get_merchant_account_details(
|
|
93
|
+
self,
|
|
94
|
+
*,
|
|
95
|
+
reference_number: str,
|
|
96
|
+
merchant_account: str,
|
|
97
|
+
merchant_reference_number: str,
|
|
98
|
+
merchant_service_product_code: Optional[str] = None,
|
|
99
|
+
) -> MerchantAccountDetailsResponse:
|
|
100
|
+
"""Validate a customer's meter, smart card or account number.
|
|
101
|
+
|
|
102
|
+
Operation: Bill payment - Validate the customer.
|
|
103
|
+
|
|
104
|
+
Checks the customer's number and returns their name. If the customer
|
|
105
|
+
chose a service, always send its ``code`` as
|
|
106
|
+
``merchant_service_product_code``. Billers that don't need it still
|
|
107
|
+
take part in the hash — send ``""`` when there is no service.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
reference_number: Your unique reference for this request.
|
|
111
|
+
merchant_account: The biller's ``uuid``.
|
|
112
|
+
merchant_reference_number: The customer's account / meter /
|
|
113
|
+
smart card number at the biller.
|
|
114
|
+
merchant_service_product_code: The chosen service's ``code``.
|
|
115
|
+
Optional, but it participates in the hash either way.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
The parsed :class:`MerchantAccountDetailsResponse`.
|
|
119
|
+
"""
|
|
120
|
+
payload: Dict[str, Any] = {
|
|
121
|
+
"referenceNumber": reference_number,
|
|
122
|
+
"merchantAccount": merchant_account,
|
|
123
|
+
"merchantReferenceNumber": merchant_reference_number,
|
|
124
|
+
}
|
|
125
|
+
# Always sent: the field is part of the hash even when unused.
|
|
126
|
+
payload["merchantServiceProductCode"] = merchant_service_product_code or ""
|
|
127
|
+
|
|
128
|
+
response = await self._request(
|
|
129
|
+
"POST",
|
|
130
|
+
"/getMerchantAccountDetails",
|
|
131
|
+
payload,
|
|
132
|
+
use_hash=True,
|
|
133
|
+
use_basic=False,
|
|
134
|
+
base_url=self.business_base_url,
|
|
135
|
+
hash_fields=MERCHANT_ACCOUNT_DETAILS_HASH_FIELDS,
|
|
136
|
+
raise_on_error=False,
|
|
137
|
+
)
|
|
138
|
+
return MerchantAccountDetailsResponse.model_validate(response.model_dump())
|
|
139
|
+
|
|
140
|
+
async def pay_bill(
|
|
141
|
+
self,
|
|
142
|
+
*,
|
|
143
|
+
reference_number: str,
|
|
144
|
+
amount: float,
|
|
145
|
+
merchant_account: str,
|
|
146
|
+
merchant_reference_number: str,
|
|
147
|
+
merchant_service: Optional[List[str]] = None,
|
|
148
|
+
currency: str = "NGN",
|
|
149
|
+
payment_channel: Optional[str] = None,
|
|
150
|
+
locale: Optional[str] = None,
|
|
151
|
+
merchant_service_product_code: Optional[str] = None,
|
|
152
|
+
) -> MerchantPaymentResponse:
|
|
153
|
+
"""Pay a bill from the business balance.
|
|
154
|
+
|
|
155
|
+
Operation: Bill payment - Pay the bill.
|
|
156
|
+
|
|
157
|
+
Pays a bill from the business balance. There is no callback: decide on
|
|
158
|
+
``responseCode``. ``integrationStatus`` is for information only.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
reference_number: Your unique bill payment reference.
|
|
162
|
+
amount: Bill amount.
|
|
163
|
+
merchant_account: The biller's UUID. From :meth:`get_merchants`.
|
|
164
|
+
merchant_reference_number: The customer's account / meter /
|
|
165
|
+
smart card / account number at the biller.
|
|
166
|
+
merchant_service: Optional chosen service code. Leave out for
|
|
167
|
+
billers with no services.
|
|
168
|
+
currency: Transaction currency. Defaults to ``"NGN"``.
|
|
169
|
+
payment_channel: Optional payment channel.
|
|
170
|
+
locale: Optional locale.
|
|
171
|
+
merchant_service_product_code: Optional chosen service code, as
|
|
172
|
+
returned by :meth:`get_merchant_services`.
|
|
173
|
+
|
|
174
|
+
Returns:
|
|
175
|
+
The parsed :class:`MerchantPaymentResponse`.
|
|
176
|
+
"""
|
|
177
|
+
payload: Dict[str, Any] = {
|
|
178
|
+
"referenceNumber": reference_number,
|
|
179
|
+
"amount": amount,
|
|
180
|
+
"merchantAccount": merchant_account,
|
|
181
|
+
"merchantReferenceNumber": merchant_reference_number,
|
|
182
|
+
"currency": currency,
|
|
183
|
+
}
|
|
184
|
+
if merchant_service is not None:
|
|
185
|
+
payload["merchantService"] = merchant_service
|
|
186
|
+
if payment_channel is not None:
|
|
187
|
+
payload["paymentChannel"] = payment_channel
|
|
188
|
+
if locale is not None:
|
|
189
|
+
payload["locale"] = locale
|
|
190
|
+
if merchant_service_product_code is not None:
|
|
191
|
+
payload["merchantServiceProductCode"] = merchant_service_product_code
|
|
192
|
+
|
|
193
|
+
response = await self._request(
|
|
194
|
+
"POST",
|
|
195
|
+
"/merchantPayment",
|
|
196
|
+
payload,
|
|
197
|
+
use_hash=True,
|
|
198
|
+
use_basic=False,
|
|
199
|
+
base_url=self.business_base_url,
|
|
200
|
+
hash_fields=BILL_PAYMENT_HASH_FIELDS,
|
|
201
|
+
raise_on_error=False,
|
|
202
|
+
)
|
|
203
|
+
return MerchantPaymentResponse.model_validate(response.model_dump())
|