繁体   English   中英

PayPal在Ruby on Rails中的集成

[英]PayPal integration in Ruby on Rails

我想将PayPal支付系统添加到我的RoR应用程序中。 为此,我确实安装了paypal-sdk-rest gem。

我有一个Feed模型,位于index.html.rb内部,路由为:

get '/:locale/feed', to: 'feed#index', as: 'feed'

我要粘贴下一个代码:

<%= link_to 'checkout', feed.paypal_url(products_url) %> 

在模型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 

但这使我感到:

undefined local variable or method `feed' for #<#<Class:0x007f5644b79520>:0x007f5644b89858> 

<%= link_to 'checkout', feed.paypal_url(feeds_url) %>

有什么问题,如何解决此错误?

UPDATE

我只想将付款用的按钮粘贴到我的网站上,金额为1 $。 我该怎么做?

Feed对象在哪里定义? 如果在控制器中,那么它应该是实例变量,例如@feed,要从视图访问在控制器中定义的变量,我们必须将它们定义为实例变量,例如@feed。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM