Decrypting credit card expiration dates?

Posts: 67
Joined: 05/05/2008
Bug Finder

Hi all,

The site I'm working on sells time-based recurring memberships. The client asked for a way to export the list of users who have current recurring memberships and whose credit cars will expire soon.

What's the best way to approach this problem?

I'm thinking that I would have to decrypt the expiration month and year from the uc_payment_credit table, and then connect the order_id to a particular user. Should be simple.

But how do I decrypt the data? Is there an UC function to handle that?

Posts: 67
Joined: 05/05/2008
Bug Finder

OK, found the following code:

<?php
$key
= uc_credit_encryption_key();
$crypt = new uc_encryption_class;
$crypt->decrypt($key, $cc_exp_month);
?>

but $key is not being set... hmm...

Posts: 67
Joined: 05/05/2008
Bug Finder

Alrighty... problem was that I have two copies of the files (one local, one on a staging server), and only the staging server has the encryption enabled (both use the same DB).

The above code works just fine on staging Smiling

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

For future reference, this won't work past RC 4 b/c of the way I changed CC data storage. It will be better in the long run for you to maybe capture the expiration as part of the checkout submission for users w/ roles... maybe just a record of how many more billing periods till it will expire or something. You can store this in the order's data array if you want to or in a separate DB table. (Heck, might just add a column to the user fee table.)

Posts: 67
Joined: 05/05/2008
Bug Finder

Thanks for the info, Ryan. Guess it's a good thing we're using RC4 Smiling.

Will definitely keep your suggestion in mind for the future, but since this project will never be upgraded (Drupal or UC), I won't mess with what works Eye-wink.