Invoice, Withdrawal, and get_transaction — covering every payment flow. Unlike the other SDKs, initialization uses module-level globals, not a class instance.
Installation
requests dependency is installed automatically.
Initialization
Python
api_key and auth_token from the LigdiCash dashboard by creating an API project.
Hosted payin
The customer is redirected to the LigdiCash-hosted payment page. This is the recommended flow for online stores.Python
Direct payin
The customer pays directly from your interface. You must collect their phone number and, depending on the operator, their OTP code.Python
The OTP mode varies by operator. For example, with a USSD operator, the customer generates the OTP on their phone before you submit. For an approval-mode operator (e.g. Moov Africa), send
otp="" — the customer approves directly in their app. See the operator page for details.Payout
Send money to a customer — refund, salary, payout.To the customer’s LigdiCash wallet
Python
Directly to mobile money
Python
type="client" uses the POST /pay/v01/withdrawal/create endpoint (via the LigdiCash wallet). type="merchant" uses POST /pay/v01/straight/payout (direct mobile money, slower). See Payout — Introduction.Status verification
Callget_transaction with the token stored at creation (not the callback token, which is different).
Python
transaction:
| Attribute | Type | Description |
|---|---|---|
status | str | "completed", "pending", "cancelled" |
response_code | str | "00" success, "01" failure |
amount | int | Transaction amount |
operator_id | str | Operator identifier |
operator_name | str | Operator name |
customer | str | Customer phone number |
token | str | Transaction token |
custom_data | dict | Custom data sent at creation |
wiki | list | Links to the endpoint’s error codes |
Error handling
Every error inherits fromligdicash.LigdicashError and exposes .code and .message.
Python
| Class | Raised when |
|---|---|
AuthenticationError | api_key or auth_token invalid |
ApplicationAuthenticationError | Application not authenticated |
MerchantPayinDisabledError | Payin not enabled on the project |
MerchantPayoutDisabledError | Payout not enabled on the project |
MerchantBalanceLowError | Merchant balance too low |
CustomerDoesNotExistError | Customer not registered on the platform |
InvalidAmountError | Amount outside the [20; 1,000,000] range |
InvalidTokenError | Invalid or missing token |
InvoiceNotFoundError | Invoice not found |
TransactionAlreadyExistError | Transaction already created |
RecipientOperatorNotIdentifiedError | Recipient’s operator not identified |
FeatureNotTestableError | Feature unavailable in "test" mode |
