将 Stripe 与 Devise 结合使用以实现 Ruby on Rails 订阅

发布于 2024-12-20 13:57:59 字数 508 浏览 7 评论 0原文

我正在尝试将 Stripe 的定期支付系统与 Devise 集成,使用 Ryan 最近的 Railscast 作为指南( http://railscasts.com/episodes/288-billing-with-stripe?view=asciicast )。

我想使用现有的用户模型,而不是订阅模型。我已经完成了添加 Stripe 键、将表单字段添加到 /users/sign_up、在 head 中添加 js 和元标记,并且在资产中创建了一个 users.js.coffee 文件。

当我提交表单时,我没有收到任何错误,也没有任何类型的反馈表明任何内容已提交给 Stripe。日志根本没有显示订阅方面的任何内容。相反,我只是使用 Devise 创建了一个用户。

知道我错过了哪一步或者我错误命名了哪个文件吗?

谢谢, - 标记

I am attempting to integrate Stripe's recurring payment system with Devise, using Ryan's recent Railscast as a guide ( http://railscasts.com/episodes/288-billing-with-stripe?view=asciicast ).

Instead of a Subscription model, I want to use my existing User model. I got past adding the Stripe keys, adding the form fields to /users/sign_up, adding the js and meta tag in the head, and I have created a users.js.coffee file in assets.

When I submit the form, I get no error, and no type of feedback that anything was submitted to Stripe. Logs show nothing at all from the subscription side of things. Instead, I just get a user created with Devise.

Any idea what step I'm missing or which file I've named incorrectly?

Thanks,
--Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒中人 2024-12-27 13:57:59

我敢打赌你没有加载 jQuery。 subscriptions.js(或 .coffee)需要 jQuery,但 Ryan 认为知识隐含在他的 Rails 转换中。

编辑:我自己刚刚解决了同样的问题,我遇到了一个简单的问题,即不将 subscriptions.js 中的 #new_subscription 替换为 html 表单名称属性。例如,如果您的 html 如下所示:

<form accept-charset="UTF-8" action="/plans" class="new_plan" id="new_plan" method="post">

那么您将使用#new_plan 而不是#new_subscription。

如果您不使用正确的表单名称,jQuery 将不会“劫持”(触发回调)表单提交按钮以在让 Rails 处理表单之前将数据发送到 stripe。

希望这有帮助!

My bet is that you're not loading jQuery. The subscriptions.js(or .coffee) requires jQuery, but Ryan assumes that knowledge is implicit in his rails cast.

Edit: Having just solved the same problem myself I had the simple issue of not replacing #new_subscription in subscriptions.js with the html form name attribute. So for example if your html looks like:

<form accept-charset="UTF-8" action="/plans" class="new_plan" id="new_plan" method="post">

Then you would use #new_plan instead of #new_subscription.

If you don't use the proper form name jQuery won't 'hijack'(trigger the callback on) the form submit button to send data to stripe before letting rails process the form.

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文