Skip to content
Snippets Groups Projects

Implement payment backends and interaction

Merged Nik | Klampfradler requested to merge payment-backends into master
Files
7
@@ -33,6 +33,13 @@ class InvoiceGroup(ExtensibleModel):
class Invoice(BasePayment, PureDjangoModel):
VARIANT_DISPLAY = {
"paypal": (_("PayPal"), "logos:paypal"),
"sofort": (_("Klarna / Sofort"), "simple-icons:klarna"),
"pledge": (_("Payment pledge / manual payment"), "mdi:hand-coin"),
"sdd": (_("SEPA Direct Debit"), "mdi:bank-transfer"),
}
group = models.ForeignKey(
InvoiceGroup, verbose_name=_("Invoice group"), related_name="invoices", on_delete=models.SET_NULL, null=True
)
@@ -43,6 +50,12 @@ class Invoice(BasePayment, PureDjangoModel):
for_object_id = models.PositiveIntegerField()
for_object = GenericForeignKey("for_content_type", "for_object_id")
def get_variant_name(self):
return self.__class__.VARIANT_DISPLAY[self.variant][0]
def get_variant_icon(self):
return self.__class__.VARIANT_DISPLAY[self.variant][1]
def get_purchased_items(self):
return self.for_object.get_purchased_items()
@@ -88,7 +101,7 @@ class Invoice(BasePayment, PureDjangoModel):
return TotalsTable(values)
def get_success_url(self):
return reverse("invoice_by_pk", kwargs={"pk": self.pk})
return reverse("invoice_by_token", kwargs={"slug": self.token})
def get_failure_url(self):
return reverse("invoice_by_pk", kwargs={"pk": self.pk})
return reverse("invoice_by_token", kwargs={"slug": self.token})
Loading