Skip to content

Commit

Permalink
Merge pull request #138 from beabee-communityrm/feat/1292-failed-firs…
Browse files Browse the repository at this point in the history
…t-payment-email

feat: add email for failed initial contributions
  • Loading branch information
wpf500 authored Feb 18, 2025
2 parents 29c8165 + 3c789d9 commit 7876dd0
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 1 deletion.
23 changes: 23 additions & 0 deletions packages/core/src/data/email/contribution-didnt-start_de.yfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
subject: Ihre erste Zahlung ist gescheitert
---

<p>Hallo *|FNAME|* *|LNAME|*</p>
<p><br /></p>
<p>
vielen Dank, dass Sie Mitglied bei *|ORGNAME|* geworden sind. Leider konnte
Ihre erste Zahlung nicht verarbeitet werden.
</p>
<p><br /></p>
<p>
Um das Problem zu beheben, können Sie sich entweder über den untenstehenden
Link einloggen, um Ihre Zahlungsdaten zu aktualisieren, oder unser
Support-Team unter <a href="mailto:*|SUPPORTEMAIL|*">*|SUPPORTEMAIL|*</a>
kontaktieren.
</p>
<p><br /></p>
<p>
<a href="*|LOGINLINK|*"><b>Zum Login</b></a>
</p>
<p><br /></p>
<p>Danke und freundliche Grüße</p>
23 changes: 23 additions & 0 deletions packages/core/src/data/email/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
subject: Deine erste Zahlung ist gescheitert
---

<p>Hallo *|FNAME|*,</p>
<p><br /></p>
<p>
vielen Dank, dass Du Mitglied bei *|ORGNAME|* geworden bist. Leider konnte
Deine erste Zahlung nicht verarbeitet werden.
</p>
<p><br /></p>
<p>
Um das Problem zu beheben, kannst Du dich entweder über den untenstehenden
Link einloggen, um Deine Zahlungsdaten zu aktualisieren, oder unser
Support-Team unter <a href="mailto:*|SUPPORTEMAIL|*">*|SUPPORTEMAIL|*</a>
kontaktieren.
</p>
<p><br /></p>
<p>
<a href="*|LOGINLINK|*"><b>Zum Login</b></a>
</p>
<p><br /></p>
<p>Danke und freundliche Grüße</p>
22 changes: 22 additions & 0 deletions packages/core/src/data/email/contribution-didnt-start_en.yfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
subject: Your first payment failed
---

<p>Hello *|FNAME|*</p>
<p><br /></p>
<p>
We're really grateful to you for starting a contribution with *|ORGNAME|*,
however unfortunately your first payment couldn't be processed.
</p>
<p><br /></p>
<p>
To fix the problem you can either login using the link below to update your
payment method, or contact our support team on
<a href="mailto:*|SUPPORTEMAIL|*">*|SUPPORTEMAIL|*</a>
</p>
<p><br /></p>
<p>
<a href="*|LOGINLINK|*"><b>Login</b></a>
</p>
<p><br /></p>
<p>Best wishes</p>
22 changes: 22 additions & 0 deletions packages/core/src/data/email/contribution-didnt-start_pt.yfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
subject: O teu primeiro pagamento falhou
---

<p>Olá *|FNAME|*,</p>
<p><br /></p>
<p>
Agradecemos muito a tua contribuição para o *|ORGNAME|*, mas infelizmente o
teu primeiro pagamento não foi processado com sucesso.
</p>
<p><br /></p>
<p>
Para corrigir o problema actualiza o teu método de pagamento no link que segue
abaixo, ou entra em contacto connosco por email via
<a href="mailto:*|SUPPORTEMAIL|*">*|SUPPORTEMAIL|*</a>.
</p>
<p><br /></p>
<p>
<a href="*|LOGINLINK|*"><b>Login</b></a>
</p>
<p><br /></p>
<p>Até já!</p>
2 changes: 1 addition & 1 deletion packages/core/src/data/email/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
subject: Mitglieder-Account existiert bereits
---

<p>Hallo *|FNAME|* *|LNAME|*,</p>
<p>Hallo *|FNAME|*,</p>
<p><br /></p>
<p>
Du hast versucht, mit dieser Email-Adresse einen Account bei uns anzulegen.
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/lib/stripe-webhook-event-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { stripe, convertStatus, getSalesTaxRateObject } from "./stripe";
import { Payment, ContactContribution } from "../models";
import config from "../config/config";

import EmailService from "../services/EmailService";
import GiftService from "../services/GiftService";
import ContactsService from "../services/ContactsService";
import PaymentService from "../services/PaymentService";
Expand Down Expand Up @@ -109,6 +110,10 @@ export class StripeWebhookEventHandler {
await PaymentService.updateData(contribution.contact, {
subscriptionId: null
});
await EmailService.sendTemplateToContact(
"contribution-didnt-start",
contribution.contact
);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/services/EmailService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ const contactEmailTemplates = {
CALLOUTTITLE: params.calloutTitle,
CALLOUTLINK: `${config.audience}/callouts/${params.calloutSlug}`,
SUPPORTEMAIL: OptionsService.getText("support-email")
}),
"contribution-didnt-start": (_: Contact) => ({
ORGNAME: OptionsService.getText("organisation"),
SUPPORTEMAIL: OptionsService.getText("support-email")
})
} as const;

Expand Down

0 comments on commit 7876dd0

Please sign in to comment.