Orders don't necessarily have a payment method when checkout is completed, e.g. an order with zero total may be programmatically completed through checkout with commerce_checkout_complete().

commerce_stripe_pi_commerce_checkout_complete() doesn't check for a payment method array key in $order->data before attempting to access it, resulting in

Notice: Undefined index: payment_method in commerce_stripe_pi_commerce_checkout_complete() (line 922 of /var/www/html/sites/all/modules/contrib/commerce_stripe_pi/commerce_stripe_pi.module). 

Simple fix:

-  if ($order->data['payment_method'] !== 'commerce_stripe_pi|commerce_payment_commerce_stripe_pi') {
+  if (!isset($order->data['payment_method']) || $order->data['payment_method'] !== 'commerce_stripe_pi|commerce_payment_commerce_stripe_pi') {
     return;
   }
CommentFileSizeAuthor
#2 3159814.patch655 bytesDavid Sparks
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David Sparks created an issue. See original summary.

David Sparks’s picture

FileSize
655 bytes

Patch attached

  • GoZ committed 14e86b2 on 7.x-1.x authored by David Sparks
    Issue #3159814 by David Sparks: PHP notice "Undefined index:...
GoZ’s picture

Status: Active » Fixed

Thanks for your contribution. Nice catch.

Status: Fixed » Closed (fixed)

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