From f2e887804099c6cff945503a87b23c9b86967697 Mon Sep 17 00:00:00 2001 From: jdungan Date: Fri, 21 Oct 2016 12:03:52 -0500 Subject: [PATCH] check with stripe for identity verification --- payments/management/commands/check_validation.py | 7 +++++-- payments/models.py | 13 +++++++++++++ payments/views.py | 5 +++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/payments/management/commands/check_validation.py b/payments/management/commands/check_validation.py index 81770ed8..f1f732d0 100644 --- a/payments/management/commands/check_validation.py +++ b/payments/management/commands/check_validation.py @@ -15,6 +15,7 @@ email_template = get_template('../templates/email/need_validation.html') + class Command(BaseCommand): def handle(self, *args, **options): @@ -23,10 +24,12 @@ def handle(self, *args, **options): try: stripe_account = stripe.Account.retrieve(account.account_id) if account.verification != stripe_account.verification: - account.verification = json.dumps(stripe_account.verification) + account.verification = json.dumps( + stripe_account.verification) account.save() if stripe_account.verification.fields_needed: - email_context = ({'expiration':stripe_account.verification.due_by}) + email_context = ( + {'expiration': stripe_account.verification.due_by}) message = email_template.render(email_context) send_mail( '[codesy] Account validation needed', diff --git a/payments/models.py b/payments/models.py index ffb2496e..e3fce95e 100644 --- a/payments/models.py +++ b/payments/models.py @@ -28,6 +28,19 @@ class StripeAccount(models.Model): verification = models.TextField(default='', blank=True) def identity_verified(self): + # codesy verification field holds verification requirement from stripe + # identity is verified if verification is blank or due_by is None + + # first, see if an account_id has been assigned by stripe + # and check on verification + if self.account_id: + stripe_account = stripe.Account.retrieve(self.account_id) + self.verification = json.dumps(stripe_account.verification) + self.save() + else: + # returning True will allow the bank account_id to be assigned + return True + if not self.verification: return True else: diff --git a/payments/views.py b/payments/views.py index 61c1a76e..28ecbfbd 100644 --- a/payments/views.py +++ b/payments/views.py @@ -30,7 +30,8 @@ def stripe_debug_values(): 'zip': '74103', 'state': 'OK', 'ssn_last_4': '0000', - 'ssn_full': '000000000' + 'ssn_full': '000000000', + 'business_name': 'Howdy Dammit LLC' }, 'card': { 'cc_number': '4111111111111111', @@ -127,7 +128,7 @@ def post(self, *args, **kwargs): class VerifyIdentityView(TemplateView): template_name = 'verify_identity.html' identity_fields = ('first_name', 'last_name', 'ssn_last_4', - 'personal_id_number', 'type',) + 'personal_id_number', 'type', 'business_name') address_fields = ('line1', 'city', 'postal_code', 'state', ) dob_fields = ('day', 'month', 'year',)