private function generateShippingOptions(array $shipping_options) {
      $response = [];
      $option_index = 1;

      foreach ($shipping_options as $option => $prices) {
        array_push($response, ['id' => strval($option_index), 'title' => $option, 'prices' => []]);

        // Register prices for the specific shipping option
        foreach ($prices as $service => $price) {
          if ($price < 0) {
            throw new Exception('Invalid negative price passed to "answerShippingQuery"');
          }

          $formatted_price = intval($price * 100);

          // Selects the most recent shipping option pushed into the array.
          array_push($response[$option_index - 1]['prices'], [
            'label' => $service, 'amount' => $formatted_price
          ]);
        }

        $option_index++;
      }

      return json_encode($response);
    }