"There is no active transaction" during Checkout

Created on 23 December 2016, almost 9 years ago
Updated 18 August 2025, about 1 month ago

We ran into this issue today after upgrading to PHP7 and a database-backed cache backend.

The result was that a Stripe payment would actually be successful (and captured as shown in the Stripe backend) but the user was unable to complete checkout, and subsequently, no payment was saved to the order. (Usually, the customer would try a second time, and that time would be successful.)

From what we can tell, this is a MYSQL error (it's actually a PDOException) that is leaking into the credit card form's error catch/handler ($e->getMessage()). One hunch is that the db_transaction that is used to save the initial pending payment transaction is destroyed, and so further saves to the same transaction will, on occasion fail.

Here is the full exception:

PDOException: There is no active transaction in CommercePaymentTransactionEntityController->save() (line 118 of commerce/modules/payment/includes/commerce_payment_transaction.controller.inc).

Line 118 is where the controller calls parent::save($transaction, $db_transaction), and for the most part only seems to affect users who are checking out with a stored Card on File. For now (testing purposes) I'm removing the additional call to _commerce_stripe_commerce_payment_transaction_save() to see if that has any impact. Otherwise I think we might need to find a better way of saving pending transactions, or just not save them at all.

I have also slightly reorganized the two hunks of code that perform charging via the Stripe API so that the transaction is only saved near the end of the operation. Not sure that will help much but it's worth investigating.

πŸ› Bug report
Status

Closed: outdated

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States torgosPizza Portland, OR

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024