public function listPayments(Payplug\Payplug $payplug = null)
    {
        if ($payplug === null) {
            $payplug = Payplug\Payplug::getDefaultConfiguration();
        }

        if (!array_key_exists('id', $this->getAttributes())) {
            throw new Payplug\Exception\UndefinedAttributeException(
                "This installment plan object has no id. You can't list payments on it.");
        }
        $httpClient = new Payplug\Core\HttpClient($payplug);
        $response = $httpClient->get(
            Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::INSTALLMENT_PLAN_RESOURCE, $this->id)
        );

        $payments = array();
        foreach ($response['httpResponse']['schedule'] as $schedule) {
            foreach ($schedule['payment_ids'] as $payment_id) {
                $payments[$payment_id] = Payment::retrieve($payment_id, $payplug);
            }
        }

        return $payments;

    }