-
Notifications
You must be signed in to change notification settings - Fork 86
Add receipt emails #661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add receipt emails #661
Conversation
| invoice = | ||
| StripeInvoice | ||
| |> Repo.get_by(id_from_stripe: invoice_id_from_stripe) | ||
| |> Repo.preload(stripe_connect_subscription: [stripe_connect_plan: :project]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's entirely possible that the invoice event has not yet hit our database. And this only works for subscriptions, since there is no invoice for one-off charges.
Perhaps we should be making use of metadata in order to associate these. I see no way we could otherwise associate a charge (to an organization) with a project (where the donation is actually made).
69c28e2 to
530d72f
Compare
|
It's entirely possible that the invoice event has not yet hit our database. And this only works for subscriptions, since there is no invoice for one-off charges. Perhaps we should be making use of metadata in order to associate these. I see no way we could otherwise associate a charge (to an organization) with a project (where the donation is actually made). |
749057d to
782ea80
Compare
config/prod.exs
Outdated
| force_ssl: [rewrite_on: [:x_forwarded_proto]], | ||
| secret_key_base: System.get_env("SECRET_KEY_BASE") | ||
|
|
||
| config :code_corps, System.get_env("SITE_URL") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we use this in this case but not the others? Would probably recommend doing codecorps.org here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed we might want to set it through the environment. I'm completely ok with setting it here directly, though.
d7bfc60 to
0b1c8db
Compare
What's in this PR?
Generates and sends a receipt email when handling the "charge.succeeded" event. The recipient is the user related to the charge customer.
Since the receipt contains information about the project, we get that through the invoice.
Since there is a non-zero chance that the invoice is not stored locally at the time the charge event is being handled, it is instead explicitly retrieved from stripe.
If something goes wrong while generating the email, the event will be marked as
:erroredReferences
Progress on: #659