Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 4x 4x 4x 4x 1x 1x 1x 4x | const api_key=require('../config/config');
const stripe = require("stripe")(api_key.stripePayment);
const Course = require('../model/courses')
exports.stripeCourse =(req,res)=>{
const courseId = req.params.courseId;
Course.findById({_id:courseId})
.then(course=>{
res.status(200).json({course:course})
})
.catch(err=>{
console.log(err)
})
}
exports.stripePayment=(req,res)=>{
let {amount,id} = req.body;
console.log(amount,id);
stripe.paymentIntents.create({
amount:amount,
currency:"inr",
description: "Coursera clone just testing",
payment_method: id,
confirm: true,
}).then(response=>{
console.log(response);
res.status(200).json({
message:"payment successful",
success:true})}
)
.catch(err=>{
console.log(err);
res.json({
message: "Payment Failed",
success: false,})
})
}
|