# Path: authorizenet/signals.py



from django.db import models
from django.db.models.signals import post_save
from django.contrib.auth.models import User
from django.contrib.localflavor.us.models import PhoneNumberField, USStateField
from authorizenet.signals import payment_was_successful, payment_was_flagged


class Invoice(models.Model):
    customer = models.ForeignKey(Customer)
    item = models.ForeignKey(Item)

    def __unicode__(self):
        return u"<Invoice: %d - %s>" % (self.id, self.customer.user.username)


def create_customer_profile(sender, instance=None, **kwargs):
    if instance is None:
        return
    profile, created = Customer.objects.get_or_create(user=instance)


post_save.connect(create_customer_profile, sender=User)


def successfull_payment(sender, **kwargs):
    response = sender
    # do something with the response


def flagged_payment(sender, **kwargs):
    response = sender
    # do something with the response


payment_was_successful.connect(successfull_payment)

# Path: authorizenet/signals.py



# Path: sample_project/samplestore/models.py
from django.db import models
from django.db.models.signals import post_save
from django.contrib.auth.models import User
from django.contrib.localflavor.us.models import PhoneNumberField, USStateField
from authorizenet.signals import payment_was_successful, payment_was_flagged



class Invoice(models.Model):
    customer = models.ForeignKey(Customer)
    item = models.ForeignKey(Item)

    def __unicode__(self):
        return u"<Invoice: %d - %s>" % (self.id, self.customer.user.username)


def create_customer_profile(sender, instance=None, **kwargs):
    if instance is None:
        return
    profile, created = Customer.objects.get_or_create(user=instance)


post_save.connect(create_customer_profile, sender=User)


def successfull_payment(sender, **kwargs):
    response = sender
    # do something with the response


def flagged_payment(sender, **kwargs):
    response = sender
    # do something with the response


payment_was_successful.connect(successfull_payment)

payment_was_flagged.connect(flagged_payment)