hcb icon indicating copy to clipboard operation
hcb copied to clipboard

@emergenitro Limits on issuing cards

Open garyhtou opened this issue 11 months ago • 0 comments

Supersedes https://github.com/hackclub/hcb/pull/9018 due to git rewrite. Original PR by @emergenitro


Reverting back to Issue #8267, there is excessive card issuing which has to be prevented. In order to prevent that, as discussed, there's been a limit on user's issuing of virtual cards to 10 and physical cards to 4. This was done by validating it when the card is being issued.

Below is how it looks if the max is reached: image

To achieve this, we added validation methods in the StripeCard model: user_physical_card_limit_not_exceeded and user_virtual_card_limit_not_exceeded. These methods check the number of cards a user has issued within the organization (event) and prevent issuing new cards if the user has reached the maximum allowed.

I added a :non_granted scope to ensure these aren't grant cards, for which, there will be no limit. When staging, please check it out and ensure that everything is a-okay. Thanks!

garyhtou avatar Mar 17 '25 06:03 garyhtou