private void updateOrder(Order order, ResponseOrError<Payment> molliePayment) {
    // Insert the Mollie ID for future reference
    order.setReference(molliePayment.getData().getId());
    order.setStatus(OrderStatus.WAITING);

    // Save the changes to the order
    orderRepository.save(order);
  }
  @Override
  public Order updateStatus(String orderReference) {
    Order order =
        orderRepository
            .findByReference(orderReference)
            .orElseThrow(
                () ->
                    new OrderNotFoundException(
                        "Order with reference " + orderReference + " not found"));

    // This try is for the Mollie API internal HttpClient
    try {
      // Request a payment from Mollie
      ResponseOrError<Payment> molliePaymentStatus = mollie.payments().get(orderReference);
      //            ResponseOrError<PaymentStatus> molliePaymentStatus =
      // mollie.getPaymentStatus(apiKey,
      // orderReference);

      // If the request was a success, we can update the order
      if (molliePaymentStatus.getSuccess()) {
        // There are a couple of possible statuses. Enum would have been nice. We select a couple of
        // relevant
        // statuses to translate to our own status.
        switch (molliePaymentStatus.getData().getStatus()) {
          case "pending":
            {
              order.setStatus(OrderStatus.WAITING);
              break;
            }
          case "cancelled":
            {
              order.setStatus(OrderStatus.CANCELLED);
              break;
            }
          case "expired":
            {
              order.setStatus(OrderStatus.EXPIRED);
              break;
            }
          case "paid":
            {
              order.setStatus(OrderStatus.PAID);
              break;
            }
          case "paidout":
            {
              order.setStatus(OrderStatus.PAID);
              break;
            }
        }
        return orderRepository.save(order);
      } else {
        // Order status could not be updated for some reason. Return the original order
        handleMollieError(molliePaymentStatus);
        return order;
      }
    } catch (IOException e) {
      // This indicates the HttpClient encountered some error
      throw new PaymentServiceConnectionException(e.getMessage());
    }
  }