Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

BillingFlowParams.Builder

public static class BillingFlowParams.Builder
extends Object

java.lang.Object
   ↳ com.android.billingclient.api.BillingFlowParams.Builder


Helps to construct BillingFlowParams that are used to initiate a purchase flow.

Summary

Public methods

BillingFlowParams.Builder addOldSku(String oldSku)

Add the SKU that the user is upgrading or downgrading from.

BillingFlowParams build()

Returns BillingFlowParams reference to initiate a purchase flow.

BillingFlowParams.Builder setAccountId(String accountId)

Specify an optional obfuscated string that is uniquely associated with the user's account in your app.

BillingFlowParams.Builder setOldSku(String oldSku)

Specify the SKU that the user is upgrading or downgrading from.

BillingFlowParams.Builder setOldSkus(ArrayList<String> oldSkus)

This method is deprecated. Use setOldSku(String) instead.

BillingFlowParams.Builder setReplaceSkusProrationMode(int replaceSkusProrationMode)

Specifies the mode of proration during subscription upgrade/downgrade.

BillingFlowParams.Builder setSku(String sku)

Specify the SKU that is being purchased or upgraded/downgraded to as published in the Google Developer console.

BillingFlowParams.Builder setType(String type)

Specify the billing type BillingClient.SkuType of the item being purchased.

BillingFlowParams.Builder setVrPurchaseFlow(boolean isVrPurchaseFlow)

Specify an optional flag indicating whether you wish to launch a VR purchase flow.

Inherited methods

From class java.lang.Object

Public methods

addOldSku

BillingFlowParams.Builder addOldSku (String oldSku)

Add the SKU that the user is upgrading or downgrading from.

Mandatory:

  • To replace an old subscription

Parameters
oldSku String

Returns
BillingFlowParams.Builder

build

BillingFlowParams build ()

Returns BillingFlowParams reference to initiate a purchase flow.

Returns
BillingFlowParams

setAccountId

BillingFlowParams.Builder setAccountId (String accountId)

Specify an optional obfuscated string that is uniquely associated with the user's account in your app.

If you pass this value, Google Play can use it to detect irregular activity, such as many devices making purchases on the same account in a short period of time. Do not use the developer ID or the user's Google ID for this field. In addition, this field should not contain the user's ID in cleartext. We recommend that you use a one-way hash to generate a string from the user's ID and store the hashed string in this field.

Optional:

  • To buy in-app item
  • To create a new subscription
  • To replace an old subscription

Parameters
accountId String

Returns
BillingFlowParams.Builder

setOldSku

BillingFlowParams.Builder setOldSku (String oldSku)

Specify the SKU that the user is upgrading or downgrading from.

Mandatory:

  • To replace an old subscription

Parameters
oldSku String

Returns
BillingFlowParams.Builder

setOldSkus

BillingFlowParams.Builder setOldSkus (ArrayList<String> oldSkus)

This method is deprecated.
Use setOldSku(String) instead.

Specify the SKU(s) that the user is upgrading or downgrading from.

Mandatory:

  • To replace an old subscription

Parameters
oldSkus ArrayList

Returns
BillingFlowParams.Builder

setReplaceSkusProrationMode

BillingFlowParams.Builder setReplaceSkusProrationMode (int replaceSkusProrationMode)

Specifies the mode of proration during subscription upgrade/downgrade. This value will only be effective if oldSkus is set.

If you set this to NO_PRORATION, the user does not receive credit or charge, and the recurrence date does not change.

If you set this to PRORATE_BY_TIME, Google Play swaps out the old SKUs and credits the user with the unused value of their subscription time on a pro-rated basis. Google Play applies this credit to the new subscription, and does not begin billing the user for the new subscription until after the credit is used up.

If you set this to PRORATE_BY_PRICE, Google Play swaps out the old SKUs and keeps the recurrence date not changed. User will be charged for the price differences to cover the time till next recurrence date.

Optional:

  • To buy in-app item
  • To create a new subscription
  • To replace an old subscription

Parameters
replaceSkusProrationMode int

Returns
BillingFlowParams.Builder

setSku

BillingFlowParams.Builder setSku (String sku)

Specify the SKU that is being purchased or upgraded/downgraded to as published in the Google Developer console.

Mandatory:

  • To buy in-app item
  • To create a new subscription
  • To replace an old subscription

Parameters
sku String

Returns
BillingFlowParams.Builder

setType

BillingFlowParams.Builder setType (String type)

Specify the billing type BillingClient.SkuType of the item being purchased.

Mandatory:

  • To buy in-app item
  • To create a new subscription
  • To replace an old subscription

Parameters
type String

Returns
BillingFlowParams.Builder

setVrPurchaseFlow

BillingFlowParams.Builder setVrPurchaseFlow (boolean isVrPurchaseFlow)

Specify an optional flag indicating whether you wish to launch a VR purchase flow.

Optional:

  • To buy in-app item
  • To create a new subscription
  • To replace an old subscription

Parameters
isVrPurchaseFlow boolean

Returns
BillingFlowParams.Builder