Issue with Stripe's Redirect URL

Neil Manchester:
Having an issue with Stripe’s redirect URL. Using Stripe Elements which works fine for card payments. However, for some payment methods such as Klarna, the confirmPayment Stripe call requires a return_url parameter. As the user is directed away from my online booking app I need to save the page’s model to FileMaker so that it can be retrieved once the user is redirected back to the app. My approach is to save $$BF_Model to my DataStore and then pass the id of the DataStore record as a query parameter to Klarna in the Stripe call and then reload the model into my redirect_url page.

//Get the DataStore ID from model
idDataStore = model.idDataStore

// Construct the return_url with fragment data
const returnUrlWithFragment = `${window.location.origin}/#/payment-handler?idDataStore=${idDataStore}`;

//Make the call
window.stripe.confirmPayment({
        elements,
        confirmParams: {
            return_url: returnUrlWithFragment
        },
        // Uncomment below if you only want redirect for redirect-based payments
        redirect: 'if_required',
})

The problem is that because of the # in the returnUrlWithFragment variable when Stripe appends it’s parameters to the URL I end up with two sets of parameters like this

<https://devbookingportalv2.fmbetterforms.com/?payment_intent=pi_3PpUhUI2wEvj3Dtm1ecpuQWB&amp;payment_intent_client_secret=pi_3PpUhUI2wEvj3Dtm1ecpuQWB_secret_bXiS1pUkf4pbkd2gdLmzPbtp0&amp;redirect_status=succeeded#/payment-handler?idDataStore=E93E776D-96B7-4997-8C09-9B6D0193C864>

If I remove the # the params are then added correctly bot I am redirected to the 404 page rather than my payment-handler page

<https://devbookingportalv2.fmbetterforms.com/payment-handler?idDataStore=82A5BA03-BF5A-47B3-B5E9-86FDD0D0046D&amp;payment_intent=pi_3PpUSWI2wEvj3Dtm0xzTU0tr&amp;payment_intent_client_secret=pi_3PpUSWI2wEvj3Dtm0xzTU0tr_secret_4sg4WwSJjSbg7DbfnpEt4NE0c&amp;redirect_status=succeeded>

Can you suggest any way of achieving this?


Delfs:
In the ‘with #’ example, I dont see the hash in the url?


Neil Manchester:
Gets added here

image


Delfs:
HAve you checked docs for that company if they have anysetting hat govern URL formatting etc. I have seen that before.


Neil Manchester:
I’ve looked at the Klarna docs but it’s all managed via the Stripe API and this is all that it says about adding your own query params (https://docs.stripe.com/js/payment_intents/confirm_payment). Is there any way of handling a BF URL which doesn’t contain the /#/ without it being redirected to the error page with a 404?

image


Delfs:
One way that could potentially work is to redirect to the API endpoint and then the APN point can actually send a 302 redirect back to the browser right away


Delfs:
Yeah, as I think about it, that would work that’s how we build URL expanders and it’s the same idea


Neil Manchester:
Of course! Should have thought of an api call. No need for the extra page then. I’ll give that a try. Thanks Charles.


Delfs:
Ping if you get stuck