小编Joh*_*nyK的帖子

如何为 Stripe 集成编写 Lambda 函数?

背景:我正在使用 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)

stripe-payments reactjs aws-lambda gatsby netlify

8
推荐指数
1
解决办法
4511
查看次数

标签 统计

aws-lambda ×1

gatsby ×1

netlify ×1

reactjs ×1

stripe-payments ×1