Created
November 10, 2015 10:49
-
-
Save eugena/92a1ed897d5607d4235d to your computer and use it in GitHub Desktop.
GoCardlessMixin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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