Block Hdfc Credit - Card Patched
await client.query('COMMIT'); return blockReq.rows[0]; catch (err) await client.query('ROLLBACK'); throw err; finally client.release();
button:hover:not(:disabled) background-color: #b91c1c; block hdfc credit card
// 2. Update card status (soft block first) await client.query( `UPDATE user_cards SET is_active = false, block_reason = $1, blocked_at = NOW() WHERE id = $2`, [reason, cardId] ); await client
CREATE TABLE user_cards ( id SERIAL PRIMARY KEY, user_id INT NOT NULL, card_number_hash VARCHAR(255) NOT NULL, -- hashed for security last_four VARCHAR(4) NOT NULL, card_network VARCHAR(20) DEFAULT 'Visa', card_type VARCHAR(20) DEFAULT 'Credit', expiry_month INT NOT NULL, expiry_year INT NOT NULL, is_active BOOLEAN DEFAULT true, is_permanently_blocked BOOLEAN DEFAULT false, block_reason VARCHAR(255), blocked_at TIMESTAMP, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE card_block_requests ( id SERIAL PRIMARY KEY, card_id INT REFERENCES user_cards(id), request_reason VARCHAR(100) NOT NULL, -- 'lost', 'stolen', 'fraud', 'other' description TEXT, status VARCHAR(20) DEFAULT 'pending', -- pending, processed, failed hdfc_reference_id VARCHAR(100), error_message TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, processed_at TIMESTAMP ); 1. Card Model ( models/Card.js ) const pool = require('../db'); class Card static async findActiveCardByUserAndLastFour(userId, lastFour) const result = await pool.query( SELECT * FROM user_cards WHERE user_id = $1 AND last_four = $2 AND is_active = true AND is_permanently_blocked = false , [userId, lastFour] ); return result.rows[0]; Create block request record const blockReq = await client
module.exports = router; api.ts const API_BASE = 'http://localhost:5000/api'; export interface BlockCardRequest 'stolen'
static async blockCard(cardId, reason, description) const client = await pool.connect(); try await client.query('BEGIN');
// 1. Create block request record const blockReq = await client.query( `INSERT INTO card_block_requests (card_id, request_reason, description, status) VALUES ($1, $2, $3, 'pending') RETURNING *`, [cardId, reason, description] );