Skip to content

Commit

Permalink
Use Oscar dynamic loading with get_class
Browse files Browse the repository at this point in the history
One of the main concern about django-oscar-adyen is that one may want
to override parts of the application. For example, how the merchantData
are used, or what to do to record a transaction.

Since there is no one-size-fit-all, I reuse here a very convenient tool
from django-oscar: `oscar.core.loading.get_class`. This tool allows us
to provide a base interface, that can be used almost out of the box,
and make possible anyone to override parts of it.

This is only the first step to a real modular django-oscar plugin, but
that's a good first step.
  • Loading branch information
Exirel committed Feb 18, 2016
1 parent dd63a65 commit 6b901b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
12 changes: 9 additions & 3 deletions adyen/facade.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# -*- coding: utf-8 -*-

import iptools
import logging

import iptools
from django.http import HttpResponse
from oscar.core.loading import get_class

from .gateway import Constants, Gateway, PaymentNotification, PaymentRedirection
from .models import AdyenTransaction
from .config import get_config
from .models import AdyenTransaction

Constants = get_class('adyen.gateway', 'Constants')
Gateway = get_class('adyen.gateway', 'Gateway')
PaymentNotification = get_class('adyen.gateway', 'PaymentNotification')
PaymentRedirection = get_class('adyen.gateway', 'PaymentRedirection')


logger = logging.getLogger('adyen')

Expand Down
5 changes: 3 additions & 2 deletions adyen/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-

from django.db import models
from django.conf import settings
from django.db import models
from django.utils import timezone
from oscar.core.loading import get_class

from .gateway import Constants
Constants = get_class('adyen.gateway', 'Constants')


class AdyenTransaction(models.Model):
Expand Down
7 changes: 5 additions & 2 deletions adyen/scaffold.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from django.utils import timezone
from oscar.core.loading import get_class

from .facade import Facade
from .gateway import Constants, MissingFieldException
from .config import get_config

Constants = get_class('adyen.gateway', 'Constants')
Facade = get_class('adyen.facade', 'Facade')
MissingFieldException = get_class('adyen.gateway', 'MissingFieldException')


class Scaffold:

Expand Down

0 comments on commit 6b901b9

Please sign in to comment.