小计(ITEMAMT)为$ 0.00时出错

时间:2013-09-29 22:24:29

标签: paypal paypal-sandbox express-checkout

当我尝试使用PayPal API的小计为0.00美元时,收到错误:

  

[10413] =>购物车项目金额的总计与订单金额不匹配。

这是传递给SetExpressCheckout的请求数据(个人信息被替换为......):

    [0] => L_PAYMENTREQUEST_0_AMT0=9.99
    [1] => L_PAYMENTREQUEST_0_NAME0=Name
    [2] => L_PAYMENTREQUEST_0_QTY0=1
    [3] => L_PAYMENTREQUEST_0_NUMBER0=1
    [4] => L_PAYMENTREQUEST_0_AMT1=-9.99
    [5] => L_PAYMENTREQUEST_0_NAME1=Discount
    [6] => L_PAYMENTREQUEST_0_QTY1=1
    [7] => L_PAYMENTREQUEST_0_NUMBER1=0
    [8] => PAYMENTREQUEST_0_AMT=2.51
    [9] => PAYMENTREQUEST_0_ITEMAMT=0.00
    [10] => PAYMENTREQUEST_0_SHIPPINGAMT=2.38
    [11] => PAYMENTREQUEST_0_TAXAMT=0.13
    [12] => PAYMENTREQUEST_0_SHIPTONAME=...
    [13] => PAYMENTREQUEST_0_SHIPTOSTREET=...
    [14] => PAYMENTREQUEST_0_SHIPTOSTREET2=...
    [15] => PAYMENTREQUEST_0_SHIPTOCITY=...
    [16] => PAYMENTREQUEST_0_SHIPTOSTATE=...
    [17] => PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=...
    [18] => PAYMENTREQUEST_0_SHIPTOZIP=...
    [19] => PAYMENTREQUEST_0_SHIPTOPHONENUM=...
    [20] => CANCELURL=...
    [21] => RETURNURL=...
    [22] => NOSHIPPING=1
    [23] => ALLOWNOTE=0

我怎样才能使这个工作?

3 个答案:

答案 0 :(得分:0)

'PAYMENTREQUEST_0_ITEMAMT = 0.00'必须大于零。

https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/pp_nvpapi_developerguide.pdf 第72页

[....字符长度和限制:价值是一个正数,任何货币都不能超过10,000美元......]

答案 1 :(得分:0)

我在代码中看不到订单总参数。请检查一下!

同时我用以下参数测试了呼叫:

            List<PaymentDetailsItemType> lineItems = 
                              new ArrayList<PaymentDetailsItemType>();

            PaymentDetailsItemType item = new PaymentDetailsItemType();
            BasicAmountType amt = new BasicAmountType();

            amt.setCurrencyID(CurrencyCodeType.fromValue(dto.getCurrencyCode()));
            amt.setValue("9.99");

            item.setAmount(amt);

            item.setQuantity(dto.getItemQuantity());
            item.setName("Name");
            item.setNumber("1");

            lineItems.add(item);

            PaymentDetailsItemType item1 = new PaymentDetailsItemType();
            BasicAmountType amt1 = new BasicAmountType();

            amt1.setCurrencyID(CurrencyCodeType.fromValue(dto.getCurrencyCode()));
            amt1.setValue("-9.99");

            item1.setAmount(amt1);
            item1.setQuantity(dto.getItemQuantity());
            item1.setName("Discount");
            item1.setNumber("0");
            lineItems.add(item1);
            ...

        BasicAmountType itemsTotal = new BasicAmountType();
        itemsTotal.setValue(Double.toString(itemTotal));

        BasicAmountType orderTotal = new BasicAmountType();
        orderTotal.setValue(Double.toString(orderTotal));

itemTotalorderTotal为0.我得到10525: This transaction cannot be processed. The amount to be charged is zero.

也许我的代码可以使用其他参数,然后使用您的代码。我想如果你在你的代码中添加订单总数,你将得到相同的10525。

请检查一下!

修改

我在网上发现了这个问题:

  

如果一个或多个小计为零,则可以包含   请求中的字段值为零,传递空字符串或   将该字段完全排除在请求之外。但是,总和了   剩余的小计字段(如果指定了任何字段)必须加起来为AMT。

Here is a link.

答案 2 :(得分:0)

您可以临时添加项目以进行结账,并添加更多折扣运费以减去临时项目金额。 Paypal接受最低金额为0.01美元。 这是我的代码。它适合我的情况:

            var itemDetails = new PaymentDetailsItemType();
            itemDetails.Name = "Shipping and Handling";
            itemDetails.Amount = new BasicAmountType(currency, "0.01");
            itemDetails.Quantity = 1;
            //itemDetails.Tax = new BasicAmountType(currency, tax.ToString());
            itemDetails.ItemCategory = ItemCategoryType.PHYSICAL;


            itemDetails.Description = "Item temporary for payment.";
            paymentDetails.PaymentDetailsItem.Add(itemDetails);

            itemTotal = (double)0.01;
            paymentDetails.ShippingDiscount = new BasicAmountType(currency, "-0.01");