-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BC5] Add product category support in
getProductInfo()
and `purchas…
…eProduct()` (#387) ## Motivation Currently, the `purchaseProduct(identifier, type)` method requires the developer to manually pass the type (either "subs" or "inapp") of the product they are purchasing. Even if they are basing this off of a fetched `StoreProduct`, the developer would need to determine what type of product it is because its currently not exposed in any of the hybrid SDKs. New hybrids versions will have a new `productCategory` property on `StoreProduct`. This value has always been sent from the Hybrid Common layer but was just never exposed on the models. It has values of "SUBSCRIPTION" and "NON_SUBSCRIPTION". These values should be able to be passed into the type of `purchaseProduct()` without any developer modification to make a purchase Example: ```dart Purchases.purchaseProduct(storeProduct.identifier, storeProduct.productCategory) ``` Goal of this is to **not** be a breaking API change but for Hybrid Common to handle these different values of legacy values ("subs" and "inapp") and the product categories of "SUBSCRIPTION" and "NON_SUBSCRIPTION" going forward. ## Description Mostly taken from #384 (which was reverted in the great unmigration of product type) - Moved hardcoded strings into `MappedProductCategory` enum with values of: - `SUBSCRIPTION` - `NON_SUBSCRIPTION` - `UNKNOWN` - New `mapStringToProductType()` helper method for converting from `String` to `ProductType` - First checks if string is a `MappedProductCategory` - Then sees if legacy value of "subs" or "inapp" - `mapStringToProductType()` is used in `getProductInfo()` and `purchaseProduct()
- Loading branch information
1 parent
2f3853d
commit 98ea582
Showing
3 changed files
with
128 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters