#Sarvesh -Collect then Transfer
1 messages ยท Page 1 of 1 (latest)
Hi there!
Can you share the ID (req_xxx) of the failing API request?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
ok
req_cUSQJKBokl1yTY
{
"account": "acct_1LeyoIAc3rv5tCBx",
"return_url": "https://02c9-103-80-116-218.in.ngrok.io/returndata",
"type": "account_onboarding",
"refresh_url": "https://02c9-103-80-116-218.in.ngrok.io/refreshdata"
}
{
"error": {
"message": "You must update your Connect branding settings with business name, icon, brand color in order to create an account link. You can set the missing fields at https://dashboard.stripe.com/settings/connect",
"type": "invalid_request_error"
}
}
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
thanks for sharing, taking a look
I think the error is self explanatory @rancid imp and tells you exactly the next step, do you have a specific concern?
yes, while creating account i need to do it from api call or from the stripe UI in test mode i need to fill it only once?
for every account creation Connect branding settings with business name, icon, brand color etc needs to setup from api call?
$account = $stripe->accounts->create([
'country' => 'US',
'type' => 'express',
'business_type' => 'company',
'business_profile' => ['url' => 'https://www.w3schools.com/'],
]);
if(!empty($account) && isset($account->id)) {
$accountLinks = $stripe->accountLinks->create(
[
'account' => $account->id,
'refresh_url' => 'https://02c9-103-80-116-218.in.ngrok.io/refreshdata',
'return_url' => 'https://02c9-103-80-116-218.in.ngrok.io/returndata',
'type' => 'account_onboarding',
]
);
}
yes you only do it once
no, its not for every account you create. It's the branding of your platform account.
when the users sign up they have to see the name of your business and a page with "Sign up for Sarvesh's Marketplace" and your company logo; you set that up once, in your platform settings.
ok, so once i finished this one type setup with my brand above code will work and return me the account link?
it should, you can try it out
ok, I will update you in few minutes, thanks
yes, I received the account link and completed the steps for the connected account registrations and I can see it in Connected accounts with status Enabled
But after completion of process, its redirected back to my URL with empty array()
https://02c9-103-80-116-218.in.ngrok.io/returndata
is it correct or I should get all info of newly registered account in the response to save on my side?
its redirected back to my URL with empty array()
we redirect the browser to your URL, as a GET request, so there's no POST data, yes
I think there's an ?account=acct_xxx in the URL when we redirect to you(you can check in test mode), your script can try to read that, then call the API to retrieve the Account object(https://stripe.com/docs/api/accounts/retrieve) and do what you need to do.
ok, I will try again
in the current redirected url I can not see any account id attached as param in url.
https://02c9-103-80-116-218.in.ngrok.io/returndata
perhaps I was wrong then. Either way , you get an account.updated webhook event. You should also be able to authenticate the user from your own cookies and look up the account ID you saved for them when you created their account.
So i need to add Webhooks in test mode for "Events on your account" and "Events on connected accounts" ?
Hi! I'm taking over this thread.
What is the use of
'refresh_url' => 'https://02c9-103-80-116-218.in.ngrok.io/refreshdata',
'return_url' => 'https://02c9-103-80-116-218.in.ngrok.io/returndata',
mentioned while creating account?
If you want to listen to account.updated event from your connected accounts, then yes you need to create a connect webhook endpoint on your platform.
mentioned while creating account?
You mean when creating an account link?
if(!empty($account) && isset($account->id)) {
$accountLinks = $stripe->accountLinks->create(
[
'account' => $account->id,
'refresh_url' => 'https://02c9-103-80-116-218.in.ngrok.io/refreshdata',
'return_url' => 'https://02c9-103-80-116-218.in.ngrok.io/returndata',
'type' => 'account_onboarding',
]
);
}
yes, will this refresh / return url does not get any info back from stripe?
These parameters are explained in the documentation here: https://stripe.com/docs/api/account_links/create
return_url
REQUIRED
The URL that the user will be redirected to upon leaving or completing the linked flow.
so it does not return any data with it so this URL will be the same url from the account link is clicked?
I just tested and yes, we redirect exactly to the return_url (no data is sent).
ok fine
so once I am back to return url and connected account it is created then which step I need to do for get some money from customer and transfer portion of it to service provider?
We recommend using Stripe Checkout, a prebuilt Stripe-hosted page, to accept payments. ?
I recommend reading this: https://stripe.com/docs/connect/charges
And in general we recommend using Checkout Sessions to accept payments.
ok checking
I have done following now by Creating separate charges and transfers manually at code level by taking last created connected account id from the Stripe UI
Stripe::setApiKey(config('services.stripe.stripeSecret'));
$method = PaymentMethod::create([
'type' => 'card',
'card' => [
'number' => '4242424242424242',
'exp_month' => 12,
'exp_year' => 34,
'cvc' => '314',
],
]);
$paymentIntent = PaymentIntent::create([
'payment_method_types' => ['card'],
'payment_method' => $method->id,
'amount' => 800,
'currency' => 'gbp',//'usd',
'transfer_group' => 'testorder10',
'confirm' => true,
]);
sleep(3);
$transfer = Transfer::create([
'amount' => 100,
'currency' => 'gbp',//'usd',
'destination' => 'acct_1LezxvPSK0cme62N', //'acct_1LefCPPSLfI3YlCp', // config('services.stripe.stripeHostAccount'),
'transfer_group' => 'testorder10',
]);
But I am getting error as
You have insufficient funds in your Stripe account. One likely reason you have insufficient funds is that your funds are automatically being paid out; try enabling manual payouts by going to https://dashboard.stripe.com/account/payouts.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
what is wrong with above code / steps?
You should set source_transaction when creating the transfer https://stripe.com/docs/api/transfers/create#create_transfer-source_transaction
ok, so I need to pass "source_transaction" => "{CHARGE_ID}",
from where i will get this {CHARGE_ID} ?
from PaymentIntent response?
"charges": {
"object": "list",
"data": [
{
"id": "ch_3Lf0dxALTlZ8nxc301jqGGiv",
"object": "charge",
"amount": 800,
so the charge_id: ch_3Lf0dxALTlZ8nxc301jqGGiv ?
Exactly.
ok, trying again
now previous error gone and got new one
The currency of source_transaction's balance transaction (usd) must be the same as the transfer currency (gbp)
now it works after make usd at both places
now i can see in platform account it receives
$8.00USD Succeeded
and in connected account shows balance of $1.02
but as per above code I transferred amount 100 so $1 so how it changes to $1.02?
now it works after make usd at both places
Great!
but as per above code I transferred amount 100 so $1 so how it changes to $1.02?
I'm not sure I follow. Can you share the PaymentIntent ID?
So this is a PI for $8. Then you did a transfer for this PI? Can you share its ID?
{
"id": "tr_3Lf0t1ALTlZ8nxc31rrOTMvw",
"object": "transfer",
maybe Default currency
GBP
so it convets $1 to 1.2 gbp?
Thanks. This is a transfer for $1. But yes like you said it then gets converted to the default currency of the connected account to GBP
hmm but still why it is 1.2? it should be 0.85 gbp right?
Where do you see 1.2? Can you share a screenshot or object ID?
I just checked the balance of your connected account (acct_1LezxvPSK0cme62N), and it's only 0.85 GBP. So what you see in the dashboard might be rounding error.
hmm ok
Here is our workflow on the website
- Our website is platform for events so website owner will register on strip and create account will be say OwnerAccount
- There will be different event hosts who will register on site and to host/publish events
- So we will create connected host accounts under OwnerAccount using owners Stripe Secret key
- We will create account link for HostAccount and ask him to complete stripe registration steps so he will get added under connected account
- Host will create some paid events and participants will register for it by paying online
- Then from the registration amount e.g. $10, Owner should get $2 and host should get $7 and remaining say $1 will be processing fee of stripe
Will this get covered with the workflow which I have completed just now right?
there?
Hi ๐ I'm jumping in as my teammate needed to step away, please bear with me a moment while I catch up on the context here.
sure, thanks
Just making sure I'm following your flow correctly, because it sounds like something that isn't supported, are you planning to create Connected Accounts from your Platform and then create Connected Accounts for your Connected Accounts?
ok, I will repeat the workflow
- our website will be event hosting platform and website owner will have stripe account
- using that stipe account secret key, we will create connected accounts via apis
$stripe->accounts->create()
$stripe->accountLinks->create()
and then we will redirect user to account links where he will complete his registration and add the bank details etc. - Then we will need to get the newly created connected account id somehow via stripe apis. For now I have hardcoded it by coping it from stripe UI.
- So that I will call further apis
PaymentIntent::create() and
Transfer::create()
with
'destination' => 'acct_1LezxvPSK0cme62N',
"source_transaction" => $paymentIntent->charges->data[0]->id,
So from event registration fee say $10 then our web platform we keep $2 and transfer $7 to event host company and $1 may be processing fee of stripe
will this get achieved from above api calls?
event hoster will create events on web platform and event participient will pay fee of it which we need to distribute in webplatform $2 and event hosts $7
is this correct?
Yes, that looks right
'destination' => 'acct_1LezxvPSK0cme62N', I have hardcoded so how I will get it from the api?
The ID of the created account is returned in the response provided to the creation request.
yes, but in return url redirects to page without any data.
so I think the flow will get cut off there?
I'm not sure I follow, the Account is being created by your backend so the frontend redirect doesn't seem relevant unless I'm overlooking something.
no, the account creation and connected account link will be done from the frontend itself
via api calls
It shouldn't be if you're using your secret key.
If you transmit your secret key to your frontend code, then everyone accessing your frontend could access your secret key and make requests for your account.
no it will be done in php side so it will not get disclosed to anyone
server side
frontend/ backend => client / server ?
Yeah
So if you have the Account ID server-side, why does a client-side redirect impact the availability of that information? If it does, then it sounds like you'll need to add some sort of persistency layer to hold that information.
ok, is there any api which can return the last created connected account?
just to cross check
You can list all connected accounts:
https://stripe.com/docs/api/accounts/list
Our list endpoints return objects ordered from most recently created to oldest.
If you rely on that approach though, it seems like your flow wouldn't be able to handle multiple accounts in parallel.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
i see ok
so I need to handle it from server side only from the response of connected account creation and process paymentIntent and transfer create calls
right?
ignore the redirect url? But if the connected account links - steps do not complete or any wrong data provided by the event hosts then how to stop process further and call refresh url again?
any webhooks will help in this case?
Yes, you should listen for webhook events to know when the connected account is ready before attempting to process a payment for them.
https://stripe.com/docs/connect/webhooks
You'll want to use a Connect webhook endpoint to listen for events from your connected account, and listen for account.updated events.
perfect. I will opt for it