ruby-on-rails - 在 Active Merchant/PayPal Express Checkout 中设置税额

标签 ruby-on-rails paypal activemerchant

我需要知道如何使用 Active Merchant 和 rails 将税额传递给 PayPal Express Checkout。一切正常(完成交易),除了我一辈子都想不出如何设置税收。

感谢您的帮助!

最佳答案

它是这样完成的。

以下代码将为 2 件价格不同(5 美元和 10 美元)的商品设置 paypal express 购买,加上附加税(50 美分)并且没有运费或手续费。

response = YOUR_PAYPAL_GAETWAY_NAME.setup_purchase(1550,
  :subtotal => 1500,
  :shipping => 0,
  :handling => 0,
  :tax => 50,
  :ip     => CLIENT_IP, # you might want to use "request.remote_ip" method from a controller to obtain this value

  :items => [
             {:name => 'ITEM_NAME_1', :description => 'ITEM_DESC_1', :amount => 500, :quantity => 1}, 
             {:name => 'ITEM_NAME_2', :description => 'ITEM_DESC_2', :amount => 1000, :quantity => 1}
            ],

  :return_url        => 'http://SOME/URL',
  :cancel_return_url => 'http://MAYBE/ANOTHER/URL'
)

redirect_to YOUR_PAYPAL_GAETWAY_NAME.redirect_url_for(response.token)

注意事项:

  • 所有金额必须以美分为单位

  • 必须指定所有 4 个选项 [:subtotal, :shipping, :handling, :tax],如果缺少一个或多个选项,其余的将被忽略,如果您不需要设置某个选项,例如处理费用,只需像上面的示例一样将其设置为零,设置为零的选项将不会出现在您的 paypal 页面上。

  • :小计必须等于以美分表示的商品总价,即(item1 * item1 的数量)+(item2 * item2 的数量)等等...

  • 订单总金额(代码中设置为1550)必须等于:subtotal + :shipping + :handling + :tax 否则paypal会返回错误(无效交易)

关于ruby-on-rails - 在 Active Merchant/PayPal Express Checkout 中设置税额,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1550072/

相关文章:

php - 如何将 PayPal 快速结帐与运输详细信息集成?

ruby-on-rails-3 - 轨道 3 : wrapping ActiveRecord operations and external credit card in a single transaction

ruby-on-rails - 如果你使用Google Checkout,你还需要在Rails中使用ActiveMerchant/Spree/some payment gateway吗?

html - Paypal 回调未验证

ruby-on-rails - 为 delayed_job 设置 MAX_RUN_TIME - 我可以设置多少时间?

javascript - $.post(url, 函数(数据,状态) {警报(数据)});警报()不工作

ruby-on-rails - Rails 中可能有 "polymorphic has_one"关系吗?

Paypal REST API - 计费协议(protocol)

ruby-on-rails - 10001 尝试使用 Activemerchant 从 PayPal 获取授权时出现内部错误

ruby-on-rails - Rails 仅作为 API 需要实例变量吗?