我正在使用Paypal API并跟随Railscast#141 Paypal基础知识 . 我在我认为正确的格式中实现了代码,并且到paypal站点的链接正在运行 . 但是,在用户将商品添加到购物车然后点击paypal链接后,该网站似乎没有注意到已添加的商品和错误“您的购物车是空的” . 出现 .

这是我购物车的视图布局

<h2>Your Cart</h2> <table>
    <%= render(cart.line_items) %>
<tr class="total_line">
<td colspan="2">Total</td>

<td class="total_cell"><%= number_to_currency(cart.total_price) %></td>
    </tr>
  </table>

<%= link_to ("paypal checkout"), @cart.paypal_url(parts_url) %>

<%= button_to "Checkout", new_order_path, method: :get %>
<%= button_to 'Empty cart', cart, method: :delete, data: { confirm: 'Are you sure?' } %>

和carts模型我有定义paypal_url方法的地方

def paypal_url(return_url)
  values = {
    :business => '',
    :cmd => '_cart',
    :upload => 1,
    :return => return_url,
    :invoice => id
  }
  line_items.each_with_index do |item, index|
    values.merge!({
      "item_name_#{index+1}" => item.part.name,
      "item_number_#{index+1}" => item.part.id,
      "quantity_#{index+1}" => item.quantity
    })
  end
  "https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query
end

如何解决这个问题的任何帮助表示赞赏,如果需要,可以随时询问更多信息 .