We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43864
    • 151 Posts
    Hey, I wonder if it's possible (and how) to submit a form using Formit to an external website. Maybe it's simple and am I overlooking something, I don't know.

    Let me explain a little bit. I have a form to submit a payment to a website of the payment-service (= goto a VISA/paypal page). But I would like, before the form is taking me to that external page, perform a hook to submit some data in the database (or in a resource of migx). Because then on return of the payment I can trigger the yes or no for succes or failed payment. (I do get an true/false code from the payment-service as feedback). I have little control over the payment page, so a formitretriever isn't possible on that page.

    What is not working:

    [[!Formit? ...]] <form action="external-website">


    --> In this case the formit isn't executed. The data is submitted to the payment-page, but I lose some data.

    [[!Formit? &hooks=`write_to_database,go_to_url` ...]] <form action="[[~[[*id]]">


    --> In this case the form is writing to the database (first hook) and then takes me to the external website, but without the data from the form, so it's more like a redirect.

    So I would like the second version, writing to database and goto payment-page, but with the data from the form.

    Any Formit specialists on the forum? Any other suggestions are also welcome, maybe this is the wrong approach, I don't know.

    Thx for help.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You would need a custom post-hook (snippet) to send the data on to the remote site, loading the necessary data into the Get. I presume they use https, so the data would be safe. Your requirement is not at all unusual, your remote payment gateway should have documentation and an API for doing just this.
        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
        • 44580
        • 189 Posts
        I've just started looking into this myself, using Stripe as the payment service. Although I'm not that far along, it seems to be the case (with Stripe) that the payment is submitted using Javascript. If your service also has that option, then you can keep the two events (submitting the payment and all the formit stuff) separate.

        (BTW, if you are using Stripe, there are some good tutorials: http://www.larryullman.com/series/processing-payments-with-stripe/ for example)
          • 43864
          • 151 Posts
          Quote from: gissirob at Oct 26, 2014, 11:30 AM
          I've just started looking into this myself, using Stripe as the payment service.

          For me it's the service Ogone (http://payment-services.ingenico.com/be/nl). Don't think I can use js there.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Actually you should be able to do both using AJAX. Send the AJAX request to another resource with the formit processor, then after that AJAX request returns successfully let the form submit normally to the payment processor.
              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