<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>thread How to Manage Status with cancellation process through the api ? in Orders, Menu Items, Catalog &amp; Fulfilment</title>
    <link>https://community.squareup.com/t5/Orders-Menu-Items-Catalog/How-to-Manage-Status-with-cancellation-process-through-the-api/m-p/841996#M23274</link>
    <description>&lt;P&gt;Dear Square Support Team,&lt;/P&gt;&lt;P&gt;I hope you are doing well.&lt;/P&gt;&lt;P&gt;I am currently integrating Square Orders and Payments APIs in my application. I am successfully able to create orders and process payments using the Orders API followed by the Payments API.&lt;/P&gt;&lt;P&gt;However, I am facing an issue related to order status management.&lt;/P&gt;&lt;P&gt;**Issue Description:**&lt;BR /&gt;When I create an order, I explicitly set the order state to **OPEN** during order creation. After that, I create the payment associated with the order. But immediately after the payment is successfully created, the order automatically moves to the **COMPLETED** state.&lt;/P&gt;&lt;P&gt;My requirement is different:&lt;/P&gt;&lt;P&gt;* When an order is created and payment is made, the order should remain in an **ACTIVE / OPEN** state.&lt;BR /&gt;* The order should only move to **COMPLETED** when I explicitly update it after fulfillment or delivery is finished.&lt;/P&gt;&lt;P&gt;**Current Implementation Flow:**&lt;/P&gt;&lt;P&gt;1. Create Order using Orders API&lt;BR /&gt;2. Set order state to `OPEN`&lt;BR /&gt;3. Create Payment using Payments API with `order_id`&lt;BR /&gt;4. Order automatically transitions to `COMPLETED`&lt;/P&gt;&lt;P&gt;**What I would like to understand:**&lt;/P&gt;&lt;P&gt;1. Is this automatic transition to `COMPLETED` expected behavior when the payment is captured successfully?&lt;BR /&gt;2. Is there a recommended way to keep the order in `OPEN` or `IN_PROGRESS` state after payment creation?&lt;BR /&gt;3. Should I be using the Fulfillment API or another mechanism to control the order lifecycle manually?&lt;BR /&gt;4. Is there a specific parameter or configuration that prevents the order from automatically completing after payment?&lt;/P&gt;&lt;P&gt;For reference, I am using:&lt;/P&gt;&lt;P&gt;* Orders API to create the order&lt;BR /&gt;* Payments API with `source_id = EXTERNAL`&lt;BR /&gt;* Square API Version: **2026-01-22**&lt;/P&gt;&lt;P&gt;Any guidance or best practices for managing order lifecycle states would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you for your support.&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Mamta Kumavat&lt;BR /&gt;Flutter Developer&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;this is my code.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Future setSquareOrderData(OrderModel orderModel, String paymentId) async {&lt;BR /&gt;try {&lt;BR /&gt;ShowToastDialog.showLoader("Please wait.");&lt;BR /&gt;String currency = "AUD";&lt;BR /&gt;NewOrderModel newOrderModel = NewOrderModel();&lt;BR /&gt;SquareOrder squareOrder = SquareOrder();&lt;/P&gt;&lt;P&gt;newOrderModel.idempotency_key = orderModel.id;&lt;BR /&gt;squareOrder.state = OrderState.open.displayName;&lt;BR /&gt;squareOrder.customer_id = orderModel.authorID;&lt;BR /&gt;squareOrder.reference_id = Constant.getUuid();&lt;BR /&gt;squareOrder.location_id = vendorModel.value.locationId;&lt;/P&gt;&lt;P&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; TAXES — define at order level with uid&lt;BR /&gt;// NO applied_money here — Square calculates it&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;List&amp;lt;OrderLineItemTax&amp;gt; newTaxSetting = [];&lt;/P&gt;&lt;P&gt;void addTax(dynamic tax, int orderSubtotal) {&lt;BR /&gt;if (tax == null) return;&lt;BR /&gt;if (tax.enable == false) return;&lt;BR /&gt;if (tax.tax == null || double.parse(tax.tax.toString()) &amp;lt;= 0) return;&lt;/P&gt;&lt;P&gt;String uid = Constant.getUuid();&lt;BR /&gt;String scope = tax.scope == 'product' ? "LINE_ITEM" : "ORDER";&lt;/P&gt;&lt;P&gt;if (tax.type == "percentage") {&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Direct percentage tax&lt;BR /&gt;newTaxSetting.add(OrderLineItemTax(&lt;BR /&gt;uid: uid,&lt;BR /&gt;name: tax.title ?? "Tax",&lt;BR /&gt;orderTaxType: "ADDITIVE",&lt;BR /&gt;scope: scope,&lt;BR /&gt;percentage: tax.tax.toString(),&lt;BR /&gt;));&lt;BR /&gt;} else if (tax.type == "fix") {&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Convert fixed amount to percentage&lt;BR /&gt;// percentage = (fixedAmount / orderSubtotal) * 100&lt;BR /&gt;if (orderSubtotal &amp;lt;= 0) {&lt;BR /&gt;print("&lt;span class="lia-unicode-emoji" title=":warning:"&gt;⚠️&lt;/span&gt; Skipping ${tax.title} — subtotal is 0");&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int fixedAmount = Constant.parseAmount(tax.tax.toString());&lt;BR /&gt;double percentage = (fixedAmount / orderSubtotal) * 100;&lt;BR /&gt;String percentageStr = percentage.toStringAsFixed(2); // e.g "1.19"&lt;/P&gt;&lt;P&gt;print(&lt;BR /&gt;"Fixed tax ${tax.title}: $fixedAmount / $orderSubtotal * 100 = $percentageStr%");&lt;/P&gt;&lt;P&gt;newTaxSetting.add(OrderLineItemTax(&lt;BR /&gt;uid: uid,&lt;BR /&gt;name: tax.title ?? "Tax",&lt;BR /&gt;orderTaxType: "ADDITIVE",&lt;BR /&gt;scope: scope,&lt;BR /&gt;percentage: percentageStr, // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; converted to percentage&lt;BR /&gt;));&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Calculate order subtotal first&lt;BR /&gt;int orderSubtotal = 0;&lt;BR /&gt;for (var product in orderModel.products!) {&lt;BR /&gt;int price = double.parse(product.discountPrice.toString()) &amp;lt;= 0&lt;BR /&gt;? Constant.parseAmount(product.price.toString())&lt;BR /&gt;: Constant.parseAmount(product.discountPrice.toString());&lt;BR /&gt;int qty = int.parse(product.quantity.toString());&lt;BR /&gt;orderSubtotal += price * qty;&lt;BR /&gt;}&lt;BR /&gt;print("Order subtotal: $orderSubtotal");&lt;BR /&gt;// Then add taxes with subtotal&lt;BR /&gt;orderModel.taxSetting?.forEach((tax) =&amp;gt; addTax(tax, orderSubtotal));&lt;BR /&gt;orderModel.driverDeliveryTax&lt;BR /&gt;?.forEach((tax) =&amp;gt; addTax(tax, orderSubtotal));&lt;BR /&gt;orderModel.packagingTax?.forEach((tax) =&amp;gt; addTax(tax, orderSubtotal));&lt;BR /&gt;orderModel.platformTax?.forEach((tax) =&amp;gt; addTax(tax, orderSubtotal));&lt;BR /&gt;print("Taxes being sent:");&lt;BR /&gt;for (var tax in newTaxSetting) {&lt;BR /&gt;print(" name: ${tax.name}, type: ${tax.orderTaxType}, "&lt;BR /&gt;"percentage: ${tax.percentage}"&lt;BR /&gt;"Money: ${tax.amount_money?.amount}");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; LINE ITEMS&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;List&amp;lt;LineItems&amp;gt; listLineItems = [];&lt;BR /&gt;List&amp;lt;int&amp;gt; extraPriceAmount = [];&lt;/P&gt;&lt;P&gt;for (var product in orderModel.products!) {&lt;BR /&gt;LineItems lineItems = LineItems();&lt;BR /&gt;lineItems.uid = Constant.squareOrderId(orderId: product.id!);&lt;BR /&gt;lineItems.name = product.name;&lt;BR /&gt;lineItems.quantity = product.quantity.toString();&lt;BR /&gt;lineItems.item_type = OrderLineItemItemType.item.displayName;&lt;BR /&gt;lineItems.metadata = product.variantInfo?.variantOptions;&lt;/P&gt;&lt;P&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Base price&lt;BR /&gt;Money baseMoney = Money();&lt;BR /&gt;if (product.extrasPrice != null || product.extrasPrice != "0") {&lt;BR /&gt;/*extraPriceAmount.add(Constant.parseAmount(product.extrasPrice)!);*/&lt;BR /&gt;if (double.parse(product.discountPrice.toString()) &amp;lt;= 0) {&lt;BR /&gt;baseMoney.amount = Constant.parseAmount(product.price.toString()) +&lt;BR /&gt;Constant.parseAmount(product.extrasPrice);&lt;BR /&gt;} else {&lt;BR /&gt;baseMoney.amount =&lt;BR /&gt;Constant.parseAmount(product.discountPrice.toString()) +&lt;BR /&gt;Constant.parseAmount(product.extrasPrice);&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;if (double.parse(product.discountPrice.toString()) &amp;lt;= 0) {&lt;BR /&gt;baseMoney.amount = Constant.parseAmount(product.price.toString());&lt;BR /&gt;} else {&lt;BR /&gt;baseMoney.amount =&lt;BR /&gt;Constant.parseAmount(product.discountPrice.toString());&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;baseMoney.currency = currency;&lt;BR /&gt;lineItems.base_price_money = baseMoney;&lt;/P&gt;&lt;P&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Applied taxes — only if product has taxSetting&lt;BR /&gt;// Reference uid from squareOrder.taxes&lt;BR /&gt;List&amp;lt;OrderLineItemAppliedTax&amp;gt; productTaxSetting = [];&lt;BR /&gt;if (product.taxSetting != null &amp;amp;&amp;amp; product.taxSetting!.isNotEmpty) {&lt;BR /&gt;for (var productTax in product.taxSetting!) {&lt;BR /&gt;// Find matching tax uid from newTaxSetting&lt;BR /&gt;final matchingTax = newTaxSetting.firstWhere(&lt;BR /&gt;(t) =&amp;gt; t.name == productTax.title,&lt;BR /&gt;orElse: () =&amp;gt; newTaxSetting.first,&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;if (matchingTax.uid != null) {&lt;BR /&gt;Money taxMoney = Money(&lt;BR /&gt;amount: Constant.parseAmount(productTax.tax.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;productTaxSetting.add(OrderLineItemAppliedTax(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;tax_uid: matchingTax.uid!, // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Must match uid in taxes array&lt;BR /&gt;applied_money: taxMoney,&lt;BR /&gt;));&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Only set applied_taxes if not empty&lt;BR /&gt;if (productTaxSetting.isNotEmpty) {&lt;BR /&gt;lineItems.applied_taxes = productTaxSetting;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Applied discounts — only if discount exists&lt;BR /&gt;if (lineItemDiscount.isNotEmpty) {&lt;BR /&gt;lineItems.applied_discounts = lineItemDiscount&lt;BR /&gt;.map((d) =&amp;gt; OrderLineItemAppliedDiscount(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;discount_uid: d.uid!, // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Must match uid in discounts array&lt;BR /&gt;))&lt;BR /&gt;.toList();&lt;BR /&gt;}*/&lt;/P&gt;&lt;P&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Extras as note, NOT as service charge&lt;BR /&gt;// (service charges need to be defined at order level)&lt;BR /&gt;if (Constant.parseAmount(product.extrasPrice.toString()) &amp;gt; 0) {&lt;BR /&gt;lineItems.note = "Extras Addons Price: ${product.extrasPrice}";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;listLineItems.add(lineItems);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;squareOrder.line_items = listLineItems;&lt;/P&gt;&lt;P&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; DISCOUNTS — define at order level with uid&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;List&amp;lt;OrderLineItemDiscount&amp;gt; lineItemDiscount = [];&lt;BR /&gt;if (orderModel.discount != null &amp;amp;&amp;amp;&lt;BR /&gt;Constant.parseAmount(orderModel.discount.toString()) &amp;gt; 0) {&lt;BR /&gt;Money discountMoney = Money(&lt;BR /&gt;amount: Constant.parseAmount(orderModel.discount.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;lineItemDiscount.add(OrderLineItemDiscount(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;name: "Discount", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; name is required&lt;BR /&gt;amount_money: discountMoney,&lt;BR /&gt;scope: "ORDER", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; scope is required&lt;BR /&gt;));&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (couponAmount.value != 0.0) {&lt;BR /&gt;Money couponDiscount = Money(&lt;BR /&gt;amount: Constant.parseAmount(couponAmount.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;lineItemDiscount.add(OrderLineItemDiscount(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;name: "Coupon Discount", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; name is required&lt;BR /&gt;amount_money: couponDiscount,&lt;BR /&gt;scope: "ORDER", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; scope is required&lt;BR /&gt;));&lt;BR /&gt;}&lt;BR /&gt;if (specialDiscountAmount.value != 0.0) {&lt;BR /&gt;Money specialDiscount = Money(&lt;BR /&gt;amount: Constant.parseAmount(specialDiscountAmount.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;lineItemDiscount.add(OrderLineItemDiscount(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;name: "Special Discount", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; name is required&lt;BR /&gt;amount_money: specialDiscount,&lt;BR /&gt;scope: "ORDER", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; scope is required&lt;BR /&gt;));&lt;BR /&gt;}&lt;BR /&gt;// squareOrder.discounts = lineItemDiscount;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; SERVICE CHARGES — define at order level with uid&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;List&amp;lt;OrderServiceCharge&amp;gt; serivceCharges = [];&lt;BR /&gt;if (packagingCharge.value != 0.0) {&lt;BR /&gt;OrderServiceCharge packagingCharges = OrderServiceCharge();&lt;BR /&gt;packagingCharges.uid = Constant.getUuid();&lt;BR /&gt;packagingCharges.name = "Packaging Charges";&lt;BR /&gt;packagingCharges.scope = "ORDER";&lt;BR /&gt;packagingCharges.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;packagingCharges.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(packagingCharge.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;serivceCharges.add(packagingCharges);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (deliveryTips.value != 0.0) {&lt;BR /&gt;OrderServiceCharge deliveryTip = OrderServiceCharge();&lt;BR /&gt;deliveryTip.uid = Constant.getUuid();&lt;BR /&gt;deliveryTip.name = "Delivery Tips";&lt;BR /&gt;deliveryTip.scope = "ORDER";&lt;BR /&gt;deliveryTip.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;deliveryTip.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(deliveryTips.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;// serivceCharges.add(deliveryTip);&lt;BR /&gt;}&lt;BR /&gt;if (deliveryCharges.value != 0.0) {&lt;BR /&gt;OrderServiceCharge deliveryCharge = OrderServiceCharge();&lt;BR /&gt;deliveryCharge.uid = Constant.getUuid();&lt;BR /&gt;deliveryCharge.name = "Delivery Charges";&lt;BR /&gt;deliveryCharge.scope = "ORDER";&lt;BR /&gt;deliveryCharge.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;deliveryCharge.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(deliveryCharges.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;// serivceCharges.add(deliveryCharge);&lt;BR /&gt;}&lt;BR /&gt;if (platformFee.value != 0.0) {&lt;BR /&gt;OrderServiceCharge platformFees = OrderServiceCharge();&lt;BR /&gt;platformFees.uid = Constant.getUuid();&lt;BR /&gt;platformFees.name = "Platform Fee";&lt;BR /&gt;platformFees.scope = "ORDER";&lt;BR /&gt;platformFees.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;platformFees.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(platformFee.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;// serivceCharges.add(platformFees);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;OrderServiceCharge productTax = OrderServiceCharge();&lt;BR /&gt;if (Constant.taxScope == 'product' &amp;amp;&amp;amp; productTaxAmount.value != 0.0) {&lt;BR /&gt;productTax.uid = Constant.getUuid();&lt;BR /&gt;productTax.name = "Tax on item total";&lt;BR /&gt;productTax.scope = "LINE_ITEM";&lt;BR /&gt;productTax.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;productTax.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(productTaxAmount.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;serivceCharges.add(productTax);&lt;BR /&gt;} else {&lt;BR /&gt;productTax.uid = Constant.getUuid();&lt;BR /&gt;productTax.name = "Tax on Order total";&lt;BR /&gt;productTax.scope = "ORDER";&lt;BR /&gt;productTax.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;productTax.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(orderTaxAmount.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;serivceCharges.add(productTax);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;double squareTotalTaxAmount = 0.0;&lt;BR /&gt;if (Constant.taxScope == 'product') {&lt;BR /&gt;if (totalTaxAmount.value &amp;gt; productTaxAmount.value) {&lt;BR /&gt;squareTotalTaxAmount = totalTaxAmount.value - productTaxAmount.value;&lt;BR /&gt;} else {&lt;BR /&gt;squareTotalTaxAmount = productTaxAmount.value - totalTaxAmount.value;&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;if (totalTaxAmount.value &amp;gt; orderTaxAmount.value) {&lt;BR /&gt;squareTotalTaxAmount = totalTaxAmount.value - orderTaxAmount.value;&lt;BR /&gt;} else {&lt;BR /&gt;squareTotalTaxAmount = orderTaxAmount.value - totalTaxAmount.value;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (squareTotalTaxAmount != 0.0) {&lt;BR /&gt;OrderServiceCharge squareTotalTaxCharge = OrderServiceCharge();&lt;BR /&gt;squareTotalTaxCharge.uid = Constant.getUuid();&lt;BR /&gt;squareTotalTaxCharge.name = "Total Tax Amount";&lt;BR /&gt;squareTotalTaxCharge.scope = "ORDER";&lt;BR /&gt;squareTotalTaxCharge.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;squareTotalTaxCharge.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(squareTotalTaxAmount.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;// serivceCharges.add(squareTotalTaxCharge);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// squareOrder.service_charges = serivceCharges;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;newOrderModel.order = squareOrder;&lt;BR /&gt;// Add this just before the API call&lt;BR /&gt;final jsonBody = jsonEncode(newOrderModel.toJson());&lt;BR /&gt;print("Final JSON: $jsonBody");&lt;/P&gt;&lt;P&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; API Call&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;final response = await http.post(&lt;BR /&gt;Uri.parse(SquareConfig.ordersUrl),&lt;BR /&gt;headers: {&lt;BR /&gt;'Authorization': 'Bearer ${vendorModel.value.squareToken}',&lt;BR /&gt;// 'Authorization': 'Bearer ${Constant.productionAccessToken}',&lt;BR /&gt;'Content-Type': 'application/json',&lt;BR /&gt;"Square-Version": "2026-01-22",&lt;BR /&gt;},&lt;BR /&gt;body: jsonEncode(newOrderModel.toJson()),&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;print("Response==&amp;gt;${response.body}");&lt;BR /&gt;final body = jsonDecode(response.body);&lt;BR /&gt;int totalOrderAmount = 0;&lt;BR /&gt;for (var amount in listLineItems) {&lt;BR /&gt;totalOrderAmount += amount.base_price_money!.amount!;&lt;BR /&gt;}&lt;BR /&gt;/*for (var extraAmount in extraPriceAmount) {&lt;BR /&gt;totalOrderAmount += extraAmount;&lt;BR /&gt;}&lt;BR /&gt;*/&lt;BR /&gt;if (body["order"] != null) {&lt;BR /&gt;String orderId = body["order"]["id"];&lt;BR /&gt;Map&amp;lt;String, dynamic&amp;gt; totalMap = (body['order']['total_money']);&lt;BR /&gt;Money totalMoney = Money.fromJson(totalMap);&lt;BR /&gt;print(&lt;BR /&gt;"PaymentId==&amp;gt;$paymentId---LocationId==&amp;gt;${squareOrder.location_id}");&lt;BR /&gt;createPayment(paymentId, orderId, orderModel, totalMoney.amount!);&lt;BR /&gt;} else {&lt;BR /&gt;print("Order creation failed: ${body["errors"]}");&lt;BR /&gt;ShowToastDialog.closeLoader();&lt;BR /&gt;}&lt;BR /&gt;} catch (e) {&lt;BR /&gt;ShowToastDialog.closeLoader();&lt;BR /&gt;log("Error fetching: $e");&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Future createPayment(String paymentId, String orderId,&lt;BR /&gt;OrderModel orderModel, int totalOrderAmount) async {&lt;BR /&gt;final response = await http.post(&lt;BR /&gt;Uri.parse(SquareConfig.paymentsUrl),&lt;BR /&gt;headers: {&lt;BR /&gt;'Authorization': 'Bearer ${vendorModel.value.squareToken}',&lt;BR /&gt;// 'Authorization': 'Bearer ${Constant.productionAccessToken}',&lt;BR /&gt;'Content-Type': 'application/json',&lt;BR /&gt;"Square-Version": "2026-01-22",&lt;BR /&gt;},&lt;BR /&gt;body: jsonEncode({&lt;BR /&gt;"idempotency_key": "pay-${DateTime.now().millisecondsSinceEpoch}",&lt;BR /&gt;"source_id": "EXTERNAL",&lt;BR /&gt;"amount_money": {"amount": totalOrderAmount, "currency": "AUD"},&lt;BR /&gt;"order_id": orderId,&lt;BR /&gt;"location_id": vendorModel.value.locationId,&lt;BR /&gt;"external_details": {&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Your gateway details here&lt;BR /&gt;"type": "OTHER", // CARD / BANK_TRANSFER / OTHER&lt;BR /&gt;"source": "Wallet", // Your gateway name&lt;BR /&gt;"source_id": paymentId&lt;BR /&gt;}&lt;BR /&gt;}),&lt;BR /&gt;);&lt;BR /&gt;if (response.statusCode == 200) {&lt;BR /&gt;orderModel.square_order_id = orderId;&lt;BR /&gt;await FireStoreUtils.setOrder(orderModel).then(&lt;BR /&gt;(value) async {&lt;BR /&gt;await FireStoreUtils.getUserProfile(&lt;BR /&gt;orderModel.vendor!.author.toString())&lt;BR /&gt;.then(&lt;BR /&gt;(value) async {&lt;BR /&gt;if (value != null) {&lt;BR /&gt;if (orderModel.scheduleTime != null) {&lt;BR /&gt;await SendNotification.sendFcmMessage(&lt;BR /&gt;Constant.scheduleOrder, value.fcmToken ?? '', {});&lt;BR /&gt;} else {&lt;BR /&gt;await SendNotification.sendFcmMessage(&lt;BR /&gt;Constant.newOrderPlaced, value.fcmToken ?? '', {});&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;);&lt;BR /&gt;ShowToastDialog.closeLoader();&lt;BR /&gt;Get.off(const OrderPlacingScreen(),&lt;BR /&gt;arguments: {"orderModel": orderModel});&lt;BR /&gt;},&lt;BR /&gt;);&lt;BR /&gt;// await Constant.sendOrderEmail(orderModel: orderModel);&lt;BR /&gt;// ShowToastDialog.closeLoader();&lt;BR /&gt;Get.off(const OrderPlacingScreen(),&lt;BR /&gt;arguments: {"orderModel": orderModel});&lt;BR /&gt;} else {&lt;BR /&gt;ShowToastDialog.closeLoader();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;print('Payment ==&amp;gt; ${response.body}');&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Mon, 04 May 2026 06:24:47 GMT</pubDate>
    <dc:creator>noQ4Food</dc:creator>
    <dc:date>2026-05-04T06:24:47Z</dc:date>
    <item>
      <title>How to Manage Status with cancellation process through the api ?</title>
      <link>https://community.squareup.com/t5/Orders-Menu-Items-Catalog/How-to-Manage-Status-with-cancellation-process-through-the-api/m-p/841996#M23274</link>
      <description>&lt;P&gt;Dear Square Support Team,&lt;/P&gt;&lt;P&gt;I hope you are doing well.&lt;/P&gt;&lt;P&gt;I am currently integrating Square Orders and Payments APIs in my application. I am successfully able to create orders and process payments using the Orders API followed by the Payments API.&lt;/P&gt;&lt;P&gt;However, I am facing an issue related to order status management.&lt;/P&gt;&lt;P&gt;**Issue Description:**&lt;BR /&gt;When I create an order, I explicitly set the order state to **OPEN** during order creation. After that, I create the payment associated with the order. But immediately after the payment is successfully created, the order automatically moves to the **COMPLETED** state.&lt;/P&gt;&lt;P&gt;My requirement is different:&lt;/P&gt;&lt;P&gt;* When an order is created and payment is made, the order should remain in an **ACTIVE / OPEN** state.&lt;BR /&gt;* The order should only move to **COMPLETED** when I explicitly update it after fulfillment or delivery is finished.&lt;/P&gt;&lt;P&gt;**Current Implementation Flow:**&lt;/P&gt;&lt;P&gt;1. Create Order using Orders API&lt;BR /&gt;2. Set order state to `OPEN`&lt;BR /&gt;3. Create Payment using Payments API with `order_id`&lt;BR /&gt;4. Order automatically transitions to `COMPLETED`&lt;/P&gt;&lt;P&gt;**What I would like to understand:**&lt;/P&gt;&lt;P&gt;1. Is this automatic transition to `COMPLETED` expected behavior when the payment is captured successfully?&lt;BR /&gt;2. Is there a recommended way to keep the order in `OPEN` or `IN_PROGRESS` state after payment creation?&lt;BR /&gt;3. Should I be using the Fulfillment API or another mechanism to control the order lifecycle manually?&lt;BR /&gt;4. Is there a specific parameter or configuration that prevents the order from automatically completing after payment?&lt;/P&gt;&lt;P&gt;For reference, I am using:&lt;/P&gt;&lt;P&gt;* Orders API to create the order&lt;BR /&gt;* Payments API with `source_id = EXTERNAL`&lt;BR /&gt;* Square API Version: **2026-01-22**&lt;/P&gt;&lt;P&gt;Any guidance or best practices for managing order lifecycle states would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you for your support.&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Mamta Kumavat&lt;BR /&gt;Flutter Developer&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;this is my code.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Future setSquareOrderData(OrderModel orderModel, String paymentId) async {&lt;BR /&gt;try {&lt;BR /&gt;ShowToastDialog.showLoader("Please wait.");&lt;BR /&gt;String currency = "AUD";&lt;BR /&gt;NewOrderModel newOrderModel = NewOrderModel();&lt;BR /&gt;SquareOrder squareOrder = SquareOrder();&lt;/P&gt;&lt;P&gt;newOrderModel.idempotency_key = orderModel.id;&lt;BR /&gt;squareOrder.state = OrderState.open.displayName;&lt;BR /&gt;squareOrder.customer_id = orderModel.authorID;&lt;BR /&gt;squareOrder.reference_id = Constant.getUuid();&lt;BR /&gt;squareOrder.location_id = vendorModel.value.locationId;&lt;/P&gt;&lt;P&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; TAXES — define at order level with uid&lt;BR /&gt;// NO applied_money here — Square calculates it&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;List&amp;lt;OrderLineItemTax&amp;gt; newTaxSetting = [];&lt;/P&gt;&lt;P&gt;void addTax(dynamic tax, int orderSubtotal) {&lt;BR /&gt;if (tax == null) return;&lt;BR /&gt;if (tax.enable == false) return;&lt;BR /&gt;if (tax.tax == null || double.parse(tax.tax.toString()) &amp;lt;= 0) return;&lt;/P&gt;&lt;P&gt;String uid = Constant.getUuid();&lt;BR /&gt;String scope = tax.scope == 'product' ? "LINE_ITEM" : "ORDER";&lt;/P&gt;&lt;P&gt;if (tax.type == "percentage") {&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Direct percentage tax&lt;BR /&gt;newTaxSetting.add(OrderLineItemTax(&lt;BR /&gt;uid: uid,&lt;BR /&gt;name: tax.title ?? "Tax",&lt;BR /&gt;orderTaxType: "ADDITIVE",&lt;BR /&gt;scope: scope,&lt;BR /&gt;percentage: tax.tax.toString(),&lt;BR /&gt;));&lt;BR /&gt;} else if (tax.type == "fix") {&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Convert fixed amount to percentage&lt;BR /&gt;// percentage = (fixedAmount / orderSubtotal) * 100&lt;BR /&gt;if (orderSubtotal &amp;lt;= 0) {&lt;BR /&gt;print("&lt;span class="lia-unicode-emoji" title=":warning:"&gt;⚠️&lt;/span&gt; Skipping ${tax.title} — subtotal is 0");&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int fixedAmount = Constant.parseAmount(tax.tax.toString());&lt;BR /&gt;double percentage = (fixedAmount / orderSubtotal) * 100;&lt;BR /&gt;String percentageStr = percentage.toStringAsFixed(2); // e.g "1.19"&lt;/P&gt;&lt;P&gt;print(&lt;BR /&gt;"Fixed tax ${tax.title}: $fixedAmount / $orderSubtotal * 100 = $percentageStr%");&lt;/P&gt;&lt;P&gt;newTaxSetting.add(OrderLineItemTax(&lt;BR /&gt;uid: uid,&lt;BR /&gt;name: tax.title ?? "Tax",&lt;BR /&gt;orderTaxType: "ADDITIVE",&lt;BR /&gt;scope: scope,&lt;BR /&gt;percentage: percentageStr, // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; converted to percentage&lt;BR /&gt;));&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Calculate order subtotal first&lt;BR /&gt;int orderSubtotal = 0;&lt;BR /&gt;for (var product in orderModel.products!) {&lt;BR /&gt;int price = double.parse(product.discountPrice.toString()) &amp;lt;= 0&lt;BR /&gt;? Constant.parseAmount(product.price.toString())&lt;BR /&gt;: Constant.parseAmount(product.discountPrice.toString());&lt;BR /&gt;int qty = int.parse(product.quantity.toString());&lt;BR /&gt;orderSubtotal += price * qty;&lt;BR /&gt;}&lt;BR /&gt;print("Order subtotal: $orderSubtotal");&lt;BR /&gt;// Then add taxes with subtotal&lt;BR /&gt;orderModel.taxSetting?.forEach((tax) =&amp;gt; addTax(tax, orderSubtotal));&lt;BR /&gt;orderModel.driverDeliveryTax&lt;BR /&gt;?.forEach((tax) =&amp;gt; addTax(tax, orderSubtotal));&lt;BR /&gt;orderModel.packagingTax?.forEach((tax) =&amp;gt; addTax(tax, orderSubtotal));&lt;BR /&gt;orderModel.platformTax?.forEach((tax) =&amp;gt; addTax(tax, orderSubtotal));&lt;BR /&gt;print("Taxes being sent:");&lt;BR /&gt;for (var tax in newTaxSetting) {&lt;BR /&gt;print(" name: ${tax.name}, type: ${tax.orderTaxType}, "&lt;BR /&gt;"percentage: ${tax.percentage}"&lt;BR /&gt;"Money: ${tax.amount_money?.amount}");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; LINE ITEMS&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;List&amp;lt;LineItems&amp;gt; listLineItems = [];&lt;BR /&gt;List&amp;lt;int&amp;gt; extraPriceAmount = [];&lt;/P&gt;&lt;P&gt;for (var product in orderModel.products!) {&lt;BR /&gt;LineItems lineItems = LineItems();&lt;BR /&gt;lineItems.uid = Constant.squareOrderId(orderId: product.id!);&lt;BR /&gt;lineItems.name = product.name;&lt;BR /&gt;lineItems.quantity = product.quantity.toString();&lt;BR /&gt;lineItems.item_type = OrderLineItemItemType.item.displayName;&lt;BR /&gt;lineItems.metadata = product.variantInfo?.variantOptions;&lt;/P&gt;&lt;P&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Base price&lt;BR /&gt;Money baseMoney = Money();&lt;BR /&gt;if (product.extrasPrice != null || product.extrasPrice != "0") {&lt;BR /&gt;/*extraPriceAmount.add(Constant.parseAmount(product.extrasPrice)!);*/&lt;BR /&gt;if (double.parse(product.discountPrice.toString()) &amp;lt;= 0) {&lt;BR /&gt;baseMoney.amount = Constant.parseAmount(product.price.toString()) +&lt;BR /&gt;Constant.parseAmount(product.extrasPrice);&lt;BR /&gt;} else {&lt;BR /&gt;baseMoney.amount =&lt;BR /&gt;Constant.parseAmount(product.discountPrice.toString()) +&lt;BR /&gt;Constant.parseAmount(product.extrasPrice);&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;if (double.parse(product.discountPrice.toString()) &amp;lt;= 0) {&lt;BR /&gt;baseMoney.amount = Constant.parseAmount(product.price.toString());&lt;BR /&gt;} else {&lt;BR /&gt;baseMoney.amount =&lt;BR /&gt;Constant.parseAmount(product.discountPrice.toString());&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;baseMoney.currency = currency;&lt;BR /&gt;lineItems.base_price_money = baseMoney;&lt;/P&gt;&lt;P&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Applied taxes — only if product has taxSetting&lt;BR /&gt;// Reference uid from squareOrder.taxes&lt;BR /&gt;List&amp;lt;OrderLineItemAppliedTax&amp;gt; productTaxSetting = [];&lt;BR /&gt;if (product.taxSetting != null &amp;amp;&amp;amp; product.taxSetting!.isNotEmpty) {&lt;BR /&gt;for (var productTax in product.taxSetting!) {&lt;BR /&gt;// Find matching tax uid from newTaxSetting&lt;BR /&gt;final matchingTax = newTaxSetting.firstWhere(&lt;BR /&gt;(t) =&amp;gt; t.name == productTax.title,&lt;BR /&gt;orElse: () =&amp;gt; newTaxSetting.first,&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;if (matchingTax.uid != null) {&lt;BR /&gt;Money taxMoney = Money(&lt;BR /&gt;amount: Constant.parseAmount(productTax.tax.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;productTaxSetting.add(OrderLineItemAppliedTax(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;tax_uid: matchingTax.uid!, // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Must match uid in taxes array&lt;BR /&gt;applied_money: taxMoney,&lt;BR /&gt;));&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Only set applied_taxes if not empty&lt;BR /&gt;if (productTaxSetting.isNotEmpty) {&lt;BR /&gt;lineItems.applied_taxes = productTaxSetting;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Applied discounts — only if discount exists&lt;BR /&gt;if (lineItemDiscount.isNotEmpty) {&lt;BR /&gt;lineItems.applied_discounts = lineItemDiscount&lt;BR /&gt;.map((d) =&amp;gt; OrderLineItemAppliedDiscount(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;discount_uid: d.uid!, // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Must match uid in discounts array&lt;BR /&gt;))&lt;BR /&gt;.toList();&lt;BR /&gt;}*/&lt;/P&gt;&lt;P&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Extras as note, NOT as service charge&lt;BR /&gt;// (service charges need to be defined at order level)&lt;BR /&gt;if (Constant.parseAmount(product.extrasPrice.toString()) &amp;gt; 0) {&lt;BR /&gt;lineItems.note = "Extras Addons Price: ${product.extrasPrice}";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;listLineItems.add(lineItems);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;squareOrder.line_items = listLineItems;&lt;/P&gt;&lt;P&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; DISCOUNTS — define at order level with uid&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;List&amp;lt;OrderLineItemDiscount&amp;gt; lineItemDiscount = [];&lt;BR /&gt;if (orderModel.discount != null &amp;amp;&amp;amp;&lt;BR /&gt;Constant.parseAmount(orderModel.discount.toString()) &amp;gt; 0) {&lt;BR /&gt;Money discountMoney = Money(&lt;BR /&gt;amount: Constant.parseAmount(orderModel.discount.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;lineItemDiscount.add(OrderLineItemDiscount(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;name: "Discount", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; name is required&lt;BR /&gt;amount_money: discountMoney,&lt;BR /&gt;scope: "ORDER", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; scope is required&lt;BR /&gt;));&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (couponAmount.value != 0.0) {&lt;BR /&gt;Money couponDiscount = Money(&lt;BR /&gt;amount: Constant.parseAmount(couponAmount.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;lineItemDiscount.add(OrderLineItemDiscount(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;name: "Coupon Discount", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; name is required&lt;BR /&gt;amount_money: couponDiscount,&lt;BR /&gt;scope: "ORDER", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; scope is required&lt;BR /&gt;));&lt;BR /&gt;}&lt;BR /&gt;if (specialDiscountAmount.value != 0.0) {&lt;BR /&gt;Money specialDiscount = Money(&lt;BR /&gt;amount: Constant.parseAmount(specialDiscountAmount.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;lineItemDiscount.add(OrderLineItemDiscount(&lt;BR /&gt;uid: Constant.getUuid(),&lt;BR /&gt;name: "Special Discount", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; name is required&lt;BR /&gt;amount_money: specialDiscount,&lt;BR /&gt;scope: "ORDER", // &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; scope is required&lt;BR /&gt;));&lt;BR /&gt;}&lt;BR /&gt;// squareOrder.discounts = lineItemDiscount;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; SERVICE CHARGES — define at order level with uid&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;List&amp;lt;OrderServiceCharge&amp;gt; serivceCharges = [];&lt;BR /&gt;if (packagingCharge.value != 0.0) {&lt;BR /&gt;OrderServiceCharge packagingCharges = OrderServiceCharge();&lt;BR /&gt;packagingCharges.uid = Constant.getUuid();&lt;BR /&gt;packagingCharges.name = "Packaging Charges";&lt;BR /&gt;packagingCharges.scope = "ORDER";&lt;BR /&gt;packagingCharges.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;packagingCharges.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(packagingCharge.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;serivceCharges.add(packagingCharges);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (deliveryTips.value != 0.0) {&lt;BR /&gt;OrderServiceCharge deliveryTip = OrderServiceCharge();&lt;BR /&gt;deliveryTip.uid = Constant.getUuid();&lt;BR /&gt;deliveryTip.name = "Delivery Tips";&lt;BR /&gt;deliveryTip.scope = "ORDER";&lt;BR /&gt;deliveryTip.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;deliveryTip.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(deliveryTips.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;// serivceCharges.add(deliveryTip);&lt;BR /&gt;}&lt;BR /&gt;if (deliveryCharges.value != 0.0) {&lt;BR /&gt;OrderServiceCharge deliveryCharge = OrderServiceCharge();&lt;BR /&gt;deliveryCharge.uid = Constant.getUuid();&lt;BR /&gt;deliveryCharge.name = "Delivery Charges";&lt;BR /&gt;deliveryCharge.scope = "ORDER";&lt;BR /&gt;deliveryCharge.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;deliveryCharge.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(deliveryCharges.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;// serivceCharges.add(deliveryCharge);&lt;BR /&gt;}&lt;BR /&gt;if (platformFee.value != 0.0) {&lt;BR /&gt;OrderServiceCharge platformFees = OrderServiceCharge();&lt;BR /&gt;platformFees.uid = Constant.getUuid();&lt;BR /&gt;platformFees.name = "Platform Fee";&lt;BR /&gt;platformFees.scope = "ORDER";&lt;BR /&gt;platformFees.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;platformFees.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(platformFee.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;// serivceCharges.add(platformFees);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;OrderServiceCharge productTax = OrderServiceCharge();&lt;BR /&gt;if (Constant.taxScope == 'product' &amp;amp;&amp;amp; productTaxAmount.value != 0.0) {&lt;BR /&gt;productTax.uid = Constant.getUuid();&lt;BR /&gt;productTax.name = "Tax on item total";&lt;BR /&gt;productTax.scope = "LINE_ITEM";&lt;BR /&gt;productTax.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;productTax.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(productTaxAmount.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;serivceCharges.add(productTax);&lt;BR /&gt;} else {&lt;BR /&gt;productTax.uid = Constant.getUuid();&lt;BR /&gt;productTax.name = "Tax on Order total";&lt;BR /&gt;productTax.scope = "ORDER";&lt;BR /&gt;productTax.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;productTax.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(orderTaxAmount.value.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;serivceCharges.add(productTax);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;double squareTotalTaxAmount = 0.0;&lt;BR /&gt;if (Constant.taxScope == 'product') {&lt;BR /&gt;if (totalTaxAmount.value &amp;gt; productTaxAmount.value) {&lt;BR /&gt;squareTotalTaxAmount = totalTaxAmount.value - productTaxAmount.value;&lt;BR /&gt;} else {&lt;BR /&gt;squareTotalTaxAmount = productTaxAmount.value - totalTaxAmount.value;&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;if (totalTaxAmount.value &amp;gt; orderTaxAmount.value) {&lt;BR /&gt;squareTotalTaxAmount = totalTaxAmount.value - orderTaxAmount.value;&lt;BR /&gt;} else {&lt;BR /&gt;squareTotalTaxAmount = orderTaxAmount.value - totalTaxAmount.value;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (squareTotalTaxAmount != 0.0) {&lt;BR /&gt;OrderServiceCharge squareTotalTaxCharge = OrderServiceCharge();&lt;BR /&gt;squareTotalTaxCharge.uid = Constant.getUuid();&lt;BR /&gt;squareTotalTaxCharge.name = "Total Tax Amount";&lt;BR /&gt;squareTotalTaxCharge.scope = "ORDER";&lt;BR /&gt;squareTotalTaxCharge.calculation_phase = "TOTAL_PHASE";&lt;BR /&gt;squareTotalTaxCharge.amount_money = Money(&lt;BR /&gt;amount: Constant.parseAmount(squareTotalTaxAmount.toString()),&lt;BR /&gt;currency: currency,&lt;BR /&gt;);&lt;BR /&gt;// serivceCharges.add(squareTotalTaxCharge);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// squareOrder.service_charges = serivceCharges;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;newOrderModel.order = squareOrder;&lt;BR /&gt;// Add this just before the API call&lt;BR /&gt;final jsonBody = jsonEncode(newOrderModel.toJson());&lt;BR /&gt;print("Final JSON: $jsonBody");&lt;/P&gt;&lt;P&gt;// ─────────────────────────────────────────&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; API Call&lt;BR /&gt;// ─────────────────────────────────────────&lt;BR /&gt;final response = await http.post(&lt;BR /&gt;Uri.parse(SquareConfig.ordersUrl),&lt;BR /&gt;headers: {&lt;BR /&gt;'Authorization': 'Bearer ${vendorModel.value.squareToken}',&lt;BR /&gt;// 'Authorization': 'Bearer ${Constant.productionAccessToken}',&lt;BR /&gt;'Content-Type': 'application/json',&lt;BR /&gt;"Square-Version": "2026-01-22",&lt;BR /&gt;},&lt;BR /&gt;body: jsonEncode(newOrderModel.toJson()),&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;print("Response==&amp;gt;${response.body}");&lt;BR /&gt;final body = jsonDecode(response.body);&lt;BR /&gt;int totalOrderAmount = 0;&lt;BR /&gt;for (var amount in listLineItems) {&lt;BR /&gt;totalOrderAmount += amount.base_price_money!.amount!;&lt;BR /&gt;}&lt;BR /&gt;/*for (var extraAmount in extraPriceAmount) {&lt;BR /&gt;totalOrderAmount += extraAmount;&lt;BR /&gt;}&lt;BR /&gt;*/&lt;BR /&gt;if (body["order"] != null) {&lt;BR /&gt;String orderId = body["order"]["id"];&lt;BR /&gt;Map&amp;lt;String, dynamic&amp;gt; totalMap = (body['order']['total_money']);&lt;BR /&gt;Money totalMoney = Money.fromJson(totalMap);&lt;BR /&gt;print(&lt;BR /&gt;"PaymentId==&amp;gt;$paymentId---LocationId==&amp;gt;${squareOrder.location_id}");&lt;BR /&gt;createPayment(paymentId, orderId, orderModel, totalMoney.amount!);&lt;BR /&gt;} else {&lt;BR /&gt;print("Order creation failed: ${body["errors"]}");&lt;BR /&gt;ShowToastDialog.closeLoader();&lt;BR /&gt;}&lt;BR /&gt;} catch (e) {&lt;BR /&gt;ShowToastDialog.closeLoader();&lt;BR /&gt;log("Error fetching: $e");&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Future createPayment(String paymentId, String orderId,&lt;BR /&gt;OrderModel orderModel, int totalOrderAmount) async {&lt;BR /&gt;final response = await http.post(&lt;BR /&gt;Uri.parse(SquareConfig.paymentsUrl),&lt;BR /&gt;headers: {&lt;BR /&gt;'Authorization': 'Bearer ${vendorModel.value.squareToken}',&lt;BR /&gt;// 'Authorization': 'Bearer ${Constant.productionAccessToken}',&lt;BR /&gt;'Content-Type': 'application/json',&lt;BR /&gt;"Square-Version": "2026-01-22",&lt;BR /&gt;},&lt;BR /&gt;body: jsonEncode({&lt;BR /&gt;"idempotency_key": "pay-${DateTime.now().millisecondsSinceEpoch}",&lt;BR /&gt;"source_id": "EXTERNAL",&lt;BR /&gt;"amount_money": {"amount": totalOrderAmount, "currency": "AUD"},&lt;BR /&gt;"order_id": orderId,&lt;BR /&gt;"location_id": vendorModel.value.locationId,&lt;BR /&gt;"external_details": {&lt;BR /&gt;// &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Your gateway details here&lt;BR /&gt;"type": "OTHER", // CARD / BANK_TRANSFER / OTHER&lt;BR /&gt;"source": "Wallet", // Your gateway name&lt;BR /&gt;"source_id": paymentId&lt;BR /&gt;}&lt;BR /&gt;}),&lt;BR /&gt;);&lt;BR /&gt;if (response.statusCode == 200) {&lt;BR /&gt;orderModel.square_order_id = orderId;&lt;BR /&gt;await FireStoreUtils.setOrder(orderModel).then(&lt;BR /&gt;(value) async {&lt;BR /&gt;await FireStoreUtils.getUserProfile(&lt;BR /&gt;orderModel.vendor!.author.toString())&lt;BR /&gt;.then(&lt;BR /&gt;(value) async {&lt;BR /&gt;if (value != null) {&lt;BR /&gt;if (orderModel.scheduleTime != null) {&lt;BR /&gt;await SendNotification.sendFcmMessage(&lt;BR /&gt;Constant.scheduleOrder, value.fcmToken ?? '', {});&lt;BR /&gt;} else {&lt;BR /&gt;await SendNotification.sendFcmMessage(&lt;BR /&gt;Constant.newOrderPlaced, value.fcmToken ?? '', {});&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;);&lt;BR /&gt;ShowToastDialog.closeLoader();&lt;BR /&gt;Get.off(const OrderPlacingScreen(),&lt;BR /&gt;arguments: {"orderModel": orderModel});&lt;BR /&gt;},&lt;BR /&gt;);&lt;BR /&gt;// await Constant.sendOrderEmail(orderModel: orderModel);&lt;BR /&gt;// ShowToastDialog.closeLoader();&lt;BR /&gt;Get.off(const OrderPlacingScreen(),&lt;BR /&gt;arguments: {"orderModel": orderModel});&lt;BR /&gt;} else {&lt;BR /&gt;ShowToastDialog.closeLoader();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;print('Payment ==&amp;gt; ${response.body}');&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2026 06:24:47 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Orders-Menu-Items-Catalog/How-to-Manage-Status-with-cancellation-process-through-the-api/m-p/841996#M23274</guid>
      <dc:creator>noQ4Food</dc:creator>
      <dc:date>2026-05-04T06:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Manage Status with cancellation process through the api ?</title>
      <link>https://community.squareup.com/t5/Orders-Menu-Items-Catalog/How-to-Manage-Status-with-cancellation-process-through-the-api/m-p/842001#M23276</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.squareup.com/t5/user/viewprofilepage/user-id/766447"&gt;@noQ4Food&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I think you will get the most help by asking your question the developer forums.&amp;nbsp;&lt;A href="https://developer.squareup.com/forums/" target="_blank"&gt;https://developer.squareup.com/forums/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2026 13:01:59 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Orders-Menu-Items-Catalog/How-to-Manage-Status-with-cancellation-process-through-the-api/m-p/842001#M23276</guid>
      <dc:creator>Manny_SelSq</dc:creator>
      <dc:date>2026-05-04T13:01:59Z</dc:date>
    </item>
  </channel>
</rss>

