我需要自己的服务器才能使用 Stripe API 吗?

Do I need my own server to use the Stripe API?

我想通过 Stripe 在我的应用程序中实现支付。我正在阅读他们的文档,它一直提到我将在从 Stripe 检索令牌后使用我自己的服务器向某人收费。 (stripe documentation)

为什么我需要一个服务器来向我的用户收费为什么我不能只调用 Stripe API 方法来收费 - 我在我的服务器上有什么特别之处?有没有不用自己建服务器就可以收费的方法? Firebase 是否足够?

谢谢

是的。您需要服务器的原因主要是为了保护 Stripe 提供给您的密钥。您不想在您的移动应用程序中嵌入密钥,因为它提供的保护几乎为零。有人可以简单地拆解您的应用程序,即使它被混淆了,并试图无助地找到散落在各处的密钥。

链接:

This Q&A 在 Stripe 网站上回答得很清楚,但没有详细说明。

This blog post 解释了端到端的过程,这可能对您阅读上下文很有帮助。

备选方案:

  1. Webtask stripe script (see the main webtask page也)。

  2. Accepton 也可以。

...不过,我建议您自己设置,这样您就可以保持尽可能多的控制。 HTTP 和 REST 的定义和细节不在这个问题的范围内,但请放心,实现此功能的代码量是微不足道的(尽管您最初 learning/effort)。

让我用我的解释扩展一下他们在说什么:

With our mobile library, we shoulder the burden of PCI compliance by eliminating the need to send card data directly to your server. Instead, our libraries send the card data directly to our servers, where we can convert them to tokens.

这意味着人们通常会收到一个信用卡号,并希望将其存储起来以备后用(例如,客户将其输入您的帐户页面以便每月向他们收费),但这使您合法必须符合 PCI 标准,这可能是一个令人头疼的问题。 Stripe 减轻了你的负担——他们会存储信用卡,如果你想稍后收费,你只需给他们他们生成的代表该信用卡的令牌。

Your app will receive the token back, and can then send the token to an endpoint on your server, where it can be used to process a payment, establish recurring billing, or merely saved for later use.

这将在下一节中进行解释,https://stripe.com/docs/mobile/android#using-tokens

Using the payment token, however it was obtained, requires an API call from your server using your secret API key. (For security purposes, you should never embed your secret API key in your app.)

(drhr提到过)

由于您需要密钥来进行 API 调用,因此需要从您自己的服务器完成,因此您确实需要一个服务器。

注意:我没有用过我记得的 Stripe,我只是想分享我对文档的阅读。

P.S。我认为您的第二个问题是独立的,但是托管 Java 网络应用程序的一些流行且简单的选择是 Heroku 和 AppEngine。然而,对于这样的事情,您可能会采用无服务器方法,例如使用 AWS Lambda https://aws.amazon.com/lambda (google has an equivalent in Alpha stage https://cloud.google.com/functions/)