BLACKROCK ENGINEERING STORE
Production-ready e-commerce platform — MedusaJS v2 backend with Stripe payments, Printful fulfillment, automated workflows, and comprehensive testing (157/157 tests passing).
Production-ready e-commerce platform — MedusaJS v2 backend with Stripe payments, Printful fulfillment, automated workflows, and comprehensive testing (157/157 tests passing).
A production-ready e-commerce platform for Blackrock Engineering's branded merchandise store. Built with MedusaJS v2 for headless commerce flexibility, integrated with Stripe for payments, Printful for print-on-demand fulfillment, and Resend for transactional emails. Features comprehensive testing, automated workflows, and production monitoring.
Complete backend implementation with custom workflows for order processing, payment capture, fulfillment automation, and email notifications. Integrated three major third-party APIs (Stripe, Printful, Resend) with comprehensive webhook handling and error recovery.
Achieved 99% launch readiness with 157/157 integration tests passing, covering all workflows, API endpoints, webhook handlers, and edge cases. Production-ready with monitoring, logging, and automated deployment.
export const sendOrderConfirmationWorkflow = createWorkflow(
'send-order-confirmation',
(input: SendOrderConfirmationInput) => {
const order = getOrderStep({ order_id: input.order_id });
const emailResult = sendEmailStep(
transform({ order }, ({ order }) => ({
to: order.email,
template: 'order-placed',
data: { order }
}))
);
const logResult = logEmailStep(
transform({ order, emailResult }, ({ order, emailResult }) => ({
order_id: order.id,
resend_email_id: emailResult.id,
template_id: 'order-placed'
}))
);
return new WorkflowResponse({ emailId: emailResult.id });
}
);export async function handlePaymentIntentSucceeded({
event: { data },
container,
}: SubscriberArgs<{ id: string }>) {
const orderModule = container.resolve(Modules.ORDER);
const paymentIntentId = data.id;
// Find order by payment intent metadata
const orders = await orderModule.listOrders({
payment_intent_id: paymentIntentId
});
if (orders[0]) {
// Update payment status
await orderModule.updateOrders([{
id: orders[0].id,
payment_status: 'captured'
}]);
// Trigger fulfillment workflow
await submitToPrintfulWorkflow(container).run({
input: { order_id: orders[0].id }
});
}
}medusaIntegrationTestRunner({
testSuite: ({ getContainer }) => {
describe('Email logging workflow', () => {
it('should log sent emails to database', async () => {
const container = getContainer();
const orderModule = container.resolve(Modules.ORDER);
// Create test order
const orders = await orderModule.createOrders([{
email: '[email protected]',
currency_code: 'usd'
}]);
// Execute workflow
const { result } = await sendOrderConfirmationWorkflow(
container
).run({
input: { order_id: orders[0].id }
});
// Verify email logged
expect(result.emailId).toBeDefined();
// Query database
const emailLog = await container.resolve('email_log')
.retrieve({ order_id: orders[0].id });
expect(emailLog.resend_email_id).toBe(result.emailId);
expect(emailLog.template_id).toBe('order-placed');
});
});
}
});Implemented event-driven workflows using MedusaJS v2 createWorkflow pattern with proper step isolation, error handling, and transaction management.
Triggered on order.placed event. Fetches order details, sends confirmation email via Resend, logs to email_log table with tracking ID.
Steps: getOrderStep → sendEmailStep → logEmailStep
Triggered after payment capture. Maps order items to Printful variants, formats shipping address, creates draft order with design files and thread colors.
Steps: validateOrderStep → mapPrintfulItemsStep → submitToPrintfulStep
Triggered on shipment.created event from Printful webhook. Sends tracking email with carrier info, estimated delivery, logs delivery status.
Steps: getShipmentStep → sendShippingEmailStep → logEmailStep