diff --git a/connection/connections/plaid_client.py b/connection/connections/plaid_client.py index c0a4156..8180564 100755 --- a/connection/connections/plaid_client.py +++ b/connection/connections/plaid_client.py @@ -43,7 +43,8 @@ class Connection(AbstractConnectionClient): secret=self.PLAID_SECRET, environment=self.PLAID_ENV, api_version='2019-05-29', - webhook='https://qrtr-services.herokuapp.com/connection/plaid-webhook/') + #webhook='https://qrtr-services.herokuapp.com/connection/plaid-webhook/' + ) public_key = self.credentials.get('public_token') auth_token = self.credentials.get('auth_token') if not auth_token and public_key: diff --git a/connection/models.py b/connection/models.py index 2bcd675..a6ea341 100644 --- a/connection/models.py +++ b/connection/models.py @@ -1,6 +1,7 @@ from django.db import models import jsonfield from qrtr_account.models import Account +import importlib class ConnectionType(models.Model): @@ -20,5 +21,11 @@ class Connection(models.Model): credentials = jsonfield.JSONField() account = models.ForeignKey(Account, on_delete=models.CASCADE) + def connect(self): + conn_lib = importlib.import_module("connection.connections." + f"{self.type.filename}") + conn = conn_lib.Connection(self.credentials) + return conn + def __str__(self): - return f"{self.name}" + return f"{self.name}" \ No newline at end of file diff --git a/connection/tasks.py b/connection/tasks.py new file mode 100644 index 0000000..2c09315 --- /dev/null +++ b/connection/tasks.py @@ -0,0 +1,4 @@ +from qrtr_account.models import Transaction +from connection.models import Connection + + diff --git a/connection/views.py b/connection/views.py index 70a5941..a0970a7 100644 --- a/connection/views.py +++ b/connection/views.py @@ -70,8 +70,9 @@ class ConnectionViewSet(viewsets.ModelViewSet): except ValueError: return Response(status=status.HTTP_503, data="ERROR: Invalid public_token") - except Exception: - return Response(status=status.HTTP_500, + except Exception as e: + print(e) + return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR, data="ERROR: Unable to contact Plaid") with transaction.atomic(): conn, created = Connection.objects \