【问题标题】:Rails PayPal proof of conceptRails PayPal 概念验证
【发布时间】:2011-01-25 17:21:28
【问题描述】:

我正在尝试创建一个与 rails 的超简单的 paypal 自定义集成。我正在关注Ryan Bates Railscast #141 关于这个主题,我已经进一步简化了它。如果您有超级简单的贝宝集成经验,任何建议都将不胜感激!

我正在尝试通过我的帐户模型传递一切。概念验证。

def paypal_url(return_url)
  values = {
    :business => 'jwade_1268181180_biz@gmail.com',
    :cmd => '_cart',
    :upload => 1,
    :return => return_url,
    :invoice => 2,
    :amount => 7,
    :item_name => 'Membership',
    :item_number => 1,
    :quantity => 1 
  }

  "https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query
end 

当然我创建了一个链接:

<%= link_to "Checkout", @account.paypal_url(accounts_path) %>

Paypal 检测到错误:“您的购物车是空的”,这很奇怪,因为我可以看到我的模型在 URL 中传递的所有内容:

https://www.sandbox.paypal.com/cgi-bin/webscr?amount=7&business=jwade_1268181180_biz@gmail.com&cmd=_cart&invoice=&item_name=Barcoden+Membership&item_number=1&quantity=1&return=/accounts&upload=1

【问题讨论】:

    标签: ruby-on-rails paypal


    【解决方案1】:

    我发现跟随 railscast 会导致出现空车错误消息。 尝试创建一个表单来替换链接,例如:

    <div>
      <%= form_tag 'https://www.sandbox.paypal.com/cgi-bin/webscr' do %>
      <input type="hidden" name="cmd" value="_cart"> 
      <input type="hidden" name="upload" value="1"> 
      <input type="hidden" name="business" value="Your sandbox biz Account"> 
      <input type="hidden" name="item_name_1" value="Some Name"> 
      <input type="hidden" name="amount_1" value="100"> 
      <input type="submit" value="PayPal">
      <% end %>
    </div>
    

    这会奏效。除非您使用发布请求,否则似乎不会创建购物车。

    link_to 助手中使用:method =&gt; :post 将不起作用。

    您可以使用 button_to 帮助器创建一个迷你表单并替换 railcast 中的 link_to。

    【讨论】:

      【解决方案2】:

      要回答这个问题,我们需要仔细查看您的代码。

      但也许这可以帮助你:A Testable PayPal IPN with Rails 2.3

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-02-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-13
        • 2015-04-19
        相关资源
        最近更新 更多