Skip to content

Commit

Permalink
Removed uniqueness from receipt, added unique_together
Browse files Browse the repository at this point in the history
  • Loading branch information
Sureiya committed Nov 14, 2013
1 parent 5fdc954 commit ba3982a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 4 additions & 1 deletion django_clickbank/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Notification(ClickBankModel):
)

# Notification Fields
receipt = models.CharField(max_length=13, unique=True, db_index=True)
receipt = models.CharField(max_length=13, db_index=True)
role = models.CharField(max_length=9, choices=ROLE_CHOICES)
transaction_type = models.CharField(max_length=15, choices=TRANSACTION_TYPE_CHOICES)
transaction_vendor = models.CharField(max_length=10, blank=True)
Expand Down Expand Up @@ -155,6 +155,9 @@ class Meta:
verbose_name = u'notification'
verbose_name_plural = u'notifications'

# Receipts are the same for chargebacks and refunds
unique_together = ('receipt', 'transaction_type')

def initialize(self, request):
""" If notification is being added from an actual Post this will set sender IP and store query if neccesary """
if settings.CLICKBANK_DEBUG or settings.CLICKBANK_STORE_POSTS:
Expand Down
9 changes: 0 additions & 9 deletions django_clickbank/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@ def ipn(request, get=False):
except Exception, e:
raise NotificationFailedValidation(e)
else:
# If the form invalidates due to duplicate receipt, we go ahead and return 200 anyway.
if 'receipt' in form.errors:
if form.errors['receipt'][0] == u'Notification with this Receipt already exists.':
notification = Notification.objects.get(receipt=form.data['receipt'])
logger.info('Notification recognized as duplicate. Returning OK.')
if settings.CLICKBANK_DEBUG:
logger.debug('Resending Signals')
notification.send_signals()
return HttpResponse(notification.id)
raise NotificationFailedValidation('{0}\n{1}\n{2}'.format(form.errors, mapped_data, data))

notification.initialize(request)
Expand Down

0 comments on commit ba3982a

Please sign in to comment.