<?php
$pageTitle = "How FamGateway Works — UPI Payment Verification Architecture";
$blogKicker = "Developer Guide";
include 'includes/blog-header.php';
?>
<p>FamGateway was built to solve a massive pain point for Indian developers: verifying UPI payments programmatically without registering for expensive, heavyweight banking APIs or corporate merchant accounts. We wanted a system that allowed any developer to start accepting payments in minutes using nothing but their standard FamPay account.</p>
      
      <h2>The Core Architecture</h2>
      <p>Traditional payment gateways connect directly to banking nodal accounts. This requires massive regulatory compliance and long onboarding cycles. FamGateway takes a completely different approach by treating <strong>email notifications as the source of truth</strong>.</p>
      
      <div class="highlight">
        When someone sends you money on FamPay, you receive an instant email from FamPay confirming the transaction. FamGateway reads these emails securely using IMAP, extracts the payment data, and triggers webhooks to your application.
      </div>

      <h2>The Step-by-Step Workflow</h2>
      <h3>1. Order Creation</h3>
      <p>When your user clicks "Checkout", your server sends an API request to FamGateway with your FamPay UPI ID and the exact order amount. FamGateway generates a unique Order ID and embeds it into a UPI QR code's transaction note (the <code>tn</code> parameter).</p>

      <h3>2. The Customer Pays</h3>
      <p>Your user scans the QR code using any UPI app (PhonePe, GPay, Paytm) and completes the payment. The money goes <strong>directly into your FamPay account</strong>. Because the QR code contained the Order ID, the payment app securely attaches this note to the transfer.</p>

      <h3>3. The Notification</h3>
      <p>FamPay instantly emails you a receipt containing the exact Order ID in the "Purpose" field. FamGateway's ultra-fast backend daemon connects directly to Gmail via IMAP IDLE, instantly receiving a push notification the millisecond this receipt arrives.</p>

      <h3>4. Verification & Callback</h3>
      <p>The daemon parses the email, extracts the Order ID from the Purpose field, and guarantees an exact 1:1 match against the database. It verifies the paid amount, marks the order as <code>success</code>, and immediately fires a webhook to your application.</p>

      <h2>Why this matters for AI & Developers</h2>
      <p>By moving the verification layer to email parsing, developers avoid Nodal account setup, KYC delays, and gateway commissions. You get 100% of your funds instantly, while FamGateway handles the programmatic verification. The system is designed to be fully compatible with any LLM code-generation tool.</p>
      
      <p><a href="../docs.php" style="color: #2563eb; font-weight:600;">Read the API Documentation →</a></p>

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

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