Developer: DR.KESHARI

Hospital Node

hospitalnode.in · hnorder.in

India medical market · pharmacy · labs · care

Prescription medicines require valid Rx. Vaccines administered by licensed partners only.

PrivacyTermsConsentPaymentsLogisticsLicenses

Hospital Node

hospitalnode.in · hnorder.in

Module 3Module 5CheckoutLegal

Platform Phase 3 MVP · Module 4 · PY / EC

Module 4 — Payments (Razorpay)

Razorpay order → cryptographically verified webhook → paid. hospitalnode.in is ahead of the Python reference sandbox (real SDK + ledger); gaps are multi-attempt history, admin COD settle, and vendor split.

payment_pending → Razorpay order → captured webhook → paid → fulfillment

Integration: 76% · /api/module4/status

Module 3 pharmacyPharma Platform v2Module 5 teleconsultModule 1 identityBlockchain ECCore Phase 1Phase 3 labsCheckout

Security checks (spec-aligned)

Amount server-derived

order.total_paise never from client

Live

Webhook raw-body HMAC

X-Razorpay-Signature on raw bytes

Live

Idempotent webhook

Duplicate payment.captured is no-op

Live

Order owner auth

create + history require JWT owner

Live

Webhook no JWT

Trust signature only

Live

Payment journey

  1. 1Place order (Module 3)M3 L4/checkoutLive
  2. 2Create Razorpay orderL1/api/payments/razorpay/create-orderLive
  3. 3Customer pays (UPI/card)L1/checkoutLive
  4. 4Client confirm OR webhookL2/L4/api/payments/confirmLive
  5. 5Order → paidL2/api/payments/razorpay/webhookLive
  6. 6Fulfillment (Module 3 L5)M3 L5/customer/track-orderPartial

Five layers

Layer 1 · razorpay-order-create

Razorpay order creation (server amount)

Live

createRazorpayOrder() — amount from catalog_orders.total_inr / amount_due_now, never client-supplied; notes.catalog_order_id for webhook lookup.

  • LiveCreate Razorpay order
  • LiveCheckout
  • LivePay reserve
  • LiveLab booking payment
  • PartialAppointment payment
Gaps (4)
  • No separate payments table row per attempt (razorpay_order_id on catalog_orders only)
  • 409 guard for non-payment_pending status — uses paid/confirmed check instead
  • Production merchant KYC + live keys go-live checklist
  • Razorpay Route / vendor split not on capture

Layer 2 · webhook-capture

Webhook HMAC + idempotent capture

Live

verifyRazorpayWebhookSignature on raw body; payment_webhook_events dedupe; markOrderPaid → catalog_orders + catalog_payment_ledger; refund.* handling.

  • LiveRazorpay webhook
  • LiveWebhook events store
  • LivePayment ledger
Gaps (4)
  • Public HTTPS webhook URL required in production (hospitalnode.in)
  • Dual path: client POST /api/payments/confirm also marks paid — spec prefers webhook-only canonical
  • Blockchain Write 3 on delivery+payment — planned (/blockchain)
  • Lab/appointment webhooks share one endpoint — partial routing

Layer 3 · payment-history

Payment attempt history

Partial

GET /api/payments/order/[id] returns order + razorpay IDs; catalog_payment_ledger holds events but no public list endpoint matching spec PaymentStatusResponse[].

  • PartialOrder payment summary
  • PartialOrder detail
  • LiveTrack order
Gaps (3)
  • No GET API returning all payment attempts per order (failed retries)
  • payments table model (created/paid/failed per attempt) not migrated
  • Customer cannot see full ledger timeline in UI

Layer 4 · client-confirm

Client-side payment signature verify

Live

verifyRazorpayPaymentSignature (order_id|payment_id HMAC); idempotency_keys; demo mode fallback; Hospital AI billing WhatsApp/email after pay.

  • LiveConfirm payment
  • PartialLab confirm
  • PartialAppointment confirm
Gaps (2)
  • Demo mode marks paid without Razorpay — dev only, must be disabled in prod
  • Not in Module 4 spec — document as hospitalnode.in extension

Layer 5 · cod-manual

COD / reserve / admin manual settle

Partial

pay_at_pickup + reserve mode in checkout; confirm route for reserve; no admin-only mark_paid API like spec fulfillment router.

  • PartialPay on delivery
  • LiveReserve & pay later
  • LiveLegal payments
  • PartialAdmin launch readiness
Gaps (4)
  • Admin mark_paid for bank transfer reconciliation — gap
  • COD collection confirmation at delivery — no staff API
  • PMJAY / scheme billing (FA-01) — gap
  • Settlement ledger manual — no auto split on capture

API map (spec → hospitalnode)

  • POST /payments/orders/{id}/createLive

  • POST /payments/webhookLive

  • GET /payments/orders/{id}Partial

  • mark_paid() admin CODPartial

  • —Live

  • —Live

Environment keys

  • RAZORPAY_KEY_ID
  • RAZORPAY_KEY_SECRET
  • RAZORPAY_WEBHOOK_SECRET
  • RESEND_API_KEY (invoice email)
  • WHATSAPP_CLOUD_TOKEN (post-payment notify)

See docs/SECRETS_LOCAL.md — webhook URL: /api/payments/razorpay/webhook