我遇到了RoR Active Merchant Express Gateway的问题。我想向客户付款添加运费。 :运费已设定。在测试模式下所有工作,但在生产中没有。 Paypal显示全部费用(小计+运费),但在整个过程后,我的结算费用不收取运费。
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :production
paypal_options = {
login: "paypal-api-login",
password: "paypal-api-password",
signature: "paypal-api-signature"
}
::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
然后订购功能:
@order = Order.new(order_params)
if @order.save
fill_order
response = EXPRESS_GATEWAY
.setup_purchase((paypal_total_amount_in_cents.to_i + paypal_shipping.to_i),
ip: request.remote_ip,
return_url: confirm_orders_url,
cancel_return_url: cart_url,
currency: "GBP",
allow_guest_checkout: true,
:subtotal => paypal_total_amount_in_cents.to_i,
:shipping => paypal_shipping.to_i,
:tax => 0.to_i,
:handling => 0.to_i,
items: paypal_items
)
@order.update(express_token: response.token, user: current_user, delivery: @delivery)
@order.created!
redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)
else
failure if not @order.save
end
Paypal显示价格不错。它表明运费会加到价格中,但付款后运费不会计入总费用。