djaodjin / djaodjin-saas

Django application for software-as-service and subscription businesses
Other
564 stars 124 forks source link

Remove `processor_deposit_*` values before attempting authorization #133

Closed smirolo closed 5 years ago

smirolo commented 6 years ago

If BankAuthorizeView.get is called twice with the same values (ie. reload of page), Stripe automatically disconnects the account. We thus need to clear processor_deposit_key, processor_priv_key, processor_pub_key and processor_refresh_token before attempting to set them otherwise the result is a 500 error due to an inconsistent with Stripe.

AuthenticationError at /billing/cowork/bank/
invalid_grant: This authorization code has already been used. All tokens issued with this code have been revoked.
File "site-packages/saas/views/billing.py" in get
 214.                     self.object, auth_code)
File "site-packages/saas/backends/stripe_processor/base.py" in connect_auth
 228.                 json_body=data)
smirolo commented 5 years ago

Implemented in commit e2654b43 and commit 9bfedf8c