Transactions Through Stripe Connect

I am trying to customize the following with Stripe:

  • Primary Account
  • Several sub-accounts (i.e. connected to the Master account through the Stripe Connect application)
  • Include payments that must be made to the sub-account, with the interest rate charged to the main account for the transaction.

I created a primary account and a child account. I connected the child account to the master account through Stripe Connect. I received and saved access_token and refresh_token at the end of the Stripe Connect process.

When payments are made, one payment may cover several elements. I have the following code (PHP) for processing a payment:

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

This is put in a loop for each billable item. It is also in a try / catch block with many Stripe exception exceptions. However, this method fails without any error.

Is this the correct class method? Source field for credit card token? Is there a way to track amounts paid against multiple items without using a loop? Is $stripeAccessToken sub-account access_token returned from a Connect or refresh_token process? Or is it the main public / private key? Or something different? Can I use this format for $ stripeAccessToken, or do I need to use Stripe::setApiKey($stripeAccessToken) before the loop?

Both Master and sub-accounts currently use a test environment and a fake card, but I would also like to test direct transactions.

+6
source share
1 answer

The first problem is that you are trying to reuse a map marker, but this is a one-time use, so once you create a board using a card token, you cannot create a new one.

If you want to charge your customer and split payments between several sellers, you will need to use shared customers . This is the thread that you will need to execute in your case:

  • Create a map marker for your customer card data using published API key
  • Create a client in your stripe account with a secret key .
  • For each of your sellers, you need to create a token for the customer, which is then used to create a fee on your sellers accounts. You will need to create separate charges here for each seller, but you do not need to repeatedly ask your client about their cards.

In the event that I misunderstood, and all the items will be received from the same seller, you will not need to do all this, and you will need to follow this stream:

  • Create a map token for your client card data with their published API that you received during the Connect stream.
  • Create a client in your account with a strip with their access_token that you received during the Connect stream passed as the second parameter of the API call.
  • Create a fee for the total number of items purchased by the buyer, using the customer ID obtained in the previous step, and access_token as the second parameter again.
+2
source

Source: https://habr.com/ru/post/983702/


All Articles