[英]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.