Python SDK configuration
You configure the SDK once, when you create the Mitu client. The constructor checks your arguments straight away, so a mistake such as a malformed key or an unknown currency raises a MituConfigError when your application starts, rather than on the first paying request.
Arguments
Sandbox and production
Your key decides which Mitu environment the SDK connects to, so there is no separate environment argument.
Use a sandbox key while you develop and test, and switch to a live key when you are ready to accept real payments. Any other value raises a MituConfigError. You can check which environment a client is using by reading mitu.environment, which is either sandbox or production.
Default currency
Most APIs price everything in one currency. Setting default_currency means you only have to write the amount on each route. A route can still name a different currency when it needs to.
A currency is written as a short code such as USD or NGN, and it must be enabled on your Mitu account. When a route is priced in a currency other than the one the caller pays in, Mitu converts the amount at a rate it locks when the payment is created.
Logging
The SDK writes its log messages through Python’s standard logging module, under a logger named mitulabs_payments. Nothing is shown until you turn it on, which you can do in the same way as for any other library.
The SDK takes care never to log anything sensitive. Its messages never include your API key, a payment credential or the body of a request.
Shutting down
The client keeps a pool of HTTP connections open to Mitu so that each request is fast. When your application stops, close the client to release those connections. Use close() in async applications and close_sync() in sync ones.
Async applications
Sync applications
In FastAPI, close the client in the application’s lifespan handler.