#thinkle1_best-practices
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/1222580103972913213
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello! You can do this, but you'd need to calculate it on your end, and it isn't generally recommended. Have a look here: https://support.stripe.com/questions/passing-the-stripe-fee-on-to-customers
@humble ivy hi, thanks for answer. So there's no way to get potential Fees before the payment via API?
I mean I can calculate, I just don't know the fee percentages
No, there isn't. Fees are only calculated and available in the API (on the Balance Transaction) after the transaction takes place.
@humble ivy thank you
Happy to help!
@humble ivy another question related to Connected Account customers. I'm using Direct Debit.
Users register on my mobile app, and I create a Stripe Customer on Platform account for each user. When I need to perform payment (Direct Debit) to connected account - I need to have this customer on connected account. So I'm just copying customer and payment method to connected account - https://docs.stripe.com/payments/payment-methods/connect#cloning-payment-methods
Also I'm checking if the payment method card changed or not, just not to create Payment Method each time user pays.
Is this the best way to do it?
My concerns: If the user changes some Stripe Customer related info (like address, name), I have to perform copying all the time when user pays. And to perform the payment - it's a lot of API requests
To make sure I understand, you're creating direct charges on your connected accounts and cloning Payment Methods, and you're wondering what the best way is to keep the Customer/Payment Method on the connected accounts in sync with the info on your platform account?
Yeah, I'm cloning the Payment Methods and Customer. Because otherwise it won't work. I still need both records to pay to Connected Account.
wondering what the best way
yes
Are these recurring payments or one-off payments?
One off
The best way to do this is to not copy the Customer at all, and clone the Payment Method for every payment. This approach avoids you having to keep anything in sync. There's only one Customer, on your platform. The primary Payment Method is also on your platform account, and you clone it once per payment, so the newest, most up-to-date payment info is always used.
When a Payment Method is cloned, the new Payment Method created on the connected account can be used for a single payment, then it's marked as used and can't be used again.
Oh, ok. So I don't need the customer on Connected Account side. Lemme try and I'll get back to you. Thanks!
@humble ivy when I clone like that
payment_method = Stripe::PaymentMethod.create({
customer: '{{CUSTOMER_ID}}',
payment_method: '{{PAYMENT_METHOD_ID}}',
}, {
stripe_account: '{{CONNECTED_ACCOUNT_ID}}',
})
CUSTOMER_ID is my Platform customer
Then I try to create PaymentIntent using this copied PaymentMethod and Platrofrm Customer.
It throws the error - "(Status 400) (Request req_0n4cyeJlTfSwbY) No such customer: 'cus_PUHzxddKmq8XiA'"
If I try to attach newly created PaymentMethod to Platform Customer - error:
"No such PaymentMethod: 'pm_1OyzXwBrNN58pqthoBggnmNx'; It's possible this PaymentMethod exists on one of your connected accounts, in which case you should retry this request on that connected account. Learn more at https://stripe.com/docs/connect/authentication"
Don't specify the Customer when creating the payment. There is no Customer on that account.
Wait...
This is an attach request.
You don't do that.
There's no Customer to attach the Payment Method to on the connected account.
You clone the Payment Method, then create and confirm a Payment Intent with it. No Customer or attachment process happens on the connected account.
The only Customer is on the platform account.
Also, you should never attach a Payment Method directly to a Customer like this. On your platform you should use a Setup Intent or a Payment Intent with setup_future_usage to set up the Payment Method for future use, which will attach the Payment Method to the Customer for you when the Intent succeeds.
I see, thanks. Lemme check
@humble ivy that worked thanks. I'm creating payment intent without customer. Just using the copied Payment Method. And everything workls. Thanks for help, it was unclear for me from docs for some reason
Glad to hear it's working! ๐