# Create order with service charge taxable in line item

**URL:** <https://developer.squareup.com/forums/t/create-order-with-service-charge-taxable-in-line-item/17018>\
**Category:** Questions\
**Created:** [June 3, 2024, 7:30am UTC](https://developer.squareup.com/forums/t/create-order-with-service-charge-taxable-in-line-item/17018 "2024-06-03T07:30:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edenlin](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@edenlin](https://developer.squareup.com/forums/u/edenlin)\
**Post date:** [June 3, 2024, 7:30am UTC](https://developer.squareup.com/forums/t/create-order-with-service-charge-taxable-in-line-item/17018/1 "2024-06-03T07:30:54Z")

</div>

i don’t know how to create a sample order with service charge taxable in line item.

**below is request:**  
{  
“idempotency\_key”: “{{$guid}}”,  
“order”: {  
“location\_id”: “LF1GYFQK5DCP4”,  
“line\_items”: [  
{  
“catalog\_object\_id”: “G254XOXDZYCYNED7CW3J6SQA”,  
“quantity”: “2”,  
“name”: “Lychee & Peach Tea Slush(LCHJ 1,T200，L1)芝芝粉荔桃”,  
“variation\_name”: “”,  
“base\_price\_money”: {  
“amount”: 200,  
“currency”: “USD”  
},  
“item\_type”: “ITEM”,  
“applied\_taxes”: [  
{  
“tax\_uid”: “e23972c7-6da5-4905-952a-26a06ac2788a”  
}  
],  
“applied\_service\_charges”: [  
{  
“uid”: “serviceCharge”,  
“service\_charge\_uid”: “e23972c7-6da5-4905-952a-26a06ac27666”  
}  
]  
}  
],  
“taxes”: [  
{  
“uid”: “e23972c7-6da5-4905-952a-26a06ac2788a”,  
“name”: “tax”,  
“percentage”:“2”,  
“type”: “ADDITIVE”,  
“scope”: “LINE\_ITEM”  
}  
],  
“service\_charges”: [  
{  
“uid”: “e23972c7-6da5-4905-952a-26a06ac27666”,  
“amount\_money”: {  
“amount”: 20,  
“currency”: “USD”  
},  
“name”: “Fee”,  
“calculation\_phase”: “SUBTOTAL\_PHASE”,  
“scope”: “LINE\_ITEM”,  
“taxable”: false,  
“applied\_taxes”: [  
{  
“tax\_uid”: “e23972c7-6da5-4905-952a-26a06ac2788a”  
}  
]  
}  
],  
“pricing\_options”: {  
“auto\_apply\_discounts”: false,  
“auto\_apply\_taxes”: false  
}  
}  
}

**and response is:**  
{  
“errors”: [  
{  
“code”: “BAD\_REQUEST”,  
“detail”: “Unexpected calculation phase SURCHARGE\_PHASE for applied service charge custom-surcharge:e23972c7-6da5-4905-952a-26a06ac27666.”,  
“category”: “INVALID\_REQUEST\_ERROR”  
}  
]  
}

could you tell me the reason why it fails,  
or give me a correct sample?

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [June 3, 2024, 7:31am UTC](https://developer.squareup.com/forums/t/create-order-with-service-charge-taxable-in-line-item/17018/2 "2024-06-03T07:31:45Z")

</div>

👋 I’m Square Dev AI, here to help answer your question!  
Based on the information you’ve provided, the following documentation will help answer your question:

> **[Orders API: How It Works](https://developer.squareup.com/docs/orders-api/how-it-works)**
>
> Learn how the Orders API processes and returns information.

> **[Create Orders](https://developer.squareup.com/docs/orders-api/create-orders)**
>
> Learn how to create an order, add line items, and track fulfillment.

> **Additional Documentation**
>
> [Square-Applied Order Taxes](https://developer.squareup.com/docs/orders-api/apply-taxes-and-discounts/auto-apply-taxes)  
> [Configure the Order-Ahead Sample Application](https://developer.squareup.com/docs/orders-api/quick-start/step-2)  
> [Create and Publish Invoices](https://developer.squareup.com/docs/invoices-api/walkthrough)

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.  
Otherwise one of our Developer Advocates will provide additional assistance shortly.

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [June 3, 2024, 4:02pm UTC](https://developer.squareup.com/forums/t/create-order-with-service-charge-taxable-in-line-item/17018/3 "2024-06-03T16:02:14Z")

</div>

The error message indicates that the calculation phase for the applied service charge is unexpected. In your request, you have set the “calculation\_phase” to “SUBTOTAL\_PHASE” for the service charge. However, the error message suggests that it should be “SURCHARGE\_PHASE”.

Also, the “scope” field in the service charge should be “ORDER” instead of “LINE\_ITEM”. The “scope” field in the service charge object determines whether the service charge is applied to the entire order or to individual line items. In your case, since you are applying the service charge at the order level, you should set the “scope” field to “ORDER”.

Here is a corrected version of your request:

```json
{
    "idempotency_key": "{{$guid}}",
    "order": {
        "location_id": "LF1GYFQK5DCP4",
        "line_items": [
            {
                "catalog_object_id": "G254XOXDZYCYNED7CW3J6SQA",
                "quantity": "2",
                "name": "Lychee & Peach Tea Slush(LCHJ 1,T200，L1)芝芝粉荔桃",
                "variation_name": "",
                "base_price_money": {
                    "amount": 200,
                    "currency": "USD"
                },
                "item_type": "ITEM",
                "applied_taxes": [
                    {
                        "tax_uid": "e23972c7-6da5-4905-952a-26a06ac2788a"
                    }
                ]
            }
        ],
        "taxes": [
            {
                "uid": "e23972c7-6da5-4905-952a-26a06ac2788a",
                "name": "tax",
                "percentage":"2",
                "type": "ADDITIVE",
                "scope": "LINE_ITEM"
            }
        ],
        "service_charges": [
            {
                "uid": "e23972c7-6da5-4905-952a-26a06ac27666",
                "amount_money": {
                    "amount": 20,
                    "currency": "USD"
                },
                "name": "Fee",
                "calculation_phase": "SURCHARGE_PHASE",
                "scope": "ORDER",
                "taxable": false,
                "applied_taxes": [
                    {
                        "tax_uid": "e23972c7-6da5-4905-952a-26a06ac2788a"
                    }
                ]
            }
        ],
        "pricing_options": {
            "auto_apply_discounts": false,
            "auto_apply_taxes": false
        }
    }
}

```

Please replace the placeholders with your actual values and try again.

_This answer was reviewed by @Bryan-Square._

---

<div class="post-metadata">

**Author:** ![edenlin](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@edenlin](https://developer.squareup.com/forums/u/edenlin)\
**Post date:** [June 4, 2024, 1:54am UTC](https://developer.squareup.com/forums/t/create-order-with-service-charge-taxable-in-line-item/17018/4 "2024-06-04T01:54:45Z")

</div>

copy the sample code in your response, it’s wrong too.

{  
“errors”: [  
{  
“code”: “INVALID\_ENUM\_VALUE”,  
“detail”: “`SURCHARGE_PHASE` is not a valid enum value for `CalculationPhase` (line 40, character 38)”,  
“field”: “order.service\_charges[0].calculation\_phase”,  
“category”: “INVALID\_REQUEST\_ERROR”  
}  
]  
}
