Skip to content

Commit

Permalink
+ fixes latest issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Boxall committed Apr 28, 2009
1 parent 4530b44 commit ce27bf2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
22 changes: 21 additions & 1 deletion standard/ipn/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import urllib2
from paypal.standard.models import PayPalStandardBase
from paypal.standard.ipn.signals import *


class PayPalIPN(PayPalStandardBase):
Expand All @@ -18,4 +19,23 @@ def _postback(self):

def _verify_postback(self):
if self.response != "VERIFIED":
self.set_flag("Invalid postback. (%s)" % self.response)
self.set_flag("Invalid postback. (%s)" % self.response)

def send_signals(self):
"""Shout for the world to hear whether a txn was successful."""
# Transaction signals:
if self.is_transaction():
if self.flag:
payment_was_flagged.send(sender=self)
else:
payment_was_successful.send(sender=self)
# Subscription signals:
else:
if self.is_subscription_cancellation():
subscription_cancel.send(sender=self)
elif self.is_subscription_signup():
subscription_signup.send(sender=self)
elif self.is_subscription_end_of_term():
subscription_eot.send(sender=self)
elif self.is_subscription_modified():
subscription_modify.send(sender=self)
25 changes: 4 additions & 21 deletions standard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# -*- coding: utf-8 -*-
from django.db import models
from django.conf import settings

from paypal.standard.signals import *
from paypal.standard.helpers import duplicate_txn_id, check_secret
from paypal.standard.conf import RECEIVER_EMAIL, POSTBACK_ENDPOINT, SANDBOX_POSTBACK_ENDPOINT

Expand Down Expand Up @@ -243,29 +241,14 @@ def get_endpoint(self):
else:
return POSTBACK_ENDPOINT

def send_signals(self):
"""Shout for the world to hear whether a txn was successful."""
# Transaction signals:
if self.is_transaction():
if self.flag:
payment_was_flagged.send(sender=self)
else:
payment_was_successful.send(sender=self)
# Subscription signals:
else:
if self.is_subscription_cancellation():
subscription_cancel.send(sender=self)
elif self.is_subscription_signup():
subscription_signup.send(sender=self)
elif self.is_subscription_end_of_term():
subscription_eot.send(sender=self)
elif self.is_subscription_modified():
subscription_modify.send(sender=self)

def initialize(self, request):
"""Store the data we'll need to make the postback from the request object."""
self.query = getattr(request, request.method).urlencode()
self.ipaddress = request.META.get('REMOTE_ADDR', '')

def send_signals(self):
"""After a transaction is completed use this to send success/fail signals"""
raise NotImplementedError

def _postback(self):
"""Perform postback to PayPal and store the response in self.response."""
Expand Down
11 changes: 8 additions & 3 deletions standard/pdt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
class PayPalSettingsError(Exception):
"""Raised when settings are incorrect."""

if not hasattr(settings.PAYPAL_IDENTITY_TOKEN):
try:
IDENTITY_TOKEN = settings.PAYPAL_IDENTITY_TOKEN
except:
raise PayPalSettingsError("You must set PAYPAL_IDENTITY_TOKEN in settings.py. Get this token by enabling PDT in your PayPal account.")
IDENTITY_TOKEN = settings.PAYPAL_IDENTITY_TOKEN



Expand Down Expand Up @@ -71,4 +72,8 @@ def _verify_postback(self, response):
qd.update(response_dict)
qd.update(dict(ipaddress=self.ipaddress, st=self.st, flag_info=self.flag_info))
pdt_form = PayPalPDTForm(qd, instance=self)
pdt_form.save(commit=False)
pdt_form.save(commit=False)

def send_signals(self):
# Sendt the PDT signals...
pass

0 comments on commit ce27bf2

Please sign in to comment.