diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/product_details.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/product_details.dart index e1e563d6f905..2d82d04ae71e 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/product_details.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/product_details.dart @@ -10,6 +10,8 @@ class ProductDetails { required this.title, required this.description, required this.price, + required this.rawPrice, + required this.currencyCode, }); /// The identifier of the product. @@ -31,4 +33,13 @@ class ProductDetails { /// /// For example, on iOS it is specified in App Store Connect; on Android, it is specified in Google Play Console. final String price; + + /// The unformatted price of the product, specified in the App Store Connect or Sku in Google Play console based on the platform. + /// The currency unit for this value can be found in the [currencyCode] property. + /// The value always describes full units of the currency. (e.g. 2.45 in the case of $2.45) + final double rawPrice; + + /// The currency code for the price of the product. + /// Based on the price specified in the App Store Connect or Sku in Google Play console based on the platform. + final String currencyCode; } diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/test/src/types/product_details_test.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/test/src/types/product_details_test.dart new file mode 100644 index 000000000000..d6cbce04c64a --- /dev/null +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/test/src/types/product_details_test.dart @@ -0,0 +1,28 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart'; + +void main() { + group('Constructor Tests', () { + test( + 'fromSkProduct should correctly parse data from a SKProductWrapper instance.', + () { + final ProductDetails productDetails = ProductDetails( + id: 'id', + title: 'title', + description: 'description', + price: '13.37', + currencyCode: 'USD', + rawPrice: 13.37); + + expect(productDetails.id, 'id'); + expect(productDetails.title, 'title'); + expect(productDetails.description, 'description'); + expect(productDetails.rawPrice, 13.37); + expect(productDetails.currencyCode, 'USD'); + }); + }); +}