Can anyone give me some advice on getting Stripe Subscriptions working with Stripe elements? I have it where the payment intent coorectly charges a user and shows up successfully in Stripe dashboard. I then capture a webhook upon successful charge and "Create Subscription" but I am having issues - Stripe is giving me an error { "error": { "message": "This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.", "request_log_url": "https://dashboard.stripe.com/test/logs/req_5s7TpU97UoH1wZ?t=1727176339", "type": "invalid_request_error" } }
I use a setup intent rather than payment intent, but it looks like you haven't attached the payment method to the customer. Use the Stripe Attach Payment Method action to connect the two.
The setup intent is what you use for a subscription where you are gathering the payment method but not charging anything immediately. It allows you to store the card for future use.
Payment intent is for collection of payment during that session.
In my use case, I am dealing with unknown potential customers so I use Setup intent to collect the credit card. At this point, no subscription is created, and no line items are needed, I'm simply creating a payment method in Stripe (not attached to a customer at this point.) Once Stripe gives me a payment method id, I go about setting up the new tenant (creating a user, a bunch of tenant setup, etc.) Now that I have a tenant, I create a stripe customer, and attach the payment method to the customer (not the subscription) so it becomes the default payment method for anything they purchase. Then I create the subscription.
Of course, there are always a few ways to do these things, but in dealing with Stripe, it's important to know what your business rules are before trying to build. Specifically here, your choice to collect cc for future use or make a payment.
User registers on my platform and at the same time a new stripe customer is created (customer id stored on database.
They click a plan to subscribe to.
They enter their credit card details to pay.
A payment intent is initiated and when payment confirmed a web hook grabs the charge succeeded call and creates a subscription for the user. I only attach the payment method to the customer in the web book action but that doesn’t seem to work as stripe is giving me that error from before
I suspect I should be using setup intent as well somewhere in the process just not sure where