我使用PayPal-SDK-Rest gem。我在feed.rb(模型)中有下一个def:
def self.paypal_url(return_path)
values = {
business: "team@team.com",
cmd: "_xclick",
upload: 1,
return: "#{Rails.application.secrets.app_host}#{return_path}",
#invoice: id,
amount: 0.01,
item_name: "9dt9",
#item_number: course.id,
quantity: '1',
notify_url: "#{Rails.application.secrets.app_host}/hook"
}
#"#{Rails.application.secrets.paypal_host}/cgi-bin/webscr?" + values.to_query
"https://www.paypal.com/cgi-bin/webscr?" + values.to_query
end
在视图文件中我放了:
<%= link_to "Checkout", @feed.paypal_url("http://my_website.com/en") %>
对于notify_url,我确实使用了feed_controller中的下一个函数:
def hook
params.permit! # Permit all Paypal input params
#status = params[:payment_status]
status = params[:st]
if status == "Completed"
Transaction.create(:status => params[:st], :transaction_id => params[:tx], :purchased_at => Time.now)
puts "Data: #{params[:st]} :: #{params[:tx]}"
else
puts "NothingHere"
end
render nothing: true
end
因此,它必须将我的参数添加到表中,但它不会。有什么问题,谁知道?为什么它不会在表格中插入任何内容?
谁可以帮助我?
更新
在MGINX日志中,我得到:
Parameters: {"tx"=>"9BK361abcdefg473M", "st"=>"Completed", "amt"=>"0.01", "cc"=>"USD", "cm"=>"", "item_number"=>"", "locale"=>"en"}