<?php
$pageTitle = "Preventing Double Payments — The 0.01 Increment Logic | FamGateway";
$blogKicker = "Developer Guide";
include 'includes/blog-header.php';
?>
<p>When relying on email notifications for payment verification, a major edge case arises: <strong>What happens if two different customers buy a ₹499 product at the exact same time?</strong></p>
      
      <p>If FamGateway only looked for emails stating <em>"Received ₹499"</em>, it would be impossible to reliably distinguish which customer actually completed the payment, leading to race conditions and "double payment" conflicts.</p>

      <h2>The Solution: Order ID Embedding</h2>
      <p>To completely eliminate collisions, FamGateway enforces a strict 1:1 mapping using the UPI <code>tn</code> (Transaction Note) parameter. When an order is created via the API, the system embeds a unique, cryptographic Order ID directly into the payment link's purpose note.</p>
      
      <div class="highlight">
        If a customer scans the QR code for a ₹499 order, their UPI app automatically locks the transaction note to <strong>"Payment for Order fg_A1B2C3D4"</strong>.
      </div>

      <h3>How it looks in practice:</h3>
      <ul>
        <li><strong>Customer A</strong> clicks Checkout. They receive a QR linked to <strong>Order fg_A1B2C3D4</strong>.</li>
        <li><strong>Customer B</strong> clicks Checkout 2 seconds later. They receive a QR linked to <strong>Order fg_X9Y8Z7W6</strong>.</li>
        <li><strong>Customer C</strong> clicks Checkout 5 seconds later. They receive a QR linked to <strong>Order fg_L5M4N3P2</strong>.</li>
      </ul>

      <p>Because every single payment intent has a uniquely generated Order ID firmly attached to its purpose note, it is impossible for transactions to collide, even if the price is identical.</p>

      <h2>Bulletproof Matching</h2>
      <p>When the payment succeeds, the FamPay email receipt explicitly states the purpose string. FamGateway's backend daemon parses the text <em>"Purpose : Payment for Order fg_X9Y8Z7W6"</em>, extracts the exact Order ID, and instantly maps it to <strong>Customer B's</strong> pending order.</p>
      
      <p>This explicit identifier mapping guarantees that payments are fulfilled with 100% precision, completely eliminating the need for banking UTR lookups or adjusting the customer's payable amount.</p>
      
      <p><a href="../docs.php" style="color: #2563eb; font-weight:600;">View the API Specs →</a></p>

      <!-- Founder & Author Bio Block -->

<?php include 'includes/blog-footer.php'; ?>
