Beispiel #1
0
 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)
         elif self.is_refund():
             payment_was_refunded.send(sender=self)
         elif self.is_reversed():
             payment_was_reversed.send(sender=self)
         else:
             payment_was_successful.send(sender=self)
     # Recurring payment signals:
     # XXX: Should these be merged with subscriptions?
     elif self.is_recurring():
         if self.is_recurring_create():
             recurring_create.send(sender=self)
         elif self.is_recurring_payment():
             recurring_payment.send(sender=self)
         elif self.is_recurring_cancel():
             recurring_cancel.send(sender=self)
         elif self.is_recurring_skipped():
             recurring_skipped.send(sender=self)
         elif self.is_recurring_failed():
             recurring_failed.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)
Beispiel #2
0
 def test_paypal_payment_cancel(self):
     #Test the my_payment_cancel_handler()
     
     #Assert first that the logged-in user has a Premium account
     self.assertTrue(self.user1.userprofile.account_level.level == 'Paid')
     
     #Cancel subscription payment
     subscription_cancel.send(sender=self)
     
     #Assert if the user's account was downgraded to Free
     user1 = User.objects.get(pk = 2)
     self.assertTrue(user1.userprofile.account_level.level == 'Free')
     logger.info('Accounts my_payment_cancel_handler() handler test successful.')