| Project: | Drupal Commerce |
| Version: | 7.x-1.x-dev |
| Component: | Payment |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I believe there's a small issue with the payment module that triggers this error on some payment methods. When I checkout using commerce_no_payment module the error is triggered, and after a quick google it seems that module is not alone:
* #1230666: Creating transactions throws undefined index for payment details
* #1670752: Notice: Undefined index: payment_details in commerce_payment_pane_checkout_form_submit()
* #1646096: Undefined index: payment_details in commerce_payment_order_transaction_add_form_validate()
* #1569386: Notice: Undefined index: payment_details
This code assumes that $pane_values has a 'payment_details' value set, which seems to not be the case always.
if ($callback = commerce_payment_method_callback($payment_method, 'submit_form_submit')) {
// If payment fails, rebuild the checkout form without progressing.
if ($callback($payment_method, $pane_form['payment_details'], $pane_values['payment_details'], $order, $balance) === FALSE) {
$form_state['rebuild'] = TRUE;
}
}The attached patch simply sets that value as needed. Not sure if it has other implications but it's no longer generating the PHP notice for me and all seems to be working fine with commerce_no_payment.
Comments
#1
#2
Sorry, the above patch does nothing... I'd commented out the only line that does anything for testing :). Anyway, this patch should actually do something.
#3
Worked for me to get rid of the error message. Nice job.
#4
Good catch. I've fixed this with a slightly different approach - basically initializing the payment details array in the $pane_values array if it doesn't exist yet:
<?php// Initialize the payment details array to accommodate payment methods
// that don't add any additional details to the checkout pane form.
if (empty($pane_values['payment_details'])) {
$pane_values['payment_details'] = array();
}
?>
Commit: http://drupalcode.org/project/commerce.git/commitdiff/a1021f4
#5
Automatically closed -- issue fixed for 2 weeks with no activity.
#6
And just did the same for the validate callback.
Commit: http://drupalcode.org/project/commerce.git/commitdiff/ce87876