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:

Example scenario: order-level charges
Let’s walk through an example scenario:
- The total payment amount is $1000
- There are 3 items being purchased:
- 1x “Item A” with a unit price of $55
- A $45 additional charge named “Color Upgrade”
- A $10 discount named “Ten Dollars Off”
- 2x “Item B” with a unit price of $150
- 4x “Item C” with a unit price of $20
- A $5 discount named “Summer Sale”
- 1x “Item A” with a unit price of $55
- 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).
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:
- Each additional charge detail
amountmust be- Partners are allowed to provide an additional charge with an amount of 0 to indicate that the charge is free
- All additional charge amounts sum up to the
total_additional_chargesfield - 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:
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:
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:
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.