Recurring fee: Initial Charge / Regular Interval confusion

Project:Ubercart Contributions
Component:Code
Category:
Priority:normal
Assigned:Unassigned
Status:active
Description
Project: 
Ubercart

After creating a product and adding a recurring fee feature, this is what it says:

"When this product is purchased, add a fee for $25.00 charged first after 1 days and every 1 days after that 99 times."

I think this implies that the person will first be charged $25 for the product (product price), then $25 the day after (initial recurring fee charge) and $25 each day afterward (regular interval charge).

However, the day after the initial purchase, nothing happens. No fee is added, but it is added the day afterward, and from then on it works as expected. The first recurring fee charge occurs 2 days after the initial purchase, not after 1 day.

So, it seems like it's either a wording confusion, or some setting is messed up. Is it intended to start the schedule on the initial charge day? That's what it seems to do now.

UPDATE: Now after I created this second product, on the first one, the Role Assignment feature description text got replaced by "When this product is purchased, add a fee for $25.00 charged first after 1 days and every 1 days after that 99 times."

Something is really not working here where the product features get messed up across products.

Any ideas on how to troubleshoot this?

Thanks,
Andrey.

Version: 
Ubercart 1.3
Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Recurring fee: Initial Charge / Regular Interval confusion

I'd expect it to act like you were expecting... could be the timing of cron jobs is just off? Regarding your second update, I guess I'm not really sure what you mean. The new product already had a feature attached to it or somehow it overwrote the previous feature? The descriptions you provided are the same. Puzzled

mr.andrey's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/12/2008
Juice: 153
Re: Re: Recurring fee: Initial Charge / Regular Interval confusi
Assigned to:Ryan» mr.andrey

More details about this here:

http://www.ubercart.org/issue/6391/major_bugs_recurring_payments_module

Best,
Andrey.

mr.andrey's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/12/2008
Juice: 153
Re: Re: Re: Recurring fee: Initial Charge / Regular Interval con

The above addresses the issue with description text replacement - it's a problem with uc_roles module.

I'm still not clear on the scheduling, however. When I set the initial charge to be 0 days, it doesn't create a recurring fee at checkout. I ran cron a few times, and still nothing is mentioned about recurring fee in the logs or orders.

How exactly does that work?

Thanks,
Andrey.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Recurring fee: Initial Charge / Regular Interval
Assigned to:mr.andrey» Ryan

Perhaps it's a result of the CIM module not handling it correctly? It's working fine for me with the core debug handler and the Auth.Net one I recently committed. You can view a list of added fees at /admin/store/orders/recurring.

mr.andrey's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/12/2008
Juice: 153
Re: Re: Re: Re: Re: Recurring fee: Initial Charge / Regular Inte
Assigned to:Ryan» mr.andrey

What's the core debug handler?

What's the best way to troubleshoot this? I looked at Trace and Devel modules.. any recommendations on where to start? I posted the issue on the CIM thread, but they are a bit slow to respond...

Does the normal Auth.net module support automatic recurring billing? We're pretty much using the CIM one because the regular Auth.net module didn't support that.

Thanks,
Andrey.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: Re: Recurring fee: Initial Charge / Regular
Assigned to:mr.andrey» Ryan

Aye, the current Bzr version of the Auth.Net module supports ARB but not CIM. I've been testing it for another client who's been paying for the development. If you set your recurring fee handler to uc_recurring, it should be good for testing/debug, though. It's just not recommended for live sites since it saves full CC info.

mr.andrey's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/12/2008
Juice: 153
Re: Re: Re: Re: Re: Re: Re: Recurring fee: Initial Charge / Regu
Assigned to:Ryan» mr.andrey

I get the following notice while using the Trace module:

[NOTICE ] E_NOTICE: Undefined variable: items in `sites/all/modules/ubercart/payment/uc_recurring/uc_recurring.module':70

No fee is charged, nothing is mentioned about the recurring fees in the logs.

Any ideas here?

Thanks,
Andrey.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: Re: Re: Re: Recurring fee: Initial Charge /
Assigned to:mr.andrey» Ryan

Looks like that's part of the menu declaration to me... Puzzled

You can post that line here, but I don't think it's the culprit. You can try adding debug info into the function uc_recurring_process() or the appropriate functions in the CIM module to see if there's even an attempt to process the fee.

mr.andrey's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/12/2008
Juice: 153
I added some checks to
Assigned to:Ryan» mr.andrey

I added some checks to uc_recurring_process(), and nothing shows up after I've done the checkout.

function uc_recurring_process($order, $fee) {

  drupal_set_message(':: Processing recurring fee');
  drupal_set_message(":: order: ".var_export($order,true));
  drupal_set_message(":: fee: ".var_export($fee,true));

The uc_recurring_process() function is called from the uc_recurring_order() function upon the submit switch. I added some checks:

function uc_recurring_order($op, &$arg1, $arg2) {
  switch ($op) {
    case 'submit':
drupal_set_message(':: uc_recurring_order - submit');
      if (variable_get('uc_recurring_checkout_process', TRUE)) {
drupal_set_message(':: uc_recurring_order - 1');
        $fees = uc_recurring_find_fees($arg1);
drupal_set_message(':: uc_recurring_order - 2');
        if (count($fees)) {
drupal_set_message(':: uc_recurring_order - 3');
          $pass = TRUE;
          foreach ($fees as $fee) {
drupal_set_message(':: uc_recurring_order - 4');
            if (!uc_recurring_process($arg1, $fee)) {
drupal_set_message(':: uc_recurring_order - 5');

The output is this:

    * :: uc_recurring_order - submit
    * :: uc_recurring_order - 1
    * :: uc_recurring_order - 2

Looks like uc_recurring_find_fees($arg1) is returning nothing.

Any ideas?

Thanks,
Andrey.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: I added some checks to
Assigned to:mr.andrey» Ryan

Hmm... not sure there. Seems the fees should be found unless this is related to the product feature ID issues from recently... Puzzled

mr.andrey's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/12/2008
Juice: 153
Re: Re: I added some checks to
Assigned to:Ryan» mr.andrey

$arg1 is:

stdClass::__set_state(array( 'order_id' => '20', 'uid' => '1', 'order_status' => 'in_checkout', 'order_total' => 35, 'primary_email' => '<removed>', 'delivery_first_name' => '', 'delivery_last_name' => '', 'delivery_phone' => '', 'delivery_company' => '', 'delivery_street1' => '', 'delivery_street2' => '', 'delivery_city' => '', 'delivery_zone' => '0', 'delivery_postal_code' => '', 'delivery_country' => '840', 'billing_first_name' => '', 'billing_last_name' => '', 'billing_phone' => '', 'billing_company' => '', 'billing_street1' => '', 'billing_street2' => '', 'billing_city' => '', 'billing_zone' => '0', 'billing_postal_code' => '', 'billing_country' => '840', 'payment_method' => 'cim', 'data' => NULL, 'created' => '1221243772', 'modified' => '1221243773', 'products' => array ( 0 => stdClass::__set_state(array( 'order_product_id' => '20', 'order_id' => '20', 'nid' => '103', 'title' => 'test 6', 'manufacturer' => '', 'model' => '0006', 'qty' => '1', 'cost' => '0.00', 'price' => '35.00', 'weight' => '0', 'data' => array ( 'attributes' => array ( ), 'model' => NULL, 'shippable' => '0', 'module' => 'uc_product', ), )), ), 'payment_details' => false, 'cim_ppid' => '158094', 'line_items' => array ( 0 => array ( 'line_item_id' => 'subtotal', 'type' => 'subtotal', 'title' => 'Subtotal', 'amount' => 35, 'weight' => 0, ), ), ))

But uc_recurring_find_fees($arg1) is still returning an empty array.

I added some checks to uc_recurring_find_fees:

function uc_recurring_find_fees($order) {
drupal_set_message(':: uc_recurring_find_fees: 1');
  if (!is_array($order->products) || count($order->products) == 0) {
    return array();
  }
drupal_set_message(':: uc_recurring_find_fees: 2');

  foreach ($order->products as $product) {  
    $models[] = check_plain($product->model);
  }
drupal_set_message(':: uc_recurring_find_fees: 3');

  $fees = array();
drupal_set_message(":: uc_recurring_find_fess query: SELECT * FROM {uc_recurring_products} WHERE mo$
  $result = db_query("SELECT * FROM {uc_recurring_products} WHERE model IN ('". implode("', '", $mo$
  while ($fee = db_fetch_object($result)) {
    $fees[] = $fee;
  }
drupal_set_message(':: uc_recurring_find_fees: 4');

  return $fees;
}

And this is the output:

# :: uc_recurring_find_fees: 1
# :: uc_recurring_find_fees: 2
# :: uc_recurring_find_fees: 3
# :: us_recurring_find_fess query: SELECT * FROM {uc_recurring_products} WHERE model IN ('0006')
# :: uc_recurring_find_fees: 4

Now looking at the `uc_recurring_products` table, the `model` field is blank. That would definitely be the problem.

I imagine this field gets populated when the product features are added to the product.

Now looking at uc_recurring_fee_save() function:

function uc_recurring_fee_save($type, $data) {
  switch ($type) {
    case 'product':
drupal_set_message(':: uc_recurring_fee_save: 1');
drupal_set_message(':: uc_recurring_fee_save: $type: '.var_export($type,true));
drupal_set_message(':: uc_recurring_fee_save: data: '.var_export($data,true));

When I update a recurring product feature, the output is:

# :: uc_recurring_fee_save: 1
# :: uc_recurring_fee_save: $type: 'product'
# :: uc_recurring_fee_save: data: array ( 'pfid' => 28, 'model' => '', 'fee_amount' => '35.00', 'initial_charge' => '0 days', 'regular_interval' => '1 days', 'number_intervals' => 100, )

Model is empty.

Now looking at uc_recurring_feature_form_submit(), which calls uc_reccurring_fee_save():

function uc_recurring_feature_form_submit($form_id, $form_values) {

drupal_set_message(':: uc_recurring_feature_form_submit: $form_values: '.var_export($form_values,true));

Output is:

:: uc_recurring_feature_form_submit: $form_values: array ( 'model' => '', 'fee_amount' => '35.00', 'initial_charge_value' => '0', 'initial_charge_unit' => 'days', 'regular_interval_value' => '1', 'regular_interval_unit' => 'days', 'number_intervals' => '100', 'nid' => 103, 'pfid' => 28, 'op' => 'Save feature', 'submit' => 'Save feature', 'form_token' => '1215610aa3a97b59365253ff1aa4fd0d', 'form_id' => 'uc_recurring_feature_form', )

Model is empty.

Now if I actually specify the model number rather than setting it to "Any", all works fine. The problem seems to be that "Any" doesn't translate into a wildcard in uc_recurring_feature_form().

Andrey.