Skip to content
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

Merged
merged 7 commits into from
Jan 26, 2024

Conversation

andrashee
Copy link
Contributor

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.

Copy link

vercel bot commented Jan 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
public ⬜️ Ignored (Inspect) Visit Preview Jan 26, 2024 4:21pm

Copy link

github-actions bot commented Jan 26, 2024

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,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@mkue
Copy link
Contributor

mkue commented Jan 26, 2024

Do you think it would make sense to update the constructContribution() function (and the Contribution model) and link the campaign name to the contribution object?

@andrashee
Copy link
Contributor Author

Do you think it would make sense to update the constructContribution() function (and the Contribution model) and link the campaign name to the contribution object?

That's a very good point, otherwise we actually lose the reference after we dismiss the original charge object.
Will change.

Base automatically changed from ahee/campaign-model to main January 26, 2024 13:16
# Conflicts:
#	admin/src/collections/Campaigns.ts
#	shared/src/types/campaign.ts
@andrashee andrashee merged commit 0b69374 into main Jan 26, 2024
22 checks passed
@andrashee andrashee deleted the ahee/campaign-updater branch January 26, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants