[in_app_purchase] Ensure the introductoryPriceMicros field is transported as a String. (#4370)

diff --git a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md
index 10c77cb..0c75ae3 100644
--- a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md
+++ b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md
@@ -1,5 +1,6 @@
-## NEXT
+## 0.1.5
 
+* Introduced the `SkuDetailsWrapper.introductoryPriceAmountMicros` field of the correct type (`int`) and deprecated the `SkuDetailsWrapper.introductoryPriceMicros` field.
 * Update dev_dependency `build_runner` to ^2.0.0 and `json_serializable` to ^5.0.2.
 
 ## 0.1.4+7
diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/sku_details_wrapper.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/sku_details_wrapper.dart
index 9c349ba..754f7a3 100644
--- a/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/sku_details_wrapper.dart
+++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/sku_details_wrapper.dart
@@ -32,7 +32,9 @@
     required this.description,
     required this.freeTrialPeriod,
     required this.introductoryPrice,
-    required this.introductoryPriceMicros,
+    @Deprecated('Use `introductoryPriceAmountMicros` parameter instead')
+        String introductoryPriceMicros = '',
+    this.introductoryPriceAmountMicros = 0,
     required this.introductoryPriceCycles,
     required this.introductoryPricePeriod,
     required this.price,
@@ -45,7 +47,9 @@
     required this.type,
     required this.originalPrice,
     required this.originalPriceAmountMicros,
-  });
+  }) : _introductoryPriceMicros = introductoryPriceMicros;
+
+  final String _introductoryPriceMicros;
 
   /// Constructs an instance of this from a key value map of data.
   ///
@@ -67,9 +71,19 @@
   @JsonKey(defaultValue: '')
   final String introductoryPrice;
 
-  /// [introductoryPrice] in micro-units 990000
-  @JsonKey(name: 'introductoryPriceAmountMicros', defaultValue: '')
-  final String introductoryPriceMicros;
+  /// [introductoryPrice] in micro-units 990000.
+  ///
+  /// Returns 0 if the SKU is not a subscription or doesn't have an introductory
+  /// period.
+  @JsonKey(name: 'introductoryPriceAmountMicros', defaultValue: 0)
+  final int introductoryPriceAmountMicros;
+
+  /// String representation of [introductoryPrice] in micro-units 990000
+  @Deprecated('Use `introductoryPriceAmountMicros` instead.')
+  @JsonKey(ignore: true)
+  String get introductoryPriceMicros => _introductoryPriceMicros.isEmpty
+      ? introductoryPriceAmountMicros.toString()
+      : _introductoryPriceMicros;
 
   /// The number of subscription billing periods for which the user will be given the introductory price, such as 3.
   /// Returns 0 if the SKU is not a subscription or doesn't have an introductory period.
@@ -131,7 +145,7 @@
         other.description == description &&
         other.freeTrialPeriod == freeTrialPeriod &&
         other.introductoryPrice == introductoryPrice &&
-        other.introductoryPriceMicros == introductoryPriceMicros &&
+        other.introductoryPriceAmountMicros == introductoryPriceAmountMicros &&
         other.introductoryPriceCycles == introductoryPriceCycles &&
         other.introductoryPricePeriod == introductoryPricePeriod &&
         other.price == price &&
@@ -150,7 +164,7 @@
         description.hashCode,
         freeTrialPeriod.hashCode,
         introductoryPrice.hashCode,
-        introductoryPriceMicros.hashCode,
+        introductoryPriceAmountMicros.hashCode,
         introductoryPriceCycles.hashCode,
         introductoryPricePeriod.hashCode,
         price.hashCode,
diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/sku_details_wrapper.g.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/sku_details_wrapper.g.dart
index 1fc450e..53d5931 100644
--- a/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/sku_details_wrapper.g.dart
+++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/sku_details_wrapper.g.dart
@@ -10,8 +10,8 @@
       description: json['description'] as String? ?? '',
       freeTrialPeriod: json['freeTrialPeriod'] as String? ?? '',
       introductoryPrice: json['introductoryPrice'] as String? ?? '',
-      introductoryPriceMicros:
-          json['introductoryPriceAmountMicros'] as String? ?? '',
+      introductoryPriceAmountMicros:
+          json['introductoryPriceAmountMicros'] as int? ?? 0,
       introductoryPriceCycles: json['introductoryPriceCycles'] as int? ?? 0,
       introductoryPricePeriod: json['introductoryPricePeriod'] as String? ?? '',
       price: json['price'] as String? ?? '',
@@ -31,7 +31,7 @@
       'description': instance.description,
       'freeTrialPeriod': instance.freeTrialPeriod,
       'introductoryPrice': instance.introductoryPrice,
-      'introductoryPriceAmountMicros': instance.introductoryPriceMicros,
+      'introductoryPriceAmountMicros': instance.introductoryPriceAmountMicros,
       'introductoryPriceCycles': instance.introductoryPriceCycles,
       'introductoryPricePeriod': instance.introductoryPricePeriod,
       'price': instance.price,
diff --git a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml
index 3a60abb..33f51cc 100644
--- a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml
+++ b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml
@@ -2,7 +2,7 @@
 description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs.
 repository: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase/in_app_purchase_android
 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
-version: 0.1.4+7
+version: 0.1.5
 
 environment:
   sdk: ">=2.12.0 <3.0.0"
diff --git a/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/sku_details_wrapper_deprecated_test.dart b/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/sku_details_wrapper_deprecated_test.dart
new file mode 100644
index 0000000..3e29d92
--- /dev/null
+++ b/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/sku_details_wrapper_deprecated_test.dart
@@ -0,0 +1,69 @@
+// 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.
+
+// TODO(mvanbeusekom): Remove this file when the deprecated
+//                     `SkuDetailsWrapper.introductoryPriceMicros` field is
+//                     removed.
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:in_app_purchase_android/billing_client_wrappers.dart';
+
+void main() {
+  test(
+      'Deprecated `introductoryPriceMicros` field reflects parameter from constructor',
+      () {
+    final SkuDetailsWrapper skuDetails = SkuDetailsWrapper(
+      description: 'description',
+      freeTrialPeriod: 'freeTrialPeriod',
+      introductoryPrice: 'introductoryPrice',
+      // ignore: deprecated_member_use_from_same_package
+      introductoryPriceMicros: '990000',
+      introductoryPriceCycles: 1,
+      introductoryPricePeriod: 'introductoryPricePeriod',
+      price: 'price',
+      priceAmountMicros: 1000,
+      priceCurrencyCode: 'priceCurrencyCode',
+      priceCurrencySymbol: r'$',
+      sku: 'sku',
+      subscriptionPeriod: 'subscriptionPeriod',
+      title: 'title',
+      type: SkuType.inapp,
+      originalPrice: 'originalPrice',
+      originalPriceAmountMicros: 1000,
+    );
+
+    expect(skuDetails, isNotNull);
+    expect(skuDetails.introductoryPriceAmountMicros, 0);
+    // ignore: deprecated_member_use_from_same_package
+    expect(skuDetails.introductoryPriceMicros, '990000');
+  });
+
+  test(
+      '`introductoryPriceAmoutMicros` constructor parameter is reflected by deprecated `introductoryPriceMicros` and `introductoryPriceAmountMicros` fields',
+      () {
+    final SkuDetailsWrapper skuDetails = SkuDetailsWrapper(
+      description: 'description',
+      freeTrialPeriod: 'freeTrialPeriod',
+      introductoryPrice: 'introductoryPrice',
+      introductoryPriceAmountMicros: 990000,
+      introductoryPriceCycles: 1,
+      introductoryPricePeriod: 'introductoryPricePeriod',
+      price: 'price',
+      priceAmountMicros: 1000,
+      priceCurrencyCode: 'priceCurrencyCode',
+      priceCurrencySymbol: r'$',
+      sku: 'sku',
+      subscriptionPeriod: 'subscriptionPeriod',
+      title: 'title',
+      type: SkuType.inapp,
+      originalPrice: 'originalPrice',
+      originalPriceAmountMicros: 1000,
+    );
+
+    expect(skuDetails, isNotNull);
+    expect(skuDetails.introductoryPriceAmountMicros, 990000);
+    // ignore: deprecated_member_use_from_same_package
+    expect(skuDetails.introductoryPriceMicros, '990000');
+  });
+}
diff --git a/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/sku_details_wrapper_test.dart b/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/sku_details_wrapper_test.dart
index 62d9104..18804a4 100644
--- a/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/sku_details_wrapper_test.dart
+++ b/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/sku_details_wrapper_test.dart
@@ -11,7 +11,7 @@
   description: 'description',
   freeTrialPeriod: 'freeTrialPeriod',
   introductoryPrice: 'introductoryPrice',
-  introductoryPriceMicros: 'introductoryPriceMicros',
+  introductoryPriceAmountMicros: 990000,
   introductoryPriceCycles: 1,
   introductoryPricePeriod: 'introductoryPricePeriod',
   price: 'price',
@@ -134,7 +134,7 @@
     'description': original.description,
     'freeTrialPeriod': original.freeTrialPeriod,
     'introductoryPrice': original.introductoryPrice,
-    'introductoryPriceAmountMicros': original.introductoryPriceMicros,
+    'introductoryPriceAmountMicros': original.introductoryPriceAmountMicros,
     'introductoryPriceCycles': original.introductoryPriceCycles,
     'introductoryPricePeriod': original.introductoryPricePeriod,
     'price': original.price,