When I update the database after installing the beta version of Stripe and the rc1 of Commerce I get the following message:

Failed: Drupal\Core\Entity\EntityStorageException: Required payment method field "payment_gateway" is empty. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 777 of ....../mystore/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

I deleted and added the Stripe payment method but I'm still getting the failed update.

Comments

barry6575 created an issue. See original summary.

bojanz’s picture

Sounds like you have broken data in your system that you'll have to clean up first.
Payment methods must always reference a payment gateway. Yours were probably orphaned when you deleted a gateway.

zenimagine’s picture

I uninstalled PayPlug and I encounter the same error. I will wait for the payment module to update.

barry6575’s picture

@bojanz can you advise where I would find the data in the system to clean up.

I deleted all of my test orders, but my add payment method page is broken so I'm unable to delete my test payment methods.

zenimagine’s picture

@barry6575 in /admin/modules/uninstall "Commerce Payment", simply click on the "Remove payment" link and update the database.

barry6575’s picture

@zenimagibe that did it...Thanks!

barry6575’s picture

Status: Active » Fixed
sriharsha.uppuluri’s picture

I have 210 payments if I do like that all the information will be lost. Is there an alternative to this?

bojanz’s picture

Yes. Fix your payment gateway. We submitted patches to each known gateway, perhaps yours is in the list, allowing you to apply the patch and then proceed to update.php

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

sagesolutions’s picture

@bojanz, you mentioned you submitted patches to each known gateway... Where would I find these patches? in particular, I need the Stripe patch.

Thanks!

bojanz’s picture

No you don't, Stripe is up to date, we committed a fix directly and tagged a release.

bbuchert’s picture

I think you have to update Stripe first and then update Commerce.

bbuchert’s picture

Sorry due to my slow connection I posted this twice.

Lukas von Blarer’s picture

@bojanz This still happened to me updating today with a deleted payment gateway caused by commerce_payment_post_update_3()...

AaronBauman’s picture

Version: 8.x-2.0-rc1 » 8.x-2.x-dev

This is the first google result for the error, so I'm providing my workaround here.

In my case, this error occured when updating from 2.13 to 2.14, but the workaround should be applicable whenever the error is encountered.

I'm testing database update locally using a sanitized database which does not include production gateway settings.
My database has one local payment method, machine name authorize_sandbox_environment.
But, the payments in tables commerce_payment and commerce_payment_method reference other payment gateways in the "payment_gateway" column, thus commerce_payment's update method fails with a fatal error that blocks all subsequent updates from completing.

I worked around the issue with the following 2 SQL queries.
These queries reassign the invalid commerce payment entries to point at the existing payment gateway config:

update commerce_payment set payment_gateway = 'authorize_sandbox_environment';
update commerce_payment_method set payment_gateway = 'authorize_sandbox_environment'

Replace "authorize_sandbox_environment" with the machine name of a valid payment config on your system.
This method is not for you if you're concerned about possibly invalidating any of your old payment data.

Alejo D’s picture

My workaround:
I had this issue with Orphans payments. I had to add again those old payments gateways removed from the system to execute that update.

Context
When you remove a Payment gateway in the table commerce_payment_method still there the relation with that payment gateway. There is why when the update try to duplicate and save the entity fails, because doesn't exists.

golubovicm’s picture

I have the same error, with Datatrans payment gateway after I'm redirected back to site and only when aliases are turned on (to support recurring payments). When they are off everything works fine. And I didn't delete any payment gateway. Also tried clicking "Remove payment" (there are actually 2 links named similar, tried clicking both) but didn't help. Any idea?

Drupal\Core\Entity\EntityStorageException: Required payment method field "payment_gateway" is empty. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).