Posts

Showing posts from May, 2025

Razorpay Payment Integration (MERN STACK)

Backend Packages:  Razorpay Code: const Razorpay = require ( ' razorpay ' ) ; const dotenv = require ( " dotenv " ) dotenv . config () const razorpay = new Razorpay ( {   key_id : process . env . RAZ_KEY_ID ,   key_secret : process . env . RAZ_KEY_SECRET , } ) ; exports . createOrder = async ( req , res ) => {     try {       const options = {         amount : req . body . amount ,         currency : ' INR ' ,         receipt : ' receipt_ ' + Math . random () . toString ( 36 ) . substring ( 7 ) ,         notes : req . body . notes               };       const order = await razorpay . orders . create ( options ) ;       res . status ( 200 ) . json ( order ) ;     } catch ( err ) {       res . status ( 500 ) . json ( { error : err . message }...

Google OAuth implementation in MERN stack

·           Get Your Client Id o    Go to : http://www.console.cloud.google.com o    Select or creat a new project and Go to Branding>Clients and create a new Client o    Add http://localhost and http://localhost:port both in the Authorised JavaScript origins sections Front end: Install : @react-oauth/google import { GoogleLogin , GoogleOAuthProvider } from "@react-oauth/google" export default function App () {   const handleSuccess = async ( response ) => {     try {       const token = response . credential       let serverResponse = await fetch ( "http://localhost:8080/api/auth/google" ,         {           method : "POST" ,           headers : { "content-type" : "application/json" },           body : JSON . stringify ({ token })       ...