strapi-examples
strapi-examples copied to clipboard
/backend/api/order/controllers/Order.js empty?
Hi, This repo is broken in many ways. The Orders entity does not have the Users relationship, and the /backend/api/order/controllers/Order.js is empty... The tutorial https://strapi.io/blog/cooking-a-deliveroo-clone-with-nuxt-vue-js-graphql-strapi-and-stripe-order-and-checkout-part-6-7, suggests that the /backend/api/order/controllers/Order.js should be populated with `'use strict'; const stripe = require('stripe')('YOU_STRIPE_API_KEY');
module.exports = { create: async ctx => { const { address, amount, dishes, postalCode, token, city, } = ctx.request.body;
// Charge the customer
try {
await stripe.charges.create({
// Transform cents to dollars.
amount: amount * 100,
currency: 'usd',
description: `Order ${new Date()} by ${ctx.state.user.id}`,
source: token,
});
// Register the order in the database
try {
const order = await strapi.services.order.create({
user: ctx.state.user.id,
address,
amount,
dishes,
postalCode,
city,
});
return order;
} catch (err) {
// Silent
}
} catch (err) {
// Silent
}
}, };` but, adding this still does not work. As a new user to Strapi, your product has a lot of potential, but please update your tutorials.