Skip to navigation

Itemized fees and discounts

Overview

We’ve updated the create_payment_session API to accept additional details about any fees and discounts you’re applying, at both the order-level and item-level. This allows us to display the information provided on our payment page to provide a better breakdown of the total payment amount to users.

All fields added are optional, and should only be provided if the partner is applying discounts or additional charges

  • all existing requests will continue to function as usual.

This page gives a general overview of the changes required to your requests. Our checkout page will display an itemized breakdown of each item and the cart if any itemized info is provided. Partners can also test that we are storing the information on a payment by using the payment_session_status or list_payment_sessions APIs. These have been updated to return the amount_details objects provided on payment creation.

When providing amount details, they must satisfy the following equation:

Total Amount Equation
Total Amount Equation

Example scenario: order-level charges

Let’s walk through an example scenario:

  1. The total payment amount is $1000
  2. There are 3 items being purchased:
    1. 1x “Item A” with a unit price of $55
      • A $45 additional charge named “Color Upgrade”
      • A $10 discount named “Ten Dollars Off”
    2. 2x “Item B” with a unit price of $150
    3. 4x “Item C” with a unit price of $20
      • A $5 discount named “Summer Sale”
  3. There is a tax of $50, a handling fee of $100, and a shipping cost of $275 applied to the order

To provide the 3 additional charges to us for display on our payment page, the request would include the fields below (note that you will be providing additional fields in the request - this is a slimmed down version for clarity).

{
"total_amount": 100000,
"order_items": [
{
"name": "Item A",
"quantity": 3,
"price": 5500,
"sku": "Item A SKU",
"amount_details": {
"total_additional_charges": 4500,
"additional_charges_details": [
{"name": "Color Upgrade", "amount": 4500}
],
"total_discounts": 1000,
"discounts_details": [
{"name": "Ten Dollars Off", "amount": 1000}
]
}
},
{
"name": "Item B",
"quantity": 2,
"price": 15000,
"sku": "Item B SKU"
},
{
"name": "Item C",
"quantity": 4,
"price": 2000,
"sku": "Item C SKU",
"amount_details": {
"total_discounts": 500,
"discounts_details": [
{"name": "Summer Sale", "amount": 500}
]
}
}
],
"amount_details": {
"total_additional_charges": 42500,
"additional_charges_details": [
{"name": "Tax", "amount": 5000},
{"name": "Handling", "amount": 10000},
{"name": "Shipping", "amount": 27500}
]
}
}

In this example scenario, there are no discounts provided at the order level, so total_discounts and discounts_details are omitted. There are also no item level fees or discounts for Item B, so amount_details is omitted from that order item. With this information, we can display each additional charge on our payment page.

The important points to note are:

  1. Each additional charge detail amount must be ≥0\geq 0
    • Partners are allowed to provide an additional charge with an amount of 0 to indicate that the charge is free
  2. All additional charge amounts sum up to the total_additional_charges field
  3. The sum of each item’s subtotal (quantity × price + item-level charges - item-level discounts) + any order-level additional charges - any order-level discounts must equal the payment’s total_amount

For the example scenario above:

100000=(3×5500+4500−1000)+(2×15000)+(4×2000−500)+42500−0100000 = (3 \times 5500 + 4500 - 1000) + (2 \times 15000) + (4 \times 2000 - 500) + 42500 - 0

Invalid info provided

If the amount_details objects provided are not valid in any way, you will receive an InvalidRequestParameter error with a message indicating the issue. If the total_amount does not equal the expected amount, you will receive a TotalAmountInvalid error.

Refund an order with order-level charges or discounts

Truemed splits each order-level charge and discount across your items in proportion to each item’s total. A tied cent goes to the item listed first. After you capture the payment, payment_session_status and the status webhook show three fields on each item in order_items:

FieldWhat it shows
order_level_amount_detailsThe item’s share of each order-level charge and discount
total_with_order_levelWhat the customer paid for the item, with its share included
total_refundable_with_order_levelWhat you can still refund for the item, with its share included

To refund an item for what the customer paid for it, set amount and the item’s item_details[].total to its total_refundable_with_order_level. Item totals cannot sum above amount.

Example: order-level charges

The cart has a $10 T-shirt and a $10 Vitamin D, with $60 of order-level tax, handling, and shipping. Truemed puts $30 of the charges on each item, so each item shows total_with_order_level: 4000. To refund the T-shirt with its tax, handling, and shipping, send this request to POST /payments/v1/refund:

{
"payment_id": "PAYMENT_SESSION_ID",
"amount": 4000,
"reason": "customer_request",
"item_details": [{"item_id": "TSHIRT_ITEM_ID", "quantity": 1, "total": 4000}]
}

Truemed returns $40, and the T-shirt then shows total_refundable_with_order_level: 0. The Vitamin D still shows 4000.

Example: order-level discount

Item A and Item B cost $100 each, and the order has a $50 order-level discount. The session total is $150. Truemed takes $25 of the discount off each item, so each item shows total_with_order_level: 7500 and total_refundable: 7500.

To refund Item A, send amount: 7500 and set Item A’s item_details[].total to 7500. Item B still shows 7500.

If you set Item A’s total to its price of 10000 and send amount: 7500, Truemed rejects the refund with a 400 error, because the item total is above amount.

To return an amount that belongs to no item, such as a shipping credit, omit item_details and send amount alone. Create Refund lists every refund rule.