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 %} + +
+
+ + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+ + + +
+
+ + + +
+
+ +{% endblock %} diff --git a/www/bank-account.html.spt b/www/bank-account.html.spt index fd25db87e9..58496fc348 100644 --- a/www/bank-account.html.spt +++ b/www/bank-account.html.spt @@ -1,6 +1,4 @@ -from datetime import datetime - -from gratipay import billing, MONTHS +from gratipay import billing from gratipay.billing.exchanges import MINIMUM_CREDIT [-----------------------------------------------------------------------------] @@ -10,8 +8,9 @@ bank_account = None status = ". . ." if not user.ANON: - balanced_customer_href = user.participant.balanced_customer_href - last_ach_result = user.participant.last_ach_result + participant = user.participant + balanced_customer_href = participant.balanced_customer_href + last_ach_result = participant.last_ach_result status = _("Your bank account is {0}not connected{1}") if balanced_customer_href: @@ -21,8 +20,6 @@ if not user.ANON: account = participant.get_balanced_account() bank_account = billing.BalancedBankAccount(balanced_customer_href) - username = user.participant.username - title = _("Bank Account") [-----------------------------------------------------------------------------] {% extends "templates/base.html" %} @@ -76,90 +73,11 @@ title = _("Bank Account") {% endif %}
+ {% if account and account.merchant_status == 'underwritten' %}
- {% if account and 'merchant' in account.roles %} -

{{ _("Identity Verification") }}  

-

{{ _("Routing Information") }}

- {% endif %} - - - {% if not account or 'merchant' not in account.roles %} -

{{ _("Identity Verification") }}

- -
- - -
- -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- -
- - -
- -
- - -
- -
- - - - -
- -
- -
- - -
- -
- -

{{ _("Routing Information") }}

- {% endif %} -
@@ -180,8 +98,14 @@ title = _("Bank Account")
+ + {% else %} +

{{ + _("You need to verify your identity first") + }}

+ {% endif %} {% if bank_account and bank_account.is_setup %}
diff --git a/www/bank-account.json.spt b/www/bank-account.json.spt index 7b2970dbe5..a88dcdafbd 100644 --- a/www/bank-account.json.spt +++ b/www/bank-account.json.spt @@ -31,33 +31,11 @@ else: balanced_account = participant.get_balanced_account() - # Ensure the user is a merchant. + # Ensure the user is identified. # ============================== - # This will possibly fail with 400 if formatted badly, or 300 if we cannot - # identify the merchant. - out = {} if balanced_account.merchant_status != 'underwritten': - - balanced_account.name = body.get('name') - balanced_account.address['line1'] = body.get('street_address') - balanced_account.address['postal_code'] = body.get('postal_code') - balanced_account.address['state'] = body.get('region') - balanced_account.phone = body.get('phone_number') - balanced_account.dob_month = body.get('dob_month') - balanced_account.dob_year = body.get('dob_year') - balanced_account.meta['dob_day'] = body.get('dob_day') - balanced_account.ssn_last4 = body.get('ssn_last4') - - try: - balanced_account.save() - except balanced.exc.HTTPError as err: - out = {"problem": "Problem", "error": err.message} - - if balanced_account.merchant_status != 'underwritten': - out = { 'problem': 'More Info Needed' - , 'error': 'Unable to verify your identity' - } + out = {'problem': _("You need to verify your identity first.")} # No errors? Great! Let's add the bank account.