Commit 08a9b2c
authored
[in_app_purchase_storekit] Add support for quantity in consumable product purchases (#171570) (#9698)
This PR adds support for specifying a `quantity` when purchasing **consumable** products using StoreKit 2 in the `in_app_purchase_storekit` package.
#### ✅ What’s changing
* Introduces logic to read the `quantity` field from `PurchaseParam` and insert it into the native StoreKit 2 `.purchase(options:)` call.
* Ensures this logic is only applied to consumable products.
* Adds null checks and default behavior to maintain compatibility with purchases that don’t specify quantity.
#### 🧪 Testing
* Added unit tests to verify quantity handling in `Sk2PurchaseParam`:
* ✅ Verifies that a custom quantity is passed correctly to native purchase options.
* ✅ Ensures that quantity defaults to `1` when not explicitly provided.
* Tests cover `buyConsumable` flows using `fakeStoreKit2Platform`.
* Verified on a real device using StoreKit 2 with different `quantity` values.
* Ensures no change to StoreKit 1 flow or other product types.
#### 📌 Fixes
Fix [#171570](flutter/flutter#171570)1 parent 3f38423 commit 08a9b2c
File tree
4 files changed
+44
-1
lines changed- packages/in_app_purchase/in_app_purchase_storekit
- darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2
- test
4 files changed
+44
-1
lines changedLines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
263 | 299 | | |
264 | 300 | | |
265 | 301 | | |
| |||
0 commit comments