Skip to content

Commit

Permalink
refact: send receipts to vendors
Browse files Browse the repository at this point in the history
  • Loading branch information
kewitz committed Mar 4, 2024
1 parent 7e18f03 commit c6158e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/lib/notifications/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { replaceVideosByImagePreviews } from './utils';

const debug = debugLib('notifications');

const VENDOR_SUBSCRIBED_ACTIVITIES = [ActivityTypes.ORDER_THANKYOU];

type NotifySubscribersOptions = {
attachments?: any[];
bcc?: string;
Expand Down Expand Up @@ -147,7 +149,12 @@ export const notify = {
const collectiveId = options?.collectiveId || activity.CollectiveId;
const collective = options?.collective || (await models.Collective.findByPk(collectiveId));
const isVendor = collective?.type === CollectiveType.VENDOR;
if (isVendor) {
if (isVendor && VENDOR_SUBSCRIBED_ACTIVITIES.includes(activity.type)) {
// Notify the vendor, prioritizing the contact information used on the pending contribution data
const email = activity.data?.fromAccountInfo?.email || collective?.data?.vendorInfo?.contact?.email;
if (email) {
await emailLib.send(options?.template || activity.type, email, activity.data, options);
}
return;
}

Expand Down
2 changes: 2 additions & 0 deletions server/lib/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ const sendOrderConfirmedEmail = async (order, transaction) => {
firstPayment: true,
subscriptionsLink: interval && getEditRecurringContributionsUrl(fromCollective),
customMessage,
// Include Pending Order contact info if available
fromAccountInfo: order.data?.fromAccountInfo,
};

// hit PDF service and get PDF (unless payment method type is gift card)
Expand Down

0 comments on commit c6158e2

Please sign in to comment.