Applying a discount
Learn how to apply discounts.
When building a checkout or creating an invoice, you can apply multiple types of discounts to the transaction. You should also be aware of validation errors thrown by zero-value discounts.

Types of discounts

Using the Checkout or Invoice resource, you can apply product, order-level, and shipping cost discounts to transactions. You can also combine discount types.
Each discount type follows the same basic rules. You specify an amountOff or percentOff. Digital River first applies the discount and then the transaction's taxes are determined based on the discounted price. In the response, we return the totalDiscount applied to the transaction.

Product discounts

For each line item that you want to discount, set either a percentOff or amountOff.
You can also provide an optional discount.quantity. This indicates how many products the discount should be applied to. If you don't specify a discount.quantity, we assume you want to apply the discount to all the products in that line item. For example, if theitems[].quantity is 3 and you don't specify a discount.quantity, then, by default, the discount is applied to all three products.
The following POST /checkouts demonstrates both types of item-level discounts. In the percent off request, the discount.quantity is set to 1, so the discount will be applied to only one of the three products. For the amount off request, discount.quantity is not specified, so the discount will be applied to all three products.:
Percent off request
Amount off request
1
curl https://api.digitalriver.com/checkouts \
2
-u sk_test_db9682a2-b04a-4e94-8e11-35fe8ec0b324: \
3
-d currency=usd \
4
...
5
-d items[0][skuId]=09062016 \
6
-d items[0][price]=10.00 \
7
-d items[0][quantity]=3
8
-d items[0][discount][percentOff]=10
9
-d items[0][discount][quantity]=1
Copied!
1
curl https://api.digitalriver.com/checkouts \
2
-u sk_test_db9682a2-b04a-4e94-8e11-35fe8ec0b324: \
3
-d currency=usd \
4
...
5
-d items[0][skuId]=09062016 \
6
-d items[0][price]=10.00 \
7
-d items[0][quantity]=3
8
-d items[0][discount[amountOff]]=2
Copied!
In each POST /checkouts response, the items[].amount value is adjusted to reflect the discount and the totalDiscount value shows the discount for the entire order.
Percent off response
Amount off response
1
...
2
"totalAmount": 31.18,
3
"subtotal": 29.0,
4
"totalFees": 0.0,
5
"totalTax": 2.18,
6
"totalDuty": 0.0,
7
"totalDiscount": 1.0,
8
"totalShipping": 0.0,
9
"items": [
10
{
11
"skuId": "09062016",
12
"amount": 29.0,
13
"quantity": 3,
14
"discount": {
15
"percentOff": 10.0,
16
"quantity": 1
17
},
18
"tax": {
19
"rate": 0.07525,
20
"amount": 2.18
21
}
22
}
23
],
24
...
Copied!
1
...
2
"totalAmount": 25.81,
3
"subtotal": 24.0,
4
"totalFees": 0.0,
5
"totalTax": 1.81,
6
"totalDuty": 0.0,
7
"totalDiscount": 6.0,
8
"totalShipping": 0.0,
9
"items": [
10
{
11
"skuId": "09062016",
12
"amount": 24.0,
13
"quantity": 3,
14
"discount": {
15
"amountOff": 2.0,
16
"quantity": 3
17
},
18
"tax": {
19
"rate": 0.07525,
20
"amount": 1.81
21
}
22
}
23
],
24
...
Copied!

Order-level discounts

You can use either the discount.percentOff or discount.amountOff parameter to create a discount on the entire order.
Percent off request
Amount off request
1
curl https://api.digitalriver.com/checkouts \
2
-u sk_test_db9682a2-b04a-4e94-8e11-35fe8ec0b324: \
3
-d currency=usd \
4
...
5
-d discount[percentOff]=20
6
-d items[0][skuId]=09062016 \
7
-d items[0][price]=10.00 \
8
-d items[0][quantity]=4 \
9
-d items[1][skuId]=11141976 \
10
-d items[1][price]=20.00 \
11
-d items[1][quantity]=2 \
Copied!
1
curl https://api.digitalriver.com/checkouts \
2
-u sk_test_db9682a2-b04a-4e94-8e11-35fe8ec0b324: \
3
-d currency=usd \
4
...
5
-d discount[amountOff]=10
6
-d items[0][skuId]=09062016 \
7
-d items[0][price]=10.00 \
8
-d items[0][quantity]=4 \
9
-d items[1][skuId]=11141976 \
10
-d items[1][price]=20.00 \
11
-d items[1][quantity]=2 \
Copied!
For all line items, Digital River first aggregates their amount values, applies the discount to arrive at a subTotal and then uses that figure to compute a totalTax. This is illustrated in the following POST /checkouts responses.
Percent off response
Amount off response
1
...
2
"totalAmount": 68.82,
3
"subtotal": 64.0,
4
"totalFees": 0.0,
5
"totalTax": 4.82,
6
"totalDuty": 0.0,
7
"totalDiscount": 16.0,
8
"totalShipping": 0.0,
9
"discount": {
10
"percentOff": 20.0
11
},
12
"items": [
13
{
14
"skuId": "09062016",
15
"amount": 40.0,
16
"quantity": 4,
17
"tax": {
18
"rate": 0.07525,
19
"amount": 2.41
20
}
21
},
22
{
23
"skuId": "11141976",
24
"amount": 40.0,
25
"quantity": 2,
26
"tax": {
27
"rate": 0.07525,
28
"amount": 2.41
29
}
30
}
31
],
32
...
Copied!
1
...
2
"totalAmount": 75.26,
3
"subtotal": 70.0,
4
"totalFees": 0.0,
5
"totalTax": 5.26,
6
"totalDuty": 0.0,
7
"totalDiscount": 10.0,
8
"totalShipping": 0.0,
9
"discount": {
10
"amountOff": 10.0
11
},
12
"items": [
13
{
14
"skuId": "09062016",
15
"amount": 40.0,
16
"quantity": 4,
17
"tax": {
18
"rate": 0.07525,
19
"amount": 2.63
20
}
21
},
22
{
23
"skuId": "11141976",
24
"amount": 40.0,
25
"quantity": 2,
26
"tax": {
27
"rate": 0.07525,
28
"amount": 2.63
29
}
30
}
31
],
32
...
Copied!

Shipping cost discounts

You can also apply discounts to shipping costs. The following POST /checkouts demonstrates how to use shippingDiscount to specify either a percentOff or amountOff:
Percent off request
Amount off request
1
curl https://api.digitalriver.com/checkouts \
2
-u sk_test_db9682a2-b04a-4e94-8e11-35fe8ec0b324: \
3
-d currency=usd \
4
...
5
-d items[0][skuId]=09062016 \
6
-d items[0][price]=10.00 \
7
-d items[0][quantity]=3
8
-d shippingChoice[amount]=8.00 \
9
-d shippingChoice[description]="USPS: Priority (1 day delivery)" \
10
-d shippingChoice[serviceLevel]= "SG"
11
-d shippingDiscount[percentOff]=25
Copied!
1
curl https://api.digitalriver.com/checkouts \
2
-u sk_test_db9682a2-b04a-4e94-8e11-35fe8ec0b324: \
3
-d currency=usd \
4
...
5
-d items[0][skuId]=09062016 \
6
-d items[0][price]=10.00 \
7
-d items[0][quantity]=3
8
-d shippingChoice[amount]=8.00 \
9
-d shippingChoice[description]="USPS: Priority (1 day delivery)" \
10
-d shippingChoice[serviceLevel]= "SG"
11
-d shippingDiscount[amountOff]=3.00
Copied!
Once again, Digital River applies the discount before calculating taxes. In the following POST /checkouts responses, totalDiscount includes the shipping cost discount.
Percent off response
Amount off response
1
...
2
"totalAmount": 38.71,
3
"subtotal": 36.0,
4
"totalFees": 0.0,
5
"totalTax": 2.71,
6
"totalDuty": 0.0,
7
"totalDiscount": 2.0,
8
"totalShipping": 8.0,
9
"items": [
10
{
11
"skuId": "09062016",
12
"amount": 30.0,
13
"quantity": 3,
14
"tax": {
15
"rate": 0.07525,
16
"amount": 2.26
17
}
18
}
19
],
20
"shippingChoice": {
21
"amount": 8.0,
22
"description": "USPS: Priority (1 day delivery)",
23
"serviceLevel": "SG",
24
"taxAmount": 0.45
25
},
26
"shippingDiscount": {
27
"percentOff": 25.0
28
},
29
...
Copied!
1
...
2
"totalAmount": 37.64,
3
"subtotal": 35.0,
4
"totalFees": 0.0,
5
"totalTax": 2.64,
6
"totalDuty": 0.0,
7
"totalDiscount": 3.0,
8
"totalShipping": 8.0,
9
"items": [
10
{
11
"skuId": "09062016",
12
"amount": 30.0,
13
"quantity": 3,
14
"tax": {
15
"rate": 0.07525,
16
"amount": 2.26
17
}
18
}
19
],
20
"shippingChoice": {
21
"amount": 8.0,
22
"description": "USPS: Priority (1 day delivery)",
23
"serviceLevel": "SG",
24
"taxAmount": 0.38
25
},
26
"shippingDiscount": {
27
"amountOff": 3.0
28
},
29
...
Copied!

Combined discounts

If you send multiple discounts in a request, Digital River first applies product discounts and then order-level discounts. Product and order-level discounts do not reduce shipping costs. If you want to give customers a break on their shipping costs, you'll need to apply a shipping discount.
The following POST /checkouts response shows a transaction with multiple discounts applied to it:
Response
1
...
2
"totalAmount": 35.48,
3
"subtotal": 33.0,
4
"totalFees": 0.0,
5
"totalTax": 2.48,
6
"totalDuty": 0.0,
7
"totalDiscount": 15.0,
8
"totalShipping": 8.0,
9
"discount": {
10
"percentOff": 25.0
11
},
12
"items": [
13
{
14
"skuId": "09062016",
15
"amount": 36.0,
16
"quantity": 4,
17
"discount": {
18
"percentOff": 10.0,
19
"quantity": 4
20
},
21
"tax": {
22
"rate": 0.07525,
23
"amount": 2.03
24
}
25
}
26
],
27
"shippingChoice": {
28
"amount": 8.0,
29
"description": "USPS: Priority (1 day delivery)",
30
"serviceLevel": "SG",
31
"taxAmount": 0.45
32
},
33
"shippingDiscount": {
34
"percentOff": 25.0
35
},
36
...
Copied!

Validation errors generated by zero-value discounts

Your integration must send a discount value greater than zero. This applies to product, order-level, and shipping cost discounts. If you submit a POST /checkouts, POST /checkouts/{id} or POST /invoices and amountOff or percentOff is 0 or less, a 400 Bad Request is returned.
Percent off
Amount off
1
{
2
"type": "bad_request",
3
"errors": [
4
{
5
"code": "invalid_discount_percent",
6
"parameter": "discount",
7
"message": "The value must be an integer between 0.01 and 100.00 inclusive."
8
}
9
]
10
}
Copied!
1
{
2
"type": "bad_request",
3
"errors": [
4
{
5
"code": "invalid_discount_amount",
6
"parameter": "discount",
7
"message": "The value 0.0 is not permitted."
8
}
9
]
10
}
Copied!
Last modified 7mo ago