My Cybersource account was just set to live mode, but apparently something is still set wrong at the Cybersource side, as my transactions don't work. CS is returning responses containing just a Response Code 150 (Error: General system failure), but no ccAuthReply field. This is causing the error handling of commerce_cybersource to throw errors like so:

Notice: Undefined property: stdClass::$ccAuthReply in commerce_cybersource_soap_cc_submit_form_submit() (line 507 of /www/sites/all/modules/commerce_cybersource/commerce_cybersource.module).
Notice: Trying to get property of non-object in commerce_cybersource_soap_cc_submit_form_submit() (line 507 of /www/sites/all/modules/commerce_cybersource/commerce_cybersource.module).
Notice: Undefined property: stdClass::$ccAuthReply in commerce_cybersource_soap_cc_submit_form_submit() (line 550 of /www/sites/all/modules/commerce_cybersource/commerce_cybersource.module).
Notice: Trying to get property of non-object in commerce_cybersource_soap_cc_submit_form_submit() (line 550 of /www/sites/all/modules/commerce_cybersource/commerce_cybersource.module).
Notice: Undefined property: stdClass::$ccAuthReply in commerce_cybersource_soap_cc_submit_form_submit() (line 551 of /www/tagitscanit/sites/all/modules/commerce_cybersource/commerce_cybersource.module).
Notice: Trying to get property of non-object in commerce_cybersource_soap_cc_submit_form_submit() (line 551 of /www/tagitscanit/sites/all/modules/commerce_cybersource/commerce_cybersource.module).
We received the following error processing your card: -
Please enter you information again or try a different card.

The offending Cybersource response causing this:

CyberSource SOAP response:

stdClass Object
(
    [requestID] => 3285482905930176056696
    [decision] => ERROR
    [reasonCode] => 150
    [requestToken] => AhhzbwSRZDZ4H2sabcrwJASapw/JR/zof1abckyro9Jt2QEg73bF
)

So.. if we just add an isset() to line 507, then it prevents the first error:

    // If we didn't get an approval response code...
    if (!isset($response->ccAuthReply->reasonCode) || $response->ccAuthReply->reasonCode != 100) {
      // Create a failed transaction with the error message.
      $transaction->status = COMMERCE_PAYMENT_STATUS_FAILURE;
    }
    else {

And then finally, some extra error handling at line 550, to again detect that error and return a meaningful response from the general Cybersource responseCode if it exists. I added the two elseif blocks at the bottom:

  // If the payment failed, display an error and rebuild the form
    if (isset($response->ccAuthReply->reasonCode) && ($response->ccAuthReply->reasonCode != 100)) {
      drupal_set_message(t('We received the following error processing your card: @reason', array('@reason' => commerce_cybersource_reason_message($response->ccAuthReply->reasonCode))), 'error');
      drupal_set_message('Please enter you information again or try a different card.', 'error');
      return FALSE;
    } // If there was no ccAuthReply key in the response, check for a general reasonCode to fail on
    elseif (!isset($response->ccAuthReply->reasonCode) && isset($response->reasonCode)) {
      drupal_set_message(t('We received the following error processing your card: @reason', array('@reason' => commerce_cybersource_reason_message($response->reasonCode))), 'error');
      drupal_set_message('Please enter you information again or try a different card.', 'error');
      return FALSE;      
    } // If there was no general reason code either, fail with a general error
    elseif (!isset($response->ccAuthReply->reasonCode) && !isset($response->reasonCode)) {
      drupal_set_message(t('We encountered an error contacting our payment processor. Please try submitting your payment again.'), 'error');
      return FALSE; 
    }

These changes have tidied it up for me, now my error message shows the correct CS error description:

We received the following error processing your card: Error: General system failure.
Please enter you information again or try a different card.

Patch coming next post, once I have the issue # to put in the filename.

Comments

damien_vancouver’s picture

Assigned: damien_vancouver » Unassigned
Status: Active » Needs review
StatusFileSize
new2.27 KB

My patch for this against 7.x-1.x-dev for review.

andyg5000’s picture

Good find here. I could reproduce this by attempting live requests with a test account. If we add checks for $response->reasonCode before attempting to check authorization and capture reasons these errors can be prevented. Here's a slightly simpler patch to fix this issue.

damien_vancouver’s picture

ah yes that is much nicer on the eyes!

damien_vancouver’s picture

Issue summary: View changes

fix typo

rszrama’s picture

Status: Needs review » Fixed

Thanks for your efforts on this back in the day, sorry we never carried this forward to a full release. I'm leaving the 7.x branch marked as supported to avoid error messages in the UI, but given the 7+ years that have elapsed, I'm marking all 7.x issues outdated and focusing on a feature complete integration in the 8.x branch.

rszrama’s picture

Status: Fixed » Closed (outdated)