Applying Discounts to Payment Orders

Arben_G
Contributor
Contributor

I would like to be able to apply discounts to payments to be shown in the Paypal payment authorization window. In the latest API version, aside from shipping discounts, there does not seem to be any way of applying discounts on payments when creating an order as documented in the create order API reference.

 

In the previous version, discount implementation can be done by simply putting a negative value in one of the payment items in the request body as shown below.

{
  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  "transactions": [
    {
      "amount": {
        "total": "1900",
        "currency": "JPY",
      },
      "item_list": {
        "items": [
          {
            "name": "Sample Item Name",
            "quantity": "1",
            "price": "2000",
            "sku": "sample1",
            "currency": "JPY"
          },
          {
            "name": "Sample Discount",
            "quantity": "1",
            "price": "-100",
            "sku": "discount1",
            "currency": "JPY"
          }
        ],
      }
    }
  ],
  "redirect_urls": {
    "return_url": "https://example.com/return",
    "cancel_url": "https://example.com/cancel"
  }
}

I tried to apply a similar implementation to the new API version's request body for creating payment order as shown below.

{
  "intent": "authorize",
  "purchase_units": [
    {
      "amount": {
        "currency_code": "JPY",
        "value": "1900",
        "breakdown": {
          "item_total": {
            "currency_code": "JPY",
            "value": "1900",
          },
        },
      },
      "items": [
        {
          "name": "Sample Item Name",
          "unit_amount": {
            "currency_code": "JPY",
            "value": "2000",
          },
          "quantity": "1",
        },
        {
          "name": "Sample Discount",
          "unit_amount": {
            "currency_code": "JPY",
            "value": "-100",
          },
          "quantity": "1",
        }
      ],
    }
  ],
}

I was expecting it to work similar to the previous version, but I received an error response as shown below instead.

{
    "name": "UNPROCESSABLE_ENTITY",
    "details": [
        {
            "field": "/purchase_units/0/item/1/unit_amount/value",
            "value": "-100",
            "issue": "CANNOT_BE_NEGATIVE",
            "description": "Must be greater than or equal to 0. If the currency supports decimals, only two decimal place precision is supported."
        }
    ],
    "message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
    "debug_id": "745c3cca484ea",
    "links": [
        {
            "href": "https://developer.paypal.com/docs/api/orders/v2/#error-CANNOT_BE_NEGATIVE",
            "rel": "information_link",
            "method": "GET"
        }
    ]
}

The item unit amount however, should be able to receive negative numbers as a monetary value as described in the corresponding API reference.

 

Is there a correct way of including custom discounts to be shown in the Paypal Payment authorization window?

Login to Me Too
7 REPLIES 7

sboisse
Contributor
Contributor

I am also looking for a way to do this. Di dyou manage to find a solution to that problem?

Login to Me Too

fullhelpapp
Member
Member

We are also experiencing the exact same issue. There's no way to add discounts to "orders", not even as a negative line item which would be acceptable.

Login to Me Too

fullhelpapp
Member
Member

After doing some testing seems like it is possible to set a discount on the purchase unit's breakdown list:

 

{
    "purchase_units": [
        {
            "amount": {
                "currency_code": "USD",
                "value": "10.00",
                "breakdown": {
                    "item_total": {
                        "currency_code": "USD",
                        "value": "10.00"
                    },
                    "discount": {
                        "currency_code": "USD",
                        "value": "1.00"
                    }
                }
            },
            "items": []
        }
    ]
}

The discount is correctly applied to the order. The documentation is missing this field.

Login to Me Too

apizana
New Community Member

I order for this to work with breakdown the quantity needs to be equal to the amount value. You need to have in mind the discount is negative.

 

Note: Include the items property.

See the example:

"amount": {
    "currency_code": "USD",
    "value": "90.00",
        "breakdown": {
            "item_total": {
                 "currency_code": "USD",
                 "value": "100.00"
             },
            "discount": {
                 "currency_code": "USD",
                 "value": "10.00"
             }
         }
    },
"items": []

 

Login to Me Too

edenoikn
Contributor
Contributor

The breakdown->discount doesn't work in v2 

Login to Me Too

MTS_Stefan
Moderator
Moderator

Hello Everyone,

 

Looking at the discussion here, we are talking about REST v2 Order calls, correct?

If so, the JSON for a full breakdown with discounts, can look as follows:

 

  "purchase_units": [
    {
      "amount": {
        "value": "29.10",
        "currency_code": "USD",
        "breakdown": {
          "item_total": {
            "currency_code" : "USD",
            "value" : "30.00"
          },
          "tax_total": {
            "currency_code" : "USD",
            "value" : "0.07"
          },
          "shipping": {
            "currency_code" : "USD",
            "value" : "0.03"
          },
          "handling": {
            "currency_code" : "USD",
            "value" : "1.0"
          },
          "shipping_discount": {
            "currency_code" : "USD",
            "value" : "1.00"
          },
          "discount" : {
            "currency_code" : "USD",
            "value" : "1.00"
          }
        }
      }
    }
  ]

Bear in mind, the discounts are positive numbers.

 

On your PayPal Account, you will then see the following, within the transaction details; Same for the buyer.

 

MTS_Stefan_0-1599587404896.png

 

I hope this helps,

Stefan

Login to Me Too

Alberto123456
Contributor
Contributor

What can I do when I also have a coupon?

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.