Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
bojanz CreditAttribution: bojanz at Centarro commentedSounds 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.
Comment #3
zenimagine CreditAttribution: zenimagine commentedI uninstalled PayPlug and I encounter the same error. I will wait for the payment module to update.
Comment #4
barry6575 CreditAttribution: barry6575 commented@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.
Comment #5
zenimagine CreditAttribution: zenimagine commented@barry6575 in /admin/modules/uninstall "Commerce Payment", simply click on the "Remove payment" link and update the database.
Comment #6
barry6575 CreditAttribution: barry6575 commented@zenimagibe that did it...Thanks!
Comment #7
barry6575 CreditAttribution: barry6575 commentedComment #8
sriharsha.uppuluri CreditAttribution: sriharsha.uppuluri at Azri Solutions commentedI have 210 payments if I do like that all the information will be lost. Is there an alternative to this?
Comment #9
bojanz CreditAttribution: bojanz at Centarro commentedYes. 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
Comment #11
sagesolutions CreditAttribution: sagesolutions commented@bojanz, you mentioned you submitted patches to each known gateway... Where would I find these patches? in particular, I need the Stripe patch.
Thanks!
Comment #12
bojanz CreditAttribution: bojanz at Centarro commentedNo you don't, Stripe is up to date, we committed a fix directly and tagged a release.
Comment #13
bbuchert CreditAttribution: bbuchert commentedI think you have to update Stripe first and then update Commerce.
Comment #14
bbuchert CreditAttribution: bbuchert commentedSorry due to my slow connection I posted this twice.
Comment #15
Lukas von Blarer@bojanz This still happened to me updating today with a deleted payment gateway caused by
commerce_payment_post_update_3()
...Comment #16
AaronBaumanThis 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
andcommerce_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:
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.
Comment #17
Alejo DMy 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.
Comment #18
golubovicm CreditAttribution: golubovicm commentedI 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).