Stripe verification failure

Hi there,

We had a little trouble with corruption in the people table, so I went through and deleted some people directly from the database. Unfortunately that’s somehow broken access to stripe verification at the username/payments address. It was completely functional before I did the delete.

Is there somewhere else in the database I missed that I need to clear out too?

Thanks!

Ouch, deleting from database is indeed a source of errors and challenges…

That’s quite difficult, as now there are probably lots of data in different places in the database that are not linked to people anymore. Good to clean up everything and review things to avoid future errors.

Have you removed the relevant data from stripe_accounts already? That might be a good way to get started.

Oh yes!

I’ve done stripe_accounts, and conversations (which fixed my inbox 500 errors). It seems to be with stripe verification - is there another table where that information is linked? Even the people who exist (and were verified) from before the delete are seeing the 500 page error on /payments/

{"method":"GET","path":"/en/georgetesttest/settings/payments","format":"html","controller":"PaymentSettingsController","action":"index","status":500,"error":"ActionView::Template::Error: no implicit conversion of nil into String","duration":91.67,"view":0.0,"db":10.82,"params":{"locale":"en","person_id":"georgetesttest"},"host":"dignityplatform.org","community_id":1,"current_user_id":"0Neh0IVm_3aPrYiJAp3eGA","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36","referer":"https://dignityplatform.org/en/georgetesttest/settings","forwarded_for":"217.138.129.44","request_uuid":"d0f4c8d7-c824-437b-b753-8a63ba2cac3f"}
  
ActionView::Template::Error (no implicit conversion of nil into String):
    89: 
    90:               = button_tag t('stripe_accounts.form_new.save_details')
    91: 
    92: - stripe_data = stripe_default_data2.dup
    93: - stripe_data = stripe_data.merge(update: true) if presenter.stripe_account_ready
    94: - content_for :extra_javascript do
    95:   :javascript
  
app/services/transaction_service/store/payment_settings.rb:194:in `digest'
app/services/transaction_service/store/payment_settings.rb:194:in `decrypt_value'
app/services/stripe_service/api/stripe_api_wrapper.rb:12:in `configure_payment_for'
app/services/stripe_service/api/stripe_api_wrapper.rb:24:in `block in with_stripe_payment_config'
app/services/stripe_service/api/stripe_api_wrapper.rb:22:in `synchronize'
app/services/stripe_service/api/stripe_api_wrapper.rb:22:in `with_stripe_payment_config'
app/services/stripe_service/api/stripe_api_wrapper.rb:290:in `test_mode?'
app/helpers/payments_helper.rb:113:in `stripe_default_data2'
app/views/payment_settings/_stripe_wizard.haml:92:in `_app_views_payment_settings__stripe_wizard_haml__2575710645293337204_91907280'
app/views/payment_settings/index.haml:64:in `_app_views_payment_settings_index_haml___315272285990892501_91185020'
lib/rack_middleware/session_context_middleware.rb:15:in `call'
lib/rack_middleware/marketplace_lookup.rb:33:in `call'
lib/rack_middleware/custom_cookie_renamer.rb:11:in `call'
lib/rack_middleware/enforce_ssl.rb:23:in `call'
lib/rack_middleware/health_check.rb:12:in `call'
{"method":"GET","path":"/500","format":"html","controller":"ErrorsController","action":"server_error","status":500,"duration":6.19,"view":1.98,"db":0.07,"params":{"locale":"en","person_id":"georgetesttest"},"host":null,"community_id":null,"current_user_id":null,"user_agent":null,"referer":null,"forwarded_for":null,"request_uuid":null}

Here’s the error in the logs, for reference!

Same problem here, resulting (presumably) from deleting a user from the database.

Solved it by regenerating the payment_setting/api_private_key in the database. This is generated from the app_encryption_key in the configuration, modified by arcane magicks before finding itself in the db.

To regenerate the key:

  1. Find payment_setting in the database
  2. Delete the following fields:
    api_private_key, api_publishable_key,api_verified,api_visible_public_key
  3. Change the app_encryption_key arbitrarily. It’s likely in config/config.defaults.yml
  4. Restart the http server (e.g., Puma, Unicorn)
  5. Navigate to /en/admin/payment_preferences in your browser
  6. Reenter your Stripe keys
  7. Test the users’ payment settings

In a live site, this could break payment settings. It’s also possible I didn’t need to clear every field or change the configuration secret key. Lots of possibilities, but this worked for me.