stevec
stevec

Reputation: 52208

Create a connected user with payouts_enabled in test mode?

Suppose we wish to perform a simple manual test of stripe connect in an app:

  1. Create a regular user
  2. Create a connected user
  3. regular user pays connected user

The problem is, unless payouts_enabled is true in step 2, then we'll always get an error when the regular user tries to pay the connected user.

Also, the way to get details_submitted is true, is by going through the browser and entering dummy info, but the problem is the test suite doesn't simply allow test info to pass - you have to enter things like social security number, street address etc manually, and it inevitably doesn't pass Stripe's standards, so details_submitted can be true, but payouts_enabled inevitably remains false

Question

I need a way to create a connected user with payouts_enabled in test mode. How can I do this?

Note

I hope there may be two possibilities to achieve this:

  1. programatically using some ruby code in the Stripe gem to generate a connected user with payouts_enabled == true
  2. through the browser (i.e. by knowing the values for address, social security number, phone number that will pass Stripe's checks and ensure payouts_enabled == true

Upvotes: 1

Views: 835

Answers (1)

stevec
stevec

Reputation: 52208

This took 2 hours' over customer support to figure out. Would love to know to know how to do this with code (will update if I figure that out). Here's how to do it via the UI:

Start by creating an account (this part uses code):


require 'stripe'

# use this if stripe test key is in credentials.yml....
# Stripe.api_key = Rails.application.credentials[Rails.env.to_sym][:stripe][:test_api_key]

# ....otherwise simply use this:
Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

account = Stripe::Account.create({
  type: 'express',
  country: 'US',
  requested_capabilities: ['card_payments', 'transfers']
})

Since Stripe docs don't contain a full set of connected user info, don't enter random values, as there's a very high chance it won't approve something you enter (e.g. an invalid address, phone number, social security number etc etc). Use these instead:

  • Email: use something really random or else a real person will get a stripe test email [email protected]
  • Business type: Individual
  • Phone: (US) 0000000000
  • Legal name: Use anything here
  • DOB: Anything
  • Address - this is fussy. Here's one that works:
  • Address line 1: 777 Brockton Avenue
  • Address line 2: Leave this field empty
  • City: Abington
  • State: Massachusetts
  • ZIP: 02351
  • Last four digits of social security: 0000

Now the connected account can receive a payment intent like so

    payment_intent = Stripe::PaymentIntent.create({
      payment_method_types: ['card'],
      amount: @amount_minor_unit, # e.g. 1000 for $10
      currency: @currency, # e.g. "USD"
      application_fee_amount: 123, 
      transfer_data: {
        destination: @user.stripe_account,
      },
    })

Upvotes: 1

Related Questions