背景:我正在使用 Gatsby -> Netlify 将我们的销售页面迁移到无服务器 CDN,并尝试实现 Stripe 自定义支付流程,因为我们想要自定义结账表单。我在这里的一个登陆页面上实现了 Stripe Checkout,但这不是我们想要的。登陆页面
Stripe 的文档非常简单,但该文档假设正在运行一台服务器。
以下代码是其文档中的服务器实现片段。
const express = require("express");
const app = express();
// This is your real test secret API key.
const stripe = require("stripe")("sk_test_51J085aDDSnMNt7v1ZO3n5fxobP6hhEhf1uC2SDmkHGIX8fCnxFiSMrxITKu06ypYUHYAMHVZ1lhc5Fqm7UoVa6dx00XvV5PZzG");
app.use(express.static("."));
app.use(express.json());
const calculateOrderAmount = items => {
// Replace this constant with a calculation of the order's amount
// Calculate the order total on the server to prevent
// people from directly manipulating the amount on the client
return 1400;
};
app.post("/create-payment-intent", …Run Code Online (Sandbox Code Playgroud)