"Untitled"
Bootstrap 4.1.1 Snippet by Arjunverma

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <h2>Strip payment integration in nodejs</h2> </div> </div>
let loginUser = req.user_data; let data = await Model.Order(req.body) if (data) { const customer = await stripe.customers.create({ description: 'My Second Test Customer', email: loginUser[0].email, name: loginUser[0].name, address: { line1: '510 Townsend St', postal_code: '98140', city: 'San Francisco', state: 'CA', country: 'US', }, }) const token = await stripe.tokens.create({ card: { number: data.number, exp_month: data.exp_month, exp_year: data.exp_year, cvc: data.cvc, }, }); const charge = await stripe.charges.create({ amount: parseInt(data.amount) * 100, currency: data.currency, description: 'This is the dummy ammount for testing purpose', source: token.id, }) // Create customer for payment // const plan = await stripe.plans.create( // { // amount: 150, // currency: 'INR', // interval: 'day', // product: { // name: 'Gold' // }, // } // ); // // Create price for payment // const price = await stripe.prices.create({ // unit_amount: plan.amount, // currency: plan.currency, // recurring: { interval: plan.interval }, // product: plan.product, // }); // // Create Subscription for payment // const subscription = await stripe.subscriptions.create({ // customer: customer.id, // items: [ // { price: price.id }, // ], // }); // let prod = await Model.Cart.find({userId :loginUser[0].id }) // console.log(prod) let items = []; let orderSave = await Model.Cart.aggregate([ { $match: { userId: loginUser[0]._id } }, { $lookup: { from: 'products', localField: 'productId', foreignField: '_id', as: "productDetails" } }, { $unwind: '$productDetails' }, { $project: { prodId: "$productId", prodPrice: "$productDetails.productPrice", prodQuantity: "$quantity" } } ]) if (orderSave.length > 0) { for (let i = 0; i < orderSave.length; i++) { let orderItem = orderSave[i]; items.push({ prodId: orderItem.prodId, prodPrice: orderItem.prodPrice, prodQuantity: orderItem.prodQuantity, }) } } console.log(orderSave, ">>>>>>") let result = Object.assign(data, { transactionId: charge.id, paidAmmount: charge.amount, currency: charge.currency, // subscriptionId: subscription.id, status: charge.status, customerId: customer.id, items: items, }) let saveOrder = await data.save(result) console.log(saveOrder) }

Related: See More


Questions / Comments: