craftcms / commerce-stripe

Stripe payment gateway for Craft Commerce
https://plugins.craftcms.com/commerce-stripe
MIT License
30 stars 50 forks source link

Incorrect hidden name attribute input provided by the example template #220

Closed patrick3Dgroup closed 1 year ago

patrick3Dgroup commented 1 year ago

Description

Following the example template causes an error with a message - 'Invalid payment or order. Please review.". Using 'gateway.getPaymentFormHtml()' works fine but when you follow the example template to create your own custom form, you will encounter an error.

I solved the issue by passing in 'paymentForm[stripe][paymentMethodId]' as the hidden input name attribute instead of what the example gave.

Steps to reproduce

  1. Install Commerce and Commerce Stripe, set up Payment Intents
  2. Submit a cart purchase using the example template

Additional info

bleepsandblops commented 1 year ago

Thanks for this, really helped me!

nfourtythree commented 1 year ago

Hi @patrick3Dgroup

Thank you for raising this. We have updated the README to reflect the current best practices when it comes to creating a payment form.

As of Commerce 4, payment forms are all namespaced by the gateway's handle this is detailed in the upgrade guide: https://craftcms.com/docs/commerce/4.x/upgrading.html#payment-forms

Hopefully, the update to the plugin's README will avoid confusion in the future.

Thanks!

tigerchick commented 1 year ago

Hi @patrick3Dgroup

Thank you for raising this. We have updated the README to reflect the current best practices when it comes to creating a payment form.

As of Commerce 4, payment forms are all namespaced by the gateway's handle this is detailed in the upgrade guide: https://craftcms.com/docs/commerce/4.x/upgrading.html#payment-forms

Hopefully, the update to the plugin's README will avoid confusion in the future.

Thanks!

Hi, apologies if I've missed something but there still seems to be the incorrect line of code in the readme:

hiddenInput.setAttribute('name', 'paymentMethodId'); // Craft Commerce only needs this

Just wasted a couple of hours on this and eventually came across this issue in the closed pile. Like I say, apologies if I got the wrong end of the stick somehow, I just don't want anyone else to be thrown by this.

chrisdaviesweb commented 1 year ago

Just had the same issue. Took 3 hours of searching around to find this. 'https://github.com/craftcms/commerce-stripe' is still showing the incorrect code for paymentMethodId.

stevecomrie commented 1 year ago

Yeah, this issue is definitely not closed. This is a glaring error in the sample documentation and is next to impossible to debug. @nfourtythree

gaelpleeroy commented 1 year ago

@nfourtythree Can you reopen the issue please? The readme is still not updated with that fix.

hatyi commented 1 year ago

Can confirm I've ran into this issue as well yesterday.

nfourtythree commented 1 year ago

Hi All

Thank you for bringing this to our attention. We have just pushed an update to the README that we believe solves the issue.

Please let us know if you have any further issues.

Thanks!