0
votes

I have built a platform with buyers and sellers and now I would like to integrate payments. I came across Stripe, it is quite easy and straight forward to use.

However, I found the documentation to be lacking since I want to implementation whereby the seller doesn't have to create a stripe account in order to get paid by the buyer. What Stripe offers is a solution they call; stripe connect.

Stripe connect has three options; Standard, Express and Custom.

The solution that makes sense for my specific use case is the custom option. From the documentation, they have this code snippet;

    Stripe.api_key = 'STRIPE_SECRET_KEY'

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

The above, they write, is used to create a custom account. Quite frankly, there isn't much to work with. Has anyone developed something that I am trying to implement. Assistance in this regard would really be helpful.

I have implemented Express Stripe connect. This is an helper that I have written;

module ApplicationHelper
  # Express Stripe url
  def stripe_url
    "https://dashboard.stripe.com/express/oauth/authorize?response_type=code&client_id=#{ENV["STRIPE_CONNECT_CLIENT_ID"]}&scope=read_write"
  end

      
  # Express Stripe Implementation
  def stripe_connect_button
    link_to stripe_url, class: "stripe-connect" do
      content_tag :span, "Connect With Stripe"
    end
  end
end

I write <%= stripe_connect_button %> in the .erb file and it rendered properly. I am able to go through the entire process.

I would like to have a somewhat similar approach but for Custom Stripe Connect because with the above implementation, I had to create a stripe account as a seller.

I was able to test the custom stripe account creation using curl based on this

With curl it is like so;

curl https://api.stripe.com/v1/accounts \
  -u STRIPE_SECRET_KEY: \
  -d country=US \
  -d type=custom \
  -d "requested_capabilities[]"=card_payments \
  -d "requested_capabilities[]"=transfers

The above returns json and I copy the id which an account_id. I use this id in another curl request;

curl https://api.stripe.com/v1/account_links \
  -u STRIPE_SECRET_KEY: \
  -d account= #{id} \
  -d refresh_url="https://example.com/reauth" \
  -d return_url="https://example.com/return" \
  -d type=account_onboarding

This returns json that looks like so;

{
  "object": "account_link",
  "created": 1594988541,
  "expires_at": 1594988841,
  "url": "https://connect.stripe.com/setup/c/AUyum7LCw4cV"
}

Then I visit the url: https://connect.stripe.com/setup/c/AUyum7LCw4cV to do the on-boarding. I have successfully been able to create a stripe connect custom account.

However, I want to translate this flow to RubyOnRails.

So, my question is, how do I cause the below code snippet to initiate account creation when a Seller clicks a button (Connect To Stripe) ?

Stripe.api_key = STRIPE_SECRET_KEY

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

In the Express Stripe Connect implementation, I had a url that I was passing to the button. With the above, I have no url to work with.

1
What are you looking for that you can't find? There is documentation for test account verification: stripe.com/docs/connect/testing-verification . And example for creating payments using Connect: stripe.com/docs/connect/destination-charges . What are you trying to do?Nolan H

1 Answers

0
votes

The code you share would create a Custom account on behalf of the seller in the API. This is only the first step before you can accept payments on their behalf and send funds to their bank account.

There are a lot of regulations around the flow of funds and the information you need to collect from the seller and you can't simply send $100 to a bank account in the US without completing those steps. Stripe covers in details all the information that needs to be collected depending on the type of business you are building and the countries you are going to operate in. You can read more about this here: https://stripe.com/docs/connect/required-verification-information

Collecting this information reliably can be fairly tricky early on for a project like yours. Similarly, rules and regulations evolve regularly, requiring you to collect more details for new users, backfill some missing information and do extra reporting.

This is why Stripe built their Connect Onboarding hosted page so that you can defer the collection of all information to them. You can read more about this here: https://stripe.com/connect/onboarding

Using Connect Onboarding is likely to be the best solution for your business as you can easily enable your sellers to provide the relevant information without having to own a Stripe account directly while you focus on the core parts of your own business.