3

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

[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

我怎样才能得到这个工作?

4

3 回答 3

0

我在您的代码中看不到 order total 参数。请检查一下!

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

            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));

和是 0。我得到itemTotalorderTotal10525: This transaction cannot be processed. The amount to be charged is zero.

也许我的代码与另一个参数一起使用,然后是您的代码。我认为如果您将订单总额添加到您的代码中,您将得到相同的 10525。

请检查一下!

编辑:

我在网上找到了这个解释:

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

这是一个链接。

于 2013-10-12T14:12:03.873 回答
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"); 
于 2014-05-07T08:08:06.667 回答
0

“PAYMENTREQUEST_0_ITEMAMT=0.00”必须大于零。

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

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

于 2013-09-30T02:34:07.763 回答