By ahmadanote26
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!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.