We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49274
    • 3 Posts
    Hello all,

    I have a question about calling some external php library.

    I have to call some external (non modx) php code that is doing a credit card payment.

    The workflow is as follows: First the user sets the amount in a form. When the Pay button it's pressed some external code should be called. The user is redirected to the payment institution website, they enter the credit card data, the payment is made or not and then I need to return to my modx website and modify some the payment status in my custom tables.

    What would be the best approach to this matter? How can I call some external php code within modx and then modify some info based on the response from an external server?

    Thank you,
    Horia

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      Doesn't they have some example-code?
      You would create a snippet, which does the same, what their example-code does.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 49274
        • 3 Posts
        I haven't received anything from the payment institution so I'm trying to prepare the worst case scenario.

        If their code has several files, how can I import those in modx or make modx aware of that files and use their code accordingly?

        Thank you,
        Horia
        • discuss.answer
          • 3749
          • 24,544 Posts
          You can either paste the code into a snippet or do this in a snippet:

          include MODX_BASE_PATH . 'path/to/file.php';  /* path will be from the MODX root */


          Note that you can't have raw HTML code in a snippet either way, so if their files switch back and forth between php and HTML, you'll either have to rewrite them or run them some other way.

          FWIW, I would not use a payment gateway that doesn't have a well-documented API.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 49274
            • 3 Posts
            @Bruno17: thank you for your answer

            @BobRay: I have to use it, the client I'm building the site for wants it. Thank you for your answer.

            Horia