Skip to content

Conversation

@begedin
Copy link
Contributor

@begedin begedin commented Jan 24, 2017

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 :errored

References

Progress on: #659

invoice =
StripeInvoice
|> Repo.get_by(id_from_stripe: invoice_id_from_stripe)
|> Repo.preload(stripe_connect_subscription: [stripe_connect_plan: :project])
Copy link
Contributor

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).

@begedin begedin force-pushed the add-receipt-emails branch 2 times, most recently from 69c28e2 to 530d72f Compare January 24, 2017 02:33
@joshsmith
Copy link
Contributor

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).

@begedin begedin force-pushed the add-receipt-emails branch 7 times, most recently from 749057d to 782ea80 Compare January 24, 2017 20:01
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")
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@begedin begedin force-pushed the add-receipt-emails branch from d7bfc60 to 0b1c8db Compare January 25, 2017 00:14
@begedin begedin merged commit b3032d2 into develop Jan 25, 2017
@begedin begedin deleted the add-receipt-emails branch January 25, 2017 00:24
@joshsmith joshsmith mentioned this pull request Jan 25, 2017
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants