1

我最近在使用 ruby​​ 的 paypal api ( https://github.com/paypal/merchant-sdk-ruby ) 时遇到了麻烦。

我正在尝试使用 PaymentDetailsItem 设置一个包含多个项目的结帐,但是当我发送请求时,我收到一条错误消息:“购物车项目的总金额与订单金额不匹配。”

我已经检查过了,你可以在下面的代码中看到。我的 OrderTotal 等于 ItemTotal、ShippingTotal、HandlingTotal 和 TaxTotal 的总和。

我已经尝试了很多东西,paypal api 的文档非常糟糕,我在网上找不到任何关于此的示例。非常感谢您的帮助。

@api = PayPal::SDK::Merchant::API.new
@set_express_checkout = @api.build_set_express_checkout({
:SetExpressCheckoutRequestDetails => {
:ReturnURL => "#{ENV['HOST']}/return",
:CancelURL => "#{ENV['HOST']}/cancel",

:PaymentDetails => [{

  :OrderTotal => {
    :currencyID => currency,
    :value => "10.00" 
  },

  :ItemTotal => {
    :currencyID => currency,
    :value => "10.00" 
  },

  :ShippingTotal => {
    :currencyID => currency,
    # :value => ship 
    :value => "0.00"
  },

  :TaxTotal => {
    :currencyID => currency,
    :value => "0.00" 
  },

  :NotifyURL => "#{ENV['HOST']}/ipn_notify",

  :PaymentDetailsItem => 
  [
    {
      :Name => "Some Product", 
      :Quantity => 1,
      :Amount => {
        :currencyID => "EUR",
        :value => "5.00"
      },
      :ItemCategory => "Physical"
    }
  ],
  :PaymentDetailsItem => 
  [
    {
      :Name => "Other Product",
      :Quantity => 1,
      :Amount => {
        :currencyID => "EUR",
        :value => "5.00" 
      },
      :ItemCategory => "Physical" 
    }
  ], 
  :PaymentAction => "Authorization" }] } })
@set_express_checkout_response = @api.set_express_checkout(@set_express_checkout)
4

1 回答 1

-1

删除其中一个:PaymentDetailsItem键并添加项目,如下所示。

:PaymentDetailsItem =>
  [
    {
      :Name => "Some Product",
      :Quantity => 1,
      :Amount => {
        :currencyID => "EUR",
        :value => "5.00"
      },
      :ItemCategory => "Physical"
    },
    {
      :Name => "Other Product",
      :Quantity => 1,
      :Amount => {
        :currencyID => "EUR",
        :value => "5.00"
      },
      :ItemCategory => "Physical"
    }
  ]
于 2013-08-06T16:03:29.570 回答