def processPayment(self, amount, fees, paidOnline=True, methodName=None, methodTxn=None, submissionUser=None, collectedByUser=None, forceFinalize=False, status=None, notify=None):
epsilon = <NUM_LIT><EOL>paymentTime = timezone.now()<EOL>logger.info('<STR_LIT>')<EOL>paymentHistory = self.data.get('<STR_LIT>',[])<EOL>paymentHistory.append({<EOL>'<STR_LIT>': paymentTime.isoformat(),<EOL>'<STR_LIT>': amount,<EOL>'<STR_LIT>': fees,<EOL>'<STR_LIT>': paidOnline,<EOL>'<STR_LIT>': methodName,<EOL>'<STR_LIT>': methodTxn,<EOL>'<STR_LIT>': getattr(submissionUser,'<STR_LIT:id>',None),<EOL>'<STR_LIT>': getattr(collectedByUser,'<STR_LIT:id>',None),<EOL>})<EOL>self.data['<STR_LIT>'] = paymentHistory<EOL>self.amountPaid += amount<EOL>self.fees += fees<EOL>self.paidOnline = paidOnline<EOL>if submissionUser and not self.submissionUser:<EOL><INDENT>self.submissionUser = submissionUser<EOL><DEDENT>if collectedByUser and not self.collectedByUser:<EOL><INDENT>self.collectedByUser = collectedByUser<EOL><DEDENT>if forceFinalize or abs(self.outstandingBalance) < epsilon:<EOL><INDENT>self.status = status or self.PaymentStatus.paid<EOL>if not self.finalRegistration and self.temporaryRegistration:<EOL><INDENT>self.finalRegistration = self.temporaryRegistration.finalize(dateTime=paymentTime)<EOL><DEDENT>else:<EOL><INDENT>self.sendNotification(invoicePaid=True,thisPaymentAmount=amount,payerEmail=notify)<EOL><DEDENT>self.save()<EOL>if self.finalRegistration:<EOL><INDENT>for eventReg in self.finalRegistration.eventregistration_set.filter(cancelled=False):<EOL><INDENT>this_invoice_item = self.invoiceitem_set.filter(<EOL>temporaryEventRegistration__event=eventReg.event,<EOL>finalEventRegistration__isnull=True<EOL>).first()<EOL>if this_invoice_item:<EOL><INDENT>this_invoice_item.finalEventRegistration = eventReg<EOL>this_invoice_item.save()<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if notify:<EOL><INDENT>self.sendNotification(invoicePaid=True,thisPaymentAmount=amount,payerEmail=notify)<EOL><DEDENT>else:<EOL><INDENT>self.sendNotification(invoicePaid=True,thisPaymentAmount=amount)<EOL><DEDENT>self.save()<EOL><DEDENT>self.allocateFees()<EOL>
When a payment processor makes a successful payment against an invoice, it can call this method
which handles status updates, the creation of a final registration object (if applicable), and
the firing of appropriate registration-related signals.