Add support for SK2 discounts#1038
Conversation
|
This pull request has been linked to Shortcut Story #11617: Create abstraction for |
NFC (not functional change) Just a small refactor while working on #1038, separating here for easier review. Simplifying these will help when adding some new types to `ProductInfo`. I'm guessing some of these things are leftovers from the Swift migration. ## Changes: - Refactored `ProductInfoExtractorTests`, moved duplicated code into `setUp` - `ProductInfoExtractor` and `ISOPeriodFormatter`: replaced method with static function: these types contain no data, and there is only one possible implementation that we can have. For that reason, we're not mocking them or injecting them anywhere, so they're simpler as static functions. As an example, we had `lazy var isoPeriodFormatter = ISOPeriodFormatter()`, but again `ISOPeriodFormatter` contains no data, only logic, so there's no point having a `lazy` variable for it.
57b9079 to
5d1f5e4
Compare
There was a problem hiding this comment.
This isn't compiled in release mode, but I think it's useful for debugging?
Not sure if we should check that it's also not 0.
There was a problem hiding this comment.
Sounds good. I can't think of a use case where it'd be valid to have 0, so we might as well check for that too
|
This is ready for review, and hoping to get some answers to the questions 🙏 |
38320de to
d69bb0b
Compare
There was a problem hiding this comment.
Previously SubscriptionPeriod.PeriodUnit. Now SubscriptionPeriod.Unit.
…ionOffer.PaymentMode` For #848.
cdc6c68 to
dc52c04
Compare
There was a problem hiding this comment.
Sounds good. I can't think of a use case where it'd be valid to have 0, so we might as well check for that too
Fixes #848 and [sc-11617].
Changes:
IntroDurationType: moved insidePromotionalOfferPaymentMode: moved insidePromotionalOfferPromotionalOffer.pricetoDecimaland usingDecimalin more placesPromotionalOffer.PaymentModewith SK2'sProduct.SubscriptionOffer.PaymentModePromotionalOffer: added constructor with SK2'sProduct.SubscriptionOfferintroductoryPriceanddiscountstoStoreProductSubscriptionPeriodtoPromotionalOfferTODO:
Figure out whyexpect(offers[1].subscriptionPeriod) == SubscriptionPeriod(value: 10, unit: .month)fails:Looks like this only fails with
PromotionalOffer.PaymentMode.payAsYouGo. It could be just a problem with.storekitfiles, but for now I've updated the tests to use multi-month.freeTrialto have a test that coversvalues higher than 1.- [ ] From #848: "Move discount logic from Purchases to a new class". Which logic?Questions:
SubscriptionPeriodtoPromotionalOffer, which gets encoded inside ofProductInfo. I’m surprised that wasn’t there already, and that the backend doesn’t need it?`PaymentModeandIntroDurationTypeseem to be almost the same, the latter only used byProductInfo. Do we need it?ProductInfo(introDuration,introDurationType,introPrice) with a single `PromotionalOffer?Answers:
ProductInfoand its.asDictionary()by encoding the data inStoreProduct#1045 to deal with those 3 questions.