欢迎参加我们将于 6 月 3 日举行的 #Android11:Beta 版发布会

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)

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

BillingFlowParams build()

Returns BillingFlowParams reference to initiate a purchase flow.

BillingFlowParams.Builder setAccountId(String accountId)

This method is deprecated. This method has been renamed to setObfuscatedAccountId(String).

BillingFlowParams.Builder setDeveloperId(String developerId)

This method is deprecated. Developer Id is not longer supported. See Account Id and Profile Id. See setObfuscatedAccountId(String) and setObfuscatedProfileId(String).

BillingFlowParams.Builder setObfuscatedAccountId(String obfuscatedAccountid)

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

BillingFlowParams.Builder setObfuscatedProfileId(String obfuscatedProfileId)

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

BillingFlowParams.Builder setOldSku(String oldSku)

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

BillingFlowParams.Builder setOldSku(String oldSku, String purchaseToken)

Specifies the SKU and purchase token that the user is upgrading or downgrading from.

BillingFlowParams.Builder setOldSkus(ArrayList<String> oldSkus)

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

BillingFlowParams.Builder setReplaceSkusProrationMode(int replaceSkusProrationMode)

Specifies the mode of proration during subscription upgrade/downgrade.

BillingFlowParams.Builder setSkuDetails(SkuDetails skuDetails)

Specifies the SkuDetails SkuDetails of the item being purchase.

BillingFlowParams.Builder setVrPurchaseFlow(boolean isVrPurchaseFlow)

Specifies 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)

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

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)

This method is deprecated.
This method has been renamed to setObfuscatedAccountId(String).

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

Parameters
accountId String

Returns
BillingFlowParams.Builder

setDeveloperId

BillingFlowParams.Builder setDeveloperId (String developerId)

This method is deprecated.
Developer Id is not longer supported. See Account Id and Profile Id. See setObfuscatedAccountId(String) and setObfuscatedProfileId(String).

Specifies an optional obfuscated string of developer profile name.

If you pass this value, Google Play can use it for payment risk evaluation. Do not use the account ID or the user's Google ID for this field.

Optional:

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

Parameters
developerId String

Returns
BillingFlowParams.Builder

setObfuscatedAccountId

BillingFlowParams.Builder setObfuscatedAccountId (String obfuscatedAccountid)

Specifies 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 this field to store any Personally Identifiable Information (PII) such as emails in cleartext. Attempting to store PII in this field will result in purchases being blocked. Google Play recommends that you use either encryption or a one-way hash to generate an obfuscated identifier to send to Google Play.

You can also retrieve this identifier via the Purchase object.

This identifier is limited to 64 characters.

Optional:

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

Parameters
obfuscatedAccountid String

Returns
BillingFlowParams.Builder

setObfuscatedProfileId

BillingFlowParams.Builder setObfuscatedProfileId (String obfuscatedProfileId)

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

Some applications allow users to have multiple profiles within a single account. Use this method to send the user's profile identifier to Google. Setting this field requests the user's obfuscated account id to be pass via setObfuscatedAccountId(String).

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 this field to store any Personally Identifiable Information (PII) such as emails in cleartext. Attempting to store PII in this field will result in purchases being blocked. Google Play recommends that you use either encryption or a one-way hash to generate an obfuscated identifier to send to Google Play.

You can also retrieve this identifier via the Purchase object.

This identifier is limited to 64 characters.

Optional:

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

Parameters
obfuscatedProfileId String

Returns
BillingFlowParams.Builder

setOldSku

BillingFlowParams.Builder setOldSku (String oldSku)

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

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

Mandatory:

  • To replace an old subscription

Parameters
oldSku String

Returns
BillingFlowParams.Builder

setOldSku

BillingFlowParams.Builder setOldSku (String oldSku, 
                String purchaseToken)

Specifies the SKU and purchase token that the user is upgrading or downgrading from. This will disambiguate situations where multiple accounts on the device own the same sku.

Mandatory:

  • To replace an old subscription

Parameters
oldSku String

purchaseToken String

Returns
BillingFlowParams.Builder

setOldSkus

BillingFlowParams.Builder setOldSkus (ArrayList<String> oldSkus)

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

Specifies 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

setSkuDetails

BillingFlowParams.Builder setSkuDetails (SkuDetails skuDetails)

Specifies the SkuDetails SkuDetails of the item being purchase.

Mandatory:

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

Parameters
skuDetails SkuDetails

Returns
BillingFlowParams.Builder

setVrPurchaseFlow

BillingFlowParams.Builder setVrPurchaseFlow (boolean isVrPurchaseFlow)

Specifies 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