25 replies [Last post]
VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Was this information Helpful?

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

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Reuse Credit Card

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

chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
Re: Re: Reuse Credit Card

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/cim/

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

olliemuh's picture
Offline
Joined: 03/04/2008
Juice: 23
That's great!!! I was going

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?

chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
Re: That's great!!! I was going

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!

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: That's great!!! I was going

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

Thanks for posting

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: Re: That's great!!! I was going

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

chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
You're welcome. 1) You can

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

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: You're welcome. 1) You can

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

olliemuh's picture
Offline
Joined: 03/04/2008
Juice: 23
Re: Re: You're welcome. 1) You can

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.

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Future Versions. I've played

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.

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Future Versions. I've played

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   
   
}
?>
chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
Re: Re: Future Versions. I've played

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.

chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
Re: Future Versions. I've played

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...

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: Future Versions. I've played

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

chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
Re: Re: Re: Future Versions. I've played

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...

chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
Re: Re: Re: You're welcome. 1) You can

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).

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: Re: Re: You're welcome. 1) You can

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;

}

?>
VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: Re: Re: Re: You're welcome. 1) You can

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.)

chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
Re: Re: Re: Re: Re: Re: You're welcome. 1) You can

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.

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: Re: Re: Re: Re: Re: You're welcome. 1) You can

I think it is written in the readme or the menu section of the module.

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Is CIM Compatible with RC5?

I just updated my Test Server to RC5, and I've tried to make a few test orders. I'm not able to process orders from stored records, and when I enter a new card in CIM, the expiration / CVV seems to be getting dropped. I have the module set to production and not test, I was just going to make a couple of charges and void from autorhize to test. I've not really tested this much yet, I just wanted to see if anyone has tested CIM with RC5.
Thanks
Jim

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Is CIM Compatible with RC5?

@Jim - With a cursory glance through the code, I can't really tell what would be preventing this from working.

@chadcrew - There shouldn't have been any changes to the API regarding when and where CC data gets stored, but I'm happy to be of service rooting out any bugs if you have any questions for me.

chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
Re: Re: Is CIM Compatible with RC5?

It's quite possible that the new credit card handling code is causing a problem with CIM. I haven't had a chance to check out RC5 yet - I've been a bit swamped lately - but will try to get to that this week and let you know what's going on.

-Chad

chadcrew's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 12/28/2007
Juice: 195
Re: Re: Re: Is CIM Compatible with RC5?

Okay, I had to update a couple things in the uc_cim module to make it compatible with Ubercart RC5, due to the new credit card security system. I just posted it in contribs. Hopefully it will be a smooth update.

Note that I'm not sure if this version will work with prior versions of Ubercart now. You're welcome to give it a try and let me know. Smiling For now, I just put a warning in there that it probably won't.

Let me know how you make out with it.

Chad

VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: Re: Re: Is CIM Compatible with RC5?

Thanks for the quick response, I'll give it a try and let you know how it goes.
J