We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36426
    • 197 Posts
    Hi I've been working on a new site in modx and wanted to use Stripe Checkout for a very simple way to take payments.

    Stripe Checkout gives a really easy 'Simple' way to integrate, but unfortunately it doesn't work with Subscription/Recurring Payments!!

    So I'm stuck with the 'Custom' option instead.

    It should be fairly easy to set up but I'm not clear from their documentation what I'm really supposed to do to actually get it working, or what I need to add to Modx...

    I've started with their 'Custom' example code:

    https://stripe.com/docs/checkout#integration-custom

    Putting it on the page I'd like to take the payment:

    <script src="https://checkout.stripe.com/checkout.js"></script>
    
    <button id="customButton">Purchase</button>
    
    <script>
    var handler = StripeCheckout.configure({
      key: 'pk_test_6pRNASCoBOKtIshFeQd4XMUh',
      image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
      locale: 'auto',
      token: function(token) {
        // You can access the token ID with `token.id`.
        // Get the token ID to your server-side code for use.
      }
    });
    
    document.getElementById('customButton').addEventListener('click', function(e) {
      // Open Checkout with further options:
      handler.open({
        name: 'Stripe.com',
        description: '2 widgets',
        zipCode: true,
        amount: 2000
      });
      e.preventDefault();
    });
    
    // Close Checkout on page navigation:
    window.addEventListener('popstate', function() {
      handler.close();
    });
    </script>


    adding this to my page works and when I click the Pay button a popup appears and takes the card info etc in test mode. But I'm not sure how I now change this to recurring payments as well as also pass the user to Payment Confirmation resource. Also how do I know the payment actually worked?

    The documentation also mentions I need to set up a client library and use this guide for Subscriptons: https://stripe.com/docs/subscriptions/quickstart

    But how does this tie in with the custom code I already have and how do I bring it all together. Apologies for my ignorance on this and thanks very much for any help at all. I'm sure a lot of users would benefit or find a solution to setting up recurring payments with this on modx.

    Thanks again smiley
      Yorkshire UK based hosting provider: https://www.simulant.uk
      • 12893
      • 13 Posts
      Hello, I'm trying to add the "simple" option of Stripe Checkout (https://stripe.com/docs/checkout#integration-simple), yet I can't get this to work. The Stripe API has a library that requires Composer to install. I did manage to install Composer successfully via SSH on my shared server, but the code still breaks and I get a HTTP 500 error. To my understanding, Composer is not compatible with MODX 2.x (I'm on 2.6).

      So I tried another method, which is the legacy method for PHP 5.3. I downloaded their library and uploaded it to my server as described here https://github.com/stripe/stripe-php#stripe-php-bindings , using the PHP 5.3 version which is what I'm running. The code still breaks. I think that even this legacy method depends on curl, json, and mbstring. These dependencies are guaranteed with Composer, but without it I'm in the dark as to how I can ensure these work with my MODX website.

      I am curious as to whether anyone has gotten Stripe to work with MODX. I'm beginning to think that there is no easy way to use Stripe with MODX 2.x and that I'll have to wait until MODX 3.x or jump ship to another CMS. Can anyone share any insight or experience?

      Thanks
        • 46886
        • 1,154 Posts
        Were you by chance running PHP 5.3 for both of these attempts? I may have read your message wrong but if you did, please upgrade to the newest php and try the first method again.

        My dev just implemented mhpaypal to handle creditcard payments through paypal but its pretty simple, you are locked into stripe?

        A lot of Russian users use Minishop2 but it has limited documentation in English
          • 12893
          • 13 Posts
          Thanks Nuan! You are 100% correct. After updating to PHP 7.2 the integration actually works. Now I have a new problem though - the FileLister add-on breaks when upgrading from PHP 5.3 to 7.2... [ed. note: ineffable last edited this post 8 years, 3 months ago.]
            • 46886
            • 1,154 Posts
            Wow!! Well pls start a new thread for the new question, I dont know php much at all so I will be no help, I am sure someone will know about updating php scripts though

            I just know php is damn useful lol