emails for rental cancelation, rental declined, rental request confirmation, payout received
This commit is contained in:
@@ -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",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user