#MrsRumi-subscription-no-pm
1 messages ยท Page 1 of 1 (latest)
Hello ๐
How are you integrating subscriptions? Are you using Checkout, Elements or something else?
I am using CardElement on the frontend and I use payment_intent for main subscription and setup_intent for first payment 100% discount subscriptions, using the client secrets
I am not sure if it was the question
yup that answers the question ๐ thanks
I want to cancel automaticaly subscription on Stripe when there is not payment method info.
do you want to cancel it immediately after its created or after the first billing cycle is complete or something else?
the fact is that in some cases users are creating a subscription without entering any payment method, and I dont want this
I have solve not aplying de suscription activation on my platform
but I have lots of "invalid" subscription activated on Stripe
I think about two solutions, better than what I aplied:
- CardElement on the frontend with the posibility of knowing when is empty
- Creating the subscription only if the paymentMethod is valid
but I dont know if are posible in a easy way
Like, taking a propiety from CardElemet for knowing something about the content or adding a property to subscription creation
answering, one sec
the fact is that in some cases users are creating a subscription without entering any payment method, and I dont want this
because you're using CardElement, this is in the control of your code that you can only create a Subscription via the API after the user has entered card details in CardElement and after you've created a PaymentMethod object from those card details
additionally, once you create the Subscription with those params above, you can use said PaymentMethod to "confirm" the Subscription's pending_setup_intent with CardElement, so that this PaymentMethod is "set up" for recurring payments after the 100% off Coupon is all used up
yes, this is what I want
but, why is doesnt work?
do you mean I need to use in front another stripe Element?
or I need to add a "verify payment methot button"?
okey
your code also needs to only create a Subscription after a user has entered their card into CardElement and you've called the Stripe API to create a PaymentMethod out of it
- CardElement on the frontend with the posibility of knowing when is empty
https://stripe.com/docs/js/element/events/on_change?type=cardElement
- Creating the subscription only if the paymentMethod is valid
create a Subscription only after you call https://stripe.com/docs/js/payment_methods/create_payment_method on CardElement
does that answer your questions?
yes! thank you very much! ๐ฅฐ
there is one more part after this but want to make sure you're good on this part first
the part after this to make sure the PaymentMethod is valid is:
when you create a Subscription with a 100% off coupon, there is a pending_setup_intent field on the Subscription. That represents a SetupIntent. That SetupIntent has a client_secret field.
You need to take the PaymentMethod ID and "confirm" the SetupIntent's client_secret using this function from Stripe.js on your frontend: https://stripe.com/docs/js/deprecated/confirm_setup_intent
Confirming a SetupIntent validates the PaymentMethod and sets it up for future recurring payments on the Subscription
this section explains in more detail:" https://stripe.com/docs/billing/subscriptions/overview#non-payment
pls give that a read