#mj_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/1298589248609320971
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi! so how do you envision this working overall? you would be processing multiple payments scheduled with logic in your system to call the API, on the customer's saved card?
Hi @pliant herald! So what we have right now is a simple system where the funeral homes create account on our platform, add their products/services and then set up their stripe connect account.
When a customer completest an order we use @stripe/react-stripe-js - PaymentElement to create a checkout for them. They enter their CC info and the payment is collected. Simple.
But given the nature of the business one of the requirements placed by the owner of the product was to split these payments into parts. A simple scenario:
- a customer finds a funeral home on our platform they like
- they add items to cart, go into checkout
- they pay - for the sake of the example - 50% of the order
- the rest is paid once the burial service is provided and completed
What would be the best way to go about this?
I was advised that Affirm might be right - but we have this manual element there of the house providing the service and then the final charge should happen - not on some arbitrary date.
probably the best way I would say is what I described, you save the payment method during the initial payment (https://stripe.com/docs/payments/save-during-payment) which is for the first amount/installment, and then you set up logic to process off-session payments on the saved payment methods for the other amounts/installments when needed
I mean Affirm can work but the way that works is you as the merchant get all the money immediately, the collection/splitting of installments is between the customer and the BNPL provider(Affirm), you're not involved in that. Also what if the customer doesn't want to pay with Affirm? To me it is more of an "additional way to pay" , it's not what you use to implement the core functionality of the flow if you 100% need instalments
I see. I haven't had a chance to see the docs for saving payment methods so this might be a simple question but - what if we're unable to charge them for the second part of service? For example card is not active anymore, or 3DS (not sure if that can happen)? I assume this would fall on us to make the funeral homes whole.
On the other hand if we simply use Connected account as we do right now, and something would be off, then the users would be able to file for a refund and that would be handled by Stripe, so we'd have no extra work on our end.
Did i get that right?
if the payment fails you'd contact the customer to visit your site again and attempt the payment there/try a different payment method and if they don't/can't you pursue it as a bad debt
Not sure what you second paragraph refers to overall really, that seems like a separate question/scenario (I'm not seeing the connection between refunds and declines when charging for the future payments)
Yeah, sorry, I was unclear. What I mean is - looking at the worst case scenarios here:
- if we stick with our current Connect solution and whole payment is collected upfront then if something goes wrong that is handled between customer <- Stripe -> merchant (any refunds etc.)
On the other hand if we are the ones who store CC info and try to recharge if something goes wrong (for example card expired/not enough funds) then we have to be the ones chasing customers to make the merchants on our platform whole.
Did I get that right?
what is your current Connect set up, is it Direct Charges? is part of what you're doing here moving to Destination Charges/Separate Charges and Transfers?
oh, sorry, this is the first time i'm developing anything with stripe, and it's been a while since I did the initial setup. I am logged into the customer's acc right now. How do I check this? I'm fairly sure it's Direct Charges.
it's not something you check, it's something you'd kind of know since you wrote the code for the API calls which is what determines which flow is used , so it's important to get a good grasp on all this.
If you have like the account ID acct_xxx of a connected account I can probably tell from that
yeah, sure, acct_1QCOaoP2HwikPYJR
(it's just test mode for now, we're pre launch)
pi_3QCo0m08SnqXCKUj1H5t27O6 some test transactions we did recently
const paymentIntent = await stripe.paymentIntents.create({
amount: Math.round(amount * 100),
currency: 'usd',
application_fee_amount: Math.round(amount * 0.1 * 100), // 10% platform fee
transfer_data: {
destination: stripeAccountId,
},
metadata: {
cartId: input.cartId,
},
});
and that's how we create the payments right now (for the whole amount)
so that is a Destination Charge, which means your platform is responsible for refunds https://docs.stripe.com/connect/charges#types
so if a customer wants a refund, they contact you, you can call the API to issue a refund, which comes from your balance, and there are parameters to 'reverse the transfer'(the one created by transfer_data ) to pull funds back from the connected account balance to your own.
as for your proposed flow, there's lots of ways of approaching it, what's not clear for example is when/how much you transfer to the connected account. Like would you charge the customer $50, but transfer $100 to the connected account(so you add float to your Stripe account balance), and then do instalments for the rest; or do you do multiple charges+transfers ; and so on, there's a lot to consider here
I see, understood. Then it seems like I was mistaken thinking we're just a middleman here and everything happens without us in this case. So either way if something goes wrong we will be involved and will have to manually handle refunds etc.
It seems your advise on storing the CC data and issuing a second charge after completion might be the best way to go forward. So if the whole cart is $1000, we would charge the user $500 at the beginning and $500 after service is completed. For each charge we would take 10% commission. The business downside is we would pay double stripe transaction fees.
But before we close this ticket I have one extra question if I may:
of course
I'm surprised you're saying we're using Destination Charge. I'm fairly sure we were looking to use Direct Charge. And this is what is see here https://dashboard.stripe.com/connect/settings/profile
Is there a way to somehow switch to direct charge? I'm not sure where we went wrong with this if that's the case. Here's another account id we've used for testing earlier acct_1PnLhl02AzZVCRKU
I don't think that settings page really "does" anything beyond tell us your intended flow for review purposes, the actual integration you use and the API calls you make are what decide what flow you're using. You can use Direct and Destination flows on the same account for example, it's all just on an API-call basis. I don't know much about this layer of the Dashboard/settings/onboarding so I could be completely off
I assume you can enter information on that page corresponding to one flow but ultimately if you make the API calls for a different flow I haven't heard of us like actively blocking them or so on
okay - so maybe for the specific account I've provided earlier we messed something up. Because I am 100% certain we never aimed to do anything but Direct Charge. We just create payment intent like this:
const paymentIntent = await stripe.paymentIntents.create({
amount: Math.round(amount * 100),
currency: 'usd',
application_fee_amount: Math.round(amount * 0.1 * 100), // 10% platform fee
transfer_data: {
destination: stripeAccountId,
},
metadata: {
cartId: input.cartId,
},
});
return { clientSecret: paymentIntent.client_secret };
and then we simply use
import {
PaymentElement,
useElements,
useStripe,
} from '@stripe/react-stripe-js';
export function StripePaymentForm({ cartId }: { cartId: string }) {
const stripe = useStripe();
const elements = useElements();
const [errorMessage, setErrorMessage] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
const handleSubmit = async (event: React.FormEvent) => {
event.preventDefault();
if (!stripe || !elements) {
return;
}
setIsLoading(true);
const { error } = await stripe.confirmPayment({
elements,
confirmParams: {
return_url: `${window.location.origin}/checkout/success/${cartId}`,
},
});
if (error) {
setErrorMessage(error.message ?? 'An unknown error occurred');
}
setIsLoading(false);
};
return (
<form onSubmit={handleSubmit}>
<PaymentElement />
So I'm not sure where do we go wrong with this potentially?
We just create payment intent like this:
that code snippet is specifically creating a Destination Charge
passing transfer_data:{destination} is what makes that a Destination Charge
ok, I must have misunderstood something here. The diagrams are the same on these pages btw. But can I collect the 10% fee when issuing a direct charge?
ok, sorry, I see that i can, my bad
yeah it's the code snippets I'm referring to not the diagrams. And yes you can take fees in either flow, that's core to Connect in general
so i should switch destination_charge to
{
stripeAccount: '{{CONNECTED_ACCOUNT_ID}}',
}
and then the refunds etc. will be handled by you guys (Stripe) instead of us (startup)
yes but read the whole guide(for example the frontend also has to change)
I mean the refunds are handled by the merchant not us
the merchant tells us to issue a refund, the funds come from the merchant's balance, we just process it. The difference with Direct and Destination is determining who the merchant is(the platform or the connected account).
Yes, that's ideal for us, at this point we need to minimize the business pressure on us
gotcha. So to wrap this up - I will read these guides and probably fix that direct charge as necessary. Regargin my original query your advise is to store CC info during checkout and do two transactions on our end manually as needed and keep track of that on our end as stripe has no mutli-step-payments entity we could use
Correct yes. MITs seem like the best option as outlined
thanks guys, you're super helpful as usual ๐