protected function doCreateIndependentCredit(PaymentInstructionInterface $instruction, $amount)
 {
     if (PaymentInstructionInterface::STATE_VALID !== $instruction->getState()) {
         throw new InvalidPaymentInstructionException('PaymentInstruction\'s state must be VALID.');
     }
     return $this->buildCredit($instruction, $amount);
 }
 protected function onUnsuccessfulPaymentInstructionValidation(PaymentInstructionInterface $instruction, PluginInvalidPaymentInstructionException $invalid)
 {
     $oldState = $instruction->getState();
     $instruction->setState(PaymentInstructionInterface::STATE_INVALID);
     $this->dispatchPaymentInstructionStateChange($instruction, $oldState);
     $result = $this->buildPaymentInstructionResult($instruction, Result::STATUS_FAILED, PluginInterface::REASON_CODE_INVALID);
     $result->setPluginException($invalid);
     return $result;
 }