mollie / WooCommerce

Official Mollie extension for WooCommerce
https://wordpress.org/plugins/mollie-payments-for-woocommerce/
Other
132 stars 53 forks source link

CreditcardInstructionStrategy::execute(): ErrorException: Warning: Undefined property: stdClass::$cardHolder #937

Closed mklepaczewski closed 1 month ago

mklepaczewski commented 1 month ago

WordPress: 6.4.1 WooCommerce: 9.0.2 PHP: 8.1.2 Mollie plugin: 7.6.0

PHP reports: Warning: Undefined property: stdClass::$cardHolder on the checkout success page. Stack trace:

ErrorException: Warning: Undefined property: stdClass::$cardHolder
#22 /wp-content/plugins/mollie-payments-for-woocommerce/src/PaymentMethods/InstructionStrategies/CreditcardInstructionStrategy.php(20): Mollie\WooCommerce\PaymentMethods\InstructionStrategies\CreditcardInstructionStrategy::execute
#21 /wp-content/plugins/mollie-payments-for-woocommerce/src/Payment/OrderInstructionsService.php(30): Mollie\WooCommerce\Payment\OrderInstructionsService::executeStrategy
#20 /wp-content/plugins/mollie-payments-for-woocommerce/src/Gateway/MolliePaymentGateway.php(840): Mollie\WooCommerce\Gateway\MolliePaymentGateway::displayInstructions
#19 /wp-content/plugins/mollie-payments-for-woocommerce/src/Gateway/MolliePaymentGateway.php(797): Mollie\WooCommerce\Gateway\MolliePaymentGateway::thankyou_page
#18 /wp-includes/class-wp-hook.php(324): WP_Hook::apply_filters
#17 /wp-includes/class-wp-hook.php(348): WP_Hook::do_action
#16 /wp-includes/plugin.php(517): do_action
#15 /wp-content/themes/flatsome/woocommerce/checkout/thankyou.php(47): include
#14 /wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): wc_get_template
#13 /wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php(335): WC_Shortcode_Checkout::order_received
#12 /wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php(65): WC_Shortcode_Checkout::output
#11 /wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(72): WC_Shortcodes::shortcode_wrapper
#10 /wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(95): WC_Shortcodes::checkout
#9 /wp-includes/shortcodes.php(433): do_shortcode_tag
#8 [internal](0): preg_replace_callback
#7 /wp-includes/shortcodes.php(273): do_shortcode
#6 /wp-includes/class-wp-hook.php(324): WP_Hook::apply_filters
#5 /wp-includes/plugin.php(205): apply_filters
#4 /wp-includes/post-template.php(256): the_content
#3 /wp-content/themes/flatsome/page.php(33): include
#2 /wp-includes/template-loader.php(106): require_once
#1 /wp-blog-header.php(19): require
#0 /index.php(17): null
asotela3911 commented 1 month ago

Hi @mklepaczewski , thank you for reporting this issue. We haven't encountered this specific warning before, and it seems to be an edge-case problem, potentially caused by a conflict with another plugin or configuration in your environment. Unfortunately, we're unable to reproduce the error on our end.

We noticed you're using an older version of the Mollie plugin (v7.6.0). It might be worth updating to the latest version, as this could resolve the issue. However, since this may also be related to Mollie's API or data structure, I would recommend reaching out to the Mollie Support Team to get further assistance, as they might have more insights on this behavior.

If you can provide more details on how to consistently reproduce this issue, feel free to share that with us, and we'll take another look.

mklepaczewski commented 1 month ago

I tracked down the issue.

According to Mollie's REST documentation for GET Payment details.cardHolder field should be string or null. However, for some transactions this field is not present at all (we can share the transaction id, if you can provide a safe manner to do it), and $payment->details->cardHolder does not exist. I confirmed that by capturing raw JSON response from Mollie.

PR has been created, see https://github.com/mollie/WooCommerce/pull/940

fjbender commented 1 month ago

You can email me at first name dot last name at mollie dot com and I'll take a look independently of our Woo integration team :)

mklepaczewski commented 1 month ago

@fjbender Sent. Thank you for the quick reply👍

fjbender commented 1 month ago

This happens for Apple Pay payments, where we treat the payment as a card payment but don't have a cardholder name. The change proposed in #940 is valid IMHO.