Applying a discount

Learn how to apply discounts.

You can apply multiple types of discounts to a transaction. On this page, you'll find information on how to give:

You can also read about validation errors thrown by zero-value discounts.

Types of discounts

Using checkouts or invoices, you can apply discounts to (1) line items, (2) an entire purchase, and (3) shipping costs. You can also combine discount types.

All the discount categories follow the same basic rules. For each, you specify an amountOff or percentOff. Digital River first applies the discount and then determines taxes based on that reduced amount. To determine the aggregate value of all applied discounts, check totalDiscount.

Line item discounts

For each items[] that you want to discount, set either a percentOff or amountOff.

To indicate how many products the discount should be applied to, assign an integer to discount.quantity. If you don't define this parameter, then the discount is applied to the entire quantity of that items[].

In the following percent off request, discount.quantity is 1, so the discount isn't applied to the entire quantity of that items[]. In the amount off request, discount.quantity isn't defined, so the discount is applied to the entire quantity.

curl https://api.digitalriver.com/checkouts \
    -u sk_test_db9682a2-b04a-4e94-8e11-35fe8ec0b324: \
    -d currency=usd \
    ...
    -d items[0][skuId]=09062016 \
    -d items[0][price]=10.00 \
    -d items[0][quantity]=3
    -d items[0][discount][percentOff]=10
    -d items[0][discount][quantity]=1

In the response, each items[].amount is adjusted to reflect the discount and totalDiscount sums up all the markdowns for the transaction.

    ...
    "totalAmount": 31.18,
    "subtotal": 29.0,
    "totalFees": 0.0,
    "totalTax": 2.18,
    "totalDuty": 0.0,
    "totalDiscount": 1.0,
    "totalShipping": 0.0,
    "items": [
        {
            "skuId": "09062016",
            "amount": 29.0,
            "quantity": 3,
            "discount": {
                "percentOff": 10.0,
                "quantity": 1
            },
            "tax": {
                "rate": 0.07525,
                "amount": 2.18
            }
        }
    ],
    ...

Entire purchase discounts

To reduce the cost of an entire transaction, define either discount.percentOff or discount.amountOff .

curl https://api.digitalriver.com/checkouts \
    -u sk_test_db9682a2-b04a-4e94-8e11-35fe8ec0b324: \
    -d currency=usd \
    ...
    -d discount[percentOff]=20
    -d items[0][skuId]=09062016 \
    -d items[0][price]=10.00 \
    -d items[0][quantity]=4 \
    -d items[1][skuId]=11141976 \
    -d items[1][price]=20.00 \
    -d items[1][quantity]=2 \

Digital River aggregates all the items[].amount values, applies the discount to arrive at a subTotal and then uses that figure to compute a totalTax.

    ...
    "totalAmount": 68.82,
    "subtotal": 64.0,
    "totalFees": 0.0,
    "totalTax": 4.82,
    "totalDuty": 0.0,
    "totalDiscount": 16.0,
    "totalShipping": 0.0,
    "discount": {
        "percentOff": 20.0
    },
    "items": [
        {
            "skuId": "09062016",
            "amount": 40.0,
            "quantity": 4,
            "tax": {
                "rate": 0.07525,
                "amount": 2.41
            }
        },
        {
            "skuId": "11141976",
            "amount": 40.0,
            "quantity": 2,
            "tax": {
                "rate": 0.07525,
                "amount": 2.41
            }
        }
    ],
    ...

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:

curl https://api.digitalriver.com/checkouts \
     -u sk_test_db9682a2-b04a-4e94-8e11-35fe8ec0b324: \
     -d currency=usd \
     ...
     -d items[0][skuId]=09062016 \
     -d items[0][price]=10.00 \
     -d items[0][quantity]=3
     -d shippingChoice[amount]=8.00 \
     -d shippingChoice[description]="USPS: Priority (1 day delivery)" \
     -d shippingChoice[serviceLevel]= "SG"
     -d shippingDiscount[percentOff]=25

Digital River applies the discount before calculating taxes and totalDiscount includes the shipping cost discount.

    ...
    "totalAmount": 38.71,
    "subtotal": 36.0,
    "totalFees": 0.0,
    "totalTax": 2.71,
    "totalDuty": 0.0,
    "totalDiscount": 2.0,
    "totalShipping": 8.0,
    "items": [
        {
            "skuId": "09062016",
            "amount": 30.0,
            "quantity": 3,
            "tax": {
                "rate": 0.07525,
                "amount": 2.26
            }
        }
    ],
    "shippingChoice": {
        "amount": 8.0,
        "description": "USPS: Priority (1 day delivery)",
        "serviceLevel": "SG",
        "taxAmount": 0.45
    },
    "shippingDiscount": {
        "percentOff": 25.0
    },
    ...

Combined discounts

If you include multiple discount types in a request, Digital River first applies any line-item discounts and then the entire purchase markdown. Product and order-level discounts don't reduce shipping costs. If you want to give customers a break on their shipping, you'll need to apply a shipping discount.

Validation errors generated by zero-value discounts

You must send a discount value greater than zero. This applies to all types of 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.

{
    "type": "bad_request",
    "errors": [
        {
            "code": "invalid_discount_percent",
            "parameter": "discount",
            "message": "The value must be an integer between 0.01 and 100.00 inclusive."
        }
    ]
}

Last updated