In my company we have a very specific pricing strategy:
- Every
Product
in our catalog has abaseUsdPrice
, for example product Foo has base USD price of 9.99$. - That does not necessary mean that will be your you'll be paying 9.99$. We check your country for price exceptions - for example in GB Foo costs 8.99$
- Further more you can choose a currency you want to pay - if you're in GB you can pay in either USD (mentioned 8.99$) or your local currency (in this case GBP).
- If you choose to pay by your local currency we calculate an equivalent of 8.99$ to british pounds based on fixed price matrix (for example here that'll be 3.99£)
- This the price you pay.
How should I design my Product
aggregate root in DDD manner to be clean, cohesive, decoupled and easy to change?
- Should
paymentPrice
be calculated by domain service and its result put as a part ofProduct
aggregate? If so that means myProductRepository
will have methods likeproduct(productId, countryId, currency)
- Should I put all calculations in domain service class
PaymentPriceCalculator
and use visitor pattern likegetPaymentPrice(Country, Currency)
? What if I need to usepaymentPrice
from my entity to perform some business rule checks?
I'm trying to wrap my head around it and I think I'm overthinking it and it hurts. ;)