cancel
Showing results for 
Search instead for 
Did you mean: 

Applying Discounts to Payment Orders

Contributor

Applying Discounts to Payment Orders

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?

4 REPLIES 4
Contributor

Re: Applying Discounts to Payment Orders

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

Member

Re: Applying Discounts to Payment Orders

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.

Member

Re: Applying Discounts to Payment Orders

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.

New Community Member

Re: Applying Discounts to Payment Orders

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": []