Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose currencyCode on Product object in IAP module #25058

Merged
merged 1 commit into from Aug 21, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/structures/product.md
Expand Up @@ -7,4 +7,5 @@
* `contentLengths` Number[] - The total size of the content, in bytes.
* `price` Number - The cost of the product in the local currency.
* `formattedPrice` String - The locale formatted price of the product.
* `currencyCode` String - 3 character code presenting a product's currency based on the ISO 4217 standard.
* `isDownloadable` Boolean - A Boolean value that indicates whether the App Store has downloadable content for this product. `true` if at least one file has been associated with the product.
3 changes: 3 additions & 0 deletions shell/browser/api/electron_api_in_app_purchase.cc
Expand Up @@ -61,6 +61,9 @@ struct Converter<in_app_purchase::Product> {
dict.Set("price", val.price);
dict.Set("formattedPrice", val.formattedPrice);

// Currency Information
dict.Set("currencyCode", val.currencyCode);

// Downloadable Content Information
dict.Set("isDownloadable", val.isDownloadable);

Expand Down
3 changes: 3 additions & 0 deletions shell/browser/mac/in_app_purchase_product.h
Expand Up @@ -28,6 +28,9 @@ struct Product {
double price = 0.0;
std::string formattedPrice;

// Currency Information
std::string currencyCode;

// Downloadable Content Information
bool isDownloadable = false;

Expand Down
8 changes: 8 additions & 0 deletions shell/browser/mac/in_app_purchase_product.mm
Expand Up @@ -146,6 +146,14 @@ - (NSString*)formatPrice:(NSDecimalNumber*)price
productStruct.formattedPrice =
[[self formatPrice:product.price
withLocal:product.priceLocale] UTF8String];

// Currency Information
if (@available(macOS 10.12, *)) {
if (product.priceLocale.currencyCode != nil) {
productStruct.currencyCode =
[product.priceLocale.currencyCode UTF8String];
}
}
}
}

Expand Down