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.
SkyRainCloud 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 |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | 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 |
|---|---|---|---|---|---|---|---|
| VPS 1 — Intel | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Business websites, small apps, scheduled jobs and bots | Order |
| VPS 2 — Intel | 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 |
| VPS 3 — Intel | 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 |
| VPS 4 — Intel | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,299/month | High-memory workloads and consolidated production servers | Check stock |
Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.