summaryrefslogtreecommitdiff
path: root/postgresqleu/transferwise/models.py
diff options
context:
space:
mode:
authorMagnus Hagander2019-03-27 14:40:33 +0000
committerMagnus Hagander2019-03-27 14:46:19 +0000
commitd59eb7566d27cbf7b19095f1d1afcec154304412 (patch)
treebd3d69494aae2eb28a5fdf2edbdbfa232521bcff /postgresqleu/transferwise/models.py
parent034c89afde2cb7625fa0ae71fac6c7c60524ed48 (diff)
Add payment provider for TransferWise
This uses the TransferWise REST API to get access to an IBAN account, allowing "traditional" bank paid invoices to be reasonably automated. The provider integrates with the "managed bank transfer" system, thereby handling automated payments using the payment reference. Since this reference is created by us it can be printed on the invoice, making it easier to deal with in traditional corporate environments. Payments that are incorrect in either amount or payment reference will now also show up in the regular "pending bank transactions" view and can be processed manually as necessary. For most SEPA transfers, TransferWise will be able to provide the IBAN number to the sending account. When this is the case, the provider also supports refunds, that will be issued as general IBAN transfers to tihs account. Note that refunds requires the API token to have "full access" as it's permissions in the TW system, meaning it can make arbitrary transfers of any funds. There is no way to specifically tie it to just refunds, as these are just transfers and not payments.
Diffstat (limited to 'postgresqleu/transferwise/models.py')
-rw-r--r--postgresqleu/transferwise/models.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/postgresqleu/transferwise/models.py b/postgresqleu/transferwise/models.py
new file mode 100644
index 00000000..8569f033
--- /dev/null
+++ b/postgresqleu/transferwise/models.py
@@ -0,0 +1,38 @@
+from django.db import models
+
+from postgresqleu.invoices.models import InvoicePaymentMethod
+
+
+class TransferwiseTransaction(models.Model):
+ paymentmethod = models.ForeignKey(InvoicePaymentMethod, blank=False, null=False)
+ twreference = models.CharField(max_length=100, blank=False, null=False)
+ datetime = models.DateTimeField(null=False, blank=False)
+ amount = models.DecimalField(decimal_places=2, max_digits=20, null=False)
+ feeamount = models.DecimalField(decimal_places=2, max_digits=20, null=False)
+ transtype = models.CharField(max_length=32, blank=False, null=False)
+ paymentref = models.CharField(max_length=200, blank=True, null=False)
+ fulldescription = models.CharField(max_length=500, blank=True, null=False)
+ counterpart_name = models.CharField(max_length=100, blank=True, null=False)
+ counterpart_account = models.CharField(max_length=100, blank=True, null=False)
+ counterpart_valid_iban = models.BooleanField(null=False, default=False)
+
+ class Meta:
+ unique_together = (
+ ('twreference', 'paymentmethod'),
+ )
+ ordering = ('-datetime', )
+
+ def __str__(self):
+ return self.twreference
+
+
+class TransferwiseRefund(models.Model):
+ origtransaction = models.ForeignKey(TransferwiseTransaction, blank=False, null=False, related_name='refund_orig')
+ refundtransaction = models.OneToOneField(TransferwiseTransaction, blank=True, null=True, related_name='refund_refund', unique=True)
+ refundid = models.BigIntegerField(null=False, unique=True)
+ uuid = models.UUIDField(blank=False, null=False, unique=True)
+ transferid = models.BigIntegerField(null=False, unique=True)
+ accid = models.BigIntegerField(null=True)
+ quoteid = models.BigIntegerField(null=True)
+ createdat = models.DateTimeField(null=False, blank=False, auto_now_add=True)
+ completedat = models.DateTimeField(null=True, blank=True)