When processing the payment form submission, the check for card on file seems to be off.
Based on the comments, the code that follows a valid "if" check in this case should be used to process a non-card-on-file payment. However looking at the checks, this will only validate if the card-on-file module and cardonfile settings value exist.
// If the customer specified payment using a new credit card, attempt that
// transaction (either with storing the card or not) and return the result.
if (module_exists('commerce_cardonfile') && $payment_method['settings']['cardonfile'] &&
$pane_values['cardonfile'] === 'new' &&
!empty($pane_values['cardonfile']) && !empty($billing_address)) { ... }
The else block for the above has code specific to cardonfile only and attempts to call commerce_cardonfile_load which obviously fails if you don't have that module installed.
I haven't looked at the cardonfile module so I don't know what options/variables are passed based on user request (use card on file, store new card, or do not store...which will act the same as not using caronfile module) so I am only assuming the checks here based on what was already in the module. This has NOT BEEN TESTED.
//Handle request to use card from file or to store the card
if (module_exists('commerce_cardonfile') && $pane_values['cardonfile']) {
if ($pane_values['cardonfile'] === 'new') {
$card = commerce_beanstream_create_profile($payment_method, $order, $pane_form, $pane_values, $billing);
if (empty($card)) {
//should there be a message here?
return FALSE;
}
}
else {
$card = commerce_cardonfile_load($pane_values['cardonfile']);
// Fail now if it is no longer available or the card is inactive.
if (empty($card) || $card->status == 0) {
drupal_set_message(t('The requested card on file is no longer valid.'), 'error');
return FALSE;
}
}
// Run the transaction on the previous/new stored card.
return commerce_beanstream_cardonfile_charge($payment_method, $card, $order, $charge);
}
else //process card as entered without using cardonfile
{
$order->data['commerce_beanstream'] = $pane_values;
// Run the transaction without storing the card.
$result = commerce_beanstream_transaction($payment_method, $order, $charge, $pane_values);
// if $result is equal to FALSE, the credit card has been declined - stop
// checkout and give user msg.
if($result == FALSE) {
return FALSE;
}
return TRUE;
}
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | commerce_beanstream-cardonfile-breakage-2428119.patch | 9.4 KB | spiderman |
Comments
Comment #1
tklawsuc commentedComment #2
spidermanHi tklawsuc,
Thanks for reporting this- the logic in this section of code does indeed look wonky, and I've been able to produce a failure in a test environment without the Card on File module. I'll try to rework this section and post a patch for testing shortly.
Thanks,
Derek
Comment #3
spidermanOk I've re-worked the logic of this section of code, and done some basic testing of the most common cases. I haven't thoroughly tested all failure cases (ie. card is declined) yet, but I'm hoping somebody else can validate my patch is at least roughly working :)
Please note this is rolled against the most recent 7.x-2.x branch, which includes a couple of patches from recently closed issues.
Comment #4
spidermanI've just re-rolled this and committed it in an effort to clean up the issue queue tonight. This is freshly rolled against a couple of other patches I've committed tonight, and it appears to be working for me. As this is prep for another "alpha" release, I'm not too worried as long as it doesn't break things entirely for anybody. On my test site, I was able to disable Card on File, and run transactions normally.
Comment #6
spidermanThis is committed and rolled into new 2.0-alpha1 release.