Order Cancel Flow
The Order Cancel Flow facilitates the processing of order cancellation plans within Omnitron. The flow retrieves a list of cancellation plans that match a specific cancellation plan status configured by the user in the flow settings. The flow operates only in an inbound mode.
Inbound order cancel flow means that the flow triggers itself at specific intervals set by the user, such as once every minute, every 1 hour, every day at midnight, every 5th day of a month, etc., to fetch eligible cancellation plans from Omnitron. It processes these plans based on the configured cancellation plan status, ensuring the correct actions are taken for each plan.
This process ensures reliable and efficient handling of order cancellations within the system, maintaining consistency and accuracy for cancellation data in Omnitron.
Order Cancel Flow Types
Inbound Flow: Indicates that the flow will read data from the Omnitron. A cron schedule is set up to ensure it runs, for example, every 5 minutes.
Example data structure for an order object and its related items can be found at the end of this document under the Example Order Cancel Data Structure from Omnitron section.
Flow Steps
Login Step: Handles logging into Omnitron and (if configured) the ERP system. If an error occurs during this step, the details are logged.
Get Data From Omnitron Step: Queries are made to the Omnitron system to fetch cancellation plans matching the user-defined cancellation plan status, cancellation plan type and channel filters.
Script Step (Optional): Transformation operations on each cancellation plan object are performed using Python, if required.
Mapping Step (Optional): Transformation operations on each cancellation plan object are performed using the Jolt Transform library. Further details can be found at the Jolt Transform website.
Write Data to ERP Step: The transformed cancellation plan information is sent to the ERP system.
Custom Response Script Step: The Write Data to ERP step's input data and the ERP response for each cancellation plan are provided to a Python script one by one to check if ERP requests are successful, extra data such as sales channel of the cancellation plan or how many rejected cancellation plans does the order have etc. are provided via attributes.
Write Data to Omnitron Step: For each successfully processed cancellation plan, the relevant updates are made in Omnitron based on the result of the Write Data to ERP Step.
Post Script Step: Runs after the Write Data to Omnitron Step if every prior step is successful.
Detailed Flow Designer Settings
Configuration Card

Omnitron API Settings
Domain URL: Omnitron's domain URL, Example: https://demo.omnitron.akinon.net/.
Get Data From Omnitron
This step works with Omnitron Cancellation Plan objects. Omnitron is queried for cancellation plans matching settings in this step.

Channel Type: Specify the type of channel from which cancellation plans should be fetched. This field is required to filter the cancellation plans by the appropriate channel type.
Cancel Type: Select the type of cancellation plan to retrieve from Omnitron. Options include:
Cancel: Fetch only cancellations.
Refund: Fetch only refunds.
All: Fetch both cancellations and refunds.
Cancel Status: Select the status of the cancellation plans to fetch from Omnitron. Options include:
Waiting: Fetch cancellation plans that are awaiting processing.
Confirmed: Fetch cancellation plans that have been confirmed.
Completed: Fetch cancellation plans that have been fully processed. (completed type cancel status task runs with modified date filter changing based on last query time, as a result failed executions can not be retried automatically)
Confirmation Waiting: Fetch cancellation plans awaiting confirmation.
Order Transaction: Fetch cancellation plans associated with specific ‘return’ type Omnitron payment transactions which have no integration mapping value. For successful jobs, an omnitron integration mapping is created marking the successful delivery. All cancellation plans retrieved with this option are also considered “completed”. This option can substitute the “Completed” status for delivering fully processed cancellation plans on sales channels where Omnitron manages return transactions. When used instead of the “completed” option, cancellation plans that couldn’t be delivered to ERP by any failure can be automatically retried in the next execution, unlike the “completed” option.
Channel ID: Enter the IDs of the channels from which to fetch cancellation plans. If specifying multiple channel IDs, separate them with commas (e.g., 1,2,3). This field is, optionally, used to narrow the scope of the data to specific channels when left empty the flow will run for all omnitron channels. Channel id’s can be retrieved from Omnitron, Sales Channels screens.
Based on the above settings following query strings are used:
If cancel status is set as Waiting, Confirmed, Completed or Confirmation Waiting:
If cancel status is set as Order Transaction:
For Order Transaction type flows the above query is used for listing cancellation plans after listing orders for each order transaction a query is made to /api/v1/cancellation_plans to fetch related cancellation plan data.
Script Card (Optional)
This is a base script that can be updated to enable script functionality within the process step.
Scripts can read incoming data from the inputStream, where the variable input_text contains a JSON string. This string should be parsed using Python's json library. Any outgoing data is written using the outputStream.write() method after converting the relevant Python object back into a JSON string.
Additionally, the script allows for the use of attributes, which provide supplementary information tied to the current execution process. These attributes can be freely accessed or modified throughout the script. For example, the get_attribute() function is used to read attribute values, while the session.putAttribute() method is used to write new string attribute values. Each attribute consists of a key-value pair, where the key uniquely identifies the attribute, and the value can be referenced in subsequent steps.
Attributes with keys starting with the prefix log.will be automatically logged at the end of the execution if a log file is generated, ensuring that important information is captured and available for later review.

Example Script:
Script Testing: The ERP response is placed in the input field, and the script's result along with the written attributes can be viewed in the result field. When the test script is run, attributes like log.script.error will appear under the "attributes" section in the result panel and should be referenced if any exceptions occur during execution. The script's output content will be found under the result_data value.
The “+ Add Attributes” button can be used to simulate incoming, readable, attributes for the script. This feature is useful when an attribute value is read and used in the script. Note that attributes added through the button are only for testing purposes and will not be saved in the flow information—they will be removed when the page is refreshed.
Example Input: Example input can be constructed using the endpoints written in Read Data From Omnitron, the input will be a cancellation plan object, not an array of objects.
Mapping Card (Optional)

Details can be found at the Jolt Transform website. The flow expects the following output to be a cancellation request object for each order, as the input will also be a cancellation plan of one order. Integrator uses the output of this mapping step as the body of the ERP request, therefore there is no expected data structure; the output structure of the mapping step is fully dependent on ERP requirements.
Mapping Testing: The result from the script or the response of the Omnitron request for cancellation plan data, if the script step is not used, is placed in the input field and the result of the mapping is viewed in the result field.
Write Data to Omnitron
The finalized data from Script and/or Mapping steps is sent to ERP using configuration entered in this step. A successful request must respond with 2xx HTTP status codes.
Next State: Select the next status for the cancellation or refund after it has been successfully reported to the ERP system. Options include:
Approved: Mark the cancellation or refund as approved.
Confirmation Waiting: Set the status to indicate it is awaiting confirmation.
Completed: Mark the cancellation or refund as fully processed.
Confirmed: Mark the cancellation or refund as confirmed.
For flows with "order_transaction" or "completed" cancellation statuses (set in Read Data From Omnitron card), the "Next State" setting is ignored.
Cancellation API URL: Provide the URL endpoint for the ERP system's cancellation API. This URL will be used to send cancellation or refund requests to the ERP system.
HTTP Method: Specify the HTTP method to use for communicating with the ERP system. Options include:
POST: Send the data using the POST method.
GET: Update data using the GET method.
PUT: Send data using the PUT method.
PATCH: Send data using the PATCH method.
Custom Response Setting: Choose whether to enable custom response handling.
True: Enable custom scripting for handling responses from the ERP system.
False: Disable custom response handling, using default behavior instead.
Custom Response Script
The Custom Response Script is a user-configurable template designed to process and evaluate the ERP system's response for each cancellation or refund request. It provides flexibility for users to customize the logic based on their specific requirements while maintaining default functionality. Below is the default script provided as a template in the flow and a description of its core features and customizable aspects:
The script retrieves the ERP response status code (
invokehttp.status.code) to evaluate the result of the request.The
relationattribute is added to the FlowFile to indicate the next action.Relation Definitions:
continue: The cancellation or refund will proceed with the next state (e.g., approved or confirmation waiting).failure: The cancellation or refund is marked as rejected and will not proceed.do_nothing: The cancellation or refund will not be further processed in this batch and will be retried later, except for “completed” status tasks.auth_fail: Indicates an authorization failure, prompting a new token request and retry.
Default Attributes Available For Use:
invokehttp.status.code: ERP HTTP status code.channel_type: The channel associated with the request (if applicable).rejected_count: Tracks how many rejected cancellation plans the current order has.
Output:
relationattribute must be added to flowFile.The FlowFile is transferred to the appropriate relationship (
REL_SUCCESSorREL_FAILURE) based on the processing outcome.
If the ERP request is successful and the custom response script result is "continue," Entegrator will automatically update the Omnitron order by using different API endpoints, depending on the "Next State" settings:
Approved:
/api/v1/orders/{order_pk}/cancellation_approved_order/Conformation Waiting or Confirmed:
/api/v1/cancellation_plans/{cancellation.pk}/update_status/Order Transaction:
/api/v1/order_transactions/{order_transaction.pk}/create_mapping/
Post Script (Optional)

This script runs with the “request_data” and “response_data” from the ERP write request after the Write Data to Omnitron step, if the Write Data to ERP step is successful and the cancellation is approved.
This script is optional, and its output is not used. It can be used for additional tasks after the order is updated in Omnitron, such as updating CRM services or performing other actions.
Example Order Cancel Data Structure from Omnitron
pk
integer
1
Primary key of the cancellation record
invoice_number
string / null
null
Invoice number related to the order
order_previous_status
string
400
Previous status of the order
Uses status value mapping
shipping_refund_amount
string / decimal
0.00
Refunded shipping amount
refund_amount
string / decimal
1905.84
Total refunded amount
discount_refund_amount
string / decimal
0.00
Refunded discount amount
status
string
completed
Current cancellation status
product
object
Current cancellation status
plan_type
string
cancel
Type of plan applied
cancellationplanorderitem_set
array of order item objects
List of order items included in the cancellation plan
created_date
string
2023-02-07T08:35:33.526498Z
Record creation date
ISO-8601 format
retail_store_remote_id
string / null
null
External retail store identifier
staff_remote_id
string / null
null
External staff identifier
created_by
object
{ pk: 12, username: mp_test_user }
User who created the record
System user object
modified_date
string
2023-02-07T08:35:33.972173Z
Last modification date
ISO-8601 format
last_updated_by
object
{ pk: 12, username: mp_test_user }
User who last updated the record
System user object
payment_plan
object
{ }
Payment plan information
Empty if not applicable
modified_by_id
integer
12
ID of the user who last modified the record
Order Object
pk
integer
3
Primary key of the order
number
string
429452907
Order number
channel
integer
2
Sales channel identifier
status
string
100
Order status
Uses status value mapping
date_placed
string
2023-02-06T17:34:11.867000Z
Date when the order was placed
ISO-8601 format
customer
integer
1
Customer identifier
shipping_address
integer
2
Shipping address identifier
billing_address
integer
2
Billing address identifier
currency
string
try
Currency code
ISO 4217
amount
string / decimal
1905.84
Total order amount including taxes
shipping_amount
string / decimal
0.00
Shipping cost
shipping_tax_rate
string / decimal
0.00
Tax rate applied to shipping
extra_field
object
{ }
Additional custom fields
Optional
payment_option
object / null
null
Payment option details
payment_option_slug
string / null
null
Payment option identifier
bin_number
string / null
null
Card BIN number
installment
integer / null
null
Installment option
installment_count
integer / null
null
Number of installments
delivery_type
string / null
null
Delivery type
installment_interest_amount
string / decimal
0.00
Interest amount applied due to installment
cargo_company
integer
2
Cargo / shipping company identifier
invoice_number
string / null
null
Invoice number
invoice_date
string / null
null
Invoice date
ISO-8601 if present
e_archive_url
string
https://example.earchive.url
E-archive invoice URL
refund_amount
string / decimal
1905.84
Total refunded amount
discount_refund_amount
string / decimal
0.00
Refunded discount amount
shipping_refund_amount
string / decimal
0.00
Refunded shipping amount
discount_amount
string / decimal
0.00
Discount applied to the order
is_send
boolean
false
Indicates whether the order was sent
net_shipping_amount
string / decimal
0.00
Net shipping amount
shipping_interest_amount
string / decimal
0.00
Interest amount related to shipping
tracking_number
string
7260000009966030
Shipping tracking number
carrier_shipping_code
string
Carrier-specific shipping code
Can be empty
remote_addr
string / null
null
Client IP address
fundstransfertransaction_set
array [object]
[]
Funds transfer transactions
has_gift_box
boolean
false
Indicates if gift box is included
gift_box_note
string
Gift box note
Optional
external_status
string / null
null
External system order status
client_type
string
default
Client type
language_code
string
Language code
notes
string
Internal notes
delivery_range
string / null
null
Delivery time range
shipping_option_slug
string
Shipping option identifier
segment
string / null
null
Customer or order segment
modified_date
string
2023-02-07T08:35:33.982189Z
Last modification date
ISO-8601 format
checkout_provider_id
string / null
null
Checkout provider identifier
created_date
string
2023-02-07T07:04:10.600994Z
Order creation date
ISO-8601 format
cancellation_info
object
{ }
Cancellation-related information
shipping_company
string / null
null
Shipping company name
cancel_status
string / null
null
Cancellation status
defined_tracking_url
string / null
null
Predefined tracking URL
installment_free
boolean
false
Indicates if installment is interest-free
first_refund_strategy
string / null
null
Strategy used for the first refund
Cancellation Plan Order Item Object
pk
integer
1
Primary key of the cancellation plan order item
order_item
object
{...}
Related order item object
Order item reference
order_item_previous_status
string
400
Previous status of the order item
Uses order item status mapping
status
string
100
Current cancellation status
Uses cancellation status mapping
modified_date
string
2023-02-07T08:35:33.531740Z
Last modification date
ISO-8601 format
Reason Object
pk
integer
1
Primary key of the cancellation reason
cancellation_type
string
cancel
Type of cancellation (refund/cancel)
extra_information_needed
boolean
false
Indicates whether extra information is required
order
integer
100
Order status
Context-dependent
subject
string
Yanlış ürün aldım.
Cancellation reason description
is_active
boolean
true
Indicates if the reason is active
send_to_remote
boolean
false
Indicates if the reason should be sent to remote systems
modified_date
string
2022-11-23T07:51:22.698626Z
Last modification date
ISO-8601 format
created_date
string
2022-11-23T07:51:22.534643Z
Creation date
ISO-8601 format
translations
object / null
null
Translation values for the subject
uuid
string (UUID)
3d32baeb-69a2-4e9e-ad6f-d58027c22bef
Unique identifier
send_to_oms
boolean
false
Last updated
Was this helpful?

