Skip to content
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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0-beta.10
Feature
* Adds 'offerPrice' to return Introductory price for Apple

## 1.0.0-beta.9
Chore
* Include latest chargebee-android with upgraded blilling client lib to v7.1.1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ To use Chargebee SDK in your Flutter app, follow these steps:

``` dart
dependencies:
chargebee_flutter: ^1.0.0-beta.9
chargebee_flutter: ^1.0.0-beta.10
```

2. Install dependency.
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.chargebee.flutter.sdk'
version '1.0.0-beta.9'
version '1.0.0-beta.10'

buildscript {
ext.kotlin_version = '1.6.0'
Expand Down
37 changes: 35 additions & 2 deletions ios/Classes/SwiftChargebeeFlutterSdkPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,39 @@ extension Encodable {

extension SKProduct {
func toMap() -> [String: Any?] {
let map: [String: Any?] = [
var map: [String: Any?] = [
"productId": productIdentifier,
"productPrice": price.doubleValue,
"productPriceString": price.description,
"productTitle": localizedTitle,
"currencyCode": priceLocale.currencyCode,
"subscriptionPeriod": subscriptionPeriod()
"subscriptionPeriod": subscriptionPeriod(),
]
if let introPrice = self.introductoryPrice {
map["offer"] = offerPrice(introPrice)
}
return map
}

func offerPrice(_ discount: SKProductDiscount) -> [String:Any?] {
let map: [String: Any?] = [
"id": discountIdentifier(discount),
"price": discount.price.doubleValue,
"priceString": discount.price.description,
"period": [ "periodUnit": periodUnit(discount.subscriptionPeriod.unit),
"numberOfUnits": discount.numberOfPeriods
]
]
return map
}

func discountIdentifier(_ discount: SKProductDiscount) -> String {
if #available(iOS 12.2, *) {
return discount.identifier ?? ""
}
return ""
}

func subscriptionPeriod() -> [String:Any?] {
let period:String = periodUnit()
let subscriptionPeriod: [String: Any?] = [
Expand All @@ -423,4 +446,14 @@ extension SKProduct {
case .none, .some(_): return ""
}
}

func periodUnit(_ period: SKProduct.PeriodUnit) -> String {
switch period {
case .day: return "day"
case .week: return "week"
case .month: return "month"
case .year: return "year"
default: return ""
}
}
}
2 changes: 1 addition & 1 deletion ios/chargebee_flutter.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'chargebee_flutter'
s.version = '1.0.0-beta.9'
s.version = '1.0.0-beta.10'
s.summary = 'This is the official Software Development Kit (SDK) for Chargebee Flutter.'
s.description = <<-DESC
A new Flutter plugin.
Expand Down
7 changes: 4 additions & 3 deletions lib/src/models/product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Product {
/// For Android, returns the basePlanId
late String? baseProductId;

/// For Android, returns the Offer details if present
/// For Android and iOS, returns the Offer details if present
late Offer? offer;

/// For Android, returns the offerToken
Expand All @@ -29,9 +29,10 @@ class Product {
/// Subscription period, which consists of unit and number of units
late SubscriptionPeriod subscriptionPeriod;


Product(this.id, this.baseProductId, this.offer, this.offerToken, this.price, this.priceString, this.title, this.currencyCode,
this.subscriptionPeriod);

/// convert json data into Product model
factory Product.fromJson(Map<String, dynamic> json) {
debugPrint('json: $json');
Expand All @@ -51,7 +52,7 @@ class Product {
json['productPriceString'] as String,
json['productTitle'] as String,
json['currencyCode'] as String,
subscriptionPeriod,
subscriptionPeriod
);
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chargebee_flutter
description: This is the official Software Development Kit (SDK) for Chargebee Flutter.
version: 1.0.0-beta.9
version: 1.0.0-beta.10
homepage: 'https://chargebee.com'
repository: 'https://github.com/chargebee/chargebee-flutter'

Expand Down