stevec
stevec

Reputation: 52528

Logic for handling each permutation of connected user onboarding status?

Apps that onboard stripe connect users need a page that checks the status of a connected user's onboarding in order to correctly display the next steps to that user.

The logic is a little complex, and a little unclear to me, so here's mine, I hope a Stripe rep or experienced Stripe Connect developer can confirm if doing exactly the right thing in each situation, and if the conditionals encapsulate all possibilities? (and if not, please provide the correct ruby (or pseudocode) to ensure the conditional logic is complete so the page can handle for all possibilities)

if details_submitted == false

  # Require user to onboard


elsif details_submitted == true && payouts_enabled == false && number_of_stripe_errors == 0

  # Ask user to wait, as they've done everything they can for now, and onboarding can take 48 hours
  # developer/app should listed to webhook for any change in payouts_enabled (i.e. change to true)


elsif details_submitted == true && number_of_stripe_errors > 0

  # User has attempted to onboard and encountered problems. Display the errors so they can be addressed 


elsif payouts_enabled == true

  # User is ready to go


end

This logic is based on my interpretation of the Stripe Connect documentation (for Express Accounts).

Question

Is the logic above complete and correct? I'm quite unsure about it, particularly about what to do when details_submitted == true && number_of_stripe_errors > 0 - does that mean the user should address the errors, or just wait (since they've submitted their details)?

Note: I'm using ruby, but I hazard a guess that the logic would hold no matter what the language/framework. Open to correction on that.

Upvotes: 0

Views: 88

Answers (2)

stevec
stevec

Reputation: 52528

Answering my own question a few years later :)

Here's what I use (in ruby/pseudo code):

<% if @user.stripe_payouts_enabled %>
  <!-- Stripe payouts are enabled message. -->
<% elsif @user.stripe_requirements_pending %>
  <!-- Link to complete onboarding. -->
<% elsif @user.stripe_details_submitted && [email protected]_requirements_pending %>
  <!-- Details submitted and stripe hasn't requested more info, so can only wait -->
<% elsif @user.stripe_payouts_enabled.nil? && @user.stripe_details_submitted.nil? && @user.stripe_requirements_pending.nil? %>
  <!-- If all three fields are nil (or false) it means the user hasn't started onboarding yet. Show them onboarding url -->
<% end %>

Basically, this requires examining three variables from the account.updated webhook payload (payouts_enabled, requirements_pending, and details_submitted)

Upvotes: 0

hmunoz
hmunoz

Reputation: 3351

It isn't clear to me what number_of_stripe_errors is here.

Typically with Connect, what you want to do is have your Platform listen to the account.updated Connect webhook event.

When you receive this event, look under the requirements.currently_due hash for any verification information that is required from the Connect account.

If there are currently due requirements, that indicates further information is required from the Connect account so they are not in a "done" state and that hash tells you what information is required for the account.

Your payouts_enabled and details_submitted checks looks good, just keep in mind that due to changing states of the Connect account, you still need to keep listening for account.updated events in case further information is required from the Connect account and payouts are disabled until more info is provided.

Upvotes: 1

Related Questions