Purchase
public class Purchase
Represents an in-app billing purchase.
Summary
Nested types |
|---|
public final class Purchase.PendingPurchaseUpdateRepresents a pending change/update to the existing purchase. |
@Retention(value = java.lang.annotation.RetentionPolicy.SOURCE)Possible purchase states. |
Public methods |
|
|---|---|
boolean |
|
AccountIdentifiers |
Returns account identifiers that were provided when the purchase was made. |
String |
Returns the payload specified when the purchase was acknowledged or consumed. |
String |
Returns a unique order identifier for the transaction. |
String |
Returns a String in JSON format that contains details about the purchase order. |
String |
Returns the application package from which the purchase originated. |
Purchase.PendingPurchaseUpdate |
Returns the |
List<String> |
Returns the product Ids. |
int |
Returns one of |
long |
Returns the time the product was purchased, in milliseconds since the epoch (Jan 1, 1970). |
String |
Returns a token that uniquely identifies a purchase for a given item and user pair. |
int |
Returns the quantity of the purchased product. |
String |
Returns String containing the signature of the purchase data that was signed with the private key of the developer. |
ArrayList<String> |
This method is deprecated. Use |
int |
hashCode() |
boolean |
Indicates whether the purchase has been acknowledged. |
boolean |
Indicates whether the subscription renews automatically. |
boolean |
Returns whether the subscription is suspended. |
String |
toString() |
Public methods
getAccountIdentifiers
public AccountIdentifiers getAccountIdentifiers()
Returns account identifiers that were provided when the purchase was made.
getDeveloperPayload
public String getDeveloperPayload()
Returns the payload specified when the purchase was acknowledged or consumed.
getOrderId
public String getOrderId()
Returns a unique order identifier for the transaction. This identifier corresponds to the Google order ID.
For subscription renewals, this method returns the order ID of the initial order. For example, instead of GPA.1234-5678-9012-34567..0 indicating the first renewal order, GPA.1234-5678-9012-34567 will be returned.
The order ID will be null if the purchase is in the PurchaseState.PENDING state and populated if the purchase has transitioned to the PurchaseState.PURCHASED state.
getOriginalJson
public String getOriginalJson()
Returns a String in JSON format that contains details about the purchase order.
getPackageName
public String getPackageName()
Returns the application package from which the purchase originated.
getPendingPurchaseUpdate
public Purchase.PendingPurchaseUpdate getPendingPurchaseUpdate()
Returns the PendingPurchaseUpdate for an uncommitted transaction.
A PendingPurchaseUpdate is normally generated from a pending transaction upgrading/downgrading an existing subscription. Returns null if this purchase does not have a pending transaction.
getPurchaseState
public int getPurchaseState()
Returns one of PurchaseState indicating the state of the purchase.
getPurchaseTime
public long getPurchaseTime()
Returns the time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
For subscriptions, this is the subscription signup time. It won't change after renewal.
getPurchaseToken
public String getPurchaseToken()
Returns a token that uniquely identifies a purchase for a given item and user pair.
getQuantity
public int getQuantity()
Returns the quantity of the purchased product.
Always returns 1 for SUBS items; could be greater than 1 for INAPP items.
getSignature
public String getSignature()
Returns String containing the signature of the purchase data that was signed with the private key of the developer. The data signature uses the RSASSA-PKCS1-v1_5 scheme.
isAcknowledged
public boolean isAcknowledged()
Indicates whether the purchase has been acknowledged.
isAutoRenewing
public boolean isAutoRenewing()
Indicates whether the subscription renews automatically. If true, the subscription is active, and will automatically renew on the next billing date. If false, indicates that the user has canceled the subscription. The user has access to subscription content until the next billing date and will lose access at that time unless they re-enable automatic renewal (or manually renew, as described in Manual Renewal). If you offer a grace period, this value remains set to true for all subscriptions, as long as the grace period has not lapsed. The next billing date is extended dynamically every day until the end of the grace period or until the user fixes their payment method.
isSuspended
public boolean isSuspended()
Returns whether the subscription is suspended. If true, the subscription has been purchased, but is not active. Either the user has paused the subscription, or the subscription has been paused due to payment decline.