Implement handling invoice.payment_succeeded and invoice.payment_failed webhooks

This commit is contained in:
PCoder 2019-04-14 00:58:13 +02:00
commit 8a59c2da1e
3 changed files with 85 additions and 0 deletions

View file

@ -435,6 +435,19 @@ class HostingBillLineItem(AssignPermissionsMixin, models.Model):
('view_hostingbilllineitem', 'View Monthly Hosting Bill Line Item'),
)
def get_vm_id(self):
"""
If VM_ID is set in the metadata extract and return it as integer
other return -1
:return:
"""
if "VM_ID" in self.metadata:
data = json.loads(self.metadata)
return int(data["VM_ID"])
else:
return None
class VMDetail(models.Model):
user = models.ForeignKey(CustomUser)