verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
93 stars 68 forks source link

Payments only taken if User Integration is successful? #1914

Open MattWilcox opened 2 weeks ago

MattWilcox commented 2 weeks ago

What are you trying to do?

We're trying to do a Subscription form for a website membership. We may be asking Formie to do too much in one go - though it does make sense from a design perspective - but here's what we're trying:

Screenshot 2024-06-07 at 11 18 18

The second page includes a Stripe Payment field and the form is using the User integration; so the site visitor fills out this first page (being forced to agree to the TOS to get to the second Payment part of the form).

It "works".

The form does not handle errors though, and will charge the payment even if the integration fails. Thats... not good.

For example, I tested with using an existing email address and a password of one character. From a user's perspective it all worked, and the membership was charged in Stripe... but the User isn't created (correctly).

The users see's "Submission Saved" with no errors.

Screenshot 2024-06-07 at 10 58 00

The back end shows there were errors (which is right, these are not valid values on the fields):

Screenshot 2024-06-07 at 10 55 10

But Stripe took the payment anyway:

Screenshot 2024-06-07 at 10 59 09

Here's the code we're using to display the form:

{{ craft.formie.renderForm('formHandle') }}

Here's the form settings:

https://www.youtube.com/watch?v=burHofRrwLc

What's your proposed solution?

  1. It seems like a bug that the errors are not showing up with the integration
  2. It feels like it should be checked that User Integrations run correctly before payments are attempted to be taken?

Additional context

Or... is this pushing Formie too far, and we should split it out so the Registration is its own normal form, and Subscriptions operate on top of an already working User?

Details

engram-design commented 2 weeks ago

This is related to https://github.com/verbb/formie/issues/829 and how the User integration uses the queue. This is just another use-case where it's actually unhelpful being run in the queue. It can be run before a payment integration is run, which would otherwise not proceed before the form fully validates.

So not so much pushing Formie too far, more that this sort of workflow isn't supported — yet. We need to introduce a mechanism to run some integrations outside of the queue, before a payment. It's probably for the best to split the steps into two different forms (which I'm keenly aware isn't amazing for the end user).

It's tricky because this behaviour (saving User/Entry/etc elements) is the exact kind of event that really slows down form submission and makes the user wait, which is not great UX. Combined with taking payment and this could in practical sense make a really slow form.

MattWilcox commented 2 weeks ago

Ok, good to know - thanks!

As additional "thoughts"... even slower if you're waiting for email verification (which we always do), and double confusing because there might legitimately be two different flows htat are prferable:

What we;re actually looking at doing now is this: