mollie-api-python icon indicating copy to clipboard operation
mollie-api-python copied to clipboard

Enable `testmode` for OAuth clients globally

Open whyscream opened this issue 2 years ago • 0 comments

In OAuth requests, you can specify testmode=true to perform API requests in your development phase. Currently this needs to be done on a per-request basis:

from mollie.api.client import Client
mollie_client = Client()
mollie_client.set_access_token("access_blah")

data = {
    "name": "Customer A",
    "email": "[email protected]",
}
customer = mollie_client.customers.create(data, testmode="true")

Of course this is hard when your API requests are all over you application, and you need to adjust all of your code to enable/disable testmode for each call. We want to support enabling this on the client level, e.g:

from mollie.api.client import Client
mollie_client = Client()
mollie_client.set_access_token("access_blah")
mollie.client.set_testmode(True)   # or False

data = {
    "name": "Customer A",
    "email": "[email protected]",
}
customer = mollie_client.customers.create(data)  # Now this will send the API request with testmode enabled

whyscream avatar Nov 08 '22 15:11 whyscream