[英]PayPal integration in Ruby on Rails
I want to add PayPal payment system to my RoR app. 我想将PayPal支付系统添加到我的RoR应用程序中。 For this I did install
paypal-sdk-rest
gem. 为此,我确实安装了
paypal-sdk-rest
gem。
I have a model Feed
and inside of index.html.rb, where the route is: 我有一个
Feed
模型,位于index.html.rb内部,路由为:
get '/:locale/feed', to: 'feed#index', as: 'feed'
I want to paste the next code: 我要粘贴下一个代码:
<%= link_to 'checkout', feed.paypal_url(products_url) %>
And inside of the model feed.rb: 在模型feed.rb中:
def paypal_url(return_url)
values = {
:business => 'my_paypal_mail@gmail.com',
:cmd => '_cart',
:upload => 1,
:return => return_url,
}
values.merge!({
"amount_1" => unit_price,
"item_name_1" => name,
"item_number_1" => id,
"quantity_1" => '1'
})
"https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query
end
But it prints me, that: 但这使我感到:
undefined local variable or method `feed' for #<#<Class:0x007f5644b79520>:0x007f5644b89858>
on 上
<%= link_to 'checkout', feed.paypal_url(feeds_url) %>
What is the problem and how can I fix this error? 有什么问题,如何解决此错误?
UPDATE UPDATE
I just want to paste button just for payment, to my website with the amount 1$. 我只想将付款用的按钮粘贴到我的网站上,金额为1 $。 How can I make it?
我该怎么做?
Where is feed object defined? Feed对象在哪里定义? If in controller then it should be instance variable like @feed, To access variables defined in controller from views we have to defined them as instance variables like @feed.
如果在控制器中,那么它应该是实例变量,例如@feed,要从视图访问在控制器中定义的变量,我们必须将它们定义为实例变量,例如@feed。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.