-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
831 additions
and
183 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[run] | ||
include = authorizenet/* | ||
omit = authorizenet/tests/* | ||
omit = tests/* | ||
branch = 1 |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Application-specific settings for django-authorizenet""" | ||
|
||
from django.conf import settings as django_settings | ||
|
||
|
||
class Settings(object): | ||
|
||
""" | ||
Retrieves django.conf settings, using defaults from Default subclass | ||
All usable settings are specified in settings attribute. Use an | ||
``AUTHNET_`` prefix when specifying settings in django.conf. | ||
""" | ||
|
||
prefix = 'AUTHNET_' | ||
settings = {'DEBUG', 'LOGIN_ID', 'TRANSACTION_KEY', 'CUSTOMER_MODEL', | ||
'DELIM_CHAR', 'FORCE_TEST_REQUEST', 'EMAIL_CUSTOMER', | ||
'MD5_HASH'} | ||
|
||
class Default: | ||
CUSTOMER_MODEL = getattr( | ||
django_settings, 'AUTH_USER_MODEL', "auth.User") | ||
DELIM_CHAR = "|" | ||
FORCE_TEST_REQUEST = False | ||
EMAIL_CUSTOMER = None | ||
MD5_HASH = "" | ||
|
||
def __init__(self): | ||
self.defaults = Settings.Default() | ||
|
||
def __getattr__(self, name): | ||
if name not in self.settings: | ||
raise AttributeError("Setting %s not understood" % name) | ||
try: | ||
return getattr(django_settings, self.prefix + name) | ||
except AttributeError: | ||
return getattr(self.defaults, name) | ||
|
||
settings = Settings() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class BillingError(Exception): | ||
|
||
"""Error due to Authorize.NET request""" |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from django.db import models | ||
|
||
|
||
class CustomerProfileManager(models.Manager): | ||
|
||
def create(self, **data): | ||
|
||
"""Create new Authorize.NET customer profile""" | ||
|
||
from .models import CustomerPaymentProfile | ||
|
||
kwargs = data | ||
sync = kwargs.pop('sync', True) | ||
kwargs = { | ||
'customer': kwargs.get('customer', None), | ||
'profile_id': kwargs.pop('profile_id', None), | ||
} | ||
|
||
# Create customer profile | ||
obj = self.model(**kwargs) | ||
self._for_write = True | ||
obj.save(force_insert=True, using=self.db, sync=sync, data=data) | ||
|
||
if sync: | ||
# Store customer payment profile data locally | ||
for payment_profile_id in obj.payment_profile_ids: | ||
CustomerPaymentProfile.objects.create( | ||
customer_profile=obj, | ||
payment_profile_id=payment_profile_id, | ||
sync=False, | ||
**data | ||
) | ||
|
||
return obj | ||
|
||
|
||
class CustomerPaymentProfileManager(models.Manager): | ||
|
||
def create(self, **kwargs): | ||
"""Create new Authorize.NET customer payment profile""" | ||
sync = kwargs.pop('sync', True) | ||
obj = self.model(**kwargs) | ||
self._for_write = True | ||
obj.save(force_insert=True, using=self.db, sync=sync) | ||
return obj |
Oops, something went wrong.