account = $account; $result->painMessage = $painMessage; $result->xmlSchema = $match[1]; $result->allowConversionToSEPATransfer = $allowConversionToSEPATransfer; return $result; } /** * @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023 */ public function serialize(): string { return serialize($this->__serialize()); } public function __serialize(): array { return [ parent::__serialize(), $this->account, $this->painMessage, $this->xmlSchema, $this->allowConversionToSEPATransfer, ]; } /** * @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023 * * @param string $serialized * @return void */ public function unserialize($serialized) { self::__unserialize(unserialize($serialized)); } public function __unserialize(array $serialized): void { list( $parentSerialized, $this->account, $this->painMessage, $this->xmlSchema, $this->allowConversionToSEPATransfer, ) = $serialized; is_array($parentSerialized) ? parent::__unserialize($parentSerialized) : parent::unserialize($parentSerialized); } 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; } 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'); } } }