# Cancellation Strategies

A total of **19 distinct cancellation and return strategies** designed to handle different scenarios of order cancellation, refund, and ERP integration. Each strategy defines specific rules regarding how shipping fees, discounts, payments, and ERP reporting are managed, ensuring that cancellations and returns comply with both business requirements and operational constraints.

The **selected strategy** is determined by its **strategy ID**, which must be created or updated by sending a `POST` request to the endpoint:

```bash
api/v1/dynamic_settings
```

The dynamic setting for cancellation strategy has the following structure:

```json
{
    "key": "CANCELLATION_STRATEGY",
    "description": null,
    "default": "StrategyOne",
    "validators": []
}
```

* **key**: `"CANCELLATION_STRATEGY"` — the identifier for the cancellation strategy setting.
* **default**: `"StrategyOne"` — by default, the system uses **Strategy 1** unless explicitly configured otherwise.
* **validators**: An optional array of validation rules for the setting.

## <mark style="color:red;">**Strategy 1**</mark> <a href="#strategy-1" id="strategy-1"></a>

The StrategyOne class inherits from the **CancellationStrategy** class, with the following rules:

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* If the `cancellation_type` of the order is `refund`, it cannot be sent to ERP. In other cases, it can be sent.
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is `payment_waiting`, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True)`.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 2**</mark> <a href="#strategy-2" id="strategy-2"></a>

The StrategyTwo class inherits from StrategyOne, with the following rules. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">Can be sent to ERP.</mark>
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is `payment_waiting`, it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 3**</mark> <a href="#strategy-3" id="strategy-3"></a>

The StrategyThree class inherits from StrategyOne, with the following rules. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* <mark style="color:blue;">If the</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">of the order is</mark> <mark style="color:blue;">`cancel`</mark><mark style="color:blue;">, the shipping fee can be refunded. If it is</mark> <mark style="color:blue;">`refund`</mark><mark style="color:blue;">, the shipping fee cannot be refunded.</mark>
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">Cannot be sent to ERP.</mark>
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is payment\_waiting, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 4**</mark> <a href="#strategy-4" id="strategy-4"></a>

The StrategyFour class inherits from StrategyOne and follows the rules listed below. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">If the order’s</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">is</mark> <mark style="color:blue;">`cancel`</mark><mark style="color:blue;">, it can be sent to ERP; if</mark> <mark style="color:blue;">`refund`</mark><mark style="color:blue;">, it cannot be sent to ERP.</mark>
* <mark style="color:blue;">Payments cannot be refunded.</mark>
* Orders that are not reported to ERP can be canceled if the order status is payment\_waiting, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 5**</mark> <a href="#strategy-5" id="strategy-5"></a>

The StrategyFive class inherits from StrategyOne and follows the rules listed below. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* <mark style="color:blue;">If the order’s cancellation\_type is ‘cancel’, the shipping cost can be refunded; if it is ‘refund’, the shipping cost cannot be refunded.</mark>
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">Cannot be sent to ERP.</mark>
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is payment\_waiting, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 6**</mark> <a href="#strategy-6" id="strategy-6"></a>

The StrategySix class inherits from StrategyOne and follows the rules listed below. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* <mark style="color:blue;">If the order’s cancellation\_type is ‘cancel’, the shipping cost can be refunded; if it is ‘refund’, the shipping cost cannot be refunded.</mark>
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* If the `cancellation_type` of the order is `refund`, it cannot be sent to ERP. In other cases, it can be sent.
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is payment\_waiting, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 7**</mark> <a href="#strategy-7" id="strategy-7"></a>

The StrategySeven class inherits from StrategyTwo and follows the rules listed below. The rules that differ from **StrategyTwo** are highlighted in <mark style="color:blue;">blue</mark>.

* <mark style="color:blue;">If the order’s</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">is</mark> <mark style="color:blue;">`cancel`</mark><mark style="color:blue;">, the shipping cost can be refunded; if it is</mark> <mark style="color:blue;">`refund`</mark><mark style="color:blue;">, the shipping cost cannot be refunded.</mark>
* Discounts can be refunded.
* <mark style="color:blue;">If the order’s</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">is</mark> <mark style="color:blue;">`cancel`</mark> <mark style="color:blue;">and the order has not been delivered, or if the</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">is</mark> <mark style="color:blue;">`refund`</mark> <mark style="color:blue;">and the order has not been delivered, partial cancellation is not allowed. In other cases, partial cancellation is allowed.</mark>
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">If the</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">of the order is</mark> <mark style="color:blue;">`refund`</mark><mark style="color:blue;">, it cannot be sent to ERP. In other cases, it can be sent.</mark>
* Payments can be refunded.
* <mark style="color:blue;">Orders that are not reported to ERP can be canceled if the order status is</mark> <mark style="color:blue;">`payment_waiting`</mark> <mark style="color:blue;">or</mark> <mark style="color:blue;">`confirmation_waiting`</mark><mark style="color:blue;">, or it cannot be sent to ERP (</mark><mark style="color:blue;">`can_be_sent_to_erp=False`</mark><mark style="color:blue;">), or if the order has already been sent to ERP (</mark><mark style="color:blue;">`is_send=True`</mark><mark style="color:blue;">).</mark>
* <mark style="color:blue;">It creates a plan using the PaymentPlanStrategyTwo class.</mark>
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 8**</mark> <a href="#strategy-8" id="strategy-8"></a>

The StrategyEight class inherits from StrategyOne and follows the rules listed below. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">If the</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">of the order is</mark> <mark style="color:blue;">`cancel`</mark><mark style="color:blue;">, it cannot be sent to ERP. In other cases, it can be sent.</mark>
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is payment\_waiting, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 9**</mark> <a href="#strategy-9" id="strategy-9"></a>

The StrategyNine class inherits from StrategyOne and follows the rules listed below. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">Cannot be sent to ERP.</mark>
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is payment\_waiting, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 10**</mark> <a href="#strategy-10" id="strategy-10"></a>

The StrategyTen class inherits from StrategyEight and follows the rules listed below. The rules that differ from **StrategyEight** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* <mark style="color:blue;">If there are order items, and any item's status is other than</mark> <mark style="color:blue;">`approved`</mark><mark style="color:blue;">, and the</mark> <mark style="color:blue;">**cancellation\_type**</mark> <mark style="color:blue;">is</mark> <mark style="color:blue;">`cancel`</mark><mark style="color:blue;">, partial cancellation is not allowed. In other cases, partial cancellations can be made.</mark>
* Shipping fees are not divided per item.
* All items are refundable.
* If the `cancellation_type` of the order is `cancel`, it cannot be sent to ERP. In other cases, it can be sent.
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is `payment_waiting`, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 11**</mark> <a href="#strategy-11" id="strategy-11"></a>

The StrategyEleven class inherits from StrategyOne and follows the rules listed below. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* If the `cancellation_type` of the order is `refund`, it cannot be sent to ERP. In other cases, it can be sent.
* <mark style="color:blue;">Payments cannot be refunded.</mark>
* <mark style="color:blue;">Cancellations can be performed on orders not reported to ERP.</mark>
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 12**</mark> <a href="#strategy-12" id="strategy-12"></a>

The StrategyTwelve class inherits from StrategyOne and follows the rules listed below. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* If the `cancellation_type` of the order is `refund`, it cannot be sent to ERP. In other cases, it can be sent.
* Payments can be refunded.
* <mark style="color:blue;">Orders that are not reported to ERP can always be canceled.</mark>\ <mark style="color:blue;">In other cases:</mark>
  * <mark style="color:blue;">If the order status is</mark> <mark style="color:blue;">`payment_waiting`</mark><mark style="color:blue;">, or</mark>
  * <mark style="color:blue;">If the order cannot be sent to ERP (</mark><mark style="color:blue;">`can_be_sent_to_erp=False`</mark><mark style="color:blue;">), or</mark>
  * <mark style="color:blue;">If the order has already been sent to ERP (</mark><mark style="color:blue;">`is_send=True`</mark><mark style="color:blue;">),</mark>
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 13**</mark> <a href="#strategy-13" id="strategy-13"></a>

The StrategyThirteen class inherits from StrategyTwo, with the following rules. The rules that differ from **StrategyTwo** are highlighted in <mark style="color:blue;">blue</mark>.

* <mark style="color:blue;">Shipping fees cannot be refunded.</mark>
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* Can be sent to ERP.
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is `payment_waiting`, it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (i`s_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 14**</mark> <a href="#strategy-14" id="strategy-14"></a>

The StrategyFourteen class inherits from StrategyTwo, with the following rules. The rules that differ from **StrategyTwo** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* <mark style="color:blue;">If the</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">is</mark> <mark style="color:blue;">`cancel`</mark><mark style="color:blue;">, partial cancellation is not allowed. In other cases, partial cancellations can be made.</mark>
* Shipping fees are not divided per item.
* All items are refundable.
* Can be sent to ERP.
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is payment\_waiting, it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 15**</mark> <a href="#strategy-15" id="strategy-15"></a>

The StrategyFifteen class inherits from StrategyTwelve and follows the rules listed below. The rules that differ from **StrategyTwelve** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">It can be sent to ERP.</mark>
* Payments can be refunded.
* Orders that are not reported to ERP can be canceled if the order status is payment\_waiting, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the **cancellation\_type** is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 16**</mark> <a href="#strategy-16" id="strategy-16"></a>

The StrategySixteen class inherits from StrategyTwo, with the following rules. The rules that differ from **StrategyTwo** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel` or `refund`, the shipping fee can be refunded. In other cases, it raises a `NotImplementedError`.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* Can be sent to ERP.
* Payments are refundable except for cash-on-delivery refund scenarios.
* <mark style="color:blue;">The scenarios for canceling orders that have not been reported to the ERP are as follows:</mark>
  * <mark style="color:blue;">If the order's</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">is</mark> <mark style="color:blue;">`cancel`</mark><mark style="color:blue;">, all orders can be canceled.</mark>
  * <mark style="color:blue;">If the order's</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">is</mark> <mark style="color:blue;">`refund`</mark><mark style="color:blue;">:</mark>
    * <mark style="color:blue;">If the order's status is</mark> <mark style="color:blue;">`payment_waiting`</mark><mark style="color:blue;">, or if it cannot be sent to ERP (</mark><mark style="color:blue;">`can_be_sent_to_erp=False`</mark><mark style="color:blue;">), or if the order has been sent to ERP (</mark><mark style="color:blue;">`is_send=True`</mark><mark style="color:blue;">), it can be canceled.</mark>
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 17**</mark> <a href="#strategy-17" id="strategy-17"></a>

The StrategySeventeen class inherits from StrategyThree, with the following rules. The rules that differ from **StrategyThree** are highlighted in <mark style="color:blue;">blue</mark>.

* If the `cancellation_type` of the order is `cancel`, the shipping fee can be refunded. If it is `refund`, the shipping fee cannot be refunded.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* Cannot be sent to ERP.
* Payments can be refunded.
* <mark style="color:blue;">Orders that have not been reported to the ERP cannot be canceled.</mark>
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 18**</mark> <a href="#strategy-18" id="strategy-18"></a>

The StrategyEighteen class inherits from StrategySix and follows the rules listed below. The rules that differ from **StrategySix** are highlighted in <mark style="color:blue;">blue</mark>.

* If the order’s `cancellation_type` is `cancel`, the shipping cost can be refunded; if it is `refund`, the shipping cost cannot be refunded.
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">It can be sent to ERP.</mark>
* <mark style="color:blue;">Payments cannot be refunded.</mark>
* Orders that are not reported to ERP can be canceled if the order status is payment\_waiting, or it cannot be sent to ERP (`can_be_sent_to_erp=False`), or if the order has already been sent to ERP (`is_send=True`).
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## <mark style="color:red;">**Strategy 19**</mark>

The StrategyNineteen class inherits from StrategyOne and follows the rules listed below. The rules that differ from **StrategyOne** are highlighted in <mark style="color:blue;">blue</mark>.

* <mark style="color:blue;">If the order's</mark> <mark style="color:blue;">`cancellation_type`</mark> <mark style="color:blue;">is</mark> <mark style="color:blue;">`cancel`</mark><mark style="color:blue;">, shipping can be refunded. If it is</mark> <mark style="color:blue;">`refund`</mark><mark style="color:blue;">, shipping cannot be refunded.</mark>
* Discounts can be refunded.
* Partial cancellations are allowed.
* Shipping fees are not divided per item.
* All items are refundable.
* <mark style="color:blue;">It can be sent to ERP.</mark>
* Payments can be refunded.
* <mark style="color:blue;">Orders that have not been reported to the ERP cannot be canceled.</mark>
* It creates a plan using the PaymentPlanStrategyOne class.
* For cash-on-delivery orders, if the `cancellation_type` is `cancel`, the `payment_option_fee` can be refunded.

## **Comparison of Strategies** <a href="#comparison-of-strategies" id="comparison-of-strategies"></a>

The comparison of cancellation strategies based on their features is provided in the table below.

<figure><img src="https://2911598027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlQinVPnOffBiOp126ldR%2Fuploads%2Fgit-blob-88c20582d591594ba210412ecf38487f48391bd8%2Funknown.png?alt=media" alt=""><figcaption></figcaption></figure>
