Reuse Credit Card

Posts: 75
Joined: 10/29/2007
Bug Finder

Has anyone setup their Ubercart to allow shoppers to re-use their credit card? I know we have the option of saving cc in the database (encrypted). Seems like we could have a link on top of the credit that says "Use Credit Card on file" (like we have for shipping address) that would copy it from database and populate for returning uses. Most large store sites, amazon, buy.com, etc, do this.

Jim

Posts: 3206
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I'm not sure... I don't think I like the security implications of something like this. I believe Amazon.com can get away with it since they're their own CC processor, but I'm not sure about others. If a payment processor offered this as part of their API, I'd consider integrating it. They just know CC security a lot better than me. Sticking out tongue

Posts: 60
Joined: 12/28/2007
Bug FinderGetting busy with the Ubercode.

I agree with Ryan on this. That's why I wrote the "Authorize.net Advanced (CIM)" module (http://www.ubercart.org/contrib/2537). You can read more about CIM here: http://www.authorize.net/solutions/merchantsolutions/merchantservices/ci...

I know that at least a couple people are using this module successfully for the purpose that you mentioned.

Posts: 9
Joined: 03/04/2008

That's great!!!
I was going to need something like this. Good to know smarter folks than I have done this.

So this should replace the authorize.net payment module? How exactly does it work? Is it an extension?

Posts: 60
Joined: 12/28/2007
Bug FinderGetting busy with the Ubercode.

Yes, it's meant to be a replacement for the standard Authorize.net module.

It takes a little bit of work to set it up, but there's a fairly detailed README file included which should walk you through it. (And if you don't think it's clear, let me know!)

Good luck!

Posts: 75
Joined: 10/29/2007
Bug Finder

This looks like perfect solution for me too, We already use Authroize as our credit vendor.

Thanks for posting

Posts: 75
Joined: 10/29/2007
Bug Finder

I just installed this and I like it, I'm going to run a few transactions through later tonight when I can put our authorize account in test mode. I have 2 questions.

1. What do you mean by "you can display the order total preview in the Cart Contents pane like I do currently."
- Are you talking about the total on the review screen or is there another place to reivew the total.

2. I noticed taht your box was centered in screen when rest of Ubercart was left justified, is this due to my zen theme, or do I need to edit your CSS to move it to the left.

Thanks for a great module.
Jim

Posts: 60
Joined: 12/28/2007
Bug FinderGetting busy with the Ubercode.

You're welcome.

1) You can theme the Cart Contents pane on the checkout screen and add anything you want there. For example, I add shipping and discounts and an order subtotal, right below the cart contents. This seems more intuitive to me - putting all of the cost information in one place.

2) I think this must be due to your theme. Mine is left justified. You should have all the CSS id's and classes you need to re-arrange it as you like. (You can override them in your style.css rather than editing the module CSS directly too...not sure if that's what you meant)

Best,
Chad

Posts: 75
Joined: 10/29/2007
Bug Finder

Super, for 2 I just added this to my style.css
.no-credit-cards-stored {float:left};

Can you upload your theme_cart_contents so I can adjust what you have, Sounds LIke I want the same thing, just shipping, and sales tex. I'm not the best themer yet Smiling

Posts: 9
Joined: 03/04/2008

Another question about integration with existing modules.
What would I need to modify to get uc_recurring to work with uc_cim?
Might be a silly question that I can find myself, but if someone has an answer, it would be much appreciated.

Posts: 75
Joined: 10/29/2007
Bug Finder

Future Versions.

I've played with this module for a couple of days, and I really like it. I added CIM to my Autoorize account ($20 a month) and I've enabled this in Ubercart. Here are a couple of suggestions for future version.

1. I'd suggest that this module does credit card number validation using check digit / etc. I have noticed that if you enter a bogus number it still gets stores in the cim and in ubercart. This should check before we see the review form.

2. This moudule seems to reset the shipping selection. So if I've picked a shipping methold, then enter a new card it makes me enter shipping info again, and it even goes out and gets quotes again. My workaround was to put the shipping pane after the payment pane, but it would be good if these worked together.

3, As stated before, a view with total + shipping, etc would be nice to have when this is enabled.

Posts: 75
Joined: 10/29/2007
Bug Finder

I had to do a little hack, and I'd like to figure out if this can be done w/o hacking the module. Before enabling this module, I had overrided the validation on the uc_cart_checkout to see if the expiration date was going to be expiring soon. I did this becuase I'm selling a product that is billed over several months, and I would like to get credit cards that are not expiring in the next few month. Anyway, I was using the values posted into the exp_month and exp_year to check this.

if (strcmp('uc_cart_checkout_form', $form_id) != 0) return;
$form['#validate'] = array('credit_check_expdate' => array());

When I installed the CIM module, I have a field when they enter a new credit card, but if they had an existing card stored, I could not check the date. I inserted 2 lines into the uc_cim.module at 774 and 792 (during review). These call the date checker, but I hate to modify contrib code. Is there a way to hook into this form my module.

These 2 lines were added to cim:
check_leap_date($arg1->payment_details['cc_exp_month'], $arg1->payment_details['cc_exp_year']); // at 774

check_leap_date($profile['cc_exp_month'], $profile['cc_exp_year']); // at 793

Then I have this function in my module

<?php
function check_leap_date($month, $year) {
      
   
$items = uc_cart_get_contents();
    for (
$i=0; $i < count($items); $i++) {
         if (
$items[$i]->model == 'LEAP')
        {
       
$mk_time mktime(0, 0, 0, date("m")+4, 0,   date("Y"));
       
$cc_exp_mktime mktime(0, 0, 0, $month, 0,   $year);
        if (
$mk_time >= $cc_exp_mktime)
            {
               
form_set_error('error', 'Your Credit Card expires Within the Next 5 months, Please enter a Credit Card that will not expire for the next 5 months');
               
drupal_goto("cart/checkout");
            }
        }       
    } 
//end for   
   
}
?>

Posts: 60
Joined: 12/28/2007
Bug FinderGetting busy with the Ubercode.

You should be able to get the credit card expiration of an existing card, as long as you know the user and order:

$profile_id = uc_cim_get_profile_id($user_id);
$credit_card = uc_cim_get_payment_profiles($profile_id, $order['cim_ppid']);

You should then be able to get the expiration from:

$credit_card['cc_exp_year'] and $credit_card['cc_exp_month']

You should then be able to use your old method, no different with CIM enabled, I think.

Posts: 60
Joined: 12/28/2007
Bug FinderGetting busy with the Ubercode.

1) I'm not sure what you mean about credit card validation. Do you have "Validate credit card numbers at checkout" selected at admin/store/settings/payment/edit/methods? It should respect that.

2) Do you mean that when you press enter in one of the credit card fields it executes a "click to calculate shipping"? This would be because that button comes first on the page, so your browser submits that button when you press enter. No way around this that I know of, other than some fancy CSS or javascript work... but maybe I misunderstood your problem.

3) For adding the total + shipping to you cart contents pane, you just need to add a function phptemplate_cart_review_table($show_subtotal = TRUE) to your template.php. You can copy and paste the standard cart_review_table into there and then tweak it...add a couple rows to the table with the extra info you need. If you want it to dynamically update with shipping selection and tax based on the state, you'll have to figure out how to integrate it with the javascript used to handle those updates. Shouldn't be too hard, i don't think, but I haven't tried it yet...

Posts: 75
Joined: 10/29/2007
Bug Finder

I've noticed that the billing information is not put in the $order object when using a cim stored card. This makes it not appear on invoices, etc. Looks like it would be pretty easy to load the $order object by using the above mentioned functions. I'm assuming that I can do this before the order is saved the final time. I'm going to code this tonight, do you see any problem in pulling up the bililng info and populating the $order?

Thanks

Jim

Posts: 60
Joined: 12/28/2007
Bug FinderGetting busy with the Ubercode.

Well, it depends what billing info you're looking for. You can get some of the credit card info (last four, type, expiration) using the above method. The billing address isn't stored there though. It is stored in the $order object the first time that card was used, so you could look for it there and duplicate it. You'd have to join {uc_order} and {uc_payment_cim} on order_id, look for the cim_ppid of the card used, and find a record where the billing info is populated in the $order object. You could then save it to the $order object for the current order. The problem with this is that when the credit card is updated to a new address, you'll probably keep pulling in the old, out-of-date info....

Alternatively, you could make a call to get_customer_payment_profile_request($profile_id, $payment_profile_id). That retrieves the info from Authorize.net's servers, so it would be most accurate, but also the slowest. Since the order object can be saved a couple times, I'd be careful about this for performance reasons...

Posts: 60
Joined: 12/28/2007
Bug FinderGetting busy with the Ubercode.

olliemuh - uc_cim already works with uc_recurring. You just need to make sure to select uc_cim as your recurring fee handler in the recurring fee setup (admin/store/settings/products/edit/features).

Posts: 75
Joined: 10/29/2007
Bug Finder

When I tried to use the save $op from hook_order, it would not save into the order object, so I used the total $op. Here's the query I used to get the latest non blank billing info from the cim and order table and save it with the order.

<?php
if ( $op == 'total' && empty($order->billing_city)  && !empty($order->cim_ppid) ) {

   
$query = "SELECT billing_first_name,billing_last_name,billing_phone,billing_company,billing_street1,
billing_street2,billing_city,billing_zone,billing_postal_code,billing_country from uc_orders inner join uc_payment_cim on uc_payment_cim.order_id = uc_orders.order_id where cim_ppid = $order->cim_ppid and billing_city <> '' and uid = $user->uid order by uc_orders.order_id desc limit 1 "
;
   
$row = db_fetch_object(db_query($query));
$order->billing_postal_code = $row->billing_postal_code;
$order->billing_first_name = $row->billing_first_name;
$order->billing_last_name= $row->billing_last_name;
$order->billing_phone = $row->billing_phone;
$order->billing_company = $row->billing_company;
$order->billing_street1 = $row->billing_street1;
$order->billing_street2 = $row->billing_street2;
$order->billing_city = $row->billing_city;
$order->billing_zone = $row->billing_zone;
$order->billing_postal_code = $row->billing_postal_code;
$order->billing_country = $row->billing_country;

}
?>

Posts: 75
Joined: 10/29/2007
Bug Finder

I just tried to open admin/store/orders/'. order# .'/cim-charge - and got the following error. This is on the initial purchase that stored the CDM,

BTW - I just processed our first refund for a partial order amount, and it worked great!

Stored Credit Card:
ERROR: E00003 (The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:customerPaymentProfileId' element is invalid - The value '' is invalid according to its datatype 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:numericString' - The Pattern constraint failed.)

Posts: 60
Joined: 12/28/2007
Bug FinderGetting busy with the Ubercode.

Hey, glad the refund worked!

For your error, it looks like you're going to (or being taken to) the wrong URL. It should be:

admin/store/orders/[order id]/cim-charge/[cim_ppid]

Without that last part, you'll get that error. I should probably trap that error before it happens. But the question remains, how did you get to that URL? Did you click "(charge)" next to the credit card you wanted to charge? Was that link missing the cim_ppid portion? I can't think of any reason that would happen, other than you're somehow missing that data in your uc_cim_payment_profiles table.