We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22019
    • 390 Posts
    I’ve not developed a paid subscriber website before, let alone one in Revo, so I’m a little confused about the options I have. I’m using PayPal for the payment gateway. As there isn’t any ready-made package for the whole process I’m thinking of doing this:

    - Resource with Register snippet, setting extended fields for Paid, and Start Date (with possibly a calculated End Date)
    - Validate, make them a member of a paid users group (inactive) and redirect to Paypal subscribe button using a weblink
    - Wait for IPN, and on verified transaction then update Paid, Start Date and End Date
    - From Paypal, return user to website and remind them to click on activation email (will this annoy people who’ve just paid?)
    - Following link in email, resource with ConfirmRegister sets them to Active.

    On renewal date, the IPN will fire again and hit the IPN script, updating End Date and possibly Paid, and usergroups (including negative outcomes like ’cancelled’) - so I would need to add a Login pre-hook to check for Paid status (Login will check for Active status out of the box).

    Does that sound about right - or have I missed something out or overcomplicated? Is there anything special I need to do on Logout?
      Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
      • 22019
      • 390 Posts
      Anybody? Bueller? BUELLER? rolleyes

      Only real progress I’ve made is that I can’t redirect using a weblink if I want to programatically add a passthrough variable to Paypal. I guess as username is unique, it doesn’t really make that much difference if that is passed rather than user id.
        Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
        • 22019
        • 390 Posts
        Ok. With the right starting points that wasn’t too painful. I’ve got subs and unsubs working - need to do a little tidying up. Opened up a few avenues I hadn’t thought possible, including graded memberships and offering an admin view of subscriptions from within MODx, not Paypal. Might even turn out to be a Paypal backend for VisionCart, who knows.

        Basically, what I’ve done is roughly:
        - Register
        - pass username to Paypal ’button’
        - extended a standard IPN listener to create MODx objects in response to Paypal IPNs
        - use username to retrieve user id and update member_groups accordingly (either adding or removing). As I did it this way, it removes the need to worry about dates of membership - Paypal does all of that for me.
        - as it starts with Register, the user still has to activate their membership from the email they get sent.

        I want to make it a little more robust (tying a transaction record into the user explicitly using Extended Fields, or possibly a remote Key on the user table - don’t quite get that bit yet). If I’m feeling very generous to the client I’ll finish off by adding a CMP front end on to the MODx objects, or at least for future clients.

        And so to bed, said Zebedee.
          Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
          • 1423
          • 24 Posts
          Hi, just discovered your thread.
          This sound interesting.

          Are you planning to publish this as a snippet eventually?
          I want to do something similar, but as a php-beginner I am already struggling quite a bit with a custom setup of Paypal IPN.

          If I may put my two cents in here:

          I was thinking to run a snippet after paypal verification which sets the unpup_date of a ressource 180 days in advance.
          Something with this
          <?php
          $t=time() + (15552000);
          echo($t);
          ?>   


          Why do you think you need an extra e-mail verification?
          I thought it should be sufficient for a proper identification to get a paypal verification.

          Thomas
            • 22019
            • 390 Posts
            Thomas, so you want to give someone access to a resource for 180 days after payment?

            I guess there’d be a number of ways of doing that, depending on whether the resource is unique to the individual or not, and whether you want / mind other people being able to see it.

            - Visible to others - You could create a table of join-date, leave-date that manipulated a user’s group or role memberships (although you’d need some form of cron job to run daily to update member group permissions - or possibly on web login a plugin could check which resources your user should still have access to).
            - Unique to user - You could give the resource name an alias of the transaction id, and unpublish date as you’ve suggested. Or you could put the user id in a tv field and check that the user viewing the page is the user logged in.
            - Another way - probably less desirable, is to set up the initial payment as a subscription with 0 repeats and period of 6 months, and add / leave groups based on the IPN.
            - Finally, there’s probably a way to do it using User Extended Fields (if they’re going to have access to many specific resources that dont’ form part of a discrete resource group).
            - I haven’t explored what the Filelister package does, but it may also cover some of this ground. (As may VisionCart).
            - I used this as my starting point for processing IPNs https://www.x.com/thread/30664?start=0&tstart=0

            The email verification I’ve left in for the standard MODx account creation process - it just seemed a little bit safer to know that they will get a forgot login email.

              Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
              • 1423
              • 24 Posts
              Thanks for your answer and the paypal script link.
              The extra E-Mail verification makes sense to me now.

              In short what I want to achieve is like this:
              Anybody can create a ressource like my-forum.example/ressourcename.
              This resource is unpuplished initially.

              After this one should fill a form to become a member and pay per Paypal for x-days.
              Upon IPN verification the ressource should be published for all to see with an unpub-date x-days in the future
              and a frontend editor should appear when logged in into the resource.

              At the moment I am more or less doing only some research of how I can accomplish this.
              Your subscription process sounds like pretty much halfway the same what I need to achieve, therefore my question if you’re planning to publish this (or parts of this) code eventually?



                • 22019
                • 390 Posts
                I see - something like a classified ad or listings service then.

                In which case you’d need to send the resource id as a passthrough variable to Paypal, so that on successful payment your IPN listener will know which resource to update. I’m not entirely sure how you’d control the user’s ability to publish or not the resource (the resource would need to be deleted rather than unpublished, or further access control placed on it). There’s probably a way to set up a Content Editor (the role - or similar- your paid user would need to be given) without publish rights, but I’m not sure.

                All I’ve done with the code I linked to is convert a small portion of it (the subscriptions bit) into using and saving MODx objects, rather than the ’normal’ MySQL tables it creates (but keeping the same structure). It’s not really ’code’ as such. But if I turn it into something packageable, I’ll share it.

                  Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
                  • 1423
                  • 24 Posts
                  Well I thought of some extra snippet to search for unpublished ressources older than a month and delete them then.
                  This is to give people who missed to renew their payment a chance to do so later on.

                  But as I said I am still in an early searching/planning state,
                  so, thanks for your insights at the moment.