Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transactions via Stripe Connect

I am trying to setup the following with Stripe:

  • A master account
  • Multiple sub-accounts (i.e. connected to the Master account via Stripe Connect app)
  • Enable payments to be made to a sub-account, with a percentage fee taken by the Master account per transaction.

I have created a Master account, and a sub account. I have connected the sub account to the Master account via Stripe Connect. I received and stored an access_token and a refresh_token at the end of the Stripe Connect process.

When payments are made, one payment can cover multiple items. I have the following code (PHP) to process the payment:

Stripe_Charge::create(array(
    "amount" => $amt,
    "currency" => "EUR",
    "source" => $stripeCardToken,
    "description" => $description),
    "application_fee_percent" => 0.5
),
    $stripeAccessToken
);

This is placed in a loop, for every item being paid for. It is also in a try / catch block with multiple Stripe exception catches. However, this method fails without any error being thrown.

Is this the correct class method to use? Is the 'source' field for the credit card token? Is there a way of tracking amounts paid against multiple items without using a loop? Is the $stripeAccessToken the sub-account's access_token returned from the Connect process, or the refresh_token? Or is it the Master Account Publishable / Secret key? Or something else? Can I use this format for the $stripeAccessToken, or do I have to instead use Stripe::setApiKey($stripeAccessToken) before the loop?

Both Master and sub-account are currently using the Test environment and a fake card, but I would like to test live transactions also.

like image 805
Eamonn Avatar asked Mar 12 '15 13:03

Eamonn


People also ask

What is Stripe Connect payment method?

Stripe Connect is the fastest and easiest way to integrate payments into your software platform or marketplace. Our set of programmable APIs and tools allows you to build and scale end-to-end payment experiences from instant onboarding to global payouts—all while having Stripe handle payments KYC.

What is a transaction from Stripe?

Any use of an issued card that results in funds entering or leaving your Stripe account, such as a completed purchase or refund, is represented by an Issuing Transaction object.

What are the 3 Stripe Connect account types?

Stripe Connect offers 3 types of accounts for marketplace platforms: Standard, Custom, and Express. Standard accounts take the least effort to integrate and administrate. There are also no platform fees.

What is a connected Stripe account?

When using Connect, you must create an account (known as a connected account) for each user that receives money on your platform. You create these accounts every time a user signs up for your platform.


1 Answers

The first issue here is that you are trying to reuse a card token but those are one-time use so once you create a charge with a card token you can't create a new one.

If you want to charge your customer and split the payments between multiple sellers, you would need to use shared customers. This is the flow you would need to follow in your case:

  • Create a card token for your customer's card details with your publishable API key
  • Create a customer in your stripe account with your secret key.
  • For each of your sellers, you need to create a token for the customer that you then use to create a charge in your sellers accounts. You would have to create separate charges here for each seller but you don't have to ask your customer for his card details multiple times.

In case I misunderstood and all items would come from the same seller you wouldn't need to do all this and you'd need to follow this flow:

  • Create a card token for your customer's card details with their publishable API key that you got during the Connect flow.
  • Create a customer in their stripe account with their access_token that you got during the Connect flow, passed as the second parameter to the API call.
  • Create a charge for the total amount of the items the customer bought passing the customer id you got at the previous step and the access_token as a second parameter again.
like image 108
koopajah Avatar answered Oct 27 '22 06:10

koopajah