Navigating Recurring Payments in India: A Backend Perspective
Shopify adapted its internal payment service to India's 2021 RBI recurring-payment rules by working with a local provider supporting cards and UPI. It reused its existing source model to represent e-mandates, verifying the source while recording and auto-refunding the ₹1 authorization charge for an audit trail. A single recurring-payment tokenization serves both recurring and one-time payments to avoid double AFA challenges, at the cost of a 24-48 hour pre-debit delay. Because UPI limits are min(bank, daily, app) and can't be read at runtime, mandates are capped at ₹5,000 and larger charges go through an on-session flow. Idempotency is built on the provider's unique order `receipt` field to prevent double charges.
Related posts
- 10 Tips for Building Resilient Payment Systems
Shopify Engineering mediumAdeptTen lessons from Shopify's payment infrastructure for keeping payment systems reliable at scale. Start with low timeouts everywhere: about 1s to open a connection and 5s to read, write or query. Use circuit breakers via Semian, keyed per merchant country so one local acquirer outage stays isolated, and reason about capacity with Little's Law. Track the four golden signals, use structured logs with correlation IDs, and make retries safe with idempotency keys. ULID keys cut INSERT time by 50% versus UUIDv4. The rest covers reconciliation anomalies, load testing against a simulated benchmark gateway, checkout throttling, and incident management and retrospectives.
- How Shopify Dynamically Routes Storefront Traffic
Shopify Engineering mediumAdeptShopify shifted storefront traffic from its legacy Rails storefront to a rewritten renderer using a rule-based routing system in nginx/OpenResty Lua load balancers, with rules stored as JSON in a control plane and managed via the spy chatbot so changes skip CI and deploys. Each rule specifies filters, target shop IDs, and sampling rates for rendering, forward verification (legacy renders, new storefront checked), reverse verification, and self-verification against the local region's deployment. Rules are checked in the nginx rewrite phase, verification is decided in the header filter phase, and duplicate requests are sent asynchronously via nginx timers in the log phase so clients never wait on both upstreams. The same mechanism let the team mirror traffic to a separate deployment disconnected from Redis to test resilience before BFCM.
- Introducing the commerce payments protocol
Shopify Engineering mediumAdeptThe Commerce Payments Protocol, built by Coinbase and Shopify on Base, brings card-style authorize-and-capture flows onchain using an immutable escrow smart contract between payer and receiver. Operators submit transactions and pay gas on behalf of merchants but are constrained: payers sign a hash of the payment terms (receiver, token, max amount, expiries, operator), signatures cannot be replayed, payers can reclaim funds after authorization expiry, and each operator's funds sit in separate buckets. Six operations (authorize, capture, charge, void, reclaim, refund) cover the payment lifecycle, with partial captures and ERC-3009 signature-based token collection enabling gasless USDC payments. The protocol powers Shopify's USDC payment method and is open for extension via operator, receiver and token-collector contracts.
- How we prepare Shopify for BFCM
Shopify Engineering mediumAdeptShopify readies for Black Friday Cyber Monday with a year-long program that runs from March to October. It combines capacity planning on Google Cloud, What Could Go Wrong risk assessments, chaos-engineering Game Days on critical journeys like checkout, and a centralized Resiliency Matrix of failure modes, RTOs and runbooks. Five scale tests at forecast and p99 load (up to 200M requests per minute) used the Genghis load generator from three GCP regions, Toxiproxy fault injection and regional failovers. The tests surfaced issues such as checkout queue backups, rate-limit paths in authenticated checkout and slow region rebalancing. The newly rebuilt analytics platform needed more Kafka partitions, API memory optimization, connection-timeout tuning and load-balancer changes before facing its first holiday peak.
- Beyond Test Cards: A Fake Payment Provider for Testing at Scale
Lyft Engineering mediumAdeptLyft built a Fake Payment Provider that implements the same provider interface as real processors (tokenize, authorize, increment, capture, charge, refund, void), so it can simulate partial failures, soft declines with retries, pending responses, timeouts and outages that processor test cards cannot. Each test scenario is encoded into a fake low-value token, persisted as a high-value token, and kept stable across the charge lifecycle. Scenarios are dictionaries of per-action specs with success predicates (including a 50% chaos mode), delays, network decline codes and per-attempt retry specs. Strict routing rules confine the fake to simulated users. That lets it run safely in production for load testing the full payment stack, and new scenarios can be added through an AI coding skill whose output still goes through code review.