Integrating Student Verification
GuideEnd-to-end tutorial on integrating student discount verification into an e-commerce checkout or SaaS registration flow.
This guide demonstrates how to integrate SyncNexa student verification into a modern web application (e.g. Next.js, Express, Rails, Django) to provide instant student discounts or educational tiers.
Integration Architecture
The standard web verification pattern combines a backend-initiated verification session with client-side redirection or modal popups and real-time webhook confirmation.
1. Backend Creates Verification Session
When the customer clicks "Verify Student Discount", your server calls the SyncNexa Verification API with your secret key:
| 1 | import axios from 'axios'; |
| 2 | |
| 3 | app.post('/api/create-student-verification', async (req, res) => { |
| 4 | const { customerId, cartId } = req.body; |
| 5 | |
| 6 | const response = await axios.post( |
| 7 | 'https://api.business.syncnexa.co/verification/v1/sessions', |
| 8 | { |
| 9 | appId: process.env.SYNCNEXA_APP_ID, |
| 10 | purpose: 'Student 20% Discount Verification', |
| 11 | requiredClaims: ['is_active_student', 'university_domain'], |
| 12 | metadata: { customerId, cartId }, |
| 13 | }, |
| 14 | { |
| 15 | headers: { |
| 16 | Authorization: `Bearer ${process.env.SYNCNEXA_SECRET_KEY}`, |
| 17 | 'Content-Type': 'application/json', |
| 18 | }, |
| 19 | } |
| 20 | ); |
| 21 | |
| 22 | res.json({ |
| 23 | verificationUrl: response.data.data.verificationUrl, |
| 24 | sessionId: response.data.data.sessionId, |
| 25 | }); |
| 26 | }); |
2. Frontend Renders "Verify with SyncID"
On your checkout page, render the button and redirect the student or open the verification modal:
| 1 | import React, { useState } from 'react'; |
| 2 | |
| 3 | export function StudentDiscountButton({ cartId }: { cartId: string }) { |
| 4 | const [loading, setLoading] = useState(false); |
| 5 | |
| 6 | const handleVerify = async () => { |
| 7 | setLoading(true); |
| 8 | const res = await fetch('/api/create-student-verification', { |
| 9 | method: 'POST', |
| 10 | headers: { 'Content-Type': 'application/json' }, |
| 11 | body: JSON.stringify({ cartId }), |
| 12 | }); |
| 13 | const { verificationUrl } = await res.json(); |
| 14 | window.location.href = verificationUrl; |
| 15 | }; |
| 16 | |
| 17 | return ( |
| 18 | <button |
| 19 | onClick={handleVerify} |
| 20 | disabled={loading} |
| 21 | className="btn-syncnexa" |
| 22 | > |
| 23 | {loading ? 'Opening SyncID...' : '🎓 Verify with SyncID for 20% Off'} |
| 24 | </button> |
| 25 | ); |
| 26 | } |
3. Backend Receives Webhook Event
When the student verifies on their mobile app or browser, your webhook handler receives the verification.completed event:
| 1 | app.post('/webhooks/syncnexa', async (req, res) => { |
| 2 | const event = req.body; |
| 3 | |
| 4 | if (event.event === 'verification.completed' && event.data.verified) { |
| 5 | const { customerId, cartId } = event.data.metadata; |
| 6 | await applyDiscountToCart(cartId, 0.20); |
| 7 | await markCustomerAsVerifiedStudent(customerId, event.data.university.name); |
| 8 | } |
| 9 | |
| 10 | res.status(200).json({ received: true }); |
| 11 | }); |
4. Unlock Student Benefit
Once the discount is applied, the checkout summary automatically updates and the student completes their order with the applied discount.