Exemplo n.º 1
0
    def testConnectPaypalSignalReceiver(self):
        payment_was_successful.connect(show_me_the_money)

        class ipn_obj:
            custom = 'atyala'

        payment_was_successful.send(sender=ipn_obj, message="Hello", level=1, object=self)
Exemplo n.º 2
0
 def __init__(self, shop):
     self.shop = shop
     # Hook the payment was successful listener on the appropriate signal sent
     # by django-paypal (success_signal)
     success_signal.connect(self.payment_was_successful, weak=False)
     assert settings.PAYPAL_RECEIVER_EMAIL, "You need to define a PAYPAL_RECEIVER_EMAIL in settings with the money recipient's email addresss"
     assert settings.PAYPAL_CURRENCY_CODE, "You need to define a PAYPAL_CURRENCY_CODE in settings with the currency code"
Exemplo n.º 3
0
def my_ipn(request):
    try:
        send_mail('my_ipn', 'in my_ipn', '*****@*****.**', ['*****@*****.**'], fail_silently=False)
        toReturn = ipn.views.ipn(request)
        payment_was_successful.connect(confirm_payment)
        return toReturn
    except Exception as e:
        send_mail('my_ipn', str(e), '*****@*****.**', ['*****@*****.**'], fail_silently=False)
        return HttpResponse('OKAY')
Exemplo n.º 4
0
 def testConnectingSignals(self):
     payment_was_successful.connect(SimpleReceiver)
     self.assertFalse(self._signalReceived)
     payment_was_successful.send(sender="Sender", message="Hello", level=1, object=self)
     self.assertTrue(self._signalReceived)
     # test disconnect signal
     self._signalReceived = False
     payment_was_successful.disconnect(SimpleReceiver)
     payment_was_successful.send(sender="Sender", message="Hello", level=1, object=self)
     self.assertFalse(self._signalReceived)
    def __init__(self, shop):
        self.shop = shop

        # Hook the payment was successful listener on the appropriate signal
        # sent by django-paypal (success_signal)
        unique_key = 'django-shop-paypal_offsite_payment-successful'
        success_signal.connect(self.payment_was_successful, weak=False,
                               dispatch_uid=unique_key)

        assert settings.PAYPAL_RECEIVER_EMAIL, "You need to define " \
                                               "PAYPAL_RECEIVER_EMAIL in " \
                                               "settings with the " \
                                               "recipient's email addresss"
Exemplo n.º 6
0
 def __init__(self, shop):
     self.shop = shop
     # Hook the payment was successful listener on the appropriate signal sent
     # by django-paypal (success_signal)
     assert settings.PAYPAL_RECEIVER_EMAIL, "You need to define a PAYPAL_RECEIVER_EMAIL in settings with the money recipient's email addresss"
     assert settings.PAYPAL_CURRENCY_CODE, "You need to define a PAYPAL_CURRENCY_CODE in settings with the currency code"
     success_signal.connect(self.payment_was_successful, weak=False)
     flagged_signal.connect(self.payment_was_flagged, weak=False)
     subscription_cancel_signal.connect(self.subscription_cancelled, weak=False)
     subscription_eot_signal.connect(self.subscription_expired, weak=False)
     subscription_modify_signal.connect(self.subscription_modified, weak=False)
     subscription_signup_signal.connect(self.subscription_signup_success, weak=False)
     recurring_create_signal.connect(self.recurring_created, weak=False)
     recurring_payment_signal.connect(self.recurring_payment, weak=False)
     recurring_cancel_signal.connect(self.recurring_cancelled, weak=False)
Exemplo n.º 7
0
def donation_successful(sender, **kwargs):
    """

    @param sender: PayPalStandardBase
    @param kwargs:
    """
    ipn_obj = sender
    # Undertake some action depending upon `ipn_obj`.

    username = ipn_obj.custom or ipn_obj.item_name.replace("Donazione da parte di: ", '')
    d, created = Donation.objects.get_or_create(from_email=ipn_obj.payer_email,
                                                from_username=username,
                                                amount=ipn_obj.auth_amount,
                                                memo=ipn_obj.memo)

    d.status=ipn_obj.auth_status
    d.save()
    payment_was_successful.connect(donation_successful)
Exemplo n.º 8
0
 def ready(self):
     from paypal.standard.ipn.signals import payment_was_successful
     payment_was_successful.connect(signals.payment_received, dispatch_uid='shop.payment_received')
Exemplo n.º 9
0
    # make Order, put in db
    # look for invoice_id
    try:
        send_mail('confirm_payment', str(sender), '*****@*****.**', ['*****@*****.**'], fail_silently=False)
        unpaid_order = UnpaidOrder.objects.get(invoice_id=sender.invoice)
        '''
        # THIS IS NOW DONE ABOVE
        dropoff_pickup_time = unpaid_order.dropoff_pickup_time
        dropoff_pickup_time.n_boxes_bought += unpaid_order.n_boxes_bought
        dropoff_pickup_time.save()
        '''
        order = Order(user=unpaid_order.user,
                      cell_number=unpaid_order.cell_number,
                      dropoff_pickup_time=unpaid_order.dropoff_pickup_time,
                      proxy_name=unpaid_order.proxy_name,
                      proxy_email=unpaid_order.proxy_email,
                      n_boxes_bought=unpaid_order.n_boxes_bought,
                      invoice_id=unpaid_order.invoice_id,
                      signature=unpaid_order.signature)
        order.save()        
    except Exception as e:
        send_mail('confirm_payment', 'something went wrong sending: ' + str(e), '*****@*****.**', ['*****@*****.**'], fail_silently=False)

payment_was_successful.connect(confirm_payment)

def handle_flagged(sender, **kwargs):
    send_mail('Subject here', 'Here is the message. (Flagged!)', '*****@*****.**',
              ['*****@*****.**'], fail_silently=False)

payment_was_flagged.connect(handle_flagged)
Exemplo n.º 10
0
        body=email_body,
        from_email='*****@*****.**',
        to=[user.email],
        bcc=['*****@*****.**'])
    mail.attach_alternative(email_body_html, 'text/html')
    mail.send()


# Signal handler
def verify_and_process_payment(sender, **kwargs):
    ipn_obj = sender
    invoice = ipn_obj.invoice
    acknowledge_payment_received(invoice)


payment_was_successful.connect(verify_and_process_payment)


@user_passes_test(logged_in_and_active)
@user_passes_test(is_service_available, login_url='/comebacksoon/')
def submit(request):
    def render_page(request,
                    order,
                    selectdiscountform=None,
                    claimdiscountform=None,
                    dropforms=None):
        context = {}
        if float(
                order.get_full_price()
        ) < 0.01:  # Free service. Don't show discount forms. Clear coupons so they are not wasted.
            context['show_discounts'] = False
Exemplo n.º 11
0
			except User.DoesNotExist:
				ipn_obj.set_flag("Payment attempted for user who does not exist: %s" % user_id)
			
			try:
				ct = ContentType.objects.get(app_label=app_label, model=model)
			except ContentType.DoesNotExist:
				ipn_obj.set_flag("Payment attempted for content type which does not exist: %s.%s" % (app_label, model))
			else:
				try:
					obj = ct.get_object_for_this_type(id=object_id)
				except ct.model_class().DoesNotExist:
					ipn_obj.set_flag("Payment attempted for %s with id %s which does not exist." % (ct.model_class().__name__, object_id))
			
			# Should this process even if the ipn is flagged?
			if not ipn_obj.flag:
				payment = Payment(
					payment_for = obj,
					user = user,
					paid = ipn_obj.mc_gross,
					payment_method = 'online',
					payment_made = datetime.datetime.now(),
					ipn = ipn_obj
				)
				payment.save()
			else:
				ipn_obj.save()
		else:
			ipn_obj.set_flag("Security data does not match passthrough variables.")
			ipn_obj.save()
	payment_was_successful.connect(process_payment)
Exemplo n.º 12
0
    ipn_obj = sender
    # logging.debug(ipn_obj.mc_gross)

    amt = float(ipn_obj.mc_gross)

    if amt == 10.0:
        credit_amt = 10.0
    elif amt == 25.0:
        credit_amt = 27.0
    elif amt == 50.0:
        credit_amt = 55.0
    elif amt == 100.0:
        credit_amt = 115.0
    elif amt == 500.0:
        credit_amt = 600.0
    elif amt == 1.0:
        credit_amt = 28.0

    company = Company.objects.get(slug=ipn_obj.custom)

    new_credit = InvoiceHistory(company=company, credit_added=credit_amt)
    new_credit.save()

    # Actuall add credit to company
    credit_obj = Credit.objects.get(company=company)
    credit_obj.credit_left = credit_obj.credit_left + float(credit_amt)
    credit_obj.save()


payment_was_successful.connect(notify_credit)
Exemplo n.º 13
0
        return

    test_ipn = getattr(settings, 'PAYPAL_TEST', False)

    if ipn_obj.test_ipn != test_ipn:
        # per Asheesh, make sure that the test_ipn setting matches the PAYPAL_TEST setting
        return

    tier_info = TierInfo.objects.get_current()
    current_tier_obj = SiteLocation.objects.get_current().get_tier()

    if float(ipn_obj.payment_gross) != current_tier_obj.dollar_cost():
        raise ValueError(
            "User paid %f instead of %f" %
            (ipn_obj.payment_gross, current_tier_obj.dollar_cost()))

    subscription_start = PayPalIPN.objects.filter(
        subscr_id=ipn_obj.subscr_id, flag=False,
        test_ipn=test_ipn).exclude(period1="").order_by('-id')[0]
    num, format = subscription_start.period1.split(' ', 1)
    num = int(num)
    if format.upper() != 'D':
        raise ValueError('invalid repeat period: %r' %
                         subscription_start.period1)

    tier_info.payment_due_date += datetime.timedelta(days=num)
    tier_info.save()


payment_was_successful.connect(handle_successful_payment)
Exemplo n.º 14
0
                                  .order_by('-price')

    def vat_value(self):
        return self.price - self.net_price()

    def net_price(self):
        return self.price / (1 + self.vat.value / 100)

if 'paypal.standard.ipn' in dsettings.INSTALLED_APPS:
    from paypal.standard.ipn.signals import payment_was_successful as paypal_payment_was_successful
    def confirm_order(sender, **kwargs):
        ipn_obj = sender
        o = Order.objects.get(code=ipn_obj.custom)
        o.confirm_order(ipn_obj.payment_date)

    paypal_payment_was_successful.connect(confirm_order)

class CreditNote(models.Model):
    invoice = models.ForeignKey(Invoice, related_name='credit_notes')
    code = models.CharField(max_length=20, unique=True)
    assopy_id =  models.CharField(max_length=22, null=True)
    emit_date = models.DateField()
    price = models.DecimalField(max_digits=6, decimal_places=2)

    def __unicode__(self):
        return ' #%s' % self.code

    def note_items(self):
        return self.refund.items.all()\
            .values('code','description') \
            .annotate(price=models.Sum('price'), count=models.Count('price')) \
Exemplo n.º 15
0
        "charset": "utf-8",
    }

    paypal_form = PayPalPaymentsForm(initial=paypal_dict)
    submit_js = "<script>document.forms['paypalsubmit'].submit()</script>"
    return render(request, 'usercenter/checkout.html', {
        'content': paypal_form.render(),
        'submit_js': submit_js
    })


# 支付成功的回调函数
def do_business(sender, **kwargs):
    baseutil.well_print('ipn received')
    ipn_obj = sender
    out_trade_no = ipn_obj.invoice  # 本站订单号
    total_fee = ipn_obj.mc_gross
    trade = get_object_or_404(Transaction, out_trade_no=out_trade_no)
    # send mail to admin
    mail_content = u"Bluessh有新用户付款成功,用户名为 %s, 付款金额为 $%s"\
                    % (trade.user.username,total_fee)
    mail_admins(u"Bluessh有新用户付款成功", mail_content, fail_silently=True)
    #创建账单对应的ssh帐号,并保存到UserProduct
    baseutil.well_print("username:%s, total_fee:%s" %
                        (trade.user.username, total_fee))
    create_ssh_user(trade)


# connect signal
payment_was_successful.connect(do_business)
Exemplo n.º 16
0
        end_at = datetime.now() + timedelta(days=365)
        if time_units == 'M':
            end_at = datetime.now() + timedelta(days=30)
        if Plan.objects.filter(txn_id=ipn_obj.txn_id).count() == 0:
            plan = Plan(user=user,
                        type=plan_type,
                        end_at=end_at,
                        payed=True,
                        status='active',
                        txn_id=ipn_obj.txn_id)
            plan.save()
            plan.notify_user_of_payment()
            profile = helpers.get_profile_for_user_id(user_id)
            if profile:
                package = helpers.create_push_package_for_profile(profile)
        else:  # there already is a plan for this transaction. Ignore.
            pass
    else:
        #send email to MANAGERS
        emails = [person[1] for person in settings.MANAGERS]
        subject = 'A payment failed: payment id ' + str(ipn_obj.id)
        message = 'Check it out in the admin'
        send_mail(subject,
                  message,
                  settings.EMAIL_HOST_USER,
                  emails,
                  fail_silently=False)


payment_was_successful.connect(mark_payment)
Exemplo n.º 17
0
#    Zoook. OpenERP e-sale, e-commerce Open Source Management Solution
#    Copyright (C) 2011 Zikzakmedia S.L. (<http://www.zikzakmedia.com>). All Rights Reserved
#    $Id$
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
############################################################################################

from django.db import models

from paypal.standard.ipn.signals import payment_was_successful


#signals
def paypal_confirm(sender, **kwargs):
    pass


payment_was_successful.connect(paypal_confirm)
Exemplo n.º 18
0
import logging

from paypal.standard.ipn.signals import payment_was_successful

from wallet.models import Invoice


def wallet_deposit(sender, **kwargs):
    logger = logging.getLogger('wallet')
    logger.debug('PayPal Signal Handler')
    invoice_id = sender.invoice
    invoice_id = int(invoice_id)
    logger.debug('Invoice ID: %d' % invoice_id)
    invoice = Invoice.objects.get(id=invoice_id)
    logger.debug('Invoice: %s' % invoice)
    wallet = invoice.user.wallets.all()[0]
    logger.debug('Wallet: %s' % wallet)
    invoice.transaction = wallet.deposit(invoice.option.wallet_amount)
    invoice.save()
    logger.debug('PayPal IPN Complete')


payment_was_successful.connect(wallet_deposit)
Exemplo n.º 19
0
    for line in order.orderline_set.all():
        order.total += line.line_price

    order.total = +order.total + Decimal(order.delivery.price)

    order.save()

    return order


def play_signals(sender, **kwargs):
    ipn = sender
    order = Order.objects.get(pk=ipn.invoice)
    order.transaction_id = str(ipn.txn_id)
    order.payment_status = str(ipn.payment_status)
    order.payer_email = str(ipn.payer_email)
    order.payer_full_name = "%s %s" % (ipn.first_name, ipn.last_name)
    if order.payment_status == "Completed":
        if not ipn.flag:
            send_order_confirmation_email(order)
    order.save()
    return


payment_was_successful.connect(play_signals)
payment_was_flagged.connect(play_signals)


def paypal_signal(ipn):
    pass
Exemplo n.º 20
0
from datetime import datetime, timedelta
from django.utils.timezone import utc

from django.conf import settings

# signals
from paypal.standard.ipn.signals import payment_was_successful


def validPayment(sender, **kwargs):
    #user = Users.objects.get(email=sender.invoice)
    print 'youhou'


payment_was_successful.connect(validPayment)


class SlotBooked(models.Model):
    user = models.ForeignKey(User, unique=True)
    slot = models.ForeignKey(Slot, unique=True)
    dateBooked = models.DateTimeField('Date Booked')
    datePaid = models.DateTimeField('Date Paid', null=True, blank=True)

    def __unicode__(self):
        return unicode(self.slot)

    def isPaid(self):
        if self.datePaid is None:
            return False
        else:
Exemplo n.º 21
0
                        pass
                    else:
                        variation.update_stock(item.quantity * -1)
                        variation.product.actions.purchased()

                code = session.get('discount_code')
                if code:
                    DiscountCode.objects.active().filter(code=code) \
                        .update(uses_remaining=F('uses_remaining') - 1)
                cart.delete()
            except Order.DoesNotExist:
                pass
        except Cart.DoesNotExist:
            pass

payment_was_successful.connect(payment_complete)


class HomePage(Page, RichText):
    '''
    A page representing the format of the home page
    '''

    content_heading = models.CharField(max_length=200,
        default="About us!")
    featured_portfolio = models.ForeignKey("Portfolio", blank=True, null=True,
        help_text="If selected items from this portfolio will be featured "
                  "on the home page.")
    

    class Meta:
Exemplo n.º 22
0
from django.db import models
from django.contrib.auth import get_user_model

# Register Signals
from paypal.standard.ipn.signals import payment_was_successful
from orders import signals
payment_was_successful.connect(signals.order_paid, dispatch_uid="paypal_payment_success")


class Supplier(models.Model):
    name = models.CharField(max_length=255)

    def __str__(self):
        return self.name


class _UnitSizeSack(object):
    name = "sack"
    description = "Sack (25Kg)"

    def plural(self, quantity):
        unit_size = self.name
        if quantity is not 1:
            unit_size = self.name + "s"
        return "%d %s" % (quantity, unit_size)


class _UnitSizeKg(object):
    name = "Kg"
    description = "1 Kg"
Exemplo n.º 23
0
from django.db import models
#from paypal.pro.signals import payment_was_successful
from paypal.standard.ipn.signals import payment_was_successful

def show_me_the_money(sender, **kwargs):
    ipn_obj = sender
    # Undertake some action depending upon `ipn_obj`.
    print "TODO OK !"

payment_was_successful.connect(show_me_the_money ,dispatch_uid="somethjjing-rational-here")
Exemplo n.º 24
0

def reset_by_upgrade_variant_or_choice_set(sender,
                                           instance,
                                           created=False,
                                           **kwargs):
    if instance.item:
        reset_menu_json(instance.item.site)


def reset_by_choice(sender, instance, created=False, **kwargs):
    if instance.group.item:
        reset_menu_json(instance.group.item.site)


payment_was_successful.connect(register_paypal_payment)
payment_was_flagged.connect(register_paypal_payment)
post_save.connect(new_site_setup)
post_save.connect(item_social_handler, sender=Item)
post_save.connect(pdf_caching_handler, sender=Item)
post_save.connect(create_defaults, sender=Item)

post_save.connect(reset_by_section_or_item, sender=Item)
post_save.connect(reset_by_section_or_item, sender=Section)
post_save.connect(reset_by_upgrade_variant_or_choice_set, sender=Upgrade)
post_save.connect(reset_by_upgrade_variant_or_choice_set, sender=Variant)
post_save.connect(reset_by_upgrade_variant_or_choice_set, sender=SideDishGroup)
post_save.connect(reset_by_choice, sender=SideDish)

pre_delete.connect(reset_by_section_or_item, sender=Item)
pre_delete.connect(reset_by_section_or_item, sender=Section)
Exemplo n.º 25
0
    #    for item in items:
    #        total += item.amount
        return render_to_response(template_name,{
                "form":form,
                "PAYPAL_URL": settings.PAYPAL_URL,
                "total": total,
                },context_instance=RequestContext(request))
    else:
        print "An user is not registered"


from paypal.standard.ipn.signals import payment_was_successful
def my_payment_was_successful_handler(sender, **kwargs):
    print 'successful payment'

payment_was_successful.connect(my_payment_was_successful_handler)
def payment_successful(request):
    '''
    handles the "IPN" from paypal. That is, when there is a successful paypal
    transaction, paypal calls this url with some info. The most important
    value here is POST['custom'], which is a comma seperated list of CartItem
    ids (ending in ,) that have been paid for.
    
    sends a list of cart_items to cart.signals.pp_ipn
    '''
    logging.debug('handling paypal IPN:')
    if request.method == 'POST':
        logging.debug('is post')
        itemids = request.POST['custom'].split(',')
        logging.debug('itemids:')
        logging.debug(itemids)
Exemplo n.º 26
0
        self.object_pk = obj.pk 
        self.content_type = ContentType.objects.get_for_model(obj).natural_key()
        super(Custom, self).__init__()
        
    def get_object(self):
        return ContentType.objects.get_by_natural_key(*self.content_type).get_object_for_this_type(pk=self.object_pk)
    
    def get_user(self):
        queryset = User.objects.filter(id=self.user_id)
        return queryset.get() if queryset else None
    
    def serialize(self):
        pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
        return base64.urlsafe_b64encode(pickled).decode("utf-8")
    
    @staticmethod
    def deserialize(serialized):
        b64 = base64.urlsafe_b64decode(serialized.encode("utf-8"))
        return pickle.loads(b64)


# Handle PayPal signals

def handle_payment_was_successful(sender, **kwargs):
    """Extends object and user objects from PayPal IPN receipt and sends a paid signal"""
    custom = Custom.deserialize(sender.custom)
    obj = custom.get_object()
    paid.send(type(obj), user=custom.get_user(), obj = obj, receipt=sender)
payment_was_successful.connect(handle_payment_was_successful)

Exemplo n.º 27
0
    user = models.OneToOneField(UserSocialAuth)
    message = models.CharField(max_length=1000)
    link = models.CharField(max_length=100)

    def __unicode__(self):
        return self.message

    class Meta:
        verbose_name_plural = "Facebook Messages"


class TwitterPostMessage(models.Model):

    user = models.OneToOneField(UserSocialAuth)
    tweet = models.CharField(max_length=140)

    def __unicode__(self):
        return self.tweet

    class Meta:
        verbose_name_plural = "Twitter Tweets"


def paypal_ipn_return(sender, **kwargs):
    import logging
    log = logging.getLogger(__name__)
    log.debug(">>>>>>>>>>>>>>>>>>IPN RETURNED " + str(kwargs))


payment_was_successful.connect(paypal_ipn_return)
Exemplo n.º 28
0
        return HttpResponse('OKAY')

def confirm_payment(sender, **kwargs):
    # make Order, put in db
    # look for invoice_id
    try:
        send_mail('confirm_payment', str(sender), '*****@*****.**', ['*****@*****.**'], fail_silently=False)
        unpaid_order = UnpaidOrder.objects.get(invoice_id=sender.invoice)
        dropoff_pickup_time = unpaid_order.dropoff_pickup_time
        dropoff_pickup_time.n_boxes_bought += unpaid_order.n_boxes_bought
        dropoff_pickup_time.save()
        order = Order(user=unpaid_order.user,
                      cell_number=unpaid_order.cell_number,
                      dropoff_pickup_time=unpaid_order.dropoff_pickup_time,
                      proxy_name=unpaid_order.proxy_name,
                      proxy_email=unpaid_order.proxy_email,
                      n_boxes_bought=unpaid_order.n_boxes_bought,
                      invoice_id=unpaid_order.invoice_id,
                      signature=unpaid_order.signature)
        order.save()        
    except Exception as e:
        send_mail('confirm_payment', 'something went wrong sending: ' + str(e), '*****@*****.**', ['*****@*****.**'], fail_silently=False)

payment_was_successful.connect(confirm_payment)

def handle_flagged(sender, **kwargs):
    send_mail('Subject here', 'Here is the message. (Flagged!)', '*****@*****.**',
              ['*****@*****.**'], fail_silently=False)

payment_was_flagged.connect(handle_flagged)
Exemplo n.º 29
0
                order=order)
            transaction.ipn.add(ipn_obj)
            transaction.save()
        else:
            logger.warning(
                "PayPal: unsuccessful ipn payment, no order found for uuid %s"
                % ipn_obj.custom)
    else:
        logger.warning(
            "PayPal: unsuccessful ipn payment signal with no ipn object")


def successful_pdt(sender, **kwargs):
    logger.info("PayPal: successful pdt payment")
    pdt_obj = sender
    mark_payment(pdt_obj, True)


def unsuccesful_pdt(sender, **kwargs):
    logger.info("PayPal: unsuccessful pdt payment")
    pdt_obj = sender
    mark_payment(pdt_obj, False)


payment_was_successful.connect(successful_payment,
                               dispatch_uid="Order.ipn_successful")
payment_was_flagged.connect(unsuccessful_payment,
                            dispatch_uid="Order.ipn_unsuccessful")
pdt_successful.connect(successful_pdt, dispatch_uid="Order.pdt_successful")
pdt_failed.connect(unsuccesful_pdt, dispatch_uid="Order.pdt_unsuccessful")
Exemplo n.º 30
0
@receiver(models.signals.post_save,sender=RaffleEntry)
def raffleEntrySaved(sender, instance, **kwargs):
  instance.user.profile.tickets = -sum(foo.tickets for foo in instance.user.entries.all())
  instance.user.profile.save()
  instance.raffle.tickets = sum(foo.tickets for foo in instance.raffle.entries.all())
  instance.raffle.save()

@receiver(models.signals.pre_save,sender=UserProfile)
def userProfileSaving(sender, instance, **kwargs):
  instance.tickets = -sum(foo.tickets for foo in instance.user.entries.all())
  instance.points = -sum(foo.points for foo in instance.user.transactions.all())


@receiver(models.signals.post_save,sender=PointTransaction)
def pointTransactionSaved(sender, instance, **kwargs):
  instance.user.profile.points = -sum(foo.points for foo in instance.user.transactions.all())
  instance.user.profile.save()
  instance.game.points = sum(foo.points for foo in instance.game.transactions.all())
  instance.game.save()


def paypal_payment_was_successful(sender, **kwargs):
  ipn_obj = sender
  ipn_hash = ipn_obj.custom.strip()
  donation = get_object_or_404(Donation, ipn_hash=ipn_hash)
  donation.approved = True
  donation.save()

payment_was_successful.connect(paypal_payment_was_successful)
Exemplo n.º 31
0
        """
        return self.price_in_local_currency - self.vat_in_local_currency

    @property
    def price_in_local_currency(self):
        return normalize_price(self.price * self.exchange_rate)


if 'paypal.standard.ipn' in dsettings.INSTALLED_APPS:
    from paypal.standard.ipn.signals import payment_was_successful as paypal_payment_was_successful
    def confirm_order(sender, **kwargs):
        ipn_obj = sender
        o = Order.objects.get(code=ipn_obj.custom)
        o.confirm_order(ipn_obj.payment_date)

    paypal_payment_was_successful.connect(confirm_order)

class CreditNote(models.Model):
    invoice = models.ForeignKey(Invoice, related_name='credit_notes')
    code = models.CharField(max_length=20, unique=True)
    assopy_id =  models.CharField(max_length=22, null=True)
    emit_date = models.DateField()
    price = models.DecimalField(max_digits=6, decimal_places=2)

    def __unicode__(self):
        return ' #%s' % self.code

    def note_items(self):
        return self.refund.items.all()\
            .values('code','description') \
            .annotate(price=models.Sum('price'), count=models.Count('price')) \
Exemplo n.º 32
0
from django.http import QueryDict
	
def receive_point_buy(sender, **kwargs):
	# FIXME: handle errors?
	ipn = sender
		
	if ipn.item_number == ITEM_PREFIX:
		query = QueryDict(ipn.query)
		quantity = int(query['option_selection1'])
		for units, price in PREPAID_UNIT_PACKS:
			if quantity == units:
				if ipn.mc_gross == Decimal(price):
					user = auth.models.User.objects.get(username=ipn.custom)
					UnitPack.credit(user, quantity, reason=RECHARGE_TEXT)
				break
payment_was_successful.connect(receive_point_buy)

class ValidUnitPackManager(models.Manager):
	def get_query_set(self):
		return super(ValidUnitPackManager, self).get_query_set().filter(
			expires__gt=datetime.date.today(), quantity__gt=0)

def _default_expires():
	if hasattr(settings,'PREPAID_DEFAULT_EXPIRY_PERIOD'):
		return datetime.date.today() + datetime.timedelta(
			settings.PREPAID_DEFAULT_EXPIRY_PERIOD)

class UnitPack(models.Model):
	# Normally we only deal with not expired and not empty unit packs,
	# but sometimes we need to peek into expired.
	all_objects = models.Manager()
Exemplo n.º 33
0
from django.contrib.auth.models import User
from room.models import Slot

from datetime import datetime, timedelta
from django.utils.timezone import utc

from django.conf import settings

# signals
from paypal.standard.ipn.signals import payment_was_successful
def validPayment(sender, **kwargs):
  #user = Users.objects.get(email=sender.invoice)
  print 'youhou'

payment_was_successful.connect(validPayment) 

class SlotBooked(models.Model):
  user = models.ForeignKey(User, unique=True)
  slot = models.ForeignKey(Slot, unique=True)
  dateBooked = models.DateTimeField('Date Booked')
  datePaid = models.DateTimeField('Date Paid', null=True, blank=True)
  
  def __unicode__(self):
    return unicode(self.slot)

  def isPaid(self):
    if self.datePaid is None:
      return False
    else:
      return True
Exemplo n.º 34
0
 def show_me_the_money(sender, **kwargs):
     ipn_obj = sender
     #Undertake some action depending upon `ipn_obj`.
     if ipn_obj.custom == "Upgrade all users!":
         UsersInfo.objects.update(paid=True)
     payment_was_successful.connect(show_me_the_money)
Exemplo n.º 35
0
############################################################################################
#
#    Zoook. OpenERP e-sale, e-commerce Open Source Management Solution
#    Copyright (C) 2011 Zikzakmedia S.L. (<http://www.zikzakmedia.com>). All Rights Reserved
#    $Id$
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
############################################################################################

from django.db import models

from paypal.standard.ipn.signals import payment_was_successful

#signals
def paypal_confirm(sender, **kwargs):
    pass

payment_was_successful.connect(paypal_confirm)
Exemplo n.º 36
0
                                  for foo in instance.raffle.entries.all())
    instance.raffle.save()


@receiver(models.signals.pre_save, sender=UserProfile)
def userProfileSaving(sender, instance, **kwargs):
    instance.tickets = -sum(foo.tickets for foo in instance.user.entries.all())
    instance.points = -sum(foo.points
                           for foo in instance.user.transactions.all())


@receiver(models.signals.post_save, sender=PointTransaction)
def pointTransactionSaved(sender, instance, **kwargs):
    instance.user.profile.points = -sum(
        foo.points for foo in instance.user.transactions.all())
    instance.user.profile.save()
    instance.game.points = sum(foo.points
                               for foo in instance.game.transactions.all())
    instance.game.save()


def paypal_payment_was_successful(sender, **kwargs):
    ipn_obj = sender
    ipn_hash = ipn_obj.custom.strip()
    donation = get_object_or_404(Donation, ipn_hash=ipn_hash)
    donation.approved = True
    donation.save()


payment_was_successful.connect(paypal_payment_was_successful)
Exemplo n.º 37
0
                                   null=True,
                                   blank=True)
    id_pago = models.CharField(max_length=100, blank=True, null=True)
    fecha = models.DateTimeField(auto_now_add=True, db_index=True)
    metodo_pago = models.ForeignKey(MetodoPago, blank=True, null=True)
    descripcion = models.CharField(max_length=100, blank=True, null=True)
    transaccion = models.CharField(max_length=100, blank=True, null=True)

    def __unicode__(self):
        return self.id_pago


from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received, payment_was_successful


def show_me_the_money(sender, **kwargs):
    ipn_obj = sender
    if ipn_obj.payment_status == ST_PP_COMPLETED:
        if ipn_obj.custom == "Comprando los mejores productos!":
            pago = Pago(cantidad=ipn_obj.mc_gross,
                        descripcion=ipn_obj.payment_status,
                        transaccion=ipn_obj.txn_id)
            pago.save()
    else:
        print 'Salio Mal'


valid_ipn_received.connect(show_me_the_money)
payment_was_successful.connect(show_me_the_money)
Exemplo n.º 38
0
from django.db import models
from django.conf import settings
from django.utils import timezone


# Create your models here.
class Magazine(models.Model):

    name = models.CharField(max_length=254, default="")
    description = models.TextField()
    price = models.DecimalField(max_digits=6, decimal_places=2)

    def __unicode__(self):
        return self.name


class Purchase(models.Model):

    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             related_name="purchases")
    magazine = models.ForeignKey(Magazine)
    subscription_end = models.DateTimeField(default=timezone.now)


from signals import subscription_created, subscription_was_cancelled, subscription_extended
from paypal.standard.ipn.signals import valid_ipn_received, payment_was_successful

valid_ipn_received.connect(subscription_created)
valid_ipn_received.connect(subscription_was_cancelled)
payment_was_successful.connect(subscription_extended)
    token.save()

    # ShoppingToken.objects.filter(payed=False).exclude(date__gte=(datetime.now() - timedelta(days=1)).date()).delete()

    form = PayPalPaymentsForm(
        initial={
            'business': settings.PAYPAL_RECEIVER_EMAIL,
            'amount': '2.00',
            'item_name': 'All themes for IDEA',
            'invoice': token.value,
            'notify_url': ROOT_URL + reverse('paypal-ipn'),
            'return_url': ROOT_URL + '/themes/download-all/',
            'cancel_return': ROOT_URL + '/themes/download-all/',
        })

    request.session['shopping_token'] = token.value
    return render(request, 'themes/download-all.html', {'form': form})


def payment_successful_handler(sender, **kwargs):
    if sender.payment_status == "Completed":
        try:
            token = ShoppingToken.objects.get(value=sender.invoice)
            token.payed = True
            token.save()
        except ObjectDoesNotExist:
            pass


payment_was_successful.connect(payment_successful_handler)
Exemplo n.º 40
0
    if not valid:
        subject, from_email = 'DA admin - Paypal subscription error', 'Directo al Artista <*****@*****.**>'
        message = render_to_string('email/paypal_subs_error.html', {
            'trans': trans,
            'object': ipn_obj.item_name,
        })

        html_content = render_to_string(
            'email/global/template.html', {
                'email_title': 'DA admin - Paypal subscription error',
                'email_content': message,
            })

        html_content = transform(html_content)
        text_content = strip_tags(html_content)

        msg = EmailMultiAlternatives(subject, text_content, from_email,
                                     ['*****@*****.**'])
        msg.attach_alternative(html_content, "text/html")
        msg.send(fail_silently=True)

    return valid


payment_was_successful.connect(payment_success)
payment_was_flagged.connect(payment_success_flagged)
payment_was_refunded.connect(paypal_refund_payment)

subscription_cancel.connect(paypal_subscription_canceled)
subscription_signup.connect(paypal_validate_plan_signup)
subscription_eot.connect(paypal_subscription_eot)
Exemplo n.º 41
0
    # someone's account.
    points = ipn_obj.mc_gross * 100
    if points <= 0 or points != int(points) or not points.is_finite(): 
        kwargs['err_on_success'] = \
                "comment points are less than 0, or there are some decimal points."
        return process_err_ipn_signal(sender, **kwargs)


    userprofile.comment_points += int(points)
    userprofile.save()

    import sys
    print >>sys.stderr, "Received payment, for " + str(ipn_obj.mc_gross) + \
            " from " + unicode(ipn_obj.custom)

payment_was_successful.connect(process_successful_ipn_signal)


def process_err_ipn_signal(sender, **kwargs):
    """
    Process an error in a Paypal payment.
    Send an email with error reporting stuff.
    """
    ipn_obj = sender

    import sys
    print >>sys.stderr, "Payment error, ipn id " + str(ipn_obj.id)


    # if err_on_success is in kwargs, that means the payment was otherwise 
    # successful, but there was an error in the things process_successful_ipn_signal
Exemplo n.º 42
0
            "invoice": out_trade_no, # 本站订单号
            "notify_url": "%s%s" % (settings.SITE_URL, '/paypal/ipn_pengzhao/'),
            "return_url": "%s/usercenter/" % settings.SITE_URL,
            "currency_code":"USD", # 人民币CNY,美元USD
            "charset":"utf-8",
            }

    paypal_form = PayPalPaymentsForm(initial=paypal_dict)
    submit_js = "<script>document.forms['paypalsubmit'].submit()</script>"
    return render(request,'usercenter/checkout.html',
                  {'content':paypal_form.render(),'submit_js':submit_js})
# 支付成功的回调函数
def do_business(sender, **kwargs):
    baseutil.well_print('ipn received')
    ipn_obj = sender
    out_trade_no = ipn_obj.invoice # 本站订单号
    total_fee = ipn_obj.mc_gross
    trade = get_object_or_404(Transaction,out_trade_no=out_trade_no)
    # send mail to admin
    mail_content = u"Bluessh有新用户付款成功,用户名为 %s, 付款金额为 $%s"\
                    % (trade.user.username,total_fee)
    mail_admins(u"Bluessh有新用户付款成功",
                mail_content,
                fail_silently=True)
    #创建账单对应的ssh帐号,并保存到UserProduct
    baseutil.well_print("username:%s, total_fee:%s" % (trade.user.username,total_fee))
    create_ssh_user(trade)
# connect signal
payment_was_successful.connect(do_business)

Exemplo n.º 43
0
    salt = sha.new(str(random.random())).hexdigest()[:5]
    confirmation_key = sha.new(salt+user.email).hexdigest()
    return confirmation_key


def get_confirmation_key_expiration():
    key_expires = datetime.datetime.utcnow().replace(tzinfo=timezone.utc) + datetime.timedelta(7)
    return key_expires


# Signal handler                                                                                                                               
def verify_and_process_payment(sender, **kwargs):
    ipn_obj = sender
    invoice = ipn_obj.invoice
    acknowledge_payment_received(invoice)
payment_was_successful.connect(verify_and_process_payment)


def acknowledge_payment_received(invoice):
    try:
        order = models.ManuscriptOrder.objects.get(invoice_id=invoice)
    except models.ManuscriptOrder.DoesNotExist:
        raise Exception('Invalid invoice id #%s' % invoice)
    order.is_payment_complete = True
    order.order_received_now()
    order.save()
    user = order.customer
    email_subject = _('Thank you! Your order to Science Writing Experts is complete')
    t = loader.get_template('payment_received.txt')
    t_html = loader.get_template('payment_received.html')
    c = Context(
Exemplo n.º 44
0
from paypal.standard.models import ST_PP_COMPLETED
from django.contrib.auth.models import User
import donomo.billing.models

import os
import logging
logging = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0])


def on_payment_successful(sender, **kwargs):
    logging.info('payment complete : %s status=%s' %
                 (kwargs, sender.payment_status))
    invoice = donomo.billing.models.Invoice.objects.get(pk=sender.invoice)
    account = donomo.billing.models.Account.objects.get_or_create(
        owner=invoice.owner, defaults={'balance': 0})[0]
    if sender.payment_status == ST_PP_COMPLETED:
        # TODO pass purchase plan code via the payment object instead of
        # having refill_account figure it out based on the gross amount
        donomo.billing.models.refill_account(account, float(sender.mc_gross))


payment_was_successful.connect(on_payment_successful)


def on_payment_flagged(sender, **kwargs):
    logging.info('payment flagged : %s flag=%s, payment_status=%s' %
                 (kwargs, sender.flag, sender.payment_status))


payment_was_flagged.connect(on_payment_flagged)
Exemplo n.º 45
0
    send_confirmation_email(purchase)
purchase_paid.connect(send_mail_on_paiement)

# ~~~ Payment handling
class IPNHandler(object):
    import logging
    log = logging.getLogger("IPN handler")

    def __init__(self, sender=None, **kwargs):
        self.ERROR = None
        self.ipn = sender
        purchase = TicketPurchase.objects.get( invoice_id = self.ipn.invoice)
        if self.ipn.test_ipn:
          return
        #assert not purchase.paid, "This ticket is already marked as paid..."
        assert self.ipn.payment_status == "Completed", \
            "Payment status is " + self.ipn.payment_status
        assert purchase.price() <= self.ipn.mc_gross, "Wrong amount: %f instead of %d" % (self.ipn.mc_gross, purchase.price())
        purchase.mark_as_paid()
        self.log.info("TicketPurchase %i paid with paypal" % purchase.pk )

payment_was_successful.connect(IPNHandler)

def alert_flagged_payment(sender,**kwargs):
    mail_admins("Flagged IPN",
      "Paypal IPN has been flagged.\n" + \
      "https://tickets.fscons.org/admin/ipn/paypalipn/%d/\n" % sender.pk + \
      "https://tickets.fscons.org/admin/ticketapp/ticketpurchase/?q=%s\n" % sender.invoice
      )
payment_was_flagged.connect(alert_flagged_payment)
Exemplo n.º 46
0
        }

    @property
    def service_url(self):
        if self.test_mode:
            return SANDBOX_POSTBACK_ENDPOINT
        return POSTBACK_ENDPOINT

    def get_urls(self):
        urlpatterns = patterns(
            '',
            (r'^', include('paypal.standard.ipn.urls')),
        )
        return urlpatterns


def unsuccessful_txn_handler(sender, **kwargs):
    transaction_was_unsuccessful.send(sender=sender.__class__,
                                      type="purchase",
                                      response=None)


def successful_txn_handler(sender, **kwargs):
    transaction_was_successful.send(sender=sender.__class__,
                                    type="purchase",
                                    response=None)


payment_was_flagged.connect(unsuccessful_txn_handler)
payment_was_successful.connect(successful_txn_handler)
Exemplo n.º 47
0
    """ Information about service delivery """
    name = models.CharField(max_length=50)
    price = models.DecimalField(max_digits=5,
                                decimal_places=2)
    time = models.TimeField()

    def get_service_for_user(self):
        return self.objects.all()


class State(models.Model):
    name = models.CharField(max_length=50)

    def __unicode__(self):
        return "".join(self.name)


def paypall_success(sender, **kwargs):
    new_hash = Order.generate_hash(sender.item_number, sender.mc_gross)
    try:
        order = Order.objects.get(id=sender.item_number)
        old_hash = Order.generate_hash(order.id, order.get_total_price_with_shiping())
        if old_hash == new_hash:
            order.confirm()
        else:
            print 'error'
    except Order.DoesNotExist:
        pass

payment_was_successful.connect(paypall_success)
Exemplo n.º 48
0
    #logging.debug(ipn_obj.mc_gross)


    amt = float(ipn_obj.mc_gross)

    if amt == 10.0:
        credit_amt = 10.0
    elif amt == 25.0:
        credit_amt = 27.0
    elif amt == 50.0:
        credit_amt = 55.0
    elif amt == 100.0:
        credit_amt = 115.0
    elif amt == 500.0:
        credit_amt = 600.0
    elif amt == 1.0:
        credit_amt = 28.0

    company = Company.objects.get(slug=ipn_obj.custom)

    new_credit = InvoiceHistory(company=company,
                         credit_added=credit_amt,
                         )
    new_credit.save()

    # Actuall add credit to company
    credit_obj = Credit.objects.get(company=company)
    credit_obj.credit_left = credit_obj.credit_left + float(credit_amt)
    credit_obj.save()
payment_was_successful.connect(notify_credit)
Exemplo n.º 49
0
    ipn_obj = sender    
    if ipn_obj:        
        order = None
        if ipn_obj.payment_status == ST_PP_COMPLETED:
            order = mark_payment(ipn_obj, PAYMENT_FLAGGED)
        else:
            order = mark_payment(ipn_obj, PAYMENT_FAILED)    
        if order is not None:
            transaction, created = PayPalOrderTransaction.objects.get_or_create(order=order)
            transaction.ipn.add(ipn_obj)
            transaction.save()
        else:
            logging.warning("unsuccessful ipn payment, no order found for uuid %s"%ipn_obj.custom)
    else:
        logging.warning("unsuccessful ipn payment signal with no ipn object")

def successful_pdt(sender, **kwargs):    
    logging.info("successful pdt payment")
    pdt_obj = sender    
    order = mark_payment(pdt_obj, True)
    
def unsuccesful_pdt(sender, **kwargs):
    logging.info("unsuccessful pdt payment")
    pdt_obj = sender
    order = mark_payment(pdt_obj, False)    
    
payment_was_successful.connect(successful_payment, dispatch_uid="Order.ipn_successful")
payment_was_flagged.connect(unsuccessful_payment, dispatch_uid="Order.ipn_unsuccessful")
pdt_successful.connect(successful_pdt, dispatch_uid="Order.pdt_successful")
pdt_failed.connect(unsuccesful_pdt, dispatch_uid="Order.pdt_unsuccessful")
    
Exemplo n.º 50
0
from paypal.standard.ipn.signals    import payment_was_successful, payment_was_flagged
from paypal.standard.models         import ST_PP_COMPLETED
from django.contrib.auth.models     import User
import donomo.billing.models

import os
import logging
logging = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0])


def on_payment_successful(sender, **kwargs):
    logging.info('payment complete : %s status=%s' % (kwargs, sender.payment_status))
    invoice = donomo.billing.models.Invoice.objects.get(pk = sender.invoice)
    account = donomo.billing.models.Account.objects.get_or_create(owner = invoice.owner, defaults={'balance' : 0})[0]
    if sender.payment_status == ST_PP_COMPLETED:
        # TODO pass purchase plan code via the payment object instead of
        # having refill_account figure it out based on the gross amount
        donomo.billing.models.refill_account(account, float(sender.mc_gross))

payment_was_successful.connect(on_payment_successful)


def on_payment_flagged(sender, **kwargs):
    logging.info('payment flagged : %s flag=%s, payment_status=%s' % (kwargs, sender.flag, sender.payment_status))
payment_was_flagged.connect(on_payment_flagged)
Exemplo n.º 51
0
        return POSTBACK_ENDPOINT

    def get_urls(self):
        urlpatterns = patterns('',
           (r'^', include('paypal.standard.ipn.urls')),
            )
        return urlpatterns

    def form_class(self):
        if self.encrypted:
            return PayPalEncryptedPaymentsForm
        return PayPalPaymentsForm

    def generate_form(self):
        return self.form_class()(initial=self.fields)


def unsuccessful_txn_handler(sender, **kwargs):
    transaction_was_unsuccessful.send(sender=sender.__class__,
                                      type="purchase",
                                      response=sender)


def successful_txn_handler(sender, **kwargs):
    transaction_was_successful.send(sender=sender.__class__,
                                    type="purchase",
                                    response=sender)

payment_was_flagged.connect(unsuccessful_txn_handler)
payment_was_successful.connect(successful_txn_handler)
Exemplo n.º 52
0
    (profile, created) = UserProfile.objects.get_or_create(paypal_id=ipn_obj.payer_id)
    profile.paypal_email = ipn_obj.payer_email
    payment_date = ipn_obj.payment_date
    if created:
        profile.first_name = ipn_obj.first_name
        profile.last_name = ipn_obj.last_name
        start_date = datetime.date(payment_date.year, payment_date.month, payment_date.day)
        profile.member_since = start_date
    end_date = datetime.date(payment_date.year, (payment_date.month + 1) % 12, payment_date.day)
    if payment_date.month == 12:
        end_date = end_date.replace(year=payment_date.year + 1)
    profile.member_until = end_date
    profile.save()


payment_was_successful.connect(paypal_to_profile, dispatch_uid="paypal_to_profile_unique_string")


def email_admins(sender, **kwargs):
    send_mail(
        "[psone] flagged payment",
        "A payment was flagged, go investigate.  http://psone-manager.herokuapp.com/admin/",
        "*****@*****.**",
        [a[1] for a in settings.ADMINS],
        fail_silently=False,
    )


payment_was_flagged.connect(email_admins, dispatch_uid="email_admins_unique_string")

from paypal.standard.ipn.signals import payment_was_successful
import logging

def show_me_the_money(sender, **kwargs):
  log = logging.getLogger("dev.ttagit.logger")
  log.debug("SIGNAL!!!!!---Successful Payment")

payment_was_successful.connect(show_me_the_money)
Exemplo n.º 54
0
    ipn_obj = sender
    # Undertake some action depending upon `ipn_obj`.

    try:
        book_copy = Book_Copy.objects.get(pk=ipn_obj.custom)
        book_copy.sold = True
        book_copy.save()
    except Book_Copy.DoesNotExist:
        pass

    mail_managers(
        "Book sold", "Book copy with id: %d has sold.\n IPN id: %d" %
        (book_copy.id, ipn_obj.id))


payment_was_successful.connect(book_copy_just_sold)


def book_copy_sale_flagged(sender, **kwargs):
    ipn_obj = sender
    mail_managers(
        "Book payment flagged.",
        "A book payment has been flagged.\n IPN id: %d." % ipn_obj.id)


payment_was_flagged.connect(book_copy_sale_flagged)


class Author(models.Model):
    name = models.CharField(max_length=100)