Rails - 付款后提供可下载文件
我正在寻找一种将购买的文件传递给网络应用程序用户的方法。基本上,用户会从我的网站购买“产品”,此时他们可以下载他们购买的文件(可能是我预编译的 zip 文件)
我正在使用 Rails 2.3.8,并让付款处理工作布伦特里解决方案。是否有使用短代码或其他方法来实现此目的的标准方法? Braintree 是否有内置的东西,是否存在插件/gem?
我真的只是在寻找正确的方向,以了解通常如何完成此操作。
谢谢!
I am looking for a way to deliver purchased files to users of a web app. Basically a user will purchase a 'product' from my site, at which point they can download the files they purchased (will likely be a zip file that I have precompiled)
I am using Rails 2.3.8, and have the payment processing working the Braintree Solutions. Is there a standard way of acheiving this, using short codes, or something? Does Braintree have something built in, does a plugin/gem exists?
I'm really looking for just a push in the right direction as to how this is typically done..
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以做的是让每个
Product
模型have_many
获得批准的用户。当 BrainTree 同意用户为产品付款后,您可以将该用户添加到批准的用户列表中。因此,在您的ProductController
中,您检查 current_user 是否是已批准的用户,如果是,则下载文件,否则重定向它们。对于示例:
product.rb
Product_controller.rb
或类似的东西。我的语法可能有点偏离,但这应该可以帮助你。
What you could do is have each
Product
modelhave_many
approved users. When BrainTree gives you the OK that a user paid for a product, you can add that user to the approved users list. So in yourProductController
you check if the current_user is a approved user, if so download the file, else redirect them.For Exsample:
product.rb
product_controller.rb
Or something like that. My syntax might be a little off, but this should get you going.