completedOrder method

void completedOrder(
  1. String orderId
)

Implementation

void completedOrder(String orderId) {
  final order = orderRepository.findById(orderId);

  order.complete();

  loyaltyPort.addPoints(
    customerId: order.customerId,
    orderId: orderId,
    orderAmount: _calculateOrderAmount(order),
  );

  order.markLoyaltyApplied();
  orderRepository.update(order);
}