summaryrefslogtreecommitdiff
path: root/postgresqleu/confreg/invoicehandler.py
diff options
context:
space:
mode:
authorMagnus Hagander2015-07-07 15:52:34 +0000
committerMagnus Hagander2015-07-08 10:49:29 +0000
commit6d75b4911982308059f85ab5071f0fbbf3b31d6c (patch)
treecca53fc8e974505fd60d3fc66e1ea721bbccb136 /postgresqleu/confreg/invoicehandler.py
parent2eeebf4c67ffd4b64630d16e7f6bb4b3fb8237be (diff)
Add ability to post-order additional options
Also update the registration dashboard to show some interesting details about the registration, instead of just a placeholder. This makes it possible to order things like training even if the main registration has completed, to help people who change their mind. This will also automatically upgrade the reservation to one that is required by the options, if necessary. If the upgraded registration type is more expensive than the current one, automatically add the cost difference to the invoice. To control this, implement the option "upsellable" for each additional option, without which an option cannot be added, and an option "upsell_target" on a registration type, without which a registration cannot be changed to that type.
Diffstat (limited to 'postgresqleu/confreg/invoicehandler.py')
-rw-r--r--postgresqleu/confreg/invoicehandler.py53
1 files changed, 52 insertions, 1 deletions
diff --git a/postgresqleu/confreg/invoicehandler.py b/postgresqleu/confreg/invoicehandler.py
index c8db9910..210c5bc5 100644
--- a/postgresqleu/confreg/invoicehandler.py
+++ b/postgresqleu/confreg/invoicehandler.py
@@ -1,6 +1,6 @@
from django.conf import settings
-from models import ConferenceRegistration, BulkPayment
+from models import ConferenceRegistration, BulkPayment, PendingAdditionalOrder
from util import notify_reg_confirmed
from datetime import datetime
@@ -166,3 +166,54 @@ class BulkInvoiceProcessor(object):
except ConferenceRegistration.DoesNotExist:
raise Exception("Could not find bulk payment %s" % invoice.processor)
return "%s/events/bulkpay/%s/%s/" % (settings.SITEBASE_SSL, bp.conference.urlname, invoice.processorid)
+
+
+
+class AddonInvoiceProcessor(object):
+ # Process invoices for additional options added to an existing
+ # registration.
+ #
+ # Since we lock the registration when the invoice is generated,
+ # we don't actually need to verify that nothing has changed.
+ #
+ # All modifications are already wrapped in a django transaction
+ def process_invoice_payment(self, invoice):
+ try:
+ order = PendingAdditionalOrder.objects.get(pk=invoice.processorid)
+ except PendingAdditionalOrder.DoesNotExist:
+ raise Exception("Could not find additional options order %s!" % invoice.processorid)
+
+ if order.payconfirmedat:
+ raise Exception("Additional options already paid")
+
+ order.payconfirmedat = datetime.today()
+ if order.newregtype:
+ order.reg.regtype = order.newregtype
+
+ for o in order.options.all():
+ order.reg.additionaloptions.add(o)
+
+ order.reg.save()
+ order.save()
+
+ def process_invoice_cancellation(self, invoice):
+ try:
+ order = PendingAdditionalOrder.objects.get(pk=invoice.processorid)
+ except PendingAdditionalOrder.DoesNotExist:
+ raise Exception("Could not find additional options order %s!" % invoice.processorid)
+
+ # We just remove the entry completely, as there is no "unlocking"
+ # here.
+ order.delete()
+
+ def process_invoice_refund(self, invoice):
+ raise Exception("Don't know how to process refunds for this!")
+
+ # Return the user to their dashboard
+ def get_return_url(self, invoice):
+ try:
+ order = PendingAdditionalOrder.objects.get(pk=invoice.processorid)
+ except PendingAdditionalOrder.DoesNotExist:
+ raise Exception("Could not find additional options order %s!" % invoice.processorid)
+
+ return "%s/events/register/%s/" % (settings.SITEBASE_SSL, order.reg.conference.urlname)