Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining Stripe One-Off and Subscription options in the same form? #2277

Open
lewisjenkins opened this issue Feb 3, 2025 · 10 comments
Open
Labels

Comments

@lewisjenkins
Copy link

Question

What are my options for combining both Stripe "One-Off" and "Subscription" options in the same form?

Currently, a Stripe field needs to be one or the other.

I tried creating a dropdown with options for "Single Payment" and "Monthly Donation", and then having two Stripe fields, each set to show/hide using conditional rules based on the dropdown. This doesn't work because the hidden field still fails validation so the form cannot submit.

It would be great if there was a way for the user to eg. check a box ("Make this a monthly donation") within the form.

Or, if a Stripe field has data-conditionally-hidden="true" then it could bypass validation.

Is there a workaround for this?

Additional context

No response

@engram-design
Copy link
Member

You can have multiple payment fields, with conditional rules set. Typically you'd give your users a choice in some fashion to be able to pick a once-off or subscription payment, which would be aligned to the conditions of showing those fields.

This doesn't work because the hidden field still fails validation so the form cannot submit.

What Formie version are you on? This should certainly work. And by the way, just adding data-conditionally-hidden="true" isn't going to bypass validation (well, it shouldn't) because there are server-side checks in place for conditions.

@lewisjenkins
Copy link
Author

I have created a reduced test case.

If I have a single Stripe field, it submits fine and everything works.

If I add a second empty Stripe field and submit, it fails. These are not required fields but possibly Stripe has its own validation.

This is Stripe test mode and test card numbers.

Image

@engram-design
Copy link
Member

What Formie version are you on?

@lewisjenkins
Copy link
Author

lewisjenkins commented Feb 4, 2025 via email

@engram-design
Copy link
Member

I'm not sure if you have any conditional logic setup, but yes - Stripe will enforce their fields to be required if they are visible. I've had a look at how to get around this, but I don't believe it's possible.

Which is why you'll want to use Formie's conditional logic for showing/hiding the right Stripe field for the type of payment you want to perform.

Image

Having them both visible for the user to pick won't work I'm afraid. Can you let me know if you've set your fields up like this? Based off your screenshot, it seems they are both visible, but I could be wrong.

@lewisjenkins
Copy link
Author

Sorry, I probably confused things with my last screenshot. I did previously have conditional logic in place but was getting errors so I had removed it.

For clarity, I have made a short video of the issue I'm having. This is a reduced test case with a simple form, which hopefully demonstrates the issue.

https://www.dropbox.com/s/fvxcjlluczxgdfo/Screen%20Recording%202025-02-04%20at%2023.58.35.mov?e=1&st=aqn1k8fl&dl=0

I hope this helps :)

@engram-design
Copy link
Member

Thanks for the video, that's pretty much what I had on my end. I thought that's what you might've done is toggling back and forth. Looks like we need to unload the Stripe JS when the field is hidden.

@engram-design
Copy link
Member

Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-5 as 3.0.20".

@lewisjenkins
Copy link
Author

Thank you for this. I can confirm everything now appears to be working. However, I have noticed that for each submission in the Control Panel, the payment is listed twice.

Image

To clarify, only one payment is taken (as expected) but it is listed twice, which could potentially cause confusion. In this example, both "View in Stripe" links are linking to the exact same URL.

@engram-design
Copy link
Member

Good call, just a visual issue because there are technically two payment fields, but only one with transaction data, so it's doubling the output.

Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-5 as 3.0.20".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants