#Constant
1 messages · Page 1 of 1 (latest)
Hi Soma!
I'm creating a paymentIntent in a cloud function that is associated with transfers. I then need to make the payment for that intent. I would prefer to create a checkoutSession and just return the url to the client.
Checkout Session will automatically create a PaymentIntent for you. So:
- You create a Checkout Session for whatever amount you need
- You get a URL that you send your customer
- If they pay, you'll end up with a PaymentIntent in a
succeededstatus
To learn how to create a Checkout Session with node, we have this guide: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout
Is it possible to create transfers within the checkout session? As I understand you can only do that with the paymentIntent
What do you mean by transfer? A transfer is to send money between Stripe accounts. And this has nothing to do with Checkout Session.
To create transfer, use this: https://stripe.com/docs/api/transfers/create
My use case is as follows. A Manager needs to pay his workers for today, they all have connect accounts. The transfer is for all the accounts he needs to pay. Does that make sense?
I'm trying to pay multiple connect accounts with one payment.
Got it. Then you need to use Separate Charges & Transfer: https://stripe.com/docs/connect/charges-transfers
- First charge the end user, for example with a Checkout Session
- Then create as many transfer as you want with https://stripe.com/docs/api/transfers/create
Ah okay. So the user would pay us, then we would pay the connect accounts via transfers?
Yes. I recommend you to read this doc: https://stripe.com/docs/connect/charges-transfers
Perfect! Thank you.
Sorry last question. Does the checkoutSession need to have the same transfer_group as the transfers?
I would recommend to use source_transaction instead, that will automatically set the transfer_group for you
https://stripe.com/docs/api/transfers/create#create_transfer-source_transaction
The Checkout Session will have a PaymentIntent, and the PaymentIntent will have a Charge. The source_transaction is the Charge ID.
Perfect. Just to double check. I create the CheckoutSession with the total that needs to be paid, then just after that I create the transfers with the Charge Id. Then I return the Checkout Session's url. The customer then pays, and once the payment is successful, the transfers automatically gets made. And I can do all this in one function?
Really appreciate your help!
No, the order is wrong:
- You create the Checkout Session
- You send the URL to the user
- And only after they completed the payment you create the transfer
Is the transfers then created via a webhook?
The simplest way to do 3. is to listen to the checkout.session.completed webhook event to create the transfer.
Great, and that would be on the platform account, not the connect account right?
Yes