将 Chargify(托管)与 Rails 应用程序集成
我正在尝试将 Chargify 的托管计费与我的 Rails 应用程序集成,但遇到了一些困难。
从那时起我是个菜鸟,我在这里遇到了一个问题:
def self.product_id(plan)
# your own logic to retrieve the Chargify product ID for
# the plan in question (hint: I store mine in the DB)
end
基本上这只是将 URL 连接到正确的 Chargify 托管页面...即每个计划都有一个 6 位数的 ID,具体取决于他们点击的计划定价页面,应该将它们带到 chargify.com/#{self.product_id(plan)}
我确信有一个简单的解决方案,但我现在无法理解它。
提前致谢。
I'm trying to integrated Chargify's hosted billing with my rails app and am running into some difficulties.
I'm following this tutorial: http://blog.formedfunction.com/post/4022209767/how-to-integrate-chargify-hosted-payment-pages-with-a
And since I'm a total noob, I'm running into a problem here:
def self.product_id(plan)
# your own logic to retrieve the Chargify product ID for
# the plan in question (hint: I store mine in the DB)
end
Basically this is just to connect the URLs to the proper Chargify hosted page... i.e. each plan has a 6 digit ID, and depending on which plan they click on the pricing page, they should be taken to chargify.com/#{self.product_id(plan)}
I'm sure there is a simple solution, I just can't wrap my head around it right now.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信 Ryan 将他的 Golf Trac 计划存储在他的数据库中,其中有一个类似于“chargify_product_id”的列,他要么手动填写该列(您可以在 Chargify UI 的“产品”选项卡下找到产品 ID),要么通过查询 API 填写。因此,第一步是在您自己的应用程序中创建产品或计划的概念,并手动或通过 API 使您的产品与 Chargify 设置保持同步。注意:如果您选择的话,这实际上可以像应用程序中的常量一样简单,即
当用户在您的网站上选择一个计划时,您将“查找”Chargify 产品 ID,以便您可以将它们发送到正确的托管页面,通过他的
hosted_signup_page_for
方法。I believe that Ryan stores his plans for Golf Trac in his database with a column like "chargify_product_id" that he either filled in manually (you can find the Product ID in the Chargify UI under the "Products" tab) or by querying the API. So the first step would be to create the notion of a product or plan in your own app, and keep your offerings in sync with your Chargify setup either manually or via the API. Note: this really could be as simple as a constant in your app, if you choose, i.e.
When a user selects a plan on your site, you would then "lookup" the Chargify Product ID so that you could send them to the proper hosted page, via his
hosted_signup_page_for
method.