试图在我的 Rails 站点中向 Venmo 发出 Post Request 以进行付款处理。
这是我在 index.html.erb 中的表格:
<!-- Venmo box -->
<div class="box box-warning">
<div class="box-header">
<%= form_tag make_payment_path do %>
<%= hidden_field_tag "access_token", @access_token %>
<h3 class="box-title">Pay Bill using Venmo Account</h3>
<div id="payment_note_input">
<%= text_field_tag "payment_note", nil, class:"form-control", placeholder: "add a note to your payment" %>
</div>
<div id="payment_target_input">
<%= text_field_tag "payment_target", nil, class:"form-control", placeholder: "pay an email address" %>
</div>
<div id="payment_amount_input">
<%= text_field_tag "payment_amount", nil, class:"form-control", placeholder: "enter the payment amount!"%>
</div>
</br>
<%= submit_tag "Make payment", class: "btn btn-danger" %>
<% end %>
</div>
这是我在控制器中的 make_payment_path 方法中的内容:
def index
if !params[:access_token].nil?
flash[:success] = "Venmo successfully authenticated!"
end
end
def make_payment_path
if !params[:access_token].nil?
uri = URI.parse("https://api.venmo.com/v1/payments")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data({"access_token" => params[:access_token], "email" => params[:payment_target],
"amount" => params[:payment_amount], "note" => params[:payment_note]} )
response = http.request(request)
end
end
helper_method :make_payment_path
我不断收到这篇文章标题中的错误:“Net::HTTPBadRequest:Class 的未定义方法 `model_name'”
我似乎找不到与此错误类似的任何其他结果。它在 Ruby 文档中作为 308 Permanent Redirect - 在草稿中出现。有人可以在这里帮忙吗?