account = $account; $result->painMessage = $painMessage; $result->xmlSchema = $match[1]; $result->allowConversionToSEPATransfer = $allowConversionToSEPATransfer; return $result; } /** {@inheritdoc} */ protected function createRequest(BPD $bpd, ?UPD $upd) { /** @var HIIPZSv1|HIIPZSv2 $hiipzs */ $hiipzs = $bpd->requireLatestSupportedParameters('HIIPZS'); $supportedSchemas = $hiipzs->parameter->getUnterstuetzteSEPADatenformate(); // If there are no SEPA formats available in the HIIPZS Parameters, we look to the general formats if (is_null($supportedSchemas)) { /** @var HISPAS $hispas */ $hispas = $bpd->requireLatestSupportedParameters('HISPAS'); $supportedSchemas = $hispas->getParameter()->getUnterstuetzteSEPADatenformate(); } // Sometimes the Bank reports supported schemas with a "_GBIC_X" postfix. // GIBC_X stands for German Banking Industry Committee and a version counter. $xmlSchema = $this->xmlSchema; $matchingSchemas = array_filter($supportedSchemas, function($value) use ($xmlSchema) { // For example urn:iso:std:iso:20022:tech:xsd:pain.001.001.09 from the xml matches // urn:iso:std:iso:20022:tech:xsd:pain.001.001.09_GBIC_4 return str_starts_with($value, $xmlSchema); }); if (count($matchingSchemas) === 0) { throw new UnsupportedException("The bank does not support the XML schema $this->xmlSchema, but only " . implode(', ', $supportedSchemas)); } /** @var HKIPZv1|HKIPZv2 $hkipz */ $hkipz = $hiipzs->createRequestSegment(); $hkipz->kontoverbindungInternational = Kti::fromAccount($this->account); $hkipz->sepaDescriptor = $this->xmlSchema; $hkipz->sepaPainMessage = new Bin($this->painMessage); if ($hiipzs instanceof HIIPZSv2) { $hkipz->umwandlungNachSEPAUeberweisungZulaessig = $hiipzs->parameter->umwandlungNachSEPAUeberweisungZulaessigErlaubt && $this->allowConversionToSEPATransfer; } return $hkipz; } /** {@inheritdoc} */ public function processResponse(Message $response) { parent::processResponse($response); // Was the instant payment converted to a regular transfer? $info = $response->findRueckmeldungen(3270); if (count($info) > 0) { $this->successMessage = implode("\n", array_map(function (Rueckmeldung $rueckmeldung) { return $rueckmeldung->rueckmeldungstext; }, $info)); return; } if ($response->findRueckmeldung(Rueckmeldungscode::ENTGEGENGENOMMEN) === null && $response->findRueckmeldung(Rueckmeldungscode::AUSGEFUEHRT) === null) { throw new UnexpectedResponseException('Bank did not confirm SEPATransfer execution'); } } }