TypeScript SDK configuration
You configure the SDK once, when you call createMitu. The function checks your options straight away, so a mistake such as a malformed key or an unknown currency stops your server at startup with a MituConfigError, rather than surfacing on the first paying request. Creating the client does not contact Mitu, so your server can start even if Mitu happens to be unreachable at that moment.
Options
Sandbox and production
Your key decides which Mitu environment the SDK connects to, so there is no separate environment setting.
Use a sandbox key while you develop and test, and switch to a live key when you are ready to accept real payments. Any value that is not a valid Mitu key causes createMitu to throw a MituConfigError. Load the key from an environment variable or a secret manager, and never commit it to source control.
Default currency
Most APIs price everything in one currency. Setting defaultCurrency means you only have to write the amount for 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 the SDK converts it to upper case for you. The currency 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 is silent unless you give it a logger. Any object with debug, info, warn and error methods will work, which includes the built-in console and most logging libraries.
The SDK takes care never to log anything sensitive. Its messages never include your API key, a payment credential, a receipt, or the body of a request or response.
Custom fetch
By default the SDK uses the global fetch to call Mitu. You can pass your own function instead, which is useful when you want to add tracing to outgoing calls or replace Mitu with a stub in your tests.