Skip to content

Commit c4fc0e0

Browse files
authored
[in_app_purchase_storekit] fix price displayed with wrong precision (#8127)
Fixes flutter/flutter#159080
1 parent 5180c03 commit c4fc0e0

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.20+2
2+
3+
* Fixes price not being displayed correctly.
4+
15
## 0.3.20+1
26

37
* Prevent devices below iOS 15 or macOS 15 from enabling StoreKit2.

packages/in_app_purchase/in_app_purchase_storekit/lib/src/types/app_store_product_details.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class AppStoreProduct2Details extends ProductDetails {
6666
id: product.id,
6767
title: product.displayName,
6868
description: product.description,
69-
price: product.priceLocale.currencySymbol + product.price.toString(),
69+
price: product.displayPrice,
7070
rawPrice: product.price,
7171
currencyCode: product.priceLocale.currencyCode,
7272
currencySymbol: product.priceLocale.currencySymbol,

packages/in_app_purchase/in_app_purchase_storekit/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: in_app_purchase_storekit
22
description: An implementation for the iOS and macOS platforms of the Flutter `in_app_purchase` plugin. This uses the StoreKit Framework.
33
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_storekit
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
5-
version: 0.3.20+1
5+
version: 0.3.20+2
66

77
environment:
88
sdk: ^3.3.0

packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/pigeon_converter_test.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
54
import 'package:flutter_test/flutter_test.dart';
5+
import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';
66
import 'package:in_app_purchase_storekit/src/messages.g.dart';
7+
import 'package:in_app_purchase_storekit/src/store_kit_2_wrappers/sk2_product_wrapper.dart';
78
import 'package:in_app_purchase_storekit/store_kit_wrappers.dart';
89

910
void main() {
@@ -104,4 +105,24 @@ void main() {
104105
expect(wrapper.domain, 'domain');
105106
expect(wrapper.userInfo, <String, Object>{});
106107
});
108+
109+
test('test AppStoreProduct2Details conversion', () {
110+
final SK2Product product = SK2Product(
111+
id: '123',
112+
displayName: 'name',
113+
displayPrice: '0.99',
114+
description: 'description',
115+
price: 9.99,
116+
type: SK2ProductType.consumable,
117+
priceLocale: SK2PriceLocale(currencyCode: 'USD', currencySymbol: r'$'));
118+
119+
final AppStoreProduct2Details details =
120+
AppStoreProduct2Details.fromSK2Product(product);
121+
122+
expect(details.sk2Product, product);
123+
expect(details.price, product.displayPrice);
124+
expect(details.id, product.id);
125+
expect(details.description, product.description);
126+
expect(details.currencySymbol, product.priceLocale.currencySymbol);
127+
});
107128
}

0 commit comments

Comments
 (0)