【问题标题】:Deep Link and Stripe redirectDeep Link 和 Stripe 重定向
【发布时间】:2022-08-19 21:21:12
【问题描述】:

因此,我试图将我的 react-native 应用程序从条带结帐页面重定向回应用程序。

app.post(\'/create-checkout-session\', async (req, res) => {
  const prices = await stripe.prices.list({
    lookup_keys: [req.body.lookup_key],
    expand: [\'data.product\'],
  });
  const session = await stripe.checkout.sessions.create({
    billing_address_collection: \'auto\',
    line_items: [
      {
        price: prices.data[0].id,
        // For metered billing, do not pass quantity
        quantity: 1,

      },
    ],
    mode: \'subscription\',
    success_url: `${YOUR_DOMAIN}/?success=true&session_id={CHECKOUT_SESSION_ID}`,
    cancel_url: `${YOUR_DOMAIN}?canceled=true`,
  });

  res.redirect(303, session.url);
});

使用成功 URL,但它不会重定向回应用程序。 我目前在 App.js 文件中使用 React Navigation、Deep Linking。

const linking = {
  prefixes: [ Linking.createURL(\"hometrack://\")],
  config:{
    screens:{
      EmployeeSignUp:{
        path:\"EmployeeSignUp/:id\",
        parse: {
          id: (id) => `${id}`,
        },
      },
      Success:{
        path:\"Success\"
      }
      
    }
  }
};

我似乎无法将其链接回应用程序。

  • 这比 React 更像是一个 Stripe 问题!您使用的是哪个版本的 API?您是否在仪表板中验证了您的域以接收重定向?
  • @cuuupid 我相信是这样,当我放置一个本地主机 URL 但不是在反应导航中使用深层链接时它可以工作。
  • 您是否尝试使用深层链接/自定义 URL 方案重定向到应用程序?如果是这样,您的深层链接是否正常工作,即如果您要去hometrack://...some url...
  • @cuuupid 当我使用这个命令时npx uri-scheme open \"exp://127.0.0.1:19000/--/hometrack://EmployeeSignUp/6264385f19b66c695f651a63\" --ios 它打开到我正在寻找的页面。
  • 为什么不使用 Stripe React Native SDK?

标签: javascript react-native stripe-payments react-navigation


【解决方案1】:

在这种情况下,使用自定义 URL 方案 (myapp://screen..) 的深层链接不起作用。 Stripe 需要一个重定向到真实网站的有效 URL。我目前面临同样的问题,我的解决方法是:

  • 将用户重定向到我的网站(例如 myapp.com/redirect)。
  • 在网站上显示“重定向回应用程序”按钮。
  • 返回应用程序的深层链接

如果我能找到另一个解决方案,我会更新我的答案。

【讨论】:

    猜你喜欢
    • 2020-12-24
    • 1970-01-01
    • 1970-01-01
    • 2021-02-17
    • 1970-01-01
    • 2018-08-14
    • 2021-02-02
    • 2018-12-08
    • 1970-01-01
    相关资源
    最近更新 更多