-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
feature(functions): update campaign amount_collected_chf in stripe hook #714
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Visit the preview URL for this PR (updated for commit 42fb6b6): https://si-admin-staging--pr714-ahee-campaign-update-rtiq802y.web.app (expires Fri, 02 Feb 2024 16:25:40 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: b7b0969384059dce6ea8fad1ee1d1737e54e6676 |
const campaign = await campaignRef.get(); | ||
const current_amount_chf = campaign.data()?.amount_collected_chf ?? 0; | ||
await campaignRef.update({ | ||
amount_collected_chf: current_amount_chf + charge.amount, |
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.
Is it possible that you should use charge.balanceTransaction.amount
here? The amount
field could be in a different currency, right?
At least that's how we do it in the constructContribution()
function.
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.
Ah very good point. Will change.
Do you think it would make sense to update the |
That's a very good point, otherwise we actually lose the reference after we dismiss the original charge object. |
# Conflicts: # admin/src/collections/Campaigns.ts # shared/src/types/campaign.ts
More an outline of how it could be done, rather than the final implementation.
Needs testing if the metadata appended here #713 actually gets appended to a charge by stripe.