Skip to content

Commit

Permalink
Add AndroidProrationMode values (#273)
Browse files Browse the repository at this point in the history
* Add AndroidProrationMode values
   New class AndroidProrationMode with valid values as per 
   https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode

* Add detailed descriptions
  • Loading branch information
henry2man authored Apr 10, 2021
1 parent c265ca7 commit 82ca70a
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions lib/flutter_inapp_purchase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ class FlutterInappPurchase {

/// Request a purchase on `Android` or `iOS`.
/// Result will be received in `purchaseUpdated` listener or `purchaseError` listener.
///
///
/// Check [AndroidProrationMode] for valid proration values
/// Identical to [requestSubscription] on `iOS`.
Future requestPurchase(
String sku, {
Expand Down Expand Up @@ -250,7 +251,8 @@ class FlutterInappPurchase {
/// Result will be received in `purchaseUpdated` listener or `purchaseError` listener.
///
/// **NOTICE** second parameter is required on `Android`.
///
///
/// Check [AndroidProrationMode] for valid proration values
/// Identical to [requestPurchase] on `iOS`.
Future requestSubscription(
String sku, {
Expand Down Expand Up @@ -658,3 +660,26 @@ class FlutterInappPurchase {
}
}
}

/// A list of valid values for ProrationMode parameter
/// https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode
class AndroidProrationMode{
/// Replacement takes effect when the old plan expires, and the new price will be charged at the same time.
/// https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode#DEFERRED
static const int DEFERRED = 4;

/// Replacement takes effect immediately, and the billing cycle remains the same. The price for the remaining period will be charged. This option is only available for subscription upgrade.
/// https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode#immediate_and_charge_prorated_price
static const int IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2;

/// Replacement takes effect immediately, and the new price will be charged on next recurrence time. The billing cycle stays the same.
/// https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode#immediate_without_proration
static const int IMMEDIATE_WITHOUT_PRORATION = 3;

/// Replacement takes effect immediately, and the remaining time will be prorated and credited to the user. This is the current default behavior.
/// https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode#immediate_with_time_proration
static const int IMMEDIATE_WITH_TIME_PRORATION = 1;

/// https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode#unknown_subscription_upgrade_downgrade_policy
static const int UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0;
}

0 comments on commit 82ca70a

Please sign in to comment.