from decimal import Decimal import gocardless_pro import os token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzA2OTY4NjI1LCJqdGkiOiJkMDUzN2I5MmIzMTg0M2RmYjE4NTdlMDg1NDUyYWRkZSIsInV1aWQiOiI4MjA4MDMxNy1mZTVlLTRjNDMtODlkZi0xOWViMzdhNWJlZDAiLCJhbGxvd2VkX2NpZHJzIjpbIjAuMC4wLjAvMCIsIjo6LzAiXX0.qr1Y3A9NEzJFqYmm6cPuZqxYqVJliL4CHy8ajRh_nis' #os.environ['ACCESS_TOKEN'] client = gocardless_pro.Client(access_token=token, environment='live') # Create a new customer. We automatically add idempotency keys to requests to create # resources, stopping duplicates accidentally getting created if something goes wrong # with the API (e.g. networking problems) - see https://developer.gocardless.com/api # -reference/#making-requests-idempotency-keys for details customer = client.customers.create(params={'email': 'markus.zimmerberger@zisco.at'}) # Fetch a payment by its ID payment = client.payments.get("PA123") # Loop through a page of payments, printing each payment's amount for payment in client.payments.list().records: decimal_amount = Decimal.Decimal(payment.amount) / 100 print('Payment for £{0}'.format(decimal_amount)) # Create a mandate PDF in a specific language client.mandate_pdfs.create( params={'links': {'mandate': 'MD00001234XYZ'}}, headers={'Accept-Language': 'fr'} )