Payment Methods & Card Vaulting Module Documentation
Module Code:
billing/client/cards
Route:/portal/cards
Backend Service:clientService.ts(ring2all-billing-api)
Database Table:payment_methods
Brand Purity: 100% White-Label Compliant (Ring2All Billing)
Table of Contents
Section titled βTable of Contentsβ- Executive Summary & PCI-DSS Scope Reduction
- Technical Architecture & Tokenization Pipeline
- π― User Roles & Key Capabilities
- Visual Interface & Screen Breakdown
- Card Lifecycle Management & Default Routing
- Stripe Elements Client Tokenization
- Database Schema & Data Dictionary
- Diagnostic CLI & Operational Playbooks
- Domain Glossary
1. Executive Summary & PCI-DSS Scope Reduction
Section titled β1. Executive Summary & PCI-DSS Scope ReductionβThe Payment Methods & Card Vaulting module enables customers to securely store, update, and manage multiple credit/debit cards for automated subscription renewals and on-demand wallet refills without exposing raw card numbers to Ring2All servers.
+-------------------------------------------------------------------------------+| COMMERCIAL & OPERATIONAL IMPACT |+-------------------------------------------------------------------------------+| β’ Zero PCI Scope for Telecom Provider: Raw PANs and CVVs never touch or || traverse Ring2All backend servers; tokenization occurs in Stripe's vault. || β’ Churn Reduction: Customers independently replace expiring or stolen cards || before monthly plan subscription renewals fail. || β’ One-Click Checkout: Default card designation enables friction-free top-ups || and instant invoice payments across the entire portal. || β’ Complete Cardholder Security: Visual card displays are strictly limited to || card brand, last 4 digits, and expiration dates. |+-------------------------------------------------------------------------------+2. Technical Architecture & Tokenization Pipeline
Section titled β2. Technical Architecture & Tokenization PipelineβWhen a customer registers a payment card, the client portal communicates directly with Stripe Elements to create a tokenized PaymentMethod ID (pm_...), which is then safely linked to the customerβs account:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Client Web Browser (Portal UI) β β Route: /portal/cards β βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββ β β 1. Raw Card β Direct HTTPS β 3. Vaulted Token Data βΌ β (pm_1N2e3f...) βββββββββββββββββββββββββββββββββββββ β β Stripe Tokenization Engine β β β β’ Validates CVV & Expiration β β β β’ Issues Opaque Token ID β β βββββββββββββββββββββ¬ββββββββββββββββ β β 2. Return Token βΌ ββββββββββββββββββΊ βββββββββββββββββββββββββββββββββββ β Ring2All Billing Core API β β POST /api/client/payment-methodsβ ββββββββββββββββββ¬βββββββββββββββββ β 4. Store Safe Metadata βΌ βββββββββββββββββββββββββββββββββββ β PostgreSQL 17 (payment_methods) β β β’ brand: 'visa' β β β’ last4: '4242' β β β’ exp_year: 2028 β β β’ gateway_method_id: 'pm_...' β βββββββββββββββββββββββββββββββββββ3. π― User Roles & Key Capabilities
Section titled β3. π― User Roles & Key CapabilitiesβAccess to stored payment methods is strictly restricted:
| User Role | Access Level | Primary Operational Capabilities |
|---|---|---|
| Enterprise Account Owner | Full Access | Adds new company payment cards, toggles default billing card, removes outdated cards. |
| Accounts Payable Manager | Card Management | Verifies card expiration dates, updates billing addresses, monitors failed transaction alerts. |
| Billing & Finance Auditor | Read-Only Audit | Verifies vaulted payment method count and default gateway configurations. |
4. Visual Interface & Screen Breakdown
Section titled β4. Visual Interface & Screen Breakdownβ4.1 Vaulted Payment Methods Inventory
Section titled β4.1 Vaulted Payment Methods InventoryβThe cards interface provides a clean cardholder dashboard:

- Card Brand Badges: Visual iconography representing Visa, Mastercard, American Express, or Discover.
- Masked Display: Masked card representation (
β’β’β’β’ β’β’β’β’ β’β’β’β’ 4242) ensuring complete privacy. - Expiration Date: Prominent display of valid month and year (
Exp: 12/2028). - Default Card Star: Visual indicator badge designating the card used for automated plan sweeps.
- Management Controls: Options to make default or permanently remove vaulted cards.
4.2 Add Vaulted Payment Method Modal
Section titled β4.2 Add Vaulted Payment Method ModalβClicking Add Payment Method opens the secure tokenization form:

- Cardholder Name: Full legal billing name matching the issuing bank account.
- Card Details: Hosted iframe fields capturing card number, expiration date, and CVC security code.
- Set as Default Toggle: Checkbox automatically configuring the new card as primary for recurring charges.
5. Card Lifecycle Management & Default Routing
Section titled β5. Card Lifecycle Management & Default RoutingβThe portal enforces deterministic rules for stored cards:
- Single Default Enforceability: Only one card can be flagged as
is_default = trueper customer. Setting a new default card automatically updates previous cards in an atomic transaction. - Deletion Safeguards: Customers cannot delete a payment method if it is currently the sole active card on an account with an active recurring subscription plan.
- Automatic Expiry Tracking: Cards nearing expiration trigger portal banner warnings 30 days prior to month end.
6. Stripe Elements Client Tokenization
Section titled β6. Stripe Elements Client TokenizationβUnder PCI-DSS SAQ-A compliance:
- The web application uses Stripe Elements iframe injection.
- Keystrokes for the 16-digit Primary Account Number (PAN) and 3-digit Card Verification Value (CVV) are captured directly by Stripeβs encrypted infrastructure.
- Ring2All servers never log, cache, or process raw credit card numbers.
7. Database Schema & Data Dictionary
Section titled β7. Database Schema & Data DictionaryβTable: public.payment_methods
Section titled βTable: public.payment_methodsβCREATE TABLE public.payment_methods ( id BIGSERIAL PRIMARY KEY, uuid UUID NOT NULL DEFAULT gen_random_uuid(), customer_id BIGINT NOT NULL REFERENCES customers(id) ON DELETE CASCADE, gateway VARCHAR(30) NOT NULL DEFAULT 'stripe', gateway_method_id VARCHAR(100) NOT NULL, type VARCHAR(30) NOT NULL DEFAULT 'card', brand VARCHAR(30), last4 VARCHAR(4), exp_month INTEGER, exp_year INTEGER, is_default BOOLEAN NOT NULL DEFAULT false, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW());
-- Partial index ensuring fast default card resolutionCREATE INDEX idx_payment_methods_default ON payment_methods (customer_id) WHERE is_default = true;8. Diagnostic CLI & Operational Playbooks
Section titled β8. Diagnostic CLI & Operational PlaybooksβVerify Customer Vaulted Cards via Database
Section titled βVerify Customer Vaulted Cards via Databaseβsu - postgres -c "psql -d ss_billing -c \"SELECT brand, last4, exp_month, exp_year, is_default, gateway_method_idFROM payment_methodsWHERE customer_id = 5;\""9. Domain Glossary
Section titled β9. Domain Glossaryβ- Gateway Method ID: Opaque token (e.g.
pm_1N2e...) representing an authorized payment instrument. - PCI-DSS SAQ-A: Payment Card Industry Self-Assessment Questionnaire A for merchants who outsource all cardholder data functions.
- PAN (Primary Account Number): The 15 or 16-digit card number embossed on physical payment cards.

