#jorge.cortez
1 messages · Page 1 of 1 (latest)
Hello there
Can you clarify a little bit what you are trying to do exactly? You want to render Payment Element and be able to accept either a one-time payment or a Subscription payment?
Using the same Payment Element instance?
Hi Bismarck, yes, that's exactly my goal
Took me a while to get the one time payment working but I'm not sure how to tackle the recurring payment
Hmm yeah you don't want to do that really. You will want to render the correct mode based on whether the PaymentMethod will be used for a Subscription or one-time payment.
Certain PaymentMethod types won't be supported for Subscriptions whereas they are for one-time payments.
So you can't just use payment mode for both
How is your customer indicating what purchase they are making?
In terms of one-time vs. Subscription
Ideally that happens prior to rendering Payment Element
Then you render accordingly
In this case is a donation form and following the stripe doc I had to wrap the form that holds those options inside the parent <Element
so is there a way to "update" the mode from within the form?
You'll basically want to send a notice up to your parent component to update your Elements Provider
can you share some links, I don't think I can follow the "notice up" approach
There aren't really links... you basically need to pass a function down to your child components using props from your parent component. Then when that function is called in your child it will also call it in your parent and you can save it to state in your parent and then use it to update your Elements Provider
I can't really write this for you as it is not Stripe-specific... you as the dev will need to work on this.
ahhh sorry I tought it was some sort of custom prop from Element
I just need to lift the state
Yep