We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31211
    • 25 Posts
    Quote from: ajayre at Dec 01, 2006, 01:48 PM

    Here is how I did it, but my solution was customized and isn’t suitable for release as a standalone system.

    1. Set up an online store and add the site access/subscription as a product
    2. Create a plugin that uses the login event
    3. When a user logs in, check the store database to see if they have purchased access.

    Andy


    1. using shopX 2.5..right?

    the rest i dont think i can handle it withount seeying how it was made...
      • 32942
      • 141 Posts
      I can give u my simple php script which needs to be converted to a plugin only.
      It is modular and extensible. Remeber it a simple script that need to be extended, cuz it is only the verification part.
      Imagine what you can do with ajax and this.
      no other words, here it is:
      <?php
      
      /**
       * Description:
       * This is a simple PHP script that checks for validity of several payment methods.
        * You can extend this code and do what you want with it.
        * It is absolutely free.
        *
       * @author Xsss4hell
       * @version 1.0
      */
      
      
      function checkCreditCard ($cardnumber, $cardname, &$errornumber, &$errortext) {
        $cards = array ( array ('name' => 'Visa', 
                                'length' => '13,16', 
                                'prefixes' => '4',
                                'checkdigit' => true
                               ),
                         array ('name' => 'MasterCard', 
                                'length' => '16', 
                                'prefixes' => '51,52,53,54,55',
                                'checkdigit' => true
                               ),
                         array ('name' => 'Diners Club', 
                                'length' => '14',
                                'prefixes' => '300,301,302,303,304,305,36,38',
                                'checkdigit' => true
                               ),
                         array ('name' => 'Carte Blanche', 
                                'length' => '14', 
                                'prefixes' => '300,301,302,303,304,305,36,38',
                                'checkdigit' => true
                               ),
                         array ('name' => 'American Express', 
                                'length' => '15', 
                                'prefixes' => '34,37',
                                'checkdigit' => true
                               ),
                         array ('name' => 'Discover', 
                                'length' => '16', 
                                'prefixes' => '6011',
                                'checkdigit' => true
                               ),
                         array ('name' => 'JCB', 
                                'length' => '15,16', 
                                'prefixes' => '3,1800,2131',
                                'checkdigit' => true
                               ),
                         array ('name' => 'Discover', 
                                'length' => '16', 
                                'prefixes' => '6011',
                                'checkdigit' => true
                               ),
                         array ('name' => 'Enroute', 
                                'length' => '15', 
                                'prefixes' => '2014,2149',
                                'checkdigit' => true
                               )
                       );        
      
        $ccErrorNo = 0;
      
        $ccErrors [0] = "Unbekannter Kartentyp";
        $ccErrors [1] = "Keine Kartennummer angegeben";
        $ccErrors [2] = "Kreditkartennummer hat ungueltiges Format";
        $ccErrors [3] = "Kreditkartennummer ist ungueltig";
        $ccErrors [4] = "Kreditkartennummer ist unvollstaendig";
                     
        $cardType = -1;
        for ($i=0; $i<sizeof($cards); $i++) {
          if (strtolower($cardname) == strtolower($cards[$i]['name'])) {
            $cardType = $i;
            break;
          }
        }
        if ($cardType == -1) {
           $errornumber = 0;     
           $errortext = $ccErrors [$errornumber];
           return false; 
        }
        if (strlen($cardnumber) == 0)  {
           $errornumber = 1;     
           $errortext = $ccErrors [$errornumber];
           return false; 
        }
        $cardexp = '^([0-9]{4})[[:space:]]?([0-9]{4})[[:space:]]?([0-9]{4})[[:space:]]?([0-9]{1,4})%body%#039;;
        if (!ereg($cardexp,$cardnumber, $matches))  {
           $errornumber = 2;     
           $errortext = $ccErrors [$errornumber];
           return false; 
        }
        $cardNo = $matches[1] . $matches[2] . $matches[3] . $matches[4];
        if ($cards[$cardType]['checkdigit']) {
          $checksum = 0;
          $mychar = "";
          $j = 1;
        
          for ($i = strlen($cardNo) - 1; $i >= 0; $i--) {
            $calc = $cardNo{$i} * $j;
            if ($calc > 9) {
              $checksum = $checksum + 1;
              $calc = $calc - 10;
            }
            $checksum = $checksum + $calc;
            if ($j ==1) {$j = 2;} else {$j = 1;};
          } 
        
          if ($checksum % 10 != 0) {
           $errornumber = 3;     
           $errortext = $ccErrors [$errornumber];
           return false; 
          }
        }  
      
        $prefix = split(',',$cards[$cardType]['prefixes']);
            
        $PrefixValid = false; 
        for ($i=0; $i<sizeof($prefix); $i++) {
          $exp = '^' . $prefix[$i];
          if (ereg($exp,$cardNo)) {
            $PrefixValid = true;
            break;
          }
        }
            
        if (!$PrefixValid) {
           $errornumber = 3;     
           $errortext = $ccErrors [$errornumber];
           return false; 
        }
          
        $LengthValid = false;
        $lengths = split(',',$cards[$cardType]['length']);
        for ($j=0; $j<sizeof($lengths); $j++) {
          if (strlen($cardNo) == $lengths[$j]) {
            $LengthValid = true;
            break;
          }
        }
        
        if (!$LengthValid) {
           $errornumber = 4;     
           $errortext = $ccErrors [$errornumber];
           return false; 
        };   
        
        return true;
      }
      
      /**
            Ein Verwendungsbeispiel:
            
            <form method="post" action="fdccvs.php">
              <p><span style="color: #ff0000; margin-left: 20px;">Kreditkarte auswählen:</span> 
                <input type="hidden" name="submitted" value="true" />       
                <select tabindex="11" name="Kartentyp" style="margin-left: 10px;" >
                  <option value="MasterCard">MasterCard</option>
                  <option value="MasterCard">MasterCard</option>
                  <option value="Visa">Visa</option>
                  <option value="American Express">American Express</option>
                  <option value="Diners Club">Diners Club</option>
                  <option value="Carte Blanche">Carte Blanche</option>
                  <option value="Discover">Discover</option>
                  <option value="JCB">JCB</option>
                  <option value="EnRoute">enRoute</option>
                </select>
                <span style="color: #ff0000; margin-left: 20px;">Nummer eingeben:
                <input type="text" name="Kartennummer" maxlength="20" size="20" style="margin-left: 10px;" value="" alt="Geben Sie ihre Kredikartennummer hier ein" tabindex="12" />    
                <input type="submit" name="submit" size="20" value="Senden"  tabindex="13" alt="Klicken Sie hier um die Kredikartennummer zu Überprng abzuschicken." />
                <br /> <span style="display: block; margin: 10px 0 0 20px; color: red; font-weight: bold;">Bitte geben Sie ihre Kredikartendetails an</span>
              </span></p>
            </form>
       */
      ?>


      If you don’t like my script you can use this:
      http://www.analysisandsolutions.com/software/download/
      It’s nice also.
        • 12652
        • 228 Posts
        Hey Ryan,

        I’m guessing not, but just wondering if you had progressed at all on your version? This is exactly what I am looking for for some planned additions to my site... that is after I port my site over into MODx to begin with wink
          | Identity Developments delivers SEO focused web design and web presence services
          - it&#39;s not about websites, it&#39;s about your identity. |
          • 15826
          • 160 Posts
          Any further progress here?

          I can kick some dough into the kitty if that helps.
            "I’d love to change the world but I can’t find the source code . . ."

            Custom ModX Templates
            • 27302
            • 154 Posts
            I too would be very interested in this. I have just discovered ModX and it looks like it is a CMS that I could work with, unlike the others which always create websites full of tables etc.

            I need to add a premium content area to my site, but I am new to PHP so I wouldn’t have a clue about how to write such a module.
              • 32525
              • 27 Posts
              I would love to see a module that can make subscription only pages available. I’m guessing this shouldn’t be too hard for using PayPal with IPN.

              The way I see it is working is to extend the WebLogin snippet and add a new table to the database for user payment status e.g. modx_web_users_payments. This could include the returned payment status from PayPal (default set to `unpaid`) and other useful details such as subscription start / end date, paid for web_groups etc.?

              Obviously this would need a module for managing user payments for the back-end.

              Over the next few months I might look into trying to develop something like this, but if anyone has any other ideas or has started something already that is along the same lines let me know...
                • 25663 MODX Staff
                • 12,272 Posts
                Actually all you need to do is create Webgroups. When paid, the plugin would change their webuser account to include this paid-only-content group. No hacks needed.
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Don’t really even need a plugin, it can be done with a snippet on the page the payment gateway returns the user to. Most gateways return the user with a full POST or GET list of data values that your snippet can process as desired. You’ll be able to "pass through" some user ID data, and use that on the return to insert the user into the appropriate web user group on success.

                  I am doing something similar (although without the user group thing, the data needs to go to a custom table) and the payment gateway has two returns, one returns the user to a specified page with some minimal information, and a full return is made via a raw POST that I wrote an external PHP file to catch and process.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 32942
                    • 141 Posts
                    have you looked into my script?
                    It does only the cc-check
                      • 13331
                      • 67 Posts
                      Hmm.. I’ve run into this thread by searching.. I need the same thing..

                      I have an account with PayPal..

                      I need users to be able to register.. When they do they will be part of one user group.. Then they should be able to pay a fee via PayPal and be automatically moved to a different user group... And it should also be possible to set it up, so after an amount of days, the user will be moved back to the old user group again.. ready for a new payment..

                      Fairly simple compared to what some of you guys have worked out.. right?

                      I can see this is an old thread so I’m hoping someone has come far in the process of this..