vakas
vakas

Reputation: 1817

How to set shipping charges in Paypal SOAP API express checkout

I am adding an item of 20.00 and setting the order total to 22.00

 paymentDetails.OrderTotal = new PayPalSandboxWS.BasicAmountType()
     {
         currencyID = ConvertProgramCurrencyToPayPalSandbox(currency),
         Value = "22.00"
     };

and setting the shipping total to 2.00

 paymentDetails.ShippingTotal = new PayPalSandboxWS.BasicAmountType()
     {
         currencyID = ConvertProgramCurrencyToPayPalSandbox(currency),
         Value = "2.00"
     };

But I am getting this error: The totals of the cart item amounts do not match order amounts.

Please assist

Upvotes: 0

Views: 591

Answers (1)

JP Hellemons
JP Hellemons

Reputation: 6047

You missed setting the ItemTotal value! That caused this erorr:

double itemTot  = 20.0;
double tot      = 22.0;
double shipping = 2.0;
string desc     = "";
var paymentDetailsItemTypes = new List<PaymentDetailsItemType>();

PaymentDetailsType pdt = new PaymentDetailsType()
{        
    OrderDescription = desc,
    OrderTotal = new BasicAmountType()
    {
        currencyID = CurrencyCodeType.EUR,
        Value = tot.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
    },
    PaymentDetailsItem = paymentDetailsItemTypes.ToArray(),
    ShippingTotal = new BasicAmountType()
    {
        currencyID = CurrencyCodeType.EUR,
        Value = shipping.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
    },
    ItemTotal = new BasicAmountType()
    {
        currencyID = CurrencyCodeType.EUR,
        Value = itemTot.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
    }
};

Upvotes: 1

Related Questions