ivish
ivish

Reputation: 612

Stripe - unable to make a transfer to connected standalone account

We are using Stripe payment gateway in one of the application.

In our model we will have customers and stripe connected accounts. We will charge customers for certain services and then periodically(weekly/monthly etc) transfer share of customer revenues to connected accounts. Connected account holders are sort of business partners.

I am being able to successfully create customers with card and charge them later using Stripe java API. But I am having problems with transferring amount to standalone connected accounts.

I am connecting to standalone accounts by following this link in Stripe documentation.
After connecting to a standalone account i am receiving account's stripe account id, publishable key, token etc in the response that i am storing in database.
Later on while trying to transfer funds to this connected account i am getting an exception.

com.stripe.exception.InvalidRequestException: No such token: pk_test_kXinGPY8H2cyc5vWOQagwkbE;

I am really not sure what should be the value of 'source' parameter when making transfer to connected account. Should it refer to payment earlier charged to the customer? Since there will be more than one payments charged to customers and only one periodic transfer to connected account I am not sure what should be the source.

My sample code is as,

Stripe.apiKey = "platform account's secret key"
Charge charge = null;
Map<String, Object> chargeParams = new HashMap<String, Object>();
chargeParams.put("amount", 200);
chargeParams.put("currency", "usd");
chargeParams.put("source", "pk_test_kXinGPY8H2cyc5vWOQagwkbE"); //{platform accounts public key}
chargeParams.put("destination", ""acct_18gKXJHZfNFseiFv""); //Connected account's id        
charge = Charge.create(chargeParams);   

I just wanted to know if the business scenario described above can be achieved through Stripe gateway. And if yes, someone please point me to any mistakes that i am possibly doing in above sample code. Thanks.

EDIT:

So it seems, under normal circumstances, Stripe does not allow transfer of funds from one Stripe account to other without transfer being directly linked to a customer charge. It allows special case transfers from one Stripe account to other but mandates that volume of such payments can not exceed 10% of your overall transactions.

I our case we just need to pay our sub-merchants their share of revenue periodically and it doesn't necessarily has to be a stripe-to-stripe transfer. we can always register our client as one of the customer in his/her own Stripe platform account. We will add client's credit/debit card details to this customer account. We can then use client's customer account to transfer funds to standalone accounts.
It should work, right?

Upvotes: 1

Views: 4144

Answers (2)

radha
radha

Reputation: 478

Why dont you create a special customer linked to the Company's target bank account and charge "him" to transfer to your share holders ? Unless you use stripe for some auditing you can just use it as a channel.

Upvotes: 0

Ywain
Ywain

Reputation: 17503

A typical payment flow with Stripe can be divided in two steps:

  1. Client-side, in your frontend code (HTML + JavaScript), you use Checkout or Stripe.js (configured with your publishable API key) to collect the customer's payment information and turn it into a token. Once the token has been created, you then send it to your server.

  2. Server-side, in your backend code (in your case, in Java), you use the token to actually create a charge.

The issue in your code is that you're using your publishable key as the source parameter. This parameter should contain the ID of the token created in the frontend. Token IDs are strings that start with "tok_" followed by random alphanumeric characters.

The rest of your code looks correct, although you might want to add an application_fee parameter if your platform needs to take a cut out of the transaction. As it is, your platform would pay Stripe's fees, but receive no money out of the transaction since all the funds are sent to the connected account.

Upvotes: 2

Related Questions