skip to Main Content

I’ve been developing an app with firebase and stripe payment. I’ve created a checkout session in stripe and added firebase dynamic links for the success_url and cancel_url. The URLs are working fine. I’ve tested them outside stripe with a simple html file and it opens the app and takes the user to the correct page. If the page doesn’t exist it’ll take the user to the assigned website. This is stripe checkout session code:

const session = await stripe.checkout.sessions.create({
        line_items: [{
            price_data: { currency: 'INR', unit_amount: amount, product_data: { name: 'name' } },
            quantity: 1,
        }],
        mode: 'payment',
        success_url: 'https://-------.page.link/payment-success',
        cancel_url: 'https://-------.page.link/payment-failed',
        payment_intent_data: {
            application_fee_amount: fee
        },
    }, {
        stripeAccount: req.query.stripeId,
    });

I’ve changed up the actual link since I don’t know how much I’m allowed to share. But I can guarantee the dynamic links works fine. But after payment, the test payment at least, it’s suppose to open the app and take the user to a payment success page. AND it was working fine for the first 2 or 3 days. After payment it re-opened the app and took the user to the correct page. But when I tried a few days later, this is what it’s taking us to:
Screenshot

Again, I’ve removed the link since I don’t know how much I’m allowed to share. It won’t even open the app right now. It just shows this message in the browser. Both success and cancel url are doing the same. Why does the links work outside the function but not in it? Has anyone ever faced any similar issues before? Any help will be greatly appreciated.

2

Answers


  1. It seems like you’re trying to open the Checkout Session in a WebView which causing the issue in the redirect. Webviews don’t know how to handle an URL Scheme other than http:// or https://. That being said, your problem isn’t uncommon and there are multiple ways of solving this.
    Your first approach would be to open the Checkout Session in an external browser as described in this answer or try to create your own WebViewClient and override shouldOverrideUrlLoading method like described in this answer. Just note that since the last edit of that answer the signature of the shouldOverrideUrlLoading method has changed but the logic should still be used the same way but instead of dealing with the String url, you will have to deal with a WebResourceRequest.

    Login or Signup to reply.
  2. Had the same issue. I solved it by changing the mode like following:

    await launchUrl(
      url,
      mode: LaunchMode.externalApplication, // Add this line
    )
    

    url_launcher version => 6.1.7

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search