verbb / formie

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

Stripe integration is throwing integrity constraint violation when using a stencil #1906

Closed d-karstens closed 4 weeks ago

d-karstens commented 4 weeks ago

Describe the bug

Hi,

I've been running into the following error after applying a stencil on our staging site, and after it happened it seems to be happening on other forms with Stripe Payment fields too. I can also replicate this on a fresh Craft install

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`wlasa_craft`.`formie_payments`, CONSTRAINT `fk_azljwtzzlvruamhogiuvdjqjbngudnlcfzag` FOREIGN KEY (`fieldId`) REFERENCES `fields` (`id`) ON DELETE CASCADE) The SQL being executed was: INSERT INTO `formie_payments` (`integrationId`, `submissionId`, `fieldId`, `subscriptionId`, `amount`, `currency`, `status`, `reference`, `code`, `message`, `note`, `response`, `dateCreated`, `dateUpdated`, `uid`) VALUES (2, 2102, 85, NULL, '100', 'AUD', 'pending', 'pi_3PLEkzAWXoIZtenH3BkoLbey', NULL, NULL, '', '{\"id\":\"pi_3PLEkzAWXoIZtenH3BkoLbey\",\"object\":\"payment_intent\",\"amount\":100,\"amount_capturable\":0,\"amount_details\":{\"tip\":[]},\"amount_received\":0,\"application\":null,\"application_fee_amount\":null,\"automatic_payment_methods\":{\"allow_redirects\":\"always\",\"enabled\":true},\"canceled_at\":null,\"cancellation_reason\":null,\"capture_method\":\"automatic\",\"charges\":{\"object\":\"list\",\"data\":[],\"has_more\":false,\"total_count\":0,\"url\":\"\\/v1\\/charges?payment_intent=pi_3PLEkzAWXoIZtenH3BkoLbey\"},\"client_secret\":\"pi_3PLEkzAWXoIZtenH3BkoLbey_secret_SE9SudC7XAqQProiFRZuuJGPB\",\"confirmation_method\":\"automatic\",\"created\":1716859397,\"currency\":\"aud\",\"customer\":\"cus_QBbykGaHsCEgFf\",\"description\":null,\"invoice\":null,\"last_payment_error\":null,\"latest_charge\":null,\"livemode\":false,\"metadata\":{\"fieldId\":\"85\",\"formHandle\":\"test\",\"submissionId\":\"2102\"},\"next_action\":null,\"on_behalf_of\":null,\"payment_method\":null,\"payment_method_configuration_details\":{\"id\":\"pmc_1OmcOEAWXoIZtenHJSbv1J7Y\",\"parent\":null},\"payment_method_options\":{\"card\":{\"installments\":null,\"mandate_options\":null,\"network\":null,\"request_three_d_secure\":\"automatic\"}},\"payment_method_types\":[\"card\"],\"processing\":null,\"receipt_email\":null,\"review\":null,\"setup_future_usage\":null,\"shipping\":null,\"source\":null,\"statement_descriptor\":null,\"statement_descriptor_suffix\":null,\"status\":\"requires_payment_method\",\"transfer_data\":null,\"transfer_group\":null}', '2024-05-28 01:23:17', '2024-05-28 01:23:17', '595aef16-c866-435d-85f9-1a5df8b37a29')

Screenshot 2024-05-28 at 10 53 31 AM

I noticed it only seems to happen when the stencil contains more fields than just the Payment one too

Let me know if you need any more details, Thanks!

Steps to reproduce

  1. Save a form with a Stripe Payment field and a Single-line Text field as a stencil
  2. Apply stencil to a new form and see error on submission

Form settings

Craft CMS version

5.1.7

Plugin version

3.0.0-beta.12

Multi-site?

No

Additional context

No response

engram-design commented 4 weeks ago

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

d-karstens commented 4 weeks ago

Working perfectly now! Thanks for the quick fix

engram-design commented 4 weeks ago

Fixed in 3.0.0-beta.13