protected function createPartialPayment($amount, $status, $write = true)
    {
        /** @var Payment $payment */
        $payment = Payment::create(array(
            'Gateway' => $this->payment->Gateway,
            'TransactionReference' => $this->payment->TransactionReference,
            'SuccessUrl' => $this->payment->SuccessUrl,
            'FailureUrl' => $this->payment->FailureUrl,
            'InitialPaymentID' => $this->payment->ID
        ));

        $payment->setCurrency($this->payment->getCurrency());
        $payment->setAmount($amount);

        // set status later, because otherwise amount and currency become immutable
        $payment->Status = $status;

        // allow extensions to update/modify the partial payment
        ErrorHandling::safeExtend($this, 'updatePartialPayment', $payment, $this->payment);

        if ($write) {
            ErrorHandling::safeguard(function () use (&$payment) {
                $payment->write();
            }, 'Unable to write newly created partial Payment!');
        }

        return $payment;
    }