Auto delete subscriptions?

Discussion in 'Customization & add-ons' started by wibblywobbly, Jan 8, 2005.

  1. wibblywobbly

    wibblywobbly Guest

    Hi - wondering if anyone can help please ....

    I've a setup where a customer subscribes to the site thru free membership subscription and then purchases a service(product) through an additional subscription (via paypal) - this is to buy n digital widgets.

    Their account (member database has extra field - "n digital widgets left") is creddited with n digital widgets which will expire after a year .... or when all the widgets have been "used up" i.e when, through a service the site offers, the number of available widgets reduces to 0. At this point, I would like to terminate/expire the subscription to digital widgets ....

    Anyone know if this is possible?

    If not - could an alternative be, add a official paypal "buy it now" thingy button in the free membership area of the site ... and after payment is executed & completed, return to aMember and credit the member with the amount of digital widgets purchased i.e. no "amember product" per se. The main question is, when returning from Paypal to a new page e.g. widget_thanks.html (could be in amember dir) - would I still have access to the member session so the member can be creditted with their digital widgets? This option obviously ignores the "expire after a year" - but I'm willing to compromise on that bit ...

    Apologies if I'm asking a bleedin obvious question - but I'm a bit new to this malarky ....

    Many thanks!
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    What are "widgets" and what these will be used for?
  3. wibblywobbly

    wibblywobbly Guest

    "widgets" is a generic engineering term for "manufactured item", "service" or the like.

    In this context, the widget is a messaging service provided by my site - and I plan that a subscriber would sign up an buy access to the service eg, 10 messages, 20 message etc ... Once they've purchased a block of messages, they're allowed access to the service. Once they've sent their allotted amount of messages, access to the service shall be denied (subscription cancelled?) and they'll have the option to buy more ..

    Would this be possible? If not, could anyone suggest a workaround?

    Thanks!
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    I don't think aMember could be suitable for this kind of usage. aMember is designed to work for time-limited subscriptions.
  5. wibblywobbly

    wibblywobbly Guest

    Ok - I'll approach this from a slightly different angle ..

    The sort of processing I would like to introduce is this:

    (a) New database field added to member database - "X". - done.
    (b) Member subscribes and pays (via paypal) for product "Y", Database Member "X" set to 10 (??)
    (c) On a specific event, "X" is decremented by one. - done.
    (d) When "X" = 0, delete(cancel) subscription to product Y (??)

    I've got time dependant subs/products which aMember handles perfectly. It's just that I'm looking to extend the functionality to encompass the above functionality. I appreciate that AMember isn't suited to this sort of thing ... but all I want to do is on a "specific event, do something" ...

    My main sticking points are:

    1. Step (b) - how can I do this? Can the database field X be set to 10 on returning from Paypal? Or when the subscription has been accepted ..

    2. Step (d), would the function call subscription_deleted($member Id, $product_id, $member) achieve this? If not - any ideas?

    I'm not afraid to dive into the code and do the work ... I'm just looking for a couple of pointers on where to start.

    Thanks! :)
  6. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    it is possible. have a look to last chapter manual: you will find lot of useful hooks.

    Here is short way:
    0. add 2 sql fields using aMember CP -> Add Fields:
    points_ordered
    points_used
    1. handle finish_waiting_payment event
    - find out user id as
    $p = $db->get_payment($payment_id);
    $member_id = $p['member_id'];
    - get all user payments ($db->get_user_payments($member_id, 1))
    - find out sum of ordered "points"
    - update user record like:
    $u = $db->get_user($member_id)
    $u['points_ordered'] = $sum_of_ordered_points_you_found_above;
    $db->update_user($member_id, $u);
    2. In YOUR code, increment
    points_used
    3. In YOUR code, check that (points_ordered > points_used)
  7. wibblywobbly

    wibblywobbly Guest

    Nice one Alex .... I'm going to be busy this weekend.

    Thanks for the help.

Share This Page