Is 'order completed' a safe way to assume that order is paid in full? I am working on a client's site. I have a requirement that when a user buys a product, a specific role should be assigned to the user.
For this, I have used 'business rules' module.
Business Rules
Reacts on event: After updating Entity
Target Entity Type: Order
Target Bundle: Default
Condition
Type: Data Comparison
Target Entity Type: Order
Target Bundle: Default
Field: state: State[state]
Data to compare: Current value
Operator: =
Value to compare: completed
Items to execute if condition succeed
Action: Add 'One year subscriber' role to user
My question is, Is this the correct way to identify that the product is purchased and order is paid in full?
That is, if order status is completed then is it safe to assume that the product is purchased and order is paid in full?
No. As with Commerce 1.x, we have a specific event in Commerce 2.x that is only triggered the first time an order is observed to be paid in full. It's defined in OrderEvents.php:
  /**
   * Name of the event fired after the order has been fully paid.
   *
   * Guaranteed to only fire once, when the order balance reaches zero.
   * Subsequent changes to the balance won't redispatch the event (e.g. in case
   * of a refund followed by an additional payment).
   *
   * Fired before the order is saved.
   *
   * @Event
   *
   * @see \Drupal\commerce_order\OrderInterface::getBalance()
   * @see \Drupal\commerce_order\Event\OrderEvent
   */
  const ORDER_PAID = 'commerce_order.order.paid';