Payment code is where small mistakes become financial losses: an order marked paid when it was not, a customer charged twice, a refund that never happened. Indian payment gateways make the mechanics straightforward, but correctness and security depend on how your server handles the flow. This guide covers the patterns that keep it right.
Integration Models
| Model | Card/UPI details touch your server? | Effort |
|---|---|---|
| Hosted checkout / payment page | No | Lowest |
| Embedded checkout (gateway's JavaScript SDK) | No (sent directly to the gateway) | Low |
| Direct server-side card handling | Yes | High; large compliance scope |
For almost every business, hosted or embedded checkout is the right choice: the gateway handles card data and authentication, and your server never stores or sees it.
The Safe Payment Flow
- Your server creates an order with the gateway, using the amount and currency your server calculated (never an amount sent from the browser).
- The customer pays in the gateway's checkout.
- The browser returns to your site; you show "processing" but do not mark the order paid yet.
- The gateway sends a webhook (or you verify server-to-server) with a signature.
- Your server verifies the signature and the amount, records the payment, and moves the order to paid.
Webhook Security and Idempotency
- Verify signatures with the gateway's webhook secret on every request; reject anything that fails.
- Check details: the payment amount, currency and order ID must match your records.
- Respond fast: store the event and return 200, then process in a background job.
- Idempotency: store processed event and payment IDs; ignore duplicates, since gateways retry.
- Handle out-of-order events using states and timestamps.
Our webhook processing guide covers the general pattern in detail.
Order State Machine
created → pending_payment → paid → fulfilled
│ └→ refund_requested → refunded
└→ failed / expired
Allow only valid transitions, record who or what triggered each, and make actions such as fulfilment happen only from the paid state. This prevents shipping unpaid orders and double refunds.
UPI Considerations
- UPI payments can complete after the customer leaves your page; rely on webhooks and status checks, not the redirect.
- Some payments remain pending for a while; show a clear pending status and resolve it from webhooks or periodic status checks.
- For subscriptions, UPI AutoPay mandates have their own lifecycle events to handle.
Refunds and Disputes
Initiate refunds through the gateway's API from your admin interface, record them against the order, and update status from refund webhooks. Keep logs and evidence (order details, delivery confirmation) for disputes and chargebacks.
Reconciliation
Every day, compare your recorded payments with the gateway's payment and settlement reports. Investigate mismatches: payments without orders, orders marked paid without payments, refunds missing on either side. Automate the comparison as a scheduled job and alert on differences.
Secrets and Keys
- Store API keys and webhook secrets in environment files readable only by the app, never in code or the repository.
- Use separate test and live keys; staging uses test mode only.
- Rotate keys if anyone who had access leaves or a leak is suspected.
- Never log full keys, secrets or payment instrument details.
Hosting Requirements
- HTTPS with a valid certificate; the webhook URL must be reachable by the gateway.
- Zero-downtime deploys so webhooks are not refused during releases (see our zero-downtime guide).
- Background workers supervised with automatic restarts (see our workers guide).
- Database backups with point-in-time recovery; payment records must never be lost.
- Monitoring of webhook errors, payment success rates and queue backlogs.
Keeping Compliance Scope Small
With hosted or embedded checkout, card data never reaches your server, which keeps your PCI DSS obligations much simpler; confirm the exact requirements with your gateway. Never build your own card form that posts to your server unless you are prepared for full compliance.
Testing
Use the gateway's test mode on staging to test every path: success, failure, pending UPI, duplicate webhooks, refunds and timeouts. Replay real webhook payloads from the test dashboard against your endpoint.
Common Mistakes
- Marking orders paid from the browser redirect.
- Trusting amounts sent from the browser.
- Not verifying webhook signatures.
- Processing webhooks twice and fulfilling orders twice.
- No daily reconciliation.
In Short
Let the gateway handle payment details, decide payment status only from verified server-side events, process them idempotently through a state machine, reconcile daily and protect your keys.
What to Monitor
- Payment success rate by method (UPI, cards, net banking).
- Webhook signature failures and processing errors.
- Orders stuck in pending payment longer than expected.
- Daily reconciliation differences.
A drop in UPI success rate, for example, often reflects a gateway or bank issue you should communicate to customers quickly. Document the setup in a short runbook covering where data lives, how integrations run, how to restore from backup and whom to contact, so the system stays dependable even when the person who configured it is unavailable or has moved on to another role. Review the setup every quarter with the people who use it, because needs change as the business grows, and small adjustments made early are far cheaper than large changes made under pressure.
ServoMix Plans for This Workload
Payment integration adds little load; size for your application. Most shops and SaaS apps handle payments comfortably on 2–4 vCores. What matters most is reliability: monitoring, backups and zero-downtime deploys.
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| SMX vPro XS (AMD EPYC) | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹420/mo | Websites, small APIs, bots, staging and VPN servers | Order |
| SMX vPro S (AMD EPYC) | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹560/mo | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| SMX vPro M (AMD EPYC) | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹840/mo | Production databases, high-traffic sites, multi-container apps | Order |
| SMX vPro L (AMD EPYC) | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹1,120/mo | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Intel Xeon Platinum 8269CY VPS
KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| SMX vCore XS (Intel Xeon) | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹270/mo | Business websites, small apps, scheduled jobs and bots | Order |
| SMX vCore S (Intel Xeon) | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,169/month | Business software, mid-size databases, several sites on one server | Check stock |
| SMX vCore M (Intel Xeon) | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,249/month | ERP/CRM stacks, heavier databases, multiple production apps | Check stock |
| SMX vCore L (Intel Xeon) | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,248/month | High-memory workloads and consolidated production servers | Check stock |
Prices are monthly in INR as listed on the ServoMix store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.
Frequently Asked Questions
Should card details pass through my server?
When should an order be marked paid?
Why not trust the redirect after payment?
How do I verify webhooks?
Why must webhook processing be idempotent?
How do I handle pending UPI payments?
What is payment reconciliation?
Where should API keys be stored?
Does hosted checkout reduce PCI DSS requirements?
What server do I need for payments?
Related Guides
Frequently Asked Questions
Should card details pass through my server?
No. Use the gateway's hosted or embedded checkout so card and UPI details go directly to the gateway.
When should an order be marked paid?
Only after a signature-verified webhook or server-to-server verification confirms the payment and amount.
Why not trust the redirect after payment?
Redirects can be manipulated or fail to arrive; UPI payments may complete later. Server-side confirmation is authoritative.
How do I verify webhooks?
Validate the signature with the webhook secret, then check amount, currency and order ID against your records.
Why must webhook processing be idempotent?
Gateways retry events, so the same event can arrive more than once; duplicates must not repeat fulfilment or refunds.
How do I handle pending UPI payments?
Show a pending status and resolve it from webhooks or periodic status checks.
What is payment reconciliation?
Comparing your records with the gateway's payment and settlement reports daily to catch mismatches.
Where should API keys be stored?
In environment files readable only by the app, never in code or logs, with separate test and live keys.
Does hosted checkout reduce PCI DSS requirements?
Yes, significantly, because card data never reaches your servers; confirm specifics with your gateway.
What server do I need for payments?
Payment handling adds little load; size for your application and focus on reliability, monitoring and backups.
Your feedback helps us continuously improve ServoMix guides.
Know someone who may find this guide useful?
