User login

Through the Ubercart payment details rabbit hole

To program you have to crawl on your belly through a maze in a dark mine shaft memorizing all the turns until you find the problem, grope at it with your hands until you understand what's broken, back out slowly, and get the tool to fix it. Then you have to remember how you crawled in there to begin with.

Robert Douglass

Trying to figure out how the credit card type is currently stored— it splits into two parts on the saving side, and the part that seems to be kept gets some weird encryption... maybe this will be more straightforward to look at from the retrieval side.

Oops.

We know we see it on the page admin/store/orders/[number] and we find that this is defined by the hook_menu implementation in the file uc_order.module:

<?php
 $items['admin/store/orders/%uc_order'] = array( ... )
?>

Which calls:
'page callback' => 'uc_order_view',
and is in:
'file' => 'uc_order.admin.inc',

Somewhere down inside the uc_order_view() function it becomes clear that this gets a whole bunch of different panes:

<?php
  $panes = _order_pane_list($view);
  foreach ($panes as $pane) {
    if (in_array($view, $pane['show']) &&
        variable_get('uc_order_pane_'. $pane['id'] .'_show_'. $view, $pane['enabled'])) {
      $func = $pane['callback'];
      if (function_exists($func) && ($contents = $func($view, $order)) != NULL) {
?>

uc_payment.module implements hook_order_pane() which is called above and returns uc_order_pane_payment() for its callback.

http://drupalcontrib.org/api/function/_save_cc_data_to_order/6

<?php
/**
 * @file
 * Module for determining credit card type from the first 2 digits.
 * @see http://en.wikipedia.org/wiki/Bank_card_number
 */

/**
 * Implements hook_order().
 */
function uccardtype_order($op, &$arg1, $arg2) {
  drupal_set_message($op . '<pre>'.var_export($arg1,TRUE).'</pre>'); // @DEBUG
  if ($op == 'save' && $arg1->payment_type == 'credit') {
    $type = uccardtype_get($arg1->payment_details['cc_number']);
    $arg1->payment_details['cc_type_auto'] = $type;
    if (!$arg->payment_details['cc_type']) {
      // If the user has not selected a type, set it to auto-determined one.
      $arg1->payment_details['cc_type'] = $type;
    }
  }
}
?>

Searched words: 
uc_order_payment_pane order payment pane pain UC commerce module

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.