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.
InvalidArgumentException : Invalid credit card type "" dans Drupal\commerce_payment\CreditCard::getType() (ligne 31 de commerce/modules/payment/src/CreditCard.php).
version Commerce: 2.2 / Drupal : 8.4.0
Comments
Comment #2
mh.marouan CreditAttribution: mh.marouan commentedComment #3
bojanz CreditAttribution: bojanz at Centarro commentedThis is a bug in your payment gateway module.
Go to admin/config/development/logging and set error reporting to "All messages, with backtrace information", then reproduce the error again, it should give us more information.
Comment #4
mh.marouan CreditAttribution: mh.marouan commentedI find this error :
Trying to get property of non-object dans Drupal\commerce_payment\Plugin\Commerce\PaymentMethodType\CreditCard->buildLabel() commerce/modules/payment/src/Plugin/Commerce/PaymentMethodType/CreditCard.php ligne 24
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedAnd on which page does this error occur? How can we reproduce it?
Some piece of code created an empty payment method, and the code trying to display it can't handle empty values (in CreditCard::buildLabel()). But from your info I was unable to determine more.
Comment #6
bojanz CreditAttribution: bojanz at Centarro commentedComment #7
jptillman CreditAttribution: jptillman commentedI'm experiencing this same error while trying to create a custom payment gateway. Here's my stack trace. Any suggestions on where to go next?
Comment #8
jptillman CreditAttribution: jptillman commentedFollowing up on this, I discovered that my
commerce_payment_method
table had a record in it that had been created during a prior test order submission and there was no corresponding record in thecommerce_payment_method__card_type
table. Deleting that record and clearing cache caused the error to go away.I suspect it may have happened because my gateway module did not properly implement the
createPaymentMethod()
method yet and some bad data got inserted. I will post more here if I manage to figure this all out.Comment #9
KartagisHello and sorry for hijacking this issue.
I've been having the same problem and my error is
Comment #10
deixadilson CreditAttribution: deixadilson commentedWhen I went to the orders page of the site I got white screen with "unexpected error" message. Went to reports page and the error was: "InvalidArgumentException: Invalid credit card type "elo" in function Drupal\commerce_payment\CreditCard::getType() (line 31 of file /modules/contrib/commerce/modules/payment/src/CreditCard.php)."
Looks like a custommer paid with a 'elo' credit card and broke the site.
I went to modules/contrib/commerce/modules/payment/src/CreditCard.php file and added the keys bellow to the $definitions array in the function Drupal\commerce_payment\CreditCard::getType()
And the problem was solved untill someone pays with a totally different card type. =P
Comment #11
Nathaniel CreditAttribution: Nathaniel commentedIt might be nice to have a way to alter that list or default to simply "Card" if the type is null or not found. I ran into some issues with this migrating uc_recurring and had to query the gateway for the card type during the migration since it was not being stored in the D7 database.
Comment #12
jsacksick CreditAttribution: jsacksick at Centarro commentedAs explained by Bojan, this seems to be caused by broken custom|contrib code, (For example the stacktrace from comment #9 seems to indicate that the izipay module is not mapping the credit card type properly.
Basically, it's the payment gateway plugin responsability to map a remote credit card type name to a credit card type known/accepted/supported by Drupal commerce.