Fix: Add missing control sum (Summenfeld) to HKCCM/HKCME for SEPA batch transfers#560
Conversation
…ch transfers When initiating a SEPA batch transfer (Sammelüberweisung) using the HKCCM or HKCME segments, some strict bank servers (e.g., Atruvia data centers for Volksbanken/Raiffeisenbanken) reject the request with the error: HIRMS:5:2:3+9010::Summenfeld nicht vorhanden. While some banks parse the total sum directly from the PAIN XML payload, others strictly enforce the HBCI specification, which requires the control sum to be explicitly declared in the segment parameters (e.g., HKCCM:3:1+...). Currently, SendSEPATransfer leaves this field empty. Changes made: Updated SendSEPATransfer::createRequest() to extract the <CtrlSum> from the provided PAIN XML (GrpHdr). Initialized the $segment->summenfeld property using \Fhp\Segment\Common\Btg::create().
Removed an extra blank line to comply with the project's coding standards.
|
Issue #558 |
|
One of my clients - an Atruvia credit institution user - reports that the patch works |
|
Sounds and looks good to me, any comments? |
Philipp91
left a comment
There was a problem hiding this comment.
Looks good in general, just two minor comments.
| // Fix for strict banks (e.g. Atruvia): Extract the batch control sum from the PAIN XML and set it on the segment | ||
| if (isset($xmlAsObject->CstmrCdtTrfInitn->GrpHdr->CtrlSum)) { | ||
| $ctrlSum = (float) $xmlAsObject->CstmrCdtTrfInitn->GrpHdr->CtrlSum; | ||
| $segment->summenfeld = \Fhp\Segment\Common\Btg::create($ctrlSum ?: 0); |
There was a problem hiding this comment.
Is it safe to assume that this is in EUR?
There was a problem hiding this comment.
Since the default value of the second argument is already EUR, and according to the specification there can be no batch transfers or direct debits with mixed currencies, I decided against it. Plus, it's the Single Euro Payments Area. Alternatively, one could pull the currency from the first entry of the items, but that seemed too error-prone to me. Furthermore, it's unclear whether the financial institutions even cross-check this at all, since the currencies are explicitly specified in the items anyway.
| // Fix for strict banks (e.g. Atruvia): Extract the batch control sum from the PAIN XML and set it on the segment | ||
| if (isset($xmlAsObject->CstmrCdtTrfInitn->GrpHdr->CtrlSum)) { | ||
| $ctrlSum = (float) $xmlAsObject->CstmrCdtTrfInitn->GrpHdr->CtrlSum; | ||
| $segment->summenfeld = \Fhp\Segment\Common\Btg::create($ctrlSum ?: 0); |
There was a problem hiding this comment.
After casting to float above, is it even possible that this is still null? I.e. does the ?: 0 do anything here?
There was a problem hiding this comment.
Valid argument, the fallback can be removed
|
Thanks! Merging… |
When initiating a SEPA batch transfer (Sammelüberweisung) using the HKCCM or HKCME segments, some strict bank servers (e.g., Atruvia data centers for Volksbanken/Raiffeisenbanken) reject the request with the error:
HIRMS:5:2:3+9010::Summenfeld nicht vorhanden.
While some banks parse the total sum directly from the PAIN XML payload, others strictly enforce the HBCI specification, which requires the control sum to be explicitly declared in the segment parameters (e.g., HKCCM:3:1+...). Currently, SendSEPATransfer leaves this field empty.
Changes made:
Updated SendSEPATransfer::createRequest() to extract the from the provided PAIN XML (GrpHdr).
Initialized the $segment->summenfeld property using \Fhp\Segment\Common\Btg::create().