Order Discount

Order discount

POST /order-discount

Applies a discount to an order. The discount can be applied to the whole order, to specific order items, or to both.

You can either send the discount amount directly or send the ID of a discount defined in Adisyo. When a defined discount is used, the amount is calculated by Adisyo. See Discount list for the available defined discounts.

Where the discount is applied

The discountId, discountAmount and discountRate fields at the root of the request apply to the whole order.

The fields inside the orderDetails list apply to the corresponding order item.

Whichever side is not sent is preserved: sending only orderDetails keeps the order's existing general discount, and sending only the root fields keeps the existing item discounts.

Sample request

Discount on the whole order
curl -X POST 'https://ext.adisyo.com/api/External/v2/order-discount' \
  --header "x-api-key: ..." \
  --header "x-api-secret: ..." \
  --header "x-api-consumer: ..." \
  --header 'Content-Type: application/json' \
  --data '{
      "orderId": 4815162342,
      "discountAmount": 50
  }'
Using a defined discount
curl -X POST 'https://ext.adisyo.com/api/External/v2/order-discount' \
  --header "x-api-key: ..." \
  --header "x-api-secret: ..." \
  --header "x-api-consumer: ..." \
  --header 'Content-Type: application/json' \
  --data '{
      "orderId": 4815162342,
      "discountId": 34
  }'
Per-item discount
curl -X POST 'https://ext.adisyo.com/api/External/v2/order-discount' \
  --header "x-api-key: ..." \
  --header "x-api-secret: ..." \
  --header "x-api-consumer: ..." \
  --header 'Content-Type: application/json' \
  --data '{
      "orderId": 4815162342,
      "orderDetails": [
        { "orderDetailId": 671962, "discountId": 77 },
        { "orderDetailId": 671963, "discountAmount": 25 }
      ]
  }'

Request parameters

ParameterData TypeDescription
orderIdNumberAdisyo ID of the order the discount is applied to
discountIdNumber?ID of the defined discount applied to the whole order. When sent, the amount/rate is taken from the definition
discountAmountDecimal?Discount amount applied to the whole order
discountRateDecimal?Discount rate applied to the whole order (0-100)
orderDetailsArray?Per-item discounts

orderDetails parameters

ParameterData TypeDescription
orderDetailIdNumberAdisyo ID of the order item. Taken from the products[].id field of the Order details response
discountIdNumber?ID of the defined discount applied to the item
discountAmountDecimal?Discount amount applied to the item
discountRateDecimal?Discount rate applied to the item (0-100)

Rules

  • The request must contain at least one discount: either for the whole order or for at least one item.
  • When discountId is sent together with discountAmount or discountRate, discountId takes precedence and the others are ignored.
  • When discountId is not sent, discountAmount and discountRate cannot be sent at the same time.
  • The same orderDetailId cannot appear more than once in the list.
  • An item discount cannot exceed the item total.
  • The total discount (item discounts + order discount) cannot exceed the order total.

Sample response

Discount applied response
{
  "status": 100,
  "message": "Discount applied successfully."
}