When I enable the Credit Card FIelds for "CVV", on the checkout page I put in a CVV and click review order... on the Review ORder page I get the error:

Notice: Undefined index: cc_cvv in uc_payment_method_credit() (line 564 of /home/content/21/7420121/html/adb_ubercart/sites/all/modules/ubercart/payment/uc_credit/uc_credit.module).

I get similiar errors with "Card Owner" text field

Comments

tr’s picture

Title: Problems when enabling Credit Card Fields (ie: CVV or Card Owner) » Credit card information unavailable at review order stage.
Priority: Major » Critical
Issue tags: +Release blocker

Looks like this part of the code didn't get ported to Drupal 7. None of the credit card information except for card number, card expiration year, and card expiration month is available on the review order page.

JohnDoranNY’s picture

I am getting the same error and it seems necessary for WPP (?) when I have it disabled and use WPP I get errors that cvv was missing.

Dylanotron’s picture

I've been using the dev version of Ubercart on a live production site, interfacing with auth.net credit payment and successfully matching CCVs until I updated to this current dev version yesterday. My previous Ubercart install was the dev version on 5-26.

JohnDoranNY’s picture

I'm using DEV versions (updating daily as they come available) and still having the CVV (and other credit card fields) not moving form checkout to review to merchant processes.

JohnDoranNY’s picture

Sorry I do not know how to do GIT patches....

in uc_credit.module -> function uc_credit_uc_order($op, $order, $arg2) (line 313)

Adding the following code under line 373:

            if (isset($order->payment_details['cc_cvv'])) {
              $cc_data['cc_cvv'] = $order->payment_details['cc_cvv'];
            }
            if (isset($order->payment_details['cc_owner'])) {
              $cc_data['cc_owner'] = $order->payment_details['cc_owner'];
            }
            if (isset($order->payment_details['cc_bank'])) {
              $cc_data['cc_bank'] = $order->payment_details['cc_bank'];
            }

This will write missing (possibly 3) pieces of information to cache...

After doing this on the reveiw page, I do in fact see the Owner and CVV (I did not check with Bank but assume it will work now too).

Now to figure out why when I submit to the PayPal WPP sandbox it issues:

•Notice: Undefined index: AVSCODE in uc_paypal_wpp_charge() (line 447 of /home/content/21/7420121/html/sites/all/modules/ubercart/payment/uc_paypal/uc_paypal.module).
•Notice: Undefined index: CVV2MATCH in uc_paypal_wpp_charge() (line 449 of /home/content/21/7420121/html/sites/all/modules/ubercart/payment/uc_paypal/uc_paypal.module).
•We were unable to process your credit card payment. Please verify your details and try again. If the problem persists, contact us to complete your order.
•Notice: Undefined index: do_complete in uc_credit_cart_review_post_form_submit() (line 1322 of /home/content/21/7420121/html/sites/all/modules/ubercart/payment/uc_credit/uc_credit....

Those are PayPal issues not related (I don't think) to this issue.. but I'll try to track it down.

Edit...

Going through the code and debugging it for the paypal module, the problem does seem to be in the credit module...

in the Order passed to the paypal module I see the following:

[payment_details] => Array
        (
            [cc_number] => 8335
            [cc_exp_month] => 6
            [cc_exp_year] => 2015
            [cc_type] => Mastercard
            [cc_cvv] => 123
            [cc_owner] => Some User
        )

SO the problem is cc_number is being sent as only last four digits to paypal wpp function throwing errors from paypal.

Looking in the uc_credit.module, there is already a function called uc_credit_display_number() that handles the truncated last 4 digit display, so there is no reason for code that exists in function uc_credit_cron() : 'cc_number' => substr($data['cc_data']['cc_number'], -4), and function uc_credit_uc_order() : under case: save -> 'cc_number' => substr($order->payment_details['cc_number'], -4), since the forms that output the credit card to the user already are using the function for it. What this was doing is saving only the last 4 digits of the credit card to the Order object, and when passed to gateways (in my case, paypal) it fails since its not a valid credit card number any longer.

By replacing 'cc_number' => substr($data['cc_data']['cc_number'], -4) with just 'cc_number' => $data['cc_data']['cc_number'] in both cases worked for me. on Review page I see: Card Number: ------------8502 and CVV : --- which is what is expected. and now finally when I click submit order I get a successful completion! yey!

gmopinillosv’s picture

Hello there

I did all what #5 suggest and didn't work for me. furthermore the cc numbers appears and cvv numbers too. It is not good.

Also I saw the next code to recover the number truncared:

// Recover cached CC data in $form_state['values']['panes']['payment']['details'] if it exists.
if (isset($form_state['values']['panes']['payment']['details']['payment_details_data'])) {
$cache = uc_credit_cache('save', $form_state['values']['panes']['payment']['details']['payment_details_data']);
}

// Account for partial CC numbers when masked by the system.
if (substr($cc_data['cc_number'], 0, strlen(t('(Last4)'))) == t('(Last4)')) {
// Recover the number from the encrypted data in the form if truncated.
if (isset($cache['cc_number'])) {
$cc_data['cc_number'] = $cache['cc_number'];
}
else {
$cc_data['cc_number'] = '';
}
}

I am having problems with this issue. I get the next error yet:

The credit card type did not pass validation.
Notice: Undefined index: cc_type in uc_paypal_wpp_charge() (line 349 of /home2/wholesa1/public_html/sites/all/modules/ubercart/payment/uc_paypal/uc_paypal.module).
Notice: Undefined index: message in uc_payment_process_payment() (line 514 of /home2/wholesa1/public_html/sites/all/modules/ubercart/payment/uc_payment/uc_payment.module).
We were unable to process your credit card payment. Please verify your details and try again. If the problem persists, contact us to complete your order.
Notice: Undefined index: do_complete in uc_credit_cart_review_post_form_submit() (line 1327 of /home2/wholesa1/public_html/sites/all/modules/ubercart/payment/uc_credit/uc_credit.module).

Any idea will be appreciated.

Thanks.

JohnDoranNY’s picture

(2) Did you make changes to:

Line 237 (in function uc_credit_cron())

'cc_number' => substr($data['cc_data']['cc_number'], -4),
to
'cc_number' => $data['cc_data']['cc_number'],

Line 368 (in function uc_credit_uc_order())

'cc_number' => substr($order->payment_details['cc_number'], -4),
to
'cc_number' => $order->payment_details['cc_number'],

(as for seeing CC# or CVV, I see it when I am logged in as an administrator only.. if i am logged in as a authenticated user, I see only the mask for CCNumber and CVV).

The error you reported Notice: Undefined index: cc_type in uc_paypal_wpp_charge() (line 349 is happening because the order object was being stored with the last-4 cc#... function uc_paypal_wpp_charge() in uc_paypal.module loads the order object on line 287, and if you look at the cc_number its only the last 4 digits (unless you make the changes I described above)... I was getting the same errors with PayPal WPP. Since it seems you are not passing the credit card type (which would be stored in the order object as well), uc_paypal_wpp_charge() calls a function to figure out what credit card type based on the first number of the credit card (3 for amex, 4 for visa, 5 for mastercard)... since its not being passed the CC_Number in full it didn't recognize what credit card type it was.

The code if (substr($cc_data['cc_number'], 0, strlen(t('(Last4)'))) == t('(Last4)')) { is looking to see if the string "Last4" was stored in the credit card number (assuming that it will be the truncated version), the pull the full out of cache... (which it shouldn't be stored as Last4: ####) it should be stored as a full credit card number, and the function to display it on the form should do the truncating.

One other change I needed to make to uc_paypal.pages.inc (function uc_paypal_ipn()) starting at line 42, the //Assign posted variables to local variables

// Assign posted variables to local variables
  if (isset($_POST['payment_status'])) {
    $payment_status = check_plain($_POST['payment_status']);
  }
  if (isset($_POST['mc_gross'])) {
    $payment_amount = check_plain($_POST['mc_gross']);
  }
  if (isset($_POST['mc_currency'])) {
    $payment_currency = check_plain($_POST['mc_currency']);
  }
  if (isset($_POST['mc_fee'])) {
    $payment_fee = check_plain($_POST['mc_fee']);
  }
  if (isset($_POST['business'])) {
    $receiver_email = check_plain($_POST['business']);
  }
  if ($receiver_email == '' && isset($_POST['receiver_email'])) {
    $receiver_email = check_plain($_POST['receiver_email']);
  }
  if (isset($_POST['txn_id'])) {
    $txn_id = check_plain($_POST['txn_id']);
  }
  if (isset($_POST['txn_type'])) {
    $txn_type = check_plain($_POST['txn_type']);
  }
  if (isset($_POST['payer_email'])) {
    $payer_email = check_plain($_POST['payer_email']);
  }

I put them all in if isset statements since I was getting errors that mc_fee didn't exist... the IPN returned back from PayPal didn't contain 'mc_fee' so it was throwing errors..

With those changes above I was able to finally get through my checkout to paypal WPP and back successfully...

PS this was done against the LATEST dev version as of 6/22/2011.

gmopinillosv’s picture

Hello again

@johnDoranNY , you are right. Only cc numbers appears on administrator (I gave him permission). So I tried again and also I added your code in uc_paypal.pages.inc too.
Also I selected "Enable card type selection on checkout form" in Payment Methods but when I save configuration appears the next message:

Notice: Undefined index: update_cc_encrypt_dir in uc_credit_settings_form_submit() (line 936 of /home2/wholesa1/public_html/sites/all/modules/ubercart/payment/uc_credit/uc_credit.module).

So, I came back how it was and the message keep appeasring.
Any idea what is happening? Thanks.

JohnDoranNY’s picture

Question: did you create a 'key' directory?

read: http://www.ubercart.org/docs/user/2731/credit_card_settings

You need to have a directory to store a encryption key.. ubercart writes a file there which is then called by line 936 as you posted above.


Credit card data security

Security is extremely important for websites handling customer credit card data. You should be as careful as possible in the way you protect the data to prevent credit card fraud. Please be sure you are selecting the right options, as some choices may decrease the security of credit card data on your website and should be avoided if at all possible. Most payment gateways will require compliance with a set of security standards called the PCI DSS. When the Ubercart credit card module is used in conjunction with an SSL certificate and Drupal's Secure Pages module, your site will conform to these standards.

First, you must configure the encryption settings for card data during checkout. To do this, you'll need to fill in the filepath textfield. Here you should specify a folder that is outside of your document root (i.e. not in your www or public_html directory) where the module can create a key file to encrypt credit card data. You will need to grant permissions on the folder that allow Drupal to write to it, but you can change this once the encryption file has been created. Relative paths will be resolved relative to the Drupal installation directory, so if you have a directory structure like the following:

mysite
mysite/www <-- Drupal installed here.
mysite/keys

You would be able to specify ../keys and Drupal will make sure the credit card encryption key is created in the proper directory. For security reasons, you should not use your site's files directory except in testing.

Note: If you are updating from a version where encryption was not required, be sure to click the link on the warning message that shows up to encrypt your existing credit card data. Once you do this, you won't be able to do it again. If you accidentally browse away from the page before encrypting existing data, just browse to /admin/store/settings/payment/cc_encrypt to see the form again.

As of Ubercart 1.0 RC 5, there is also a credit card debug mode that you can use when testing or to store encrypted card data with orders for offline processing. This may open you up to vulnerabilities, but you should be aware that even in debug mode Ubercart will truncate credit card numbers to the last 4 digits when a card gets processed. This is in accordance with the PCI DSS restriction that full card numbers and expiration dates should not be stored locally after a card has been authorized/charged. If you must use debug mode for offline processing, you should either manually wipe the numbers or use the "Debug mode data clearing" options on this form to make sure credit card data is not stored any longer than necessary. You may need to consult your terms of service with your payment processor to make sure this method is even possible according to your contract.

Finally, credit card masking by default applies to all users of the site, but it is possible in your user access control settings for you to designate roles that can view whole CC numbers when they're stored.

I hope this helps!

gmopinillosv’s picture

Yes, I already had a key directory and I gave it all permission to write it.

I am using ubercart 7.x-3.0-beta3 May 23 2011.
Will it have something to see?
I don't know why suddendly that message is appearing if I came back how it was.

Thanks.

gmopinillosv’s picture

I forgot to say too that I kept with the process of payment still with that message and when i clicked "submit order" appears the next:

Notice: Undefined index: AVSCODE in uc_paypal_wpp_charge() (line 465 of /home2/wholesa1/public_html/sites/all/modules/ubercart/payment/uc_paypal/uc_paypal.module).
Notice: Undefined index: CVV2MATCH in uc_paypal_wpp_charge() (line 467 of /home2/wholesa1/public_html/sites/all/modules/ubercart/payment/uc_paypal/uc_paypal.module).
We were unable to process your credit card payment. Please verify your details and try again. If the problem persists, contact us to complete your order.
Notice: Undefined index: do_complete in uc_credit_cart_review_post_form_submit() (line 1327 of /home2/wholesa1/public_html/sites/all/modules/ubercart/payment/uc_credit/uc_credit.module).

I am looking for a solution yet. Thanks.

JohnDoranNY’s picture

I am using the latest version of the DEV branch as of June 22 (there may be a new one today I haven't checked yet hehehe)... I was seeing the AVSCODE error and CVV2MATCH error until I made the changes to the credit module I listed above.. then things worked fine as it was getting the 'full' credit card number and could get the credit card type from that (btw: I don't think you need to have credit card type on your checkout form.. you can disable that... paypal wpp function will call a function that checks the first digit of the credit card number and figure out it from there.. (3 = amex, 4 = visa, 5 = mastercard)... so I disabled mine (why make the user fill in one more field than necessary on an already long check out on my clients site where they have to fill out like 15 options or more at any given time).

Once I made teh change to the credit module (using the latest dev version) the error I got was that mc_fee didn't exist, so the code I put above for the uc_paypal.pages.inc fixed that problem... now the only problem I still have (which is reported in another thread) is event though the IPN comes in and is validated by ubercart, the status always stays as 'pending'.

My suggestion would be to download the latest DEV version (not the beta), carefully make the edits I listed above... and test again. I hope that will fix your issue... I know how frustrating it can be as I was ripping my hair out, and what hair I missed, my client found and ripped out :D

rhodet’s picture

@JohnDoranNY....
John thank you for your reply to my question. I've tried to apply the patch you suggested but it hasn't stopped the following notice:Undefined index: cc_cvv in uc_payment_method_credit()...
I would be very appreciative of any suggestions on how to fix this problem....

Thanks,
Temi

JohnDoranNY’s picture

Sorry if this seems like a stupid question but.. do you have CVV enabled on your payment->credit card options? It is required by PayPal WPP...

There REALLY NEEDS to be some built in logic/checking in the Credit Card/PayPal module that if you enable PayPal WPP then the admin should force you to enable CVV (since its not stated on the admin screen that its needed for PayPal WWP). Make sure you have CVV enabled so it gets stored in the 'Order' object and the function for paypal wpp can access it and pass it on to paypal.

I added an issue/feature reqest at #1198414: Adjust Credit Module/PayPal To Force Certain Options When Selected

rhodet’s picture

I just checked and the CVV was enabled...FYI, I have been testing credit card check out not paypal yet...I just don't understand why I keep getting this error

JohnDoranNY’s picture

Now I am more confused as the code you posted earlier was for uc_paypal_wpp (with the AVSCODE and CVV2MATCH error messages in #11 above).. thats the PayPal Website Pro function in the paypal module.

I have only been using/testing the PayPal Website Payment Pro since thats the only method my client wants on their site. I have not tried with other gateways.

rhodet’s picture

sorry for the confusion....I just don't know what to do to fix this problem...very frustrated

gmopinillosv’s picture

Hello again

@JohnDoranNY, I did your recomendation. I renamed old ubercart to ubercart-beta3 and I put new ubercart (dev) But everything keep working with ubercat-beta3 . It didn't recognize the new ubercart folder. So I came back how it was but the entire site crashed. It said missing something and it path showed ubercart-beta3 (which it already not was any longer). I was very worried. After that I renamed again ubercat to ubercart-beta3 and it worked.

Now I stayed with that name and I don't know how came back at its original name.

Have you any idea? Thanks

longwave’s picture

@gmopinillosv: You should not have two copies of the Ubercart folder inside a single Drupal installation, Drupal will get very confused if you do this, which is probably what happened in your case. You should just back up the entire site then replace the ubercart folder with a new version if you are attempting a temporary upgrade.

JohnDoranNY’s picture

This is my first time trying to create a patch.. it was run against the 6/23/2007 DEV branch..

(TR or longwave, if i did this wrong please let me know... )

@gmopinillosv: You need to move the backup out of the sites/all/modules directory to like a /backup/ubercart directory.. Drupal will auto-scan the sites/all/modules directory and try to find modules there.

Edit

Make that the 6/23/2011 branch.. I lost 4 years somewhere!

longwave’s picture

Patch format looks good, but this needs work:

             // Otherwise, save only some limited, PCI compliant data.
             $cc_data = array(
-              'cc_number' => substr($order->payment_details['cc_number'], -4),
+              'cc_number' => $order->payment_details['cc_number'],
               'cc_exp_month' => $order->payment_details['cc_exp_month'],
               'cc_exp_year' => $order->payment_details['cc_exp_year'],
             );

This cannot be committed as it stands. We have to ensure full credit card numbers are not stored once they have been processed, so this needs investigating and fixing in a different way.

JohnDoranNY’s picture

But wouldn't the credit card need to be stored in the cache (attached to the Order Object) so on the next page it can be accessed via the gateway? I think this was overwriting the cached copy of the data with a truncated last-4 digit and when the next page requested it, it no longer had the full cc_number. I would think it would be the job of the procedure used after gateway response (passed or failed) that should clear out the data?

longwave’s picture

This code worked in D6, so we need to figure out how the flow has changed in D7 to stop it working.

Dylanotron’s picture

Was working correctly in Beta 2 version on 5/26/11.

gmopinillosv’s picture

@JohnDoranNY, I can not remove the backup (ubercart-beta3) because the entire site crash. Also if I rename that folder too.
I don't know what to do. How do I reset all site without loss my information?

Any idea will be hight appreciated? Thanks.

longwave’s picture

Status: Active » Needs review
StatusFileSize
new2.74 KB

The attached patch fixes the following:

  • Full credit card number is correctly passed to the gateway for processing.
  • CVV is removed from the order review screen (we should not need to show this back to the user anyway).
  • Order details store everything except the last 4 digits and the CVV when not in debug mode (this is still PCI compliant).

Please test and give feedback.

JohnDoranNY’s picture

longwave, you are the man!

I applied it to the latest dev version (today, 6/30/2011) and it worked perfectly! Woo Hoo! Thanks!

longwave’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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

mpearrow’s picture

Sorry to re-open this, but I am experiencing the same errors reported in comment #11. I am using Drupal 7.7 and Ubercart 7.x-3.x-dev (having previously tried beta4, getting the errors, and replacing it with the dev version).

I can't quite make out from the dialog in this thread if the patch referenced in #26 is now part of beta4 or 7.x-3.x-dev? I see that the patch was committed but not sure if it is in the actual release now.

mpearrow’s picture

Status: Closed (fixed) » Active
Island Usurper’s picture

Status: Active » Closed (fixed)

The errors in #11 don't really have anything to do with the patch. They are caused by a failure message from PayPal not having the information we expect, not missing credit card data during the form submission.

The patch in #26 was indeed committed before beta4 was released, so credit card data should reach any of the payment gateways correctly.

It could be that the API for PayPal WPP was changed recently, so make a new issue for this problem and I'll see if that's the case.

Island Usurper’s picture

Actually, taking care of it in #1266824: Notices on failed PayPal WPP payment. Those notices are easy to take out.