Express checkout voucher handling (AMOUNT_MISMATCH)

353 views Asked by At

Since upgrading to the PayPal REST API we have a problem with our express checkout.

When using Express Checkout the User will be first sent to the Paypal site to authenticate so we can get his address details.

in this phase the following values are set:

Create payment

    "transactions": [
    {
      "amount": {
        "currency": "EUR",
        "total": "11.95",
        "details": {
          "shipping": "2.00",
          "subtotal": "9.95"
        }
      },
      "item_list": {
        "items": [
          {
            "quantity": "1",
            "name": "Some item :)",
            "price": "9.95",
            "currency": "EUR",
            "sku": "123"
          }
        ]
      }
    }
  ]

After returning to our checkout page the user has the option to apply a voucher to his order. We are not sure how to reflect this change in the PayPal REST API.

In the old API we used to create a new item in the item_list with a negative price.

Is there sine way in the REST API to update the item_list after the authentication?

Both the Update and Execute payment commands only support a new value for the "amount" object but not the "item_list". If we send a new (discounted) amount as follows we receive the AMOUNT_MISMATCH error because the new "amount" doesn't reflect the "item_list" anymore.

Execute Payment

"transactions": [
    {
      "amount": {
        "currency": "EUR",
        "total": "6.95",
        "details": {
          "shipping": "2.00",
          "subtotal": "4.95"
        }
      }
    }
  ]

Results in

Error code : 400 with response : {"name":"AMOUNT_MISMATCH","message":"The totals of the cart item amounts do not match sale amounts"}

How should the Voucher be applied properly? Suggestions?

1

There are 1 answers

1
Paizo On

You can specify the discount amount or percent using the discount variable, see https://developer.paypal.com/docs/api/