emails for rental cancelation, rental declined, rental request confirmation, payout received

This commit is contained in:
jackiettran
2025-10-27 13:07:02 -04:00
parent 407c69aa22
commit 502d84a741
17 changed files with 2690 additions and 45 deletions

View File

@@ -1,5 +1,6 @@
const { Rental, User } = require("../models");
const { Rental, User, Item } = require("../models");
const StripeService = require("./stripeService");
const emailService = require("./emailService");
const { Op } = require("sequelize");
class PayoutService {
@@ -21,6 +22,10 @@ class PayoutService {
},
},
},
{
model: Item,
as: "item",
},
],
});
@@ -75,6 +80,20 @@ class PayoutService {
`Payout completed for rental ${rental.id}: $${rental.payoutAmount} to ${rental.owner.stripeConnectedAccountId}`
);
// Send payout notification email to owner
try {
await emailService.sendPayoutReceivedEmail(rental);
console.log(
`Payout notification email sent to owner for rental ${rental.id}`
);
} catch (emailError) {
// Log error but don't fail the payout
console.error(
`Failed to send payout notification email for rental ${rental.id}:`,
emailError.message
);
}
return {
success: true,
transferId: transfer.id,
@@ -151,6 +170,10 @@ class PayoutService {
},
},
},
{
model: Item,
as: "item",
},
],
});