title | description |
---|---|
Invoice Receipt |
Send invoices or receipts immediately after a user purchases. |
Invoices and receipts require custom fields such as the order number, billing details, and objects purchased which must be dynamically fetched from the database. The use of step controls and the payload schema simplifies the fetching of that unique data.
Explore the source code on GitHub
<img style={{ borderRadius: '0.5rem' }} src="/images/how-to/invoice-receipt.png" />
import { workflow } from '@novu/framework';
import { renderAppleReceiptEmail } from '../emails/apple-receipt';
import { zodControlSchema, jsonSchema, zodPayloadSchema } from './schemas';
/**
* Apple Receipt workflow
*/
export const appleReceipt = workflow(
"Apple Receipt",
async ({ step, payload }) => {
await step.email(
"send-email",
async (controls) => {
return {
subject: controls.receiptSubject,
body: renderAppleReceiptEmail(controls, payload),
};
},
{
controlSchema: zodControlSchema
},
);
},
{
payloadSchema: zodPayloadSchema
}
);