#hamid_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1403364876860264559
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hey synthrider!
hello!
So this is known as "separate charges and transfers" and does have some restrictions on where those transfers can be sent, primarily cross-border
Since your platform is in the US, you can look at using Cross Border Payouts: https://docs.stripe.com/connect/cross-border-payouts
This requires creating the connected account with a recipient service agreement, which is related to the error you're encountering
So the flow you describe is supported, broadly, but the accounts need to be created/onboarded slightly differently.
(Different restrictions, different information collected etc)
Yes, the connected account you're trying to create the transfer to
okie, so no need to change anything in platform account?
Also, this is how i am creating an account for connect.
It works for US to US but not US to MX.
account_params = {
type: 'express',
country: country_code,
email: account_info[:email],
business_type: account_type,
capabilities: {
card_payments: { requested: true },
transfers: { requested: true }
}
}
common_address = account_info[:address]
if account_type == 'individual'
account_params[:individual] = {
first_name: user.first_name,
last_name: user.last_name,
phone: clean_phone,
address: common_address
}
else
account_params[:company] = {
name: account_info[:business_name],
phone: clean_phone,
address: common_address
}
end
account = Stripe::Account.create(account_params)
After creation account I use this to link the account.
def create_account_link(return_url, refresh_url)
return { error: "No Stripe account found" } unless @carrier_company.stripe_account_id.present?
begin
account_link = Stripe::AccountLink.create({
account: @carrier_company.stripe_account_id,
return_url: return_url,
refresh_url: refresh_url,
type: 'account_onboarding'
})
Rails.logger.info "Created account link for company #{@carrier_company.name}"
{
success: true,
url: account_link.url
}
rescue Stripe::StripeError => e
Rails.logger.error "Account link creation failed: #{e.message}"
{ error: "Failed to create account link: #{e.message}" }
rescue => e
Rails.logger.error "Account link creation failed: #{e.message}"
{ error: "Failed to create account link: #{e.message}" }
end
end
So you need to change that account creation step
Take a look here: https://docs.stripe.com/connect/service-agreement-types?connect-account-creation-pattern=typed&lang=ruby#choosing-type-with-api
Since you're using the legacy account type (express), switching to recipient agreement is done by adding tos_acceptance: {service_agreement: 'recipient'}, to the account creation params (in Ruby).
Note that this will mean you cannot collect payments with on_behalf_of in case that is relevant. That and cross border recipient flows are mutually exclusive patterns
now i have two main questions.
- so to make transfer happen i need to change, following.
while account creation.
FROM
type: 'express',
country: country_code,
email: account_info[:email],
business_type: account_type,
capabilities: {
card_payments: { requested: true },
transfers: { requested: true }
}
}```
TO THIS
```account_params = {
type: 'custom',
country: country_code,
email: account_info[:email],
business_type: account_type,
capabilities: { transfers: { requested: true } },
tos_acceptance: { service_agreement: 'recipient' }
}```
- As per for my business flow, I authorize the amount in first step, by this.
amount: @order.amount_cents,
currency: @order.currency,
customer: customer.id,
capture_method: 'manual',
metadata: {
order_id: @order.id,
job_request_id: @order.job_request_id,
shipper_user_id: @order.shipper_user_id
},
description: "Job Request Publication Fee - #{@order.job_request.company_name}"
})```
Question: Can I split this authorized payment in one go, to platform and connected account?
Question: Can I split this authorized payment in one go, to platform and connected account?
What do you mean by that? Can you say more?
You can use a destination charge with either an application_fee_amount or transfer_amount instead of the separate transfers, if thats what you mean.
see, I have two users.
one is Shipper
second is Carrier
Shipper basically authorize amount, lets say 130 usd(pasted code above, payment intent creation)
Carrier completes a certain job, and upload proof to our webiste.
We as a platform want to transfer funds to carrier 88% and then take our cut like 12%.
But at the time of authorization I don't have destination account, I got that later.
can I still split amount?
Destination charges can only go to a single connected account. If the split is between your platform and a single connected account, you can use that approach.
https://docs.stripe.com/connect/destination-charges?platform=web&ui=elements#collect-fees
If you need to send funds to more than other connected account, you need to manage that manually with separate transfers.
no no, i just have platform and connected account to split
I don't really understand how you would not have this up front, but if thats your model then destination charges will not work. You can change the amount to transfer later, but not the destination account.
https://docs.stripe.com/api/payment_intents/update#update_payment_intent-transfer_data-amount
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
but have you see my this message?
But at the time of authorization I don't have destination account, I got that later.
Payment Intent is already created.
I need to just charge and split
Right, if you don't know that when you create/confirm the payment intent, then you can't use destination charge patterns, you'll have to manage manual transfers to the account when you know it.
see this
amount: @order.amount_cents,
currency: @order.currency,
customer: customer.id,
capture_method: 'manual',
metadata: {
order_id: @order.id,
job_request_id: @order.job_request_id,
shipper_user_id: @order.shipper_user_id
},
description: "Job Request Publication Fee - #{@order.job_request.company_name}"
})```
okie question 2, is clear, thanks. So i am doing the correct thing. but doing
- Authorizing (payment intent manual)
- Capture(goes to platform)
- Transfer to Shipper(this is what failing, cross border thing)
Now Question 1.
Let me paste here again for you.
So to make corss border transfer happen i need to change, following. Coz for the US -> US my code works but fails when I do US -> MX, and the error I already pasted, when I started the discussion.
while account creation.
FROM
type: 'express',
country: country_code,
email: account_info[:email],
business_type: account_type,
capabilities: {
card_payments: { requested: true },
transfers: { requested: true }
}
}```
TO THIS
```account_params = {
type: 'custom',
country: country_code,
email: account_info[:email],
business_type: account_type,
capabilities: { transfers: { requested: true } },
tos_acceptance: { service_agreement: 'recipient' }
}```
Updated message above.
Yes, that seems right, using transfers and recipient service agreement.
Yes, this separate transfer restriction is only applicable to cross-border flows
You can already transfer to your US connected accounts because they are in the same country (region) as your platform
just to double check, this will fix following error.
Funds can't be sent to accounts located in MX when the account is under the `full` service agreement. To learn more, see https://stripe.com/docs/connect/service-agreement-types
Yes, because you'll instead use recipient agreement type for those MX accounts
Thanks a lot for the detailed, help, Let me work on it and I will get back to you if anything require. thanks again. really appreciated.
NP!