Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Philip Hayton 98 posts 435 karma points
    Aug 29, 2021 @ 13:15
    Philip Hayton
    0

    Emulate BeginPaymentForm serverside

    Hi guys,

    I only need a single page as part of my checkout flow; to capture the billing information and accept terms. I want to be able to capture the billing information via a postback (as per the demos) but then immediately send the user to Stripe to take the payment.

    Is this possible? And if so, how what do I need to do?

    Also as an additional - has anybody managed to use Stripe Elements yet? Would I need to create a new payment provider for this?

    Any help is greatly appreciated.

    TIA! Phil

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 30, 2021 @ 08:24
    Matt Brailsford
    100

    Hey Philip,

    We can't entirely emulate BeginPaymentForm on the server side as depending on the payment provider being used, some of them return javascript that needs to be executed so we can't just return a URL to navigate to.

    If you know the payment gateway, and you know it returns a URL and you want to bypass everything Vendr does, you can call order.InitializeTransaction() to give the order an order number before redirecting to the known providers URL.

    My generally recommended approach though if you want it to work for any payment gateway is to do what we do on the Vendr.net site and introduce an interim page after the single page checkout that displays a brief message "Redirecting to payment gateway" then on that page, render the BeginPaymentForm and use some javascript to automatically submit it. This is ultimately the JS that we use for auto submitting the form.

    setTimeout(function() {
        var form = document.getElementById("paymentForm");
        if (form.hasAttribute("onsubmit")) {
            form.dispatchEvent(new Event('submit', { cancelable: true }));
        } else {
            form.submit();
        }
    }, 100)00)
    

    Hope this helps

    Matt

  • Philip Hayton 98 posts 435 karma points
    Aug 30, 2021 @ 08:33
    Philip Hayton
    0

    Hi Matt,

    Thanks for the swift response on both of these questions (on a bank holiday no less!). Yeah the intermedite page seems like a reasonable stop gap for now, didn't think of that.

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft