Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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
4 changes: 4 additions & 0 deletions packages/in_app_purchase/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.1

* iOS: Add currencyCode to priceLocale on productDetails.

## 0.2.0+8

* Add dependency on `androidx.annotation:annotation:1.0.0`.
Expand Down
2 changes: 2 additions & 0 deletions packages/in_app_purchase/ios/Classes/FIAObjectTranslator.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ + (NSDictionary *)getMapFromNSLocale:(NSLocale *)locale {
NSMutableDictionary *map = [[NSMutableDictionary alloc] init];
[map setObject:[locale objectForKey:NSLocaleCurrencySymbol] ?: [NSNull null]
forKey:@"currencySymbol"];
[map setObject:[locale objectForKey:NSLocaleCurrencyCode] ?: [NSNull null]
forKey:@"currencyCode"];
return map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ class SKProductWrapper {
// https://github.com/flutter/flutter/issues/26610
@JsonSerializable()
class SKPriceLocaleWrapper {
SKPriceLocaleWrapper({@required this.currencySymbol});
SKPriceLocaleWrapper(
{@required this.currencySymbol, @required this.currencyCode});

/// Constructing an instance from a map from the Objective-C layer.
///
Expand All @@ -318,6 +319,9 @@ class SKPriceLocaleWrapper {
///The currency symbol for the locale, e.g. $ for US locale.
final String currencySymbol;

///The currency code for the locale, e.g. USD for US locale.
final String currencyCode;

@override
bool operator ==(Object other) {
if (identical(other, this)) {
Expand All @@ -327,9 +331,10 @@ class SKPriceLocaleWrapper {
return false;
}
final SKPriceLocaleWrapper typedOther = other;
return typedOther.currencySymbol == currencySymbol;
return typedOther.currencySymbol == currencySymbol &&
typedOther.currencyCode == currencyCode;
}

@override
int get hashCode => this.currencySymbol.hashCode;
int get hashCode => hashValues(this.currencySymbol, this.currencyCode);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/in_app_purchase/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: in_app_purchase
description: A Flutter plugin for in-app purchases. Exposes APIs for making in-app purchases through the App Store and Google Play.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase
version: 0.2.0+8
version: 0.2.1


dependencies:
async: ^2.0.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ void main() {
productResponseWrapper.products.first.priceLocale.currencySymbol,
'\$',
);

expect(
productResponseWrapper.products.first.priceLocale.currencySymbol,
isNot('A'),
);
expect(
productResponseWrapper.products.first.priceLocale.currencyCode,
'USD',
);
expect(
productResponseWrapper.invalidProductIdentifiers,
isNotEmpty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final SKPaymentTransactionWrapper dummyTransaction =
);

final SKPriceLocaleWrapper dummyLocale =
SKPriceLocaleWrapper(currencySymbol: '\$');
SKPriceLocaleWrapper(currencySymbol: '\$', currencyCode: 'USD');

final SKProductSubscriptionPeriodWrapper dummySubscription =
SKProductSubscriptionPeriodWrapper(
Expand Down Expand Up @@ -67,7 +67,10 @@ final SkProductResponseWrapper dummyProductResponseWrapper =
);

Map<String, dynamic> buildLocaleMap(SKPriceLocaleWrapper local) {
return {'currencySymbol': local.currencySymbol};
return {
'currencySymbol': local.currencySymbol,
'currencyCode': local.currencyCode
};
}

Map<String, dynamic> buildSubscriptionPeriodMap(
Expand Down