#uchi-subscriptins-referral
1 messages · Page 1 of 1 (latest)
Hello! Whether you use "Elements" or a "client_secret" doesn't really change anything to the flow so I'm not sure I follow what part is confusing you
Ok, so this is the flow I have:
- user enters checkout page
- as soon as they enter, a stripe customer account is created
- Once that happens, it creates a subscription with the status "incomplete"
- at this point, I have access to the payment intent of that "incomplete" via a client_secret
- Once the user enter their payment details, I use ElementsPayment to handle the card details.
On the function, I am using stripe.confirmCardPayment, which all it needs is the client_secret and the card details, and the payment is processed. At this point, I am confused on how to implement transfers
Should it be something done on a webhook?
Yes, basically when you get payment_intent.succeeded you know the payment succeeded and at that point you decide if you need to create a Transfer to transfer funds to a specific connected account. Note https://stripe.com/docs/connect/charges-transfers#transfer-availability and make sure to read that section carefully
Ah awesome. So, anything that has to do with transfers or commissions, I can manage it on webhooks then, correct? Basically, once I get the succeeded event, right?
yes
you can also set transfer_data on the PaymentIntent so that it's done automatically
You mean within the client_secret?
not really
Hmmm could you give me a quick sample?
I'm sorry I'm a bit lost I don't understnad what you don't understand
Is there a reason you use separate charges and transfers?
you mentioned a "checkout page" but seems you don't use Checkout. You also mentioned subscriptions but don't use our Subscription API
Sorry trying to grasp what you need help with
Ok, let me see if I can explain it better. The checkout page is a custom page I created. What I am using in there that's from Stripe, is ElementsPayment, which creates the UI for the credit card form. I am creating the subscription using stripe.subscriptions.create, and adding expand to get the latest_invoice.payment_intent, which brings the client_secret. Then, I use that client secret on ElementsPayment and submit the payment form using stripe.confirmCardPayment
At that point, everything works as expected. The payment goes through, and the subscription becomes active. My roadblock is on how to add a transfer to that flow
okay so you do use our Subscriptions API and you're making an exception on the first payment to transfer funds to the referral person
so yeah in that case a webhook is the right approach
Alrighty, got it. I will try that. Is there any specific data I can send to the webhook? Like userID for example?
I will need something like that so that I can specify who is receiving the commission
Since they will be using a Connect account
usually you'd map that in your own database
or set as metadata on the Subscription for example
Ah ok, got it. I will experiment with it then. Thank you!