我需要知道如何使用 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/