|Pathologically Eclectic Rubbish Lister|
Multidimensional arraysby Bod (Vicar)
|on Jun 06, 2023 at 14:55 UTC||Need Help??|
Bod has asked for the wisdom of the Perl Monks concerning the following question:
We operate a few sites with subscriptions. Until recently, the subscription cost has been fixed with just three plan options - monthly, 6 monthly or annually. However, we now want to increase the cost on one site for new members but not existing members. Existing members will have their current subscription rate locked for life.
Currently, the three subscription rates are declared in a parameters file:
The price code is passed to Stripe during the checkout process.
Having multiple prices in the future means we need to adopt a different approach. Users have the option to change between payment plans so they can swap from monthly or annually, etc. Therefore, we need to know which pricing level they are on as well as the plan. We can (and currently do) easily get the plan from Stripe. But getting the level is more tricky. We'd have to get the price code and work backwards.
So, I am thinking of adding two fields to the Subscription table of the database - priceLevel and pricePlan - and replacing the above declarations with a two dimensional Perl array of hashref:
The two dimensions of the array corresponding to the two newly added database fields.
I have two doubts about this approach...
Any advice very welcome...