<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: David at Lokta</title>
    <description>The latest articles on DEV Community by David at Lokta (@david_r_95e4498aab2d99ccf).</description>
    <link>https://dev.to/david_r_95e4498aab2d99ccf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4222235%2F3c3d2431-4594-41b0-b7a7-bd20ce014d78.png</url>
      <title>DEV Community: David at Lokta</title>
      <link>https://dev.to/david_r_95e4498aab2d99ccf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/david_r_95e4498aab2d99ccf"/>
    <language>en</language>
    <item>
      <title>One Repayment, Two Webhooks: Preventing Duplicate Loan Postings</title>
      <dc:creator>David at Lokta</dc:creator>
      <pubDate>Mon, 02 Nov 2026 12:03:17 +0000</pubDate>
      <link>https://dev.to/david_r_95e4498aab2d99ccf/one-repayment-two-webhooks-preventing-duplicate-loan-postings-4f2h</link>
      <guid>https://dev.to/david_r_95e4498aab2d99ccf/one-repayment-two-webhooks-preventing-duplicate-loan-postings-4f2h</guid>
      <description>&lt;p&gt;A borrower makes one repayment. Your payment provider sends a notification, your system processes it, and the response times out. The provider sends the notification again.&lt;/p&gt;

&lt;p&gt;What stops the loan account from receiving the same repayment twice?&lt;/p&gt;

&lt;p&gt;That question belongs in your integration tests before launch.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I work at Lokta. This article presents an illustrative engineering approach, not a customer case study or a description of Lokta’s implementation.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Separate the notification from the accounting effect
&lt;/h2&gt;

&lt;p&gt;A webhook tells your application that something happened. Your application still needs to decide whether that event should change a loan account.&lt;/p&gt;

&lt;p&gt;There are two different duplicate checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Delivery check:&lt;/strong&gt; Have we already received this provider event?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Posting check:&lt;/strong&gt; Have we already applied this particular business operation?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These checks solve different problems. Two notifications can have different event IDs while describing the same intended repayment posting.&lt;/p&gt;

&lt;p&gt;Stripe explicitly documents duplicate events and delivery without guaranteed ordering. Other providers may have different contracts, so check their documentation rather than assuming identical behaviour. &lt;a href="https://docs.stripe.com/webhooks" rel="noopener noreferrer"&gt;Source: Stripe webhook documentation&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Give each intended posting a stable identity
&lt;/h2&gt;

&lt;p&gt;A payment ID alone is too broad. The same payment might later have a refund or reversal that requires a separate action.&lt;/p&gt;

&lt;p&gt;Define a business key that identifies the intended effect. Depending on your integration, that could include:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tenant + provider account + payment reference + operation&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The operation distinguishes the original repayment from a legitimate adjustment. Define these identities against your provider’s actual event model.&lt;/p&gt;

&lt;p&gt;Enforce uniqueness in storage. A separate “check whether it exists, then insert” sequence can fail when two workers run concurrently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accept events durably, then process them
&lt;/h2&gt;

&lt;p&gt;One possible design is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Verify the provider’s signature using its documented procedure.&lt;/li&gt;
&lt;li&gt;Store the accepted event in a durable inbox.&lt;/li&gt;
&lt;li&gt;Acknowledge receipt promptly after durable acceptance.&lt;/li&gt;
&lt;li&gt;Let a worker validate and process the event.&lt;/li&gt;
&lt;li&gt;Retain processing status and failure details for recovery.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you acknowledge an event, your worker needs a reliable retry mechanism. An event sitting in an inbox indefinitely is still an operational failure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Close the crash window
&lt;/h2&gt;

&lt;p&gt;If the posting and processing marker share a transactional database, commit them together.&lt;/p&gt;

&lt;p&gt;When the ledger is a separate system, the failure becomes harder: the ledger might accept the repayment, but the worker could crash before recording success.&lt;/p&gt;

&lt;p&gt;A durable outbox can coordinate dispatch, but messages may still be delivered repeatedly. The receiving system also needs an idempotency key or equivalent protection against duplicate effects.&lt;/p&gt;

&lt;p&gt;Stripe’s request idempotency is an example of retry protection for outgoing API calls. It is a separate concern from deduplicating incoming webhooks. &lt;a href="https://docs.stripe.com/api/idempotent_requests" rel="noopener noreferrer"&gt;Source: Stripe idempotent requests&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe99njthx3a4drvms4fcz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe99njthx3a4drvms4fcz.gif" alt="Illustrative animation of one repayment event being redelivered without a duplicate intended posting" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Conceptual animation using synthetic identifiers: a repeated delivery reuses the completed result. This illustrates expected behaviour; it is not a recorded Lokta test or a product demonstration.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the failures deliberately
&lt;/h2&gt;

&lt;p&gt;Before launch, test:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The same event arriving twice.&lt;/li&gt;
&lt;li&gt;Two workers handling duplicates concurrently.&lt;/li&gt;
&lt;li&gt;A timeout after a posting has committed.&lt;/li&gt;
&lt;li&gt;A crash before the posting commits.&lt;/li&gt;
&lt;li&gt;A legitimate refund or reversal for an existing payment.&lt;/li&gt;
&lt;li&gt;An event that cannot be matched to a loan account.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Where to inspect the account outcome
&lt;/h3&gt;

&lt;p&gt;The following Lokta demo screens show transaction and schedule records a team might inspect while checking a repayment. They were not captured during a webhook replay test and are not a before-and-after test result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fabr771jdeejlfdo0nr18.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fabr771jdeejlfdo0nr18.jpg" alt="Lokta demo transaction history with transaction IDs, external reference, dates, amounts and principal outstanding" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lokta demo transaction history. Review transaction IDs, available external references, dates, amounts and principal outstanding while tracing a posting. This view alone does not establish webhook deduplication.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk30t512rs1rsli88063o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk30t512rs1rsli88063o.jpg" alt="Lokta demo repayment schedule showing due dates, paid dates and demanded and collected amounts" width="799" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lokta demo repayment schedule. Compare the relevant periods and balance fields with independently calculated expected results. This is account context, not evidence that a duplicate-event test passed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The expected outcome should be explicit: duplicate deliveries produce one intended accounting effect, while legitimate adjustments remain possible.&lt;/p&gt;

&lt;p&gt;For lending teams turning these scenarios into vendor evaluation requirements, &lt;a href="https://lokta.ai/lms-rfp/" rel="noopener noreferrer"&gt;Lokta’s LMS RFP toolkit&lt;/a&gt; provides company-authored evaluation resources.&lt;/p&gt;

&lt;p&gt;Start with one test: resend a successfully processed repayment event and inspect the resulting account entries.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
