Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[in_app_purchase_platform_interface] Added additional fields to ProductDetails #3826

Merged
merged 3 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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');
});
});
}