Payments Service Idempotency
Idempotency is a crucial concept in payment processing systems to ensure that operations like fund transfers are not accidentally performed more than once. This is particularly important in scenarios where network issues, retries, or other uncertainties might lead to the same operation being requested multiple times. In the context of the LHV Connect API, idempotency helps in avoiding duplicate payments when the same request is inadvertently submitted more than once.
Idempotency and the PAIN.001 File
For the Payments service in LHV Connect, idempotency is managed using the MsgId
(Message Identification) field in the PAIN.001 XML file. The PAIN.001 file is a standardized format used for initiating credit transfer payments. Here's how it works:
MsgId
Field: TheMsgId
field is a unique identifier for each payment instruction. When a payment request is submitted, the system records theMsgId
. If a subsequent request is made with the sameMsgId
, the system recognizes it as a duplicate and ignores the new request, ensuring that the payment is not processed more than once.Uniqueness of
MsgId
: It is critical that theMsgId
is unique for each new payment request. Reusing the sameMsgId
across different requests will trigger the idempotency check, causing the system to reject the duplicate request. Therefore, careful management ofMsgId
values is essential for avoiding unintentional rejections or processing errors.Practical Example: Suppose a payment initiation request is sent with a
MsgId
ofPAY-12345
. If the payment process needs to be retried due to a timeout or any other issue, resending the request with the sameMsgId
(PAY-12345
) will not result in a duplicate payment. The system will recognize thisMsgId
and ensure that only one payment is executed.
However, it does not prevent the processing of payments that have similar amounts, payment details, or other fields, as long as each request has a unique MsgId
. This means that two payment requests with identical amounts, recipients, and dates can still be processed separately if their MsgId
values differ. Therefore, while idempotency protects against accidental re-submission of the same transaction, it does not prevent intentional or unintentional creation of similar but distinct payments.
Sample
Sample of related PAIN.001 request and response where uniqueness check finds a duplicate message:
Summary
Idempotency in the Payments service of LHV Connect is effectively managed through the MsgId
field in the PAIN.001 file. This ensures that payment requests are processed exactly once, even if they are submitted multiple times, thereby safeguarding against duplicate transactions and ensuring the reliability of the payment process.
Last updated