【问题标题】:Challenges with Stripe integration in MeteorMeteor 中 Stripe 集成的挑战
【发布时间】:2020-10-01 15:43:22
【问题描述】:
我还没有找到任何真正可靠的教程/将支付集成到 Meteor 应用程序的示例,只是将 Nodes.JS 与 Express 结合使用的内容
Stripe guide我正在尝试(但失败)关注/集成到我的应用中
这是一个possible solution,但我可以按照上面列出的指南帮助剖析它以进行 Stripe 集成
有没有不包含 mrgalaxy:stripe 作为解决方案的简单指南
该软件包自 2016 年以来未更新,我真的更喜欢最新的依赖项
我特别卡在 await / async / promises 上,可以在结帐部分使用一些帮助
如果我需要粘贴代码,我会,但主要是我正在寻找可以帮助我集成简单结帐流程的更新的东西
谢谢!
【问题讨论】:
标签:
javascript
node.js
meteor
async-await
stripe-payments
【解决方案1】:
Meteor 似乎对npm 包有很好的兼容性,所以这里应该没有什么必要的。看起来你也在 Meteor 论坛上提问过,所以你可能会在那里得到更好、更具体的答案。
【解决方案2】:
我已将 Stripe 集成到我的 Meteor 应用程序中。如前所述,您可以在服务器端使用stripe npm。
meteor npm install stripe
我倾向于在我的项目中的某处有一个文件来初始化我的条带。例如。 /imports/stripe.js:
import { Meteor } from 'meteor/meteor'
import Stripe from 'stripe'
const stripe = new Stripe(Meteor.settings.Stripe.secretKey, {
maxNetworkRetries: 2,
})
export default stripe
然后,每当我需要使用项目中的条带 api 时,我就可以这样做:
import stripe from '/imports/stripe'
如果您愿意,还可以利用 checkout.js 或客户端的其他前端集成。它们往往就像将 <script> 标签放入您的项目 index.html
一样简单
https://stripe.com/docs/payments/checkout/accept-a-payment#redirect-checkout