def show_me_the_money(cls, sender: PayPalIPN, **kwargs): from lindy.ticket.models import TicketAddOn try: ipn_obj = sender custom = cls.parse_custom(ipn_obj.custom) # super important do this first Ticket.objects.filter(pk=custom.ticket_id).update(is_pending=True, is_checkout_finalized=True) TicketAddOn.objects.filter(pk__in=custom.addon_ids).update(is_pending=True, is_checkout_finalized=True) ticket = cls.objects.get(pk=custom.ticket_id) logger.info( 'show me the money\n\t--> ipn: %s\n\t--> custom: %s\n\t--> ticket_id: %s\n\t--> custom_id: %s', ipn_obj.id, ipn_obj.custom, ticket.id, custom.ticket_id ) ticket.paypal_ipn_set.add(ipn_obj) if ipn_obj.recurring: ticket.is_subscription = True with as_robot_user(): ticket.is_paid # NOTE: is_paid property scribbles on t._is_paid database value. Just needs to be saved. ticket.save() # Do this last, as it may fail ipn_obj.admin_url = admin_url(ipn_obj) slack_message( 'ticket/ipn.slack', { 'ticket': ticket, 'ipn_obj': ipn_obj, } ) except Exception as e: logger.exception(e)
def admin_url(self): return admin_url(self)