diff --git a/gratipay/main.py b/gratipay/main.py index dc3fdd50f7..d047a2a68b 100644 --- a/gratipay/main.py +++ b/gratipay/main.py @@ -32,9 +32,11 @@ # This is shared via class inheritance with jinja2_htmlescaped. 'b64encode': base64.b64encode, 'enumerate': enumerate, + 'filter': filter, 'filter_profile_subnav': utils.filter_profile_subnav, 'float': float, 'len': len, + 'map': map, 'range': range, 'str': str, 'to_javascript': utils.to_javascript, diff --git a/js/gratipay/payments.js b/js/gratipay/payments.js index af2dd869b9..070b36bace 100644 --- a/js/gratipay/payments.js +++ b/js/gratipay/payments.js @@ -91,31 +91,13 @@ Gratipay.payments.ba.submit = function (e) { routing_number: $('#routing_number').val() }; - Gratipay.payments.ba.merchantData = { - //type: 'person', // Oooh, may need to vary this some day? - street_address: $('#address_1').val(), - postal_code: $('#zip').val(), - phone_number: $('#phone_number').val(), - region: $('#state').val(), - dob_month: $('#dob-month').val(), - dob_year: $('#dob-year').val(), - dob_day: $('#dob-day').val(), - name: $('#name').val() - }; var errors = []; // Require some fields. // ==================== - // We only require fields that are actually on the page. Since we don't - // load the identity verification fields if they're already verified, not - // all of these will necessarily be present at all. var requiredFields = { - name: 'Your legal name is required.', - address_1: 'Your street address is required.', - zip: 'Your ZIP or postal code is required.', - phone_number: 'A phone number is required.', account_name: 'The name on your bank account is required.', account_number: 'Your bank account number is required.', routing_number: 'A routing number is required.' diff --git a/www/%username/identity.spt b/www/%username/identity.spt new file mode 100644 index 0000000000..1ba8422a31 --- /dev/null +++ b/www/%username/identity.spt @@ -0,0 +1,145 @@ +import balanced + +from gratipay.billing.exchanges import repr_exception +from gratipay.utils import get_participant + +[---] +request.allow('GET', 'POST') +participant = get_participant(state, restrict=True) +title = _("Identity Verification") +error = '' + +if request.method == 'POST': + account = participant.get_balanced_account() + + body = request.body + account.name = body.get('name') + account.address['line1'] = body.get('address_1') + account.address['line2'] = body.get('address_2') + account.address['postal_code'] = body.get('postal_code') + account.address['city'] = body.get('city') + account.address['state'] = body.get('region') + account.address['country_code'] = body.get('country') + account.phone = body.get('phone_number') + account.ssn_last4 = body.get('ssn_last4') or None + + dob = body.get('dob', '') + if dob: + try: + account.dob_year, account.dob_month, account.meta['dob_day'] = \ + map(int, dob.split('-')) + except ValueError: + error = _("Invalid date of birth.") + + if not error: + # This will possibly fail with 400 if formatted badly, or 300 if we + # cannot identify the merchant. + try: + account.save() + except balanced.exc.HTTPError as err: + error = repr_exception(err) + else: + if account.merchant_status != 'underwritten': + error = _("Unable to verify your identity") + +elif participant.balanced_customer_href: + account = participant.get_balanced_account() + +else: + account = balanced.Customer() + +[---] text/html +{% extends "templates/base.html" %} + +{% block scripts %} + {{ super() }} + +{% endblock %} + +{% block content %} + +