How to Build a Pharmacy Discount Card
Pharmacy discount cards save patients 20–80% on prescription medications. Companies like GoodRx, SingleCare, and RxSaver have built billion-dollar businesses on this model. But the technical infrastructure behind these cards is poorly documented. This guide covers the end-to-end technical architecture: from BIN/PCN registration to live claim adjudication at the pharmacy counter.
What happens when a patient uses a discount card
When a patient presents a discount card at the pharmacy counter, here's the actual technical flow:
- 1.Card scan: The pharmacist enters the BIN, PCN, Group, and Member ID from the card into their pharmacy management system (PMS)
- 2.NCPDP encoding: The PMS encodes a B1 claim in NCPDP Telecommunication D.0 format, a binary, pipe-delimited protocol with 400+ field definitions
- 3.Switch routing: The claim is sent to a pharmacy switch (RelayHealth, Change Healthcare) which routes it based on the BIN number to the correct processor
- 4.Adjudication: Your claims processor (or PBM partner) receives the claim, applies your pricing logic, and returns an adjudication response with the patient pay amount
- 5.Response: The pharmacy displays the discounted price. Patient pays. Transaction complete.
The entire round-trip takes 2–5 seconds. Every major pharmacy in the US processes claims this way. It's the universal protocol.
The three numbers that make it work: BIN, PCN, and Group
Every discount card has three critical identifiers. Understanding them is essential:
A 6-digit number assigned by NCPDP that routes the claim to the correct processor. Think of it as the "phone number" of your claims processor. You get this from your PBM or claims processing partner.
An optional secondary routing code that identifies a specific plan or program within a BIN. One BIN can serve multiple PCNs, which is useful if you run different discount tiers or employer programs.
Identifies the specific benefit group (employer, organization, or plan). Used by the processor to look up pricing rules and formulary information.
Beyond these three, each card also has a Member ID (unique per cardholder) and a Person Code (01 for primary, 02 for spouse, 03+ for dependents).
Traditional approach: 6 months and $500K+
Historically, launching a discount card program required:
- 1.PBM partnership: Contract with a PBM or claims administrator to process your claims and provide a BIN/PCN. This alone takes 2–4 months of negotiation.
- 2.Switch connectivity: Negotiate contracts with pharmacy switches (RelayHealth, etc.) for claim routing. Requires VPN setup, certification testing, dedicated connectivity.
- 3.NCPDP implementation: Build or license an NCPDP D.0 encoder/decoder to speak the binary protocol. Most teams spend 3–6 months on this.
- 4.Pricing engine: Build the adjudication logic: MAC pricing, AWP discounts, pharmacy network reimbursement rates, dispensing fees.
- 5.Certification: Pass NCPDP certification testing. Demonstrate correct handling of all transaction types, edge cases, and reject scenarios.
Total cost: $300K–$500K+ in engineering time, plus ongoing switch fees, PBM fees, and maintenance. That's before you've signed a single customer.
The API approach: launch in weeks
Starlight API eliminates the infrastructure layer. Instead of building an NCPDP stack, you send JSON:
// Check if a member's card is valid before they visit the pharmacy
const eligibility = await fetch('https://starlight.claims/api/v1/submit', {
method: 'POST',
headers: {
'X-API-Key': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
transaction_type: 'E1',
patient: {
first_name: 'JANE',
last_name: 'DOE',
date_of_birth: '19850615'
},
insurance: {
bin_number: '610341', // Your assigned BIN
pcn: 'DISCOUNT', // Your program PCN
group_id: 'EMPLOYER001', // Employer or plan group
cardholder_id: 'MBR12345', // Member's card number
}
})
});
const result = await eligibility.json();
// result.header.responseStatus === 'A' → member is eligibleWhen it's time to process an actual claim at the pharmacy counter, Starlight handles the NCPDP encoding, switch routing, and response parsing. You focus on your product (pricing logic, member management, pharmacy network), not infrastructure.
Architecture for a discount card startup
Here's the minimal architecture you need:
Web/mobile app where members sign up, get their card (BIN/PCN/Group/Member ID), and check their savings history.
Your core business logic. Negotiated rates with pharmacy networks, MAC pricing tables, dispensing fee schedules. This is your competitive moat.
Handles NCPDP encoding, switch routing, and claim adjudication. You call our API, we handle the infrastructure.
Track claims volume, savings delivered, pharmacy utilization, revenue per claim. Essential for investor reporting and optimization.
Contracts with pharmacies or pharmacy networks (PSAO) that define your reimbursement rates and dispensing fees.
Revenue model: how discount cards make money
Understanding the economics is critical for building a sustainable business:
- • Spread pricing: You negotiate rates with pharmacies (e.g., AWP - 80% + $2.00 dispensing fee) and charge patients slightly more. The spread is your revenue. Typical margin: $3–$8 per claim.
- • Per-transaction fees: Some models charge pharmacies a per-claim processing fee (typically $0.10–$0.25).
- • Employer-funded: Employers pay a per-employee-per-month (PEPM) fee for their workforce to have access to discounted prescriptions. Typical PEPM: $2–$5.
- • Affiliate/referral: Earn fees by directing patients to specific pharmacies. Common in the GoodRx model.
At scale, even $3/claim margin across millions of monthly claims generates significant revenue. GoodRx processes ~100M claims/year.
Common technical pitfalls
- • BIN routing errors: If your BIN isn't properly registered with all major switches, pharmacies in certain regions won't be able to process your card. Test across multiple pharmacy chains before launch.
- • Reject code handling: NCPDP defines 100+ reject codes. Your system needs to handle each one gracefully: refill-too-soon (79), drug not covered (70), prior auth required (75), and dozens more.
- • Coordination of Benefits (COB): When a patient has both insurance and your discount card, the claim flow gets complex. Build clear logic for when to bill primary insurance vs. your discount program.
- • State regulations: Some states have specific requirements for discount card programs (registration, disclosures, fee caps). Check your target states before launch.
Related guides
- • BIN PCN Lookup API — understand the routing identifiers your card needs
- • How to Submit Pharmacy Claims via API — the claims submission your card program will use
- • Insurance Eligibility Verification API — check if the patient has primary insurance first
- • Pharmacy Claims Processing Workflow — how discount card claims flow through the system
Launch your discount card with Starlight
Skip the 6-month infrastructure build. Start processing claims in your sandbox today and go live when your pricing engine is ready.