Hi,

I have set User Points as the only Payment method in Uebercart. When I purchase an article The Price ist listet with the correct amount of points but after submit no points get subtrated. Is there special configuration I have to do?

Seems like I am not the only one with that issue: http://drupal.org/node/926686

Comments

Sagar Ramgade’s picture

Hi,

I am also facing the same problem with points deduction after making purchase. I am using paypal as the payment method and userpoints discount method as the approach. It works fine if payment method is check, points are getting deducted and message is appearing.
I managed to get it working by using conditional actions by checking the conditions like payment method and updated order status. In actions i executed a piece of php code given below :

 $paymethod = strtolower($order->payment_method);
if ($paymethod != 'points') {
    if (variable_get(USERPOINTS_DISCOUNT, 1) != 0) {
        global $user;
        $curUserId = $order->uid;
        $ptamt = $order->ptamt;
        $multiplier = intval(variable_get(USERPOINTS_UC_DISC, 0));

        // Payment completed
        if ($curUserId != 0) {
            // User id from the transaction
            $points = intval(($ptamt) * $multiplier);
            $points = -$points;
            $params = array('tid' => variable_get(USERPOINTS_DISCOUNT_CATEGORY, 0), 'uid' =>
                $curUserId, 'points' => $points, 'operation' => 'delete', 'description' =>
                'User Discount, taking poings (Ubercart Order ID ' . $order->order_id . ')',
                'entity_id' => $order->order_id, 'entity_type' => 'Ubercart Transaction',
                'moderate' => variable_get(UC_USERPOINTS_DISCOUNT_MODERATE, 0), );
            userpoints_userpointsapi($params);
        }
    }
}
mwangi’s picture

there is a patch somewhere on this site that makes this change

cedric_a’s picture

Title: Points don't get subtraceted after paypment » Points don't get subtraceted after payment

For the record : some (a lot of) payment modules replaces the submit button of the order validation form so that the code inside "case 'submit' :" is never called (in function uc_userpoints_discount_order()).
To fix this I applied the advise in #1 here http://www.ubercart.org/forum/support/2629/problem_hook_order_submit_and_paypal
and replaced the whole "case 'submit' :" by this :

 		case 'update':
			// fires when the order is completed and adds/subtracts thier points
			if ($paymethod != 'points' && $arg1->order_status != 'completed' && $arg2 == 'completed') {
				if (variable_get(USERPOINTS_DISCOUNT,1) != 0) {
					$curUserId = $arg1->uid;
					$ptamt = $arg1->ptamt;
					$multiplier 	= intval(variable_get(USERPOINTS_UC_DISC, 0));
				
					// Payment completed
					if ($curUserId != 0) {
					// User id from the transaction
						$points = intval(($ptamt) * $multiplier);
						$points = -$points;
						$params = array (
						'tid' => variable_get(USERPOINTS_DISCOUNT_CATEGORY, 0),
						'uid' => $curUserId,
						'points' => $points,
						'operation' => 'delete',
						'description' => 'User Discount, taking poings (Ubercart Order ID ' . $order->order_id . ')',
						'entity_id' => $order->order_id,
						'entity_type' => 'Ubercart Transaction',
						'moderate' => variable_get(UC_USERPOINTS_DISCOUNT_MODERATE, 0),
						);
						userpoints_userpointsapi($params);
					db_query('INSERT INTO {uc_updiscounts} (uid, oid, ptamt, points) VALUES (%d, %d, \'%f\', %d)', $curUserId, $arg1->order_id, $ptamt, $points);
					}

				}
			}
			break;

IMO it has sense to substract points when order is completed (it's done at the same moment for points added with conditional actions).
Hope this helps.

cedric_a’s picture

Title: Points don't get subtraceted after payment » Points don't get subtracted after payment

... fixing the title spelling for better search results