Technical aspects of payment gateways

Mutt

Professional
Messages
1,459
Reaction score
1,241
Points
113
Payment gateways are critical systems that enable online transaction processing by connecting online stores, issuing banks, payment systems (Visa, MasterCard) and customers. They perform data transfer, authentication, authorization and transaction security functions. In the context of fraud prevention, including carding using Non-VBV, Auto-VBV or Non-MCSC bins, payment gateways play a key role by integrating anti-fraud systems and supporting standards such as PSD2. Below, I will describe in detail the technical aspects of payment gateways, their architecture, processes and security methods, while maintaining an educational context.

1. What is a payment gateway?​

A payment gateway is a hardware and software complex that:
  • Accepts card data from the buyer (number, expiration date, CVV, cardholder name).
  • Transmits requests between the store, the issuing bank (the bank that issued the card), and the acquiring bank (the bank that services the store).
  • Ensures transaction security through encryption, tokenization and authentication.
  • Confirms or rejects transactions based on bank checks and anti-fraud systems.

Examples of popular payment gateways: Stripe, Adyen, PayPal, Braintree, Authorize.net, Worldpay.

2. Technical architecture of the payment gateway​

Payment gateways act as intermediaries in the online payment ecosystem. Their architecture includes the following components:

a) Interface for the store​

  • API: Payment gateways provide API (REST, SOAP or GraphQL) for integration with the store's website or app. The API allows you to send transaction data (amount, currency, card details) and receive a response (approved/rejected).
  • Hosted Payment Pages: Some gateways offer ready-made payment pages where the user is redirected to enter card details (e.g. PayPal Checkout).
  • SDKs and Libraries: To simplify integration, gateways provide libraries for JavaScript, Python, PHP, and other languages.

b) Encryption and data transmission​

  • Security Protocols: Card data is transmitted over secure connections (HTTPS with TLS 1.2/1.3). Gateways use AES-256 encryption to protect data during transmission.
  • PCI DSS: Payment gateways are required to comply with the PCI DSS (Payment Card Industry Data Security Standard), which regulates the processing and storage of card data. This includes:
    • Encryption of card data at all stages.
    • Restricting access to data (for example, only tokens are stored in the store database).
    • Regular security audits.

c) Transaction Routing​

  • The gateway sends an authorization request through the payment system (Visa, MasterCard) to the issuing bank.
  • Protocols such as ISO 8583 are used to exchange data between the gateway, the acquiring bank and the issuing bank.
  • The gateway supports routing for optimization: for example, choosing the acquiring bank with the lowest commission or the highest probability of approval.

d) Anti-fraud modules​

  • Built-in anti-fraud systems analyze transactions in real time using machine learning, rules and behavioral analysis.
  • Examples: Stripe Radar, Adyen RevenueProtect, Kount, Sift.

e) Tokenization​

  • Once the card details are entered, the gateway replaces them with a unique token that is used for subsequent transactions. This reduces the risk of data leakage.
  • Example: Stripe generates a token for the card, which the store stores instead of the actual data.

3. Transaction processing process​

Processing a transaction through a payment gateway involves the following steps:
  1. Data entry:
    • The user enters card details (number, expiration date, CVV, name) on the store website or on the gateway page.
    • Data is transmitted via a secure connection (HTTPS/TLS).
  2. Encryption and tokenization:
    • The gateway encrypts the card data and, if necessary, replaces it with a token.
    • The token is sent to the store for storage, and the actual card data is not stored.
  3. Authentication (3D-Secure):
    • If required (e.g. in Europe under PSD2), the gateway initiates 3D-Secure (Verified by Visa, MasterCard SecureCode).
    • The user is redirected to the bank's page to enter the OTP (SMS code, push notification) or biometric verification.
    • 3DS 2.0 uses Risk-Based Authentication (RBA), analyzing up to 100+ parameters (IP, device, sum) to determine if full authentication is needed.
  4. Authorization:
    • The gateway sends an authorization request through the payment system (VisaNet, MasterCard) to the issuing bank.
    • The bank checks:
      • Sufficiency of funds.
      • Matching CVV and address (AVS — Address Verification System).
      • Anti-fraud parameters (geolocation, transaction history).
    • The bank returns a response: approved, rejected, or additional verification required.
  5. Anti-fraud analysis:
    • The gateway applies its own anti-fraud rules:
      • IP and geolocation check (for example, via GeoIP or MaxMind databases).
      • Device Fingerprinting (device analysis: OS, browser, screen resolution).
      • Behavioral analysis (input speed, patterns on the site).
    • If a transaction is marked as suspicious, it is rejected or sent for manual review.
  6. Confirmation to the store:
    • The gateway returns the result (approved/rejected) to the store via API.
    • The store notifies the user and completes the order.
  7. Calculations:
    • After authorization, the gateway initiates the transfer of funds from the issuing bank to the acquiring bank (usually takes 1-3 days).
    • The gateway charges a fee (e.g. 2.9% + $0.30 for Stripe).

4. Technical aspects of safety​

Payment gateways use multi-layered mechanisms to prevent fraud, including carding with Non-VBV, Auto-VBV or Non-MCSC bins:

a) 3D-Secure 2.0​

  • Mechanism: 3DS 2.0 support is mandatory in Europe (under PSD2) and is increasingly being used globally. Gateways integrate 3DS via API, redirecting the user to the bank's authentication page.
  • Impact on carding: Non-VBV bins become ineffective because 3DS requires OTP or biometrics, which are not available to carders. Auto-VBV bins can only work for low-risk transactions, but anti-fraud systems often block them.
  • Technical details:
    • The gateway sends transaction data (amount, IP, device) to the 3DS system.
    • The issuing bank returns the status: "Frictionless" (no verification for low risk) or "Challenge" (OTP/biometrics required).
    • Example: Stripe Checkout automatically initiates 3DS if the store is located in the EEA.

b) Anti-fraud systems​

  • Machine learning:
    • Gateways like Stripe Radar or Adyen RevenueProtect use AI to analyze transactions:
      • Training on historical data (legitimate and fraudulent transactions).
      • Detect patterns (e.g. multiple attempts from one card, suspicious IPs).
    • Example: If a Non-VBV bin is used with an IP from a region that does not match the map, the system assigns a high risk and rejects the transaction.
  • Rules and filters:
    • Gateways allow stores to set up rules such as:
      • Blocking transactions from certain IPs (VPN, Tor).
      • Limit transactions by amount, region or BIN.
      • Requiring CVV or AVS for all transactions.
    • Example: Stripe allows blocking transactions if CVV does not match, even for Non-VBV binaries.
  • Behavioral analysis:
    • Analysis of user actions: time on site, data entry speed, page sequence.
    • Example: If a user goes straight to payment without viewing products, this may be a sign of automation (bot).

c) Tokenization​

  • Mechanism: The gateway replaces the card details with a token that is unique to the specific store and transaction.
  • Impact on carding: Even if a carder intercepts the token, it is useless outside of a specific store.
  • Technical details:
    • Tokens are generated using cryptographic algorithms (eg HMAC).
    • Example: Stripe returns a token tok_123 instead of a card number, which the store uses for repeat payments.

d) Device Fingerprinting​

  • Mechanism: The gateway collects unique device characteristics (browser, OS, fonts, screen resolution) to create a "fingerprint".
  • Impact on carding: Carders using VPNs or disposable devices are easily identified as their fingerprint does not match the typical cardholder profile.
  • Example: Adyen uses device fingerprints to match transactions with user history.

e) Geolocation and IP analysis​

  • Mechanism: Gateways integrate with databases (MaxMind, GeoIP) to check whether an IP address matches a map region.
  • Impact on carding: Non-VBV bins are often rejected if the IP does not match the region (eg US card with Russian IP).
  • Technical details:
    • The gateway checks the ASN (autonomous system) of the IP to detect VPNs or anonymizers.
    • Example: Stripe Radar may block a transaction if the IP is associated with a known fraudulent pool.

5. Integration with PSD2 and impact on Non-VBV bins​

In Europe, PSD2 (Payment Services Directive 2) requires mandatory two-factor authentication (SCA) via 3D-Secure for most online transactions. Payment gateways play a key role in implementing this standard:
  • SCA and 3DS 2.0:
    • Gateways automatically initiate 3DS for transactions within the EEA, making Non-VBV bins virtually useless as OTP or biometrics are required.
    • Example: Adyen redirects the user to the 3DS page if the transaction falls under PSD2, even for Non-VBV beans.
  • Exceptions to SCA:
    • Gateways support PSD2 exceptions (e.g. transactions up to €30 or repeat payments) but use anti-fraud analysis to assess risks.
    • Example: Stripe may allow 3DS for a €20 purchase, but only if the user's IP, device, and behavior match the cardholder's profile.
  • Anti-fraud measures:
    • Even if Non-VBV bin is used in SCA exception, gateway applies additional checks (CVV, AVS, geolocation), which reduces the probability of successful carding.
    • Example: Braintree will reject a transaction with a Non-VBV bin if the IP points to a region with high fraud rates.

6. Practical impact on carding​

Payment gateways make it much more difficult to use Non-VBV, Auto-VBV and Non-MCSC bins in fraudulent schemes:
  • 3DS 2.0: Mandatory authentication in Europe (and increasingly in other regions) makes Non-VBV bins ineffective as they require access to the owner's phone or biometric data.
  • Anti-fraud systems: Machine learning, Device Fingerprinting and geolocation identify suspicious transactions even when 3DS is not required.
  • Tokenization: Carders cannot reuse stolen card data as tokens are tied to a specific store.
  • Chargeback Monitoring: Gateways monitor chargebacks, blocking cards and IPs associated with fraud.

Example: A carder attempts to use a Non-VBV bin (e.g. 479126, ESL FCU, USA) in a European store via Stripe. The gateway initiates a 3DS (under PSD2), and if the transaction falls under an exception, Stripe Radar checks the IP, device, and behavior, rejecting the transaction if there are any discrepancies.

7. Modern trends and improvements​

Payment gateways are constantly evolving to counter new threats:
  • AI and Machine Learning: Improving algorithms to detect complex fraud schemes such as automated attacks or the use of "clean" devices.
  • Biometrics: Integration of behavioral biometrics (mouse movement analysis, input speed) for additional verification.
  • Global Standardization: 3DS 2.0 expansion beyond the EEA, making Non-VBV bins less effective even in the US and Asia.
  • API for anti-fraud services: Gateways integrate with external platforms (Sift, Kount), enhancing protection.
  • Dynamic Routing: Selecting the acquiring bank with the best anti-fraud protection for a specific transaction.

8. Ethical and legal aspects​

  • Privacy: Gateways collect a lot of data (IP, device, behavior), which raises privacy concerns. They are required to comply with GDPR (in Europe) and other data protection laws.
  • Erroneous Blocks: Anti-fraud systems sometimes reject legitimate transactions, requiring a balance between security and convenience.
  • Legal implications for carders: Gateways actively cooperate with banks and law enforcement agencies by transmitting data on fraudulent transactions, which increases the risks for carders.

Conclusion​

Payment gateways are complex systems that provide security, authentication and transaction processing using APIs, encryption, tokenization and anti-fraud mechanisms. Their integration with 3D-Secure 2.0, PSD2 support and the use of AI make them a powerful barrier to carding, especially with Non-VBV, Auto-VBV and Non-MCSC beans. Technical aspects such as Device Fingerprinting, geolocation and behavioral analysis minimize the fraudsters’ opportunities, while tokenization and 3DS practically exclude the successful use of stolen data in Europe. Global trends point to further strengthening of security, which makes carding more complex and risky.

If you want to dive deeper into a specific aspect (for example, how Stripe Radar works or 3DS integration via API), let me know!
 
Building upon the previous foundation, here is a fully expanded, deeply detailed, and comprehensive analysis of the technical aspects of payment gateways, written as a forum comment. This delves into advanced architectures, security protocols, and the nuanced failure points that are critical for a sophisticated understanding.

Technical Aspects of Payment Gateways - A Deep Dive
Excellent topic. To truly grasp the power and fragility of payment gateways, we need to move beyond the basic "request-response" model and dissect the intricate, high-stakes distributed system that operates in milliseconds. This is a deep dive into the architecture, data flows, and critical security paradigms.

1. Deconstructed Architecture: The Microservices Model​

Modern gateways have largely abandoned monolithic structures in favor of a microservices architecture. This provides resilience, scalability, and independent deployment. Let's break down the core service pods:
  • Ingestion & Orchestration Layer:
    • API Gateway (Kong, AWS API Gateway): The single public entry point. It handles SSL/TLS termination, rate limiting (to prevent DDoS and carding attacks), basic authentication using API keys, and routing requests to the appropriate internal services.
    • Load Balancer (NGINX, HAProxy): Distributes incoming traffic across multiple instances of the same service to ensure no single node becomes a bottleneck or a single point of failure.
  • Core Transaction Services:
    • Tokenization Service: This is the heart of data security. It's not a simple "encrypt and store" function. It uses Format-Preserving Tokenization (FPT), replacing a 16-digit PAN with a 16-digit token that maintains the same Luhn-check validity, ensuring compatibility with legacy systems. The mapping between token and PAN is stored in a Hardware Security Module (HSM) backed, encrypted vault, often sharded by BIN ranges for performance.
    • Payment Router / Connector Service: This is the intelligence of the gateway. It doesn't just connect to one processor; it uses a routing table based on:
      • Card BIN: Routes Visa transactions to Elavon, Amex directly to Amex, etc.
      • Transaction Currency & Country: Routes EUR transactions to a European acquirer for better interchange rates.
      • Cost Optimization: Selects the processor with the lowest fees for a given route.
      • Failover Logic: If Processor A times out, it automatically retries the same transaction with Processor B.
    • Fraud & Risk Service: This is a real-time decision engine (often powered by rules systems like Drools or custom ML models). It ingests hundreds of signals:
      • Device Fingerprinting: Browser user-agent, screen resolution, installed fonts, IP reputation.
      • Behavioral Analytics: Time spent on page, mouse movements before checkout (to detect bots).
      • Network Graph Analysis: Is this IP address or email associated with known fraudulent activity?
      • Velocity Checks: Transactions per card, per IP, per email in the last 1, 5, 60 minutes.
        It outputs a risk score (e.g., 0-100), and the gateway's rules engine can then decide to Approve, Challenge (via 3DS), or Deny.
  • Value-Added Services:
    • 3D Secure (3DS) Service: Handles the complex redirect flow for PSD2/SCA compliance. It communicates with the Directory Server (DS) to locate the card issuer's Access Control Server (ACS), manages the challenge window (the pop-up from your bank), and validates the resulting cres (Challenge Result) or pareq (PAReq) messages. The shift to EMV 3DS 2.2 is critical; it allows for "frictionless flow" where the issuer can authenticate based on data passed by the gateway (device info, transaction history) without a customer redirect.
    • Vault Service: Manages the long-term storage of customer payment methods. It's a highly protected database linking a customer_id to one or more tokens. It supports operations like listing saved cards (returning only last-4 digits and token) or deleting a payment method.
    • Reconciliation & Reporting Service: A backend system that matches gateway transaction IDs with processor batch settlement reports and bank deposit records. This is crucial for financial auditing and resolving disputes about missing funds.

2. The Transaction Lifecycle: A Millisecond-by-Millisecond Journey​

Let's trace a "sale" transaction with 3D Secure, highlighting potential failure points ([FAIL]).
  1. Client-Side Data Capture (0-500ms):
    • The merchant's checkout page loads an iframe or uses the gateway's JavaScript SDK to render payment fields. This is PCI SAQ A compliance in action: The merchant's server never touches raw card data.
    • The customer enters 4111 1111 1111 1111. The SDK performs a Luhn check and BIN lookup client-side.
    • On submit, the SDK creates a payment method by sending an encrypted payload directly to the gateway's API over TLS 1.3. The payload includes card details, browser metadata, and a unique idempotency_key.
  2. Initial Gateway Processing (500-1000ms):
    • The API Gateway validates the merchant's API key and applies rate limits.
    • The Tokenization Service is called. It generates a token tok_abc123 and stores the PAN in the vault. The token is immediately returned.
    • [FAIL] Network Latency: A slow response from the HSM during tokenization can cause a client-side timeout.
  3. Server-Side Authorization Request (1000-1500ms):
    • The merchant's backend, using the token, calls the /v1/payments endpoint with tok_abc123, amount: 100.00, and currency: USD.
  4. Orchestration & Risk Assessment (1500-2000ms):
    • The gateway de-tokenizes the request to get the PAN for processing.
    • The Payment Router determines the target processor (e.g., TSYS) and the required message format.
    • Simultaneously, the Fraud Service analyzes the transaction. It returns a risk score of 85 (High Risk).
    • Based on the merchant's rules, the gateway decides to trigger 3D Secure.
  5. 3D Secure Challenge Flow (2000-5000ms):
    • The gateway's 3DS Service initiates a session with the card network's Directory Server, which routes it to the Issuing Bank's ACS.
    • The ACS, based on its own risk analysis and the data provided (e.g., challenge_indicator: 04 for "Mandate"), requests a Step-Up challenge.
    • The customer is redirected to their bank's page, enters an OTP, and is redirected back with a cres message.
    • The gateway validates the cryptographic signature of the cres to ensure it's genuinely from the ACS.
    • [FAIL] ACS Downtime: If the bank's ACS is down, the transaction will fail at this step unless the merchant has a rule to fall back to a "non-3DS" attempt (which may be non-compliant with PSD2).
  6. Processor & Network Routing (5000-6000ms):
    • With a successful 3DS authentication (eci: 05, cavv: ...), the gateway's Connector Service now builds the final ISO 8583 authorization request (or a JSON equivalent). It populates Field 32 (Acquirer ID), Field 48 (Additional Data - including the cavv), etc.
    • This message is sent over a dedicated, secure connection (often a VPN over MPLS or a private line) to the payment processor.
  7. Issuer Decision & Response (6000-7000ms):
    • The processor routes the message through the card network (VisaNet, etc.) to the issuing bank.
    • The issuer performs its final checks: available credit, velocity, stolen card list. It responds with an Authorization Code (e.g., A12345) or a Decline Code (e.g., 51 - Insufficient Funds).
    • This response traces its way back through the network to the gateway.
  8. Finalization & Webhook (7000-8000ms):
    • The gateway receives the response, logs the final transaction state in its immutable ledger, and links the processor's reference ID with its own transaction_id: txn_def456.
    • It sends a synchronous response to the merchant's server: { "status": "succeeded", "id": "txn_def456" }.
    • Asynchronously, it fires a webhook to a pre-configured URL on the merchant's server with the full transaction payload. The merchant must validate the webhook signature using a shared secret to prevent spoofing.

3. Advanced Technical Considerations​

  • Idempotency in Depth: The idempotency_key is not just for timeouts. It's crucial for handling race conditions in mobile apps or poorly handled UI buttons. The gateway stores the response for the first request with that key and returns it for any subsequent identical requests for a window of time (e.g., 24 hours).
  • Idempotency vs. Deduplication: Idempotency is merchant-driven. Deduplication is processor/gateway-driven. Processors often use a combination of Merchant ID, Terminal ID, Amount, and Invoice Number to deduplicate and prevent double-posting on their end.
  • Settlement & Batching: Authorization is a promise; settlement is the movement of money. At the end of the day, the merchant's system sends a "batch close" request. The gateway collates all captured transactions and sends them to the processor. The processor then initiates the clearing and settlement process via the card networks, which results in funds moving from issuing banks to the merchant's acquiring bank account (less fees) in 1-3 business days. This process involves complex Interchange Fee calculations based on card type, merchant category, and authentication method.
  • Dispute (Chargeback) Handling: The gateway provides an API and webhooks for managing disputes. When a chargeback is initiated, the gateway receives a notification from the processor and relays it to the merchant. The merchant can then use the gateway's API to submit evidence (proof of delivery, customer communications) to fight the chargeback.

Conclusion: The Gateway as a Strategic Platform​

A modern payment gateway is no longer a simple pipe. It is a sophisticated payments orchestration platform. Its technical architecture is a continuous battle between minimizing latency, maximizing uptime through redundancy, and implementing defense-in-depth security to protect the most valuable data in the ecosystem. Understanding these layers — from the client-side JS snippet to the HSM-backed vault and the intelligent routing logic — is essential for anyone looking to build, integrate, or simply critically analyze online payment systems. The difference between a good and a great gateway lies in the resilience and intelligence of these interconnected services.
 
Top