Report this

What is the reason for this report?

Débloquez un tutoriel vidéo après le paiement avec le nodejs Stripe ex: (les tutorials de udemy)

Posted on September 15, 2020

I created a registration page for the user to have their own account and a login page for them to log in. Now, after the user is logged in, I submit a video tutorial payable with Stripe. What I wanted was after purchasing this course with Stripe. The tutorial automatically unlocks for the user.

here is my code with Stripe. I tested it and it works great.

const postCharge = (req, res) =>{
    console.log(req.body);

   const email = req.body.stripeEmail
   const source = req.body.stripeToken

   const savePayment = new Payment({
       email: email,
       source: source
   })

   /***  */
    savePayment.save((err, userPayment) =>{
        if(err) console.log(err);
    })
   /*** */
   
  
    stripe.customers.create({
      email: email,
      source:  source
    })
    .then(customer => stripe.charges.create({
        amount: 2500,
        currency: "usd",
        customer: customer.id
    }))
    
    .then(() => res.render('success'))
    .catch((error) => console.log(error))
    
    
}

I want to save somewhere that user now has access to the tutorial (eg in MongoDB if you are using it)

s soon as he clicks he goes directly to the tutorial now unlocked thanks to the payment

<button class=“btn btn-info my-2 my-sm-0 m-3”> <a class=“nav-link text-white " href=”/Tuto"> Access aux Cours </a> </button>

But his link doesn’t work if he pays



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.