16 replies [Last post]
mediumgrade's picture
Offline
Joined: 05/21/2009
Juice: 61
Was this information Helpful?

Not sure if this is the right forum for my question, but here goes...

I want to be able to sell account subscriptions such that a customer pays to have an account on the site and the account is automatically disabled if the customer fails to pay.

How difficult is it to set something like this up?

Abilnet's picture
Offline
Uber DonorBug Finder
Joined: 12/28/2007
Juice: 718
Re: New to Ubercart... how do I setup subcription accounts?

Hi there... maybe you want to take a look at the great documentation of Ubercart, there's a section for selling access to the site. Hopefully this is what you're looking after, all the best Smiling

adrian_arg's picture
Offline
Joined: 08/05/2009
Juice: 20
Re: Re: New to Ubercart... how do I setup subcription accounts?

Is it possible to have no products page and no cart and the registration page would be the one to get payment data and charge the card when the account is made?

If my question would be more related to a different topic or thread, please let me know

deepakg83's picture
Offline
Joined: 07/24/2009
Juice: 187
Re: Re: Re: New to Ubercart... how do I setup subcription accoun

In the case, where is it you are expecting the payment data. The anonymous user / registered user.
In case it is a registered user, i suppose he can be charged to maintain the account.

What if there is a bulk registration concept then. A person wanting to have multiple accounts , possibly cart usage will be a better option.

However, if one can venture into depths , nothing is impossible. but the payment modules are linked to products, and might need to have a custom module written to address the need, not sure though

Deepak Gupta

adrian_arg's picture
Offline
Joined: 08/05/2009
Juice: 20
Re: Re: Re: Re: New to Ubercart... how do I setup subcription ac

thank you for your reply.

Payment data would be collected during the registration. So from an anonymous user, once they pay they become registered. It is just a one time charge.
I have activated and setup the roles module. Looks like what I need to happen is to make the registration page do the job of the checkout process.

b0b
b0b's picture
Offline
Joined: 06/25/2009
Juice: 23
adrian_arg wrote: Is it
adrian_arg wrote:

Is it possible to have no products page and no cart and the registration page would be the one to get payment data and charge the card when the account is made?

I think it would be easier to come at this the opposite way. Turn off Drupal's registration (admin generation only) and use Ubercart to sell roles and set-up accounts.

adrian_arg's picture
Offline
Joined: 08/05/2009
Juice: 20
Re: adrian_arg wrote: Is it

Here's one thing that I'm planning on doing...

create a module that will modify the user/registration by calling these functions from uc_cart and uc_order:

1. uc_cart_add_item($nid, $qty = 1, $data = NULL, $cid = NULL, $msg = TRUE, $check_redirect = TRUE) - add the only item that we have

2. uc_order_new($uid = 0, $state = 'in_checkout') - create a new order

3. uc_order_product_save($order_id, $product) - add a product to the order

4. uc_cart_complete_sale($order, $login = FALSE) - complete the sale and also create the user

5. uc_payment_process($method, $order_id, $amount, $data = NULL, $default = FALSE, $selected = NULL, $redirect = TRUE)

Now here are some of my questions:
Would step #1 be unnecessary since the other steps don't actually need a cart? I can just go ahead and process an order right?

Step #4 sets the order status from checkout to pending and creates the user and logs them in, But does it also process the payment (credit card)? Is step #5 needed?

What do you guys think? Would this work? Would a module in drupal be able to access these functions or does this need to be a contrib in ubercart?

adrian_arg's picture
Offline
Joined: 08/05/2009
Juice: 20
Re: Re: adrian_arg wrote: Is it

I used function_exists in my module to see if the functions are there and they are. I'm assuming for now that functions from all modules are accessible by other modules

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6855
Re: Re: Re: adrian_arg wrote: Is it

In general, that's true. Some modules put rarely used functions in other files, and they aren't always included. If you want to use those functions you'll have to use include_once() and drupal_get_path() to load them into memory.

adrian_arg's picture
Offline
Joined: 08/05/2009
Juice: 20
Re: Re: Re: Re: adrian_arg wrote: Is it

I'm planning to put those functions I mentioned above inside a hook_user() in a if($op=='insert'){}

But would the code be executed before or after the user is created in the db?

I've also been reviewing the functions and it seems that I may not need #1 and #4

From my understanding #1 isn't needed since it seems that we can process the order without a cart. Also it seems that what #4 does is create an account if there is none and set the order status from checkout to pending. It seems that all I need to do after a user is created is create an order for the user and add the product then process the payment which will set the status of the order to completed.

adrian_arg's picture
Offline
Joined: 08/05/2009
Juice: 20
Re: Re: Re: Re: Re: adrian_arg wrote: Is it

But would the code be executed before or after the user is created in the db?

so I put this inside the hook_user
echo $op." ".($account->uid).'';
when i registered an account
i got this:
register
register
load 0
validate
load 202
load 202
insert 202
load 202
load 202
login 202

but when i put this:
global $user
echo $op." ".($user->uid).'';
i got a uid only in the login $op.

so right after validate we already have uid that the ubercart functions can use.

adrian_arg's picture
Offline
Joined: 08/05/2009
Juice: 20
Re: Re: Re: Re: Re: Re: adrian_arg wrote: Is it

as of this post what i have is this:

//create order
$order=uc_order_new();
//add product
uc_order_product_save($order->order_id, $product);
//recreate order obj with the product
$order=uc_order_load($order->order_id);
//save order with product to database
uc_order_save($order);

this will be in the validate op incase there will be payment problems the account wont be created.

this creates an order adds a product then reloads the order obj (now with a product) and saved the order with a product to the db.

Now my problem is how to process the payment for it.
Please let me know if you guys have suggestions.

adrian_arg's picture
Offline
Joined: 08/05/2009
Juice: 20
in my implementation of

in my implementation of hook_user I have credit card processing code in the validate $op. In case the credit card processing fails, how do I throw an error so that the registration won't continue? (user doesn't get created)
this is the code that I have so far...
$pass = uc_payment_process('credit', $order->order_id, $order->order_total, $data, TRUE, NULL, FALSE);
if($pass===true){
uc_order_update_status($order->order_id,'completed');
}
else{
drupal_set_message('The payment was not accepted.','error');
uc_order_update_status($order->order_id,'canceled');
}

I entered bogus card numbers and the order is being set as canceled but I'm not getting any error messages and the user is still being created.

adrian_arg's picture
Offline
Joined: 08/05/2009
Juice: 20
Re: in my implementation of

in case anyone is interested instead drupal_set_message() i used form_set_error()

gauravkhambhala's picture
Offline
Joined: 12/03/2008
Juice: 25
Re: Re: in my implementation of

I am also looking for such module. If you can share the files I can also work for it.

gauravkhambhala's picture
Offline
Joined: 12/03/2008
Juice: 25
Guys, Any updates on this???

Guys,

Any updates on this???

Garion's picture
Offline
Joined: 05/09/2011
Juice: 5
What was the result of this?

Hi adrian, i realize it has been years since this thread was created but what came of this?

1. Did you create the module and was it working fine?
2. Would you be willing to share your knowledge or module(s) ?

Thanks