I am accepting payments via stripe on a page and i am entering the successful payments data into a database via wixData.insert
If I wish to send an email from this database with a Hook, how to go about it ?
This is what my data.js looks like
//data.js
import {sendEmail, sendEmailWithRecipient} from 'backend/newOrder';
export function Payments_afterInsert(item, context) {
let hookContext = context; {
const subject1 = `Order ${item.orderId}`; //id from database
const body1 = `test`;
const recipient = item.clientEmail; //email from database
const subject2 = `Order ${item.amount} `; //amount from database
const body2 = `test`;
sendEmailWithRecipient(subject1, body1, recipient)
.then(response => console.log(response));
sendEmail(subject2, body2)
.then(response => console.log(response));
}
return item;
}
Please be kind First attempt at this