Skip to content

Instantly share code, notes, and snippets.

@eugena
Created November 10, 2015 10:49
Show Gist options
  • Save eugena/92a1ed897d5607d4235d to your computer and use it in GitHub Desktop.
Save eugena/92a1ed897d5607d4235d to your computer and use it in GitHub Desktop.
GoCardlessMixin
from django.conf import settings
import gocardless_pro
class GoCardless(object):
"""
GoCardless wrapper
"""
def __init__(self):
self.client = gocardless_pro.Client(
access_token=settings.GOCARDLESS_ACCESS_TOKEN,
environment=settings.GOCARDLESS_ENVIRONMENT)
class GoCardlessMixin(object):
"""
A mixin which adds the GoCardLess client to a View
"""
client = None
@property
def gocardless_client(self):
"""
Returns the GoCardless client
"""
if self.client is None:
self.client = GoCardless().client
return self.client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment