# Purchase


```
public class Purchase
```

<br />

*** ** * ** ***

Represents an in-app billing purchase.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/com/android/billingclient/api/Purchase.PendingPurchaseUpdate` Represents a pending change/update to the existing purchase. |
| `@https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/java.lang.annotation.RetentionPolicy.html#SOURCE) public annotation https://developer.android.com/reference/com/android/billingclient/api/Purchase.PurchaseState` Possible purchase states. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/android/billingclient/api/Purchase#Purchase(java.lang.String,java.lang.String)(https://developer.android.com/reference/java/lang/String.html jsonPurchaseInfo, https://developer.android.com/reference/java/lang/String.html signature)` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html o)` |
| `https://developer.android.com/reference/com/android/billingclient/api/AccountIdentifiers` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getAccountIdentifiers()()` Returns account identifiers that were provided when the purchase was made. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getDeveloperPayload()()` Returns the payload specified when the purchase was acknowledged or consumed. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getOrderId()()` Returns a unique order identifier for the transaction. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getOriginalJson()()` Returns a String in JSON format that contains details about the purchase order. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getPackageName()()` Returns the application package from which the purchase originated. |
| `https://developer.android.com/reference/com/android/billingclient/api/Purchase.PendingPurchaseUpdate` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getPendingPurchaseUpdate()()` Returns the `https://developer.android.com/reference/com/android/billingclient/api/Purchase.PendingPurchaseUpdate` for an uncommitted transaction. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getProducts()()` Returns the product Ids. |
| `int` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getPurchaseState()()` Returns one of `https://developer.android.com/reference/com/android/billingclient/api/Purchase.PurchaseState` indicating the state of the purchase. |
| `long` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getPurchaseTime()()` Returns the time the product was purchased, in milliseconds since the epoch (Jan 1, 1970). |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getPurchaseToken()()` Returns a token that uniquely identifies a purchase for a given item and user pair. |
| `int` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getQuantity()()` Returns the quantity of the purchased product. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getSignature()()` Returns String containing the signature of the purchase data that was signed with the private key of the developer. |
| `https://developer.android.com/reference/java/util/ArrayList.html<https://developer.android.com/reference/java/lang/String.html>` | `[getSkus](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getSkus())()` **This method is deprecated.** Use `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getProducts()` instead. <br /> |
| `int` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#isAcknowledged()()` Indicates whether the purchase has been acknowledged. |
| `boolean` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#isAutoRenewing()()` Indicates whether the subscription renews automatically. |
| `boolean` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#isSuspended()()` Returns whether the subscription is suspended. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/com/android/billingclient/api/Purchase#toString()()` |

## Public constructors

### Purchase

```
public Purchase(String jsonPurchaseInfo, String signature)
```

## Public methods

### equals

```
public boolean equals(Object o)
```

| See also |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html#equals(java.lang.Object)` |   |

### 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 `https://developer.android.com/reference/com/android/billingclient/api/Purchase.PurchaseState#PENDING()` state and populated if the purchase has transitioned to the `https://developer.android.com/reference/com/android/billingclient/api/Purchase.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 `https://developer.android.com/reference/com/android/billingclient/api/Purchase.PendingPurchaseUpdate` for an uncommitted transaction.

A `https://developer.android.com/reference/com/android/billingclient/api/Purchase.PendingPurchaseUpdate` is normally generated from a pending transaction upgrading/downgrading an existing subscription. Returns `null` if this purchase does not have a pending transaction.

### getProducts

```
public List<String> getProducts()
```

Returns the product Ids.

### getPurchaseState

```
public int getPurchaseState()
```

Returns one of `https://developer.android.com/reference/com/android/billingclient/api/Purchase.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.

### getSkus

```
public ArrayList<String> [getSkus](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getSkus())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/com/android/billingclient/api/Purchase#getProducts()` instead.

Returns the product Ids.

### hashCode

```
public int hashCode()
```

| See also |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html#hashCode()` |   |

### 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.

### toString

```
public String toString()
```