Skip to main content

Cancellation Plan Services

In Omnitron, a cancellation plan is initiated when either an order item or the entire order is canceled or refunded. When this cancellation plan is generated, it triggers a cancellation webhook, which is then transmitted to OMS.

The CancellationPlanViewSet is responsible for handling the data received through this webhook. Its role is to assess whether the package containing the product marked for cancellation or refund can indeed be canceled or refunded.

POST Run Cancellation Plan Service

Path: /api/v1/oms/cancellation_plan/

Request Body

PropertyData TypeRequiredInDescriptions
eventjsontruebodyDetails of the event (webhook type and uuid)
payloadjsontruebodyDetails of the cancellation plan created for cancelled / refunded order item or order

Example Request Body

The data transmitted from Omnitron maintains a consistent format for both cancellation and refund operations. The only distinction lies in the plan_type field, which must be set to cancel when it pertains to cancellation and refund when it pertains to refund operations.

{
"event": {
"type": "cancellation_plan.created",
"uuid": "4e7ab2024a3e4e8ba400c2470b84f976"
},
"payload": {
"pk": 2839,
"order": {
"pk": 1883,
"notes": null,
"amount": "13.49",
"number": "1472672233418128",
"status": "50",
"channel": 1,
"is_send": true,
"segment": null,
"currency": "try",
"customer": 232,
"bin_number": null,
"client_type": "default",
"date_placed": "2020-10-12T07:54:06.714184Z",
"extra_field": {},
"installment": 69,
"remote_addr": "212.115.28.8",
"has_gift_box": false,
"invoice_date": null,
"cargo_company": 1,
"delivery_type": null,
"e_archive_url": null,
"gift_box_note": null,
"language_code": "tr-tr",
"modified_date": "2023-02-08T14:40:25.643841Z",
"refund_amount": "0.00",
"delivery_range": null,
"invoice_number": null,
"payment_option": 67,
"billing_address": 298,
"discount_amount": "220.01",
"external_status": null,
"shipping_amount": "9.00",
"tracking_number": null,
"shipping_address": 298,
"installment_count": 1,
"shipping_tax_rate": null,
"net_shipping_amount": "9.00",
"payment_option_slug": "credit_card",
"checkout_provider_id": null,
"shipping_option_slug": null,
"carrier_shipping_code": null,
"discount_refund_amount": "0.00",
"shipping_refund_amount": "0.00",
"shipping_interest_amount": "0.00",
"installment_interest_amount": "0.00",
"fundstransfertransaction_set": []
},
"status": "completed",
"plan_type": "cancel",
"created_by": {
"pk": 1387,
"email": "test@akinon.com",
"groups": [
1,
2
],
"is_staff": true,
"username": "test",
"is_active": true,
"last_name": "Doe",
"first_name": "John",
"last_login": "2023-02-08T12:52:49.880154Z",
"date_joined": "2022-04-04T21:10:20.324120Z",
"is_superuser": true
},
"created_date": "2023-02-08T14:40:25.692898Z",
"modified_date": "2023-02-08T14:40:25.692930Z",
"refund_amount": "13.49",
"invoice_number": null,
"last_updated_by": {
"pk": 1387,
"email": "test@akinon.com",
"groups": [
1,
2
],
"is_staff": true,
"username": "test",
"is_active": true,
"last_name": "Doe",
"first_name": "John",
"last_login": "2023-02-08T12:52:49.880154Z",
"date_joined": "2022-04-04T21:10:20.324120Z",
"is_superuser": true
},
"staff_remote_id": null,
"order_previous_status": "400",
"discount_refund_amount": "220.01",
"retail_store_remote_id": null,
"shipping_refund_amount": "9.00",
"cancellationplanorderitem_set": [
{
"pk": 2872,
"reason": {
"pk": 2,
"order": 100,
"subject": "Ürünü satın almaktan vazgeçtim.",
"is_active": true,
"modified_date": "2020-04-07T14:13:34.807272Z",
"send_to_remote": true,
"cancellation_type": "cancel",
"extra_information_needed": false
},
"status": "100",
"order_item": {
"pk": 1883,
"image": null,
"order": {
"pk": 1883,
"notes": null,
"amount": "13.49",
"number": "1472672233418128",
"status": "50",
"channel": 1,
"is_send": true,
"segment": null,
"currency": "try",
"customer": 232,
"bin_number": null,
"client_type": "default",
"date_placed": "2020-10-12T07:54:06.714184Z",
"extra_field": {},
"installment": 69,
"remote_addr": "212.115.28.8",
"has_gift_box": false,
"invoice_date": null,
"cargo_company": 1,
"delivery_type": null,
"e_archive_url": null,
"gift_box_note": null,
"language_code": "tr-tr",
"modified_date": "2023-02-08T14:40:25.643841Z",
"refund_amount": "0.00",
"delivery_range": null,
"invoice_number": null,
"payment_option": 67,
"billing_address": 298,
"discount_amount": "220.01",
"external_status": null,
"shipping_amount": "9.00",
"tracking_number": null,
"shipping_address": 298,
"installment_count": 1,
"shipping_tax_rate": null,
"net_shipping_amount": "9.00",
"payment_option_slug": "credit_card",
"checkout_provider_id": null,
"shipping_option_slug": null,
"carrier_shipping_code": null,
"discount_refund_amount": "0.00",
"shipping_refund_amount": "0.00",
"shipping_interest_amount": "0.00",
"installment_interest_amount": "0.00",
"fundstransfertransaction_set": []
},
"price": "224.50",
"parent": null,
"status": "50",
"product": {
"pk": 5076,
"sku": "868206122521",
"name": "GOMLEK .V33 .39",
"uuid": "73f4c35a-33fe-4a73-ad66-58d2b7adc7e0",
"parent": null,
"base_code": "M868206122521",
"is_active": true,
"attributes": {
"erp_size": "39",
"erp_color": "33",
"erp_drying": "4",
"erp_gender": "E",
"erp_weight": "0",
"erp_ironing": "+",
"erp_washing": "a",
"erp_resource": "10",
"erp_vat_rate": "8",
"erp_bleaching": "9",
"erp_is_outlet": "True",
"erp_materials": "KUMAŞ: %100.0 Pamuk",
"erp_dimensions": "0",
"erp_sale_rules": "10",
"erp_config_attr": "SIZE",
"erp_resource_id": "1",
"erp_season_name": "K",
"erp_season_year": "2020",
"filterable_size": "39",
"erp_date_updated": "2021-04-04T08:41:19+0300",
"erp_dry_cleaning": "W",
"filtrable_season": "2020",
"integration_size": "39",
"erp_attribute_set": "120",
"erp_barcode_color": "868206122521",
"erp_barcode_ean13": "8682061225213",
"erp_barcode_model": "868206122521",
"filterable_gender": "Erkek",
"filtrable_color_1": "Mavi",
"integration_color": "33",
"integration_drying": "4",
"integration_gender": "E",
"integration_ironing": "+",
"integration_washing": "a",
"integration_resource": "10",
"integration_vat_rate": "8",
"filterable_dimensions": "Standart",
"integration_bleaching": "9",
"integration_is_outlet": "False",
"integration_materials": "KUMAŞ: %100.0 Pamuk",
"integration_dimensions": "0",
"integration_sale_rules": "13",
"erp_discount_prohibited": "0",
"integration_config_attr": "SİZE",
"integration_resource_id": "1",
"integration_season_name": "K",
"integration_season_year": "2020",
"filterable_attribute_set": "GÖMLEK",
"integration_date_updated": "2019-11-06T10:30:13+0300",
"integration_dry_cleaning": "W",
"integration_attribute_set": "290",
"integration_barcode_color": "868206122521",
"integration_barcode_ean13": "8682061225213",
"integration_barcode_model": "868206122521",
"integration_discount_prohibited": "0"
},
"data_source": null,
"listing_code": "33",
"product_type": "0",
"attribute_set": 1,
"modified_date": "2022-04-04T09:41:30.700264Z",
"group_products": [],
"extra_attributes": {},
"productimage_set": [],
"attributes_kwargs": {
"erp_size": {
"label": "39",
"value": "39",
"data_type": "dropdown"
},
"erp_color": {
"label": "MAVI",
"value": "33",
"data_type": "dropdown"
},
"erp_gender": {
"label": "E",
"value": "E",
"data_type": "dropdown"
},
"erp_is_outlet": {
"label": "True",
"value": "True",
"data_type": "dropdown"
},
"erp_dimensions": {
"label": "0",
"value": "0",
"data_type": "dropdown"
},
"erp_config_attr": {
"label": "SIZE",
"value": "SIZE",
"data_type": "dropdown"
},
"erp_season_year": {
"label": "2020",
"value": "2020",
"data_type": "dropdown"
},
"filterable_size": {
"label": "39",
"value": "39",
"data_type": "dropdown"
},
"filtrable_season": {
"label": "2020",
"value": "2020",
"data_type": "dropdown"
},
"integration_size": {
"label": "39",
"value": "39",
"data_type": "dropdown"
},
"erp_attribute_set": {
"label": "GOMLEK",
"value": "120",
"data_type": "dropdown"
},
"filterable_gender": {
"label": "Erkek",
"value": "Erkek",
"data_type": "dropdown"
},
"filtrable_color_1": {
"label": "Mavi",
"value": "Mavi",
"data_type": "dropdown"
},
"integration_color": {
"label": "MAVI",
"value": "33",
"data_type": "dropdown"
},
"integration_gender": {
"label": "E",
"value": "E",
"data_type": "dropdown"
},
"filterable_dimensions": {
"label": "Standart",
"value": "Standart",
"data_type": "dropdown"
},
"integration_is_outlet": {
"label": "False",
"value": "False",
"data_type": "dropdown"
},
"integration_dimensions": {
"label": "0",
"value": "0",
"data_type": "dropdown"
},
"erp_discount_prohibited": {
"label": "0",
"value": "0",
"data_type": "dropdown"
},
"integration_config_attr": {
"label": "SIZE",
"value": "SİZE",
"data_type": "dropdown"
},
"integration_season_year": {
"label": "2020",
"value": "2020",
"data_type": "dropdown"
},
"filterable_attribute_set": {
"label": "GÖMLEK",
"value": "GÖMLEK",
"data_type": "dropdown"
},
"integration_attribute_set": {
"label": "AYAKKABI",
"value": "290",
"data_type": "dropdown"
},
"integration_discount_prohibited": {
"label": "0",
"value": "0",
"data_type": "dropdown"
}
},
"productization_date": "2020-02-14T11:23:09.556066Z",
"custom_attribute_set": null
},
"tax_rate": "8.00",
"attributes": {},
"net_amount": "224.50",
"price_list": {
"pk": 1,
"code": "shop_price_list",
"name": "shop_price_list",
"currency": "try",
"created_date": "2020-02-10T14:29:48.674885Z",
"is_auto_sync": true,
"modified_date": "2020-02-10T14:29:48.674915Z"
},
"stock_list": {
"pk": 1,
"code": "shop_stock_list",
"name": "shop_stock_list",
"created_date": "2020-02-10T14:30:00.218712Z",
"is_auto_sync": true,
"modified_date": "2020-02-10T14:30:00.218745Z"
},
"data_source": null,
"extra_field": {},
"invoice_date": null,
"retail_price": "449.00",
"tracking_url": null,
"cancel_status": "waiting",
"e_archive_url": null,
"shipment_code": null,
"invoice_number": null,
"price_currency": "try",
"status_display": "cancellation waiting",
"discount_amount": "220.01",
"external_status": null,
"tracking_number": null,
"shipping_company": null,
"attributes_kwargs": {},
"benefitapplicant_set": [
{
"id": 431,
"order_item": 1883,
"created_date": "2020-10-12T08:14:08.972369Z",
"discount_item": 431,
"modified_date": "2020-10-12T08:14:09.032379Z",
"discount_share": "220.01"
}
],
"estimated_delivery_date": null,
"installment_interest_amount": "0.00"
},
"modified_date": "2023-02-08T14:40:25.699842Z",
"order_item_previous_status": "400"
}
]
}
}

Example Request

To run this service, a POST request should be sent to the /api/v1/oms/cancellation_plan/endpoint. In the headers, set the Authorization header to include the api token for authentication.

Here's an example of how to make the request in python:

import requests
import json

url = "https://{domain_url}/api/v1/oms/cancellation_plan/"
token = "11111XXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
"event": {
"type": "cancellation_plan.created",
"uuid": "4e7ab2024a3e4e8ba400c2470b84f976"
},
"payload": {
"pk": 2839,
"order": {
"pk": 1883,
"notes": null,
"amount": "13.49",
"number": "1472672233418128",
"status": "50",
"channel": 1,
"is_send": true,
"segment": null,
"currency": "try",
"customer": 232,
"bin_number": null,
"client_type": "default",
"date_placed": "2020-10-12T07:54:06.714184Z",
"extra_field": {},
"installment": 69,
"remote_addr": "212.115.28.8",
"has_gift_box": false,
"invoice_date": null,
"cargo_company": 1,
"delivery_type": null,
"e_archive_url": null,
"gift_box_note": null,
"language_code": "tr-tr",
"modified_date": "2023-02-08T14:40:25.643841Z",
"refund_amount": "0.00",
"delivery_range": null,
"invoice_number": null,
"payment_option": 67,
"billing_address": 298,
"discount_amount": "220.01",
"external_status": null,
"shipping_amount": "9.00",
"tracking_number": null,
"shipping_address": 298,
"installment_count": 1,
"shipping_tax_rate": null,
"net_shipping_amount": "9.00",
"payment_option_slug": "credit_card",
"checkout_provider_id": null,
"shipping_option_slug": null,
"carrier_shipping_code": null,
"discount_refund_amount": "0.00",
"shipping_refund_amount": "0.00",
"shipping_interest_amount": "0.00",
"installment_interest_amount": "0.00",
"fundstransfertransaction_set": []
},
"status": "completed",
"plan_type": "cancel",
"created_by": {
"pk": 1387,
"email": "test@akinon.com",
"groups": [
1,
2
],
"is_staff": true,
"username": "test",
"is_active": true,
"last_name": "Doe",
"first_name": "John",
"last_login": "2023-02-08T12:52:49.880154Z",
"date_joined": "2022-04-04T21:10:20.324120Z",
"is_superuser": true
},
"created_date": "2023-02-08T14:40:25.692898Z",
"modified_date": "2023-02-08T14:40:25.692930Z",
"refund_amount": "13.49",
"invoice_number": null,
"last_updated_by": {
"pk": 1387,
"email": "test@akinon.com",
"groups": [
1,
2
],
"is_staff": true,
"username": "test",
"is_active": true,
"last_name": "Doe",
"first_name": "John",
"last_login": "2023-02-08T12:52:49.880154Z",
"date_joined": "2022-04-04T21:10:20.324120Z",
"is_superuser": true
},
"staff_remote_id": null,
"order_previous_status": "400",
"discount_refund_amount": "220.01",
"retail_store_remote_id": null,
"shipping_refund_amount": "9.00",
"cancellationplanorderitem_set": [
{
"pk": 2872,
"reason": {
"pk": 2,
"order": 100,
"subject": "Ürünü satın almaktan vazgeçtim.",
"is_active": true,
"modified_date": "2020-04-07T14:13:34.807272Z",
"send_to_remote": true,
"cancellation_type": "cancel",
"extra_information_needed": false
},
"status": "100",
"order_item": {
"pk": 1883,
"image": null,
"order": {
"pk": 1883,
"notes": null,
"amount": "13.49",
"number": "1472672233418128",
"status": "50",
"channel": 1,
"is_send": true,
"segment": null,
"currency": "try",
"customer": 232,
"bin_number": null,
"client_type": "default",
"date_placed": "2020-10-12T07:54:06.714184Z",
"extra_field": {},
"installment": 69,
"remote_addr": "212.115.28.8",
"has_gift_box": false,
"invoice_date": null,
"cargo_company": 1,
"delivery_type": null,
"e_archive_url": null,
"gift_box_note": null,
"language_code": "tr-tr",
"modified_date": "2023-02-08T14:40:25.643841Z",
"refund_amount": "0.00",
"delivery_range": null,
"invoice_number": null,
"payment_option": 67,
"billing_address": 298,
"discount_amount": "220.01",
"external_status": null,
"shipping_amount": "9.00",
"tracking_number": null,
"shipping_address": 298,
"installment_count": 1,
"shipping_tax_rate": null,
"net_shipping_amount": "9.00",
"payment_option_slug": "credit_card",
"checkout_provider_id": null,
"shipping_option_slug": null,
"carrier_shipping_code": null,
"discount_refund_amount": "0.00",
"shipping_refund_amount": "0.00",
"shipping_interest_amount": "0.00",
"installment_interest_amount": "0.00",
"fundstransfertransaction_set": []
},
"price": "224.50",
"parent": null,
"status": "50",
"product": {
"pk": 5076,
"sku": "868206122521",
"name": "GOMLEK .V33 .39",
"uuid": "73f4c35a-33fe-4a73-ad66-58d2b7adc7e0",
"parent": null,
"base_code": "M868206122521",
"is_active": true,
"attributes": {
"erp_size": "39",
"erp_color": "33",
"erp_drying": "4",
"erp_gender": "E",
"erp_weight": "0",
"erp_ironing": "+",
"erp_washing": "a",
"erp_resource": "10",
"erp_vat_rate": "8",
"erp_bleaching": "9",
"erp_is_outlet": "True",
"erp_materials": "KUMAŞ: %100.0 Pamuk",
"erp_dimensions": "0",
"erp_sale_rules": "10",
"erp_config_attr": "SIZE",
"erp_resource_id": "1",
"erp_season_name": "K",
"erp_season_year": "2020",
"filterable_size": "39",
"erp_date_updated": "2021-04-04T08:41:19+0300",
"erp_dry_cleaning": "W",
"filtrable_season": "2020",
"integration_size": "39",
"erp_attribute_set": "120",
"erp_barcode_color": "868206122521",
"erp_barcode_ean13": "8682061225213",
"erp_barcode_model": "868206122521",
"filterable_gender": "Erkek",
"filtrable_color_1": "Mavi",
"integration_color": "33",
"integration_drying": "4",
"integration_gender": "E",
"integration_ironing": "+",
"integration_washing": "a",
"integration_resource": "10",
"integration_vat_rate": "8",
"filterable_dimensions": "Standart",
"integration_bleaching": "9",
"integration_is_outlet": "False",
"integration_materials": "KUMAŞ: %100.0 Pamuk",
"integration_dimensions": "0",
"integration_sale_rules": "13",
"erp_discount_prohibited": "0",
"integration_config_attr": "SİZE",
"integration_resource_id": "1",
"integration_season_name": "K",
"integration_season_year": "2020",
"filterable_attribute_set": "GÖMLEK",
"integration_date_updated": "2019-11-06T10:30:13+0300",
"integration_dry_cleaning": "W",
"integration_attribute_set": "290",
"integration_barcode_color": "868206122521",
"integration_barcode_ean13": "8682061225213",
"integration_barcode_model": "868206122521",
"integration_discount_prohibited": "0"
},
"data_source": null,
"listing_code": "33",
"product_type": "0",
"attribute_set": 1,
"modified_date": "2022-04-04T09:41:30.700264Z",
"group_products": [],
"extra_attributes": {},
"productimage_set": [],
"attributes_kwargs": {
"erp_size": {
"label": "39",
"value": "39",
"data_type": "dropdown"
},
"erp_color": {
"label": "MAVI",
"value": "33",
"data_type": "dropdown"
},
"erp_gender": {
"label": "E",
"value": "E",
"data_type": "dropdown"
},
"erp_is_outlet": {
"label": "True",
"value": "True",
"data_type": "dropdown"
},
"erp_dimensions": {
"label": "0",
"value": "0",
"data_type": "dropdown"
},
"erp_config_attr": {
"label": "SIZE",
"value": "SIZE",
"data_type": "dropdown"
},
"erp_season_year": {
"label": "2020",
"value": "2020",
"data_type": "dropdown"
},
"filterable_size": {
"label": "39",
"value": "39",
"data_type": "dropdown"
},
"filtrable_season": {
"label": "2020",
"value": "2020",
"data_type": "dropdown"
},
"integration_size": {
"label": "39",
"value": "39",
"data_type": "dropdown"
},
"erp_attribute_set": {
"label": "GOMLEK",
"value": "120",
"data_type": "dropdown"
},
"filterable_gender": {
"label": "Erkek",
"value": "Erkek",
"data_type": "dropdown"
},
"filtrable_color_1": {
"label": "Mavi",
"value": "Mavi",
"data_type": "dropdown"
},
"integration_color": {
"label": "MAVI",
"value": "33",
"data_type": "dropdown"
},
"integration_gender": {
"label": "E",
"value": "E",
"data_type": "dropdown"
},
"filterable_dimensions": {
"label": "Standart",
"value": "Standart",
"data_type": "dropdown"
},
"integration_is_outlet": {
"label": "False",
"value": "False",
"data_type": "dropdown"
},
"integration_dimensions": {
"label": "0",
"value": "0",
"data_type": "dropdown"
},
"erp_discount_prohibited": {
"label": "0",
"value": "0",
"data_type": "dropdown"
},
"integration_config_attr": {
"label": "SIZE",
"value": "SİZE",
"data_type": "dropdown"
},
"integration_season_year": {
"label": "2020",
"value": "2020",
"data_type": "dropdown"
},
"filterable_attribute_set": {
"label": "GÖMLEK",
"value": "GÖMLEK",
"data_type": "dropdown"
},
"integration_attribute_set": {
"label": "AYAKKABI",
"value": "290",
"data_type": "dropdown"
},
"integration_discount_prohibited": {
"label": "0",
"value": "0",
"data_type": "dropdown"
}
},
"productization_date": "2020-02-14T11:23:09.556066Z",
"custom_attribute_set": null
},
"tax_rate": "8.00",
"attributes": {},
"net_amount": "224.50",
"price_list": {
"pk": 1,
"code": "shop_price_list",
"name": "shop_price_list",
"currency": "try",
"created_date": "2020-02-10T14:29:48.674885Z",
"is_auto_sync": true,
"modified_date": "2020-02-10T14:29:48.674915Z"
},
"stock_list": {
"pk": 1,
"code": "shop_stock_list",
"name": "shop_stock_list",
"created_date": "2020-02-10T14:30:00.218712Z",
"is_auto_sync": true,
"modified_date": "2020-02-10T14:30:00.218745Z"
},
"data_source": null,
"extra_field": {},
"invoice_date": null,
"retail_price": "449.00",
"tracking_url": null,
"cancel_status": "waiting",
"e_archive_url": null,
"shipment_code": null,
"invoice_number": null,
"price_currency": "try",
"status_display": "cancellation waiting",
"discount_amount": "220.01",
"external_status": null,
"tracking_number": null,
"shipping_company": null,
"attributes_kwargs": {},
"benefitapplicant_set": [
{
"id": 431,
"order_item": 1883,
"created_date": "2020-10-12T08:14:08.972369Z",
"discount_item": 431,
"modified_date": "2020-10-12T08:14:09.032379Z",
"discount_share": "220.01"
}
],
"estimated_delivery_date": null,
"installment_interest_amount": "0.00"
},
"modified_date": "2023-02-08T14:40:25.699842Z",
"order_item_previous_status": "400"
}
]
}
})

headers = {
'Content-Type': 'application/json',
'Authorization': f'Token {token}'
}

response = requests.request('POST', url, headers=headers, data=payload)

print(response.json())

Example Response (200 OK)

OMS adheres to its own set of rules when processing package cancellations or refunds. If a package meets the criteria for either cancellation or refund, OMS will proceed with the operation and issue a successful response, a status code of 200 OK.

The response body will not contain any additional objects or messages.

Example Response (202 ACCEPTED)

In specific scenarios, OMS does not cancel or refund a package, yet it also avoids generating an error. In such cases, OMS will provide a response with a status code of 202 ACCEPTED.

The response body will not include any additional objects or messages.

These situations include:

  • When the order item does not exist.
  • When a refund is disallowed due to the order being in an invalid state.
  • When partial cancellation is not allowed for the package.

Example Response (406 NOT ACCEPTABLE)

If the package does not meet the criteria for cancellation or refund, OMS will respond with a status code of 406 NOT ACCEPTABLE.

The response body will include a message similar to the following:

{
"error": {
"non_field_errors": "Cancellation is not allowed for this order item",
"error_code": "order_100_123"
},
"status_code": 406
}