-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[in_app_purchase] Ensure the introductoryPriceMicros field is transported as a String. #4370
Changes from all commits
1c7a0e5
48e3159
1ed3090
0fbf9e3
68744d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,9 @@ class SkuDetailsWrapper { | |
required this.description, | ||
required this.freeTrialPeriod, | ||
required this.introductoryPrice, | ||
required this.introductoryPriceMicros, | ||
@Deprecated('Use `introductoryPriceAmountMicros` parameter instead') | ||
String introductoryPriceMicros = '', | ||
this.introductoryPriceAmountMicros = 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the better option here is to make this
Then you don't need all the complicated logic in the getter, or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure that will work as the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll be changing it to required at that point presumably to match everything else, and it will already be a breaking change in general, so that doesn't seem like a significant issue. But it's not a big deal either way. |
||
required this.introductoryPriceCycles, | ||
required this.introductoryPricePeriod, | ||
required this.price, | ||
|
@@ -45,7 +47,9 @@ class SkuDetailsWrapper { | |
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 @@ class SkuDetailsWrapper { | |
@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; | ||
|
||
stuartmorgan-g marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// 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 @@ class SkuDetailsWrapper { | |
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 @@ class SkuDetailsWrapper { | |
description.hashCode, | ||
freeTrialPeriod.hashCode, | ||
introductoryPrice.hashCode, | ||
introductoryPriceMicros.hashCode, | ||
introductoryPriceAmountMicros.hashCode, | ||
introductoryPriceCycles.hashCode, | ||
introductoryPricePeriod.hashCode, | ||
price.hashCode, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
stuartmorgan-g marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// 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'); | ||
}); | ||
} | ||
stuartmorgan-g marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was published; it shouldn't be removed from the changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right and fixed it.