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

Add AndroidProrationMode values #273

Merged
merged 2 commits into from
Apr 10, 2021
Merged
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
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, {
String obfuscatedAccountIdAndroid,
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 @@ -648,3 +650,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;
}