Purchase

This reference document contains the details of Purchase class and its methods.

    public class Purchase extends Object 
        
        java.lang.Object
            gg.now.billingclient.api.Purchase

Details

Purchase is a part of class PurchasesResult and is used for in-app purchases.

Public Constructors

    Purchase

     Purchase (String jsonPurchaseInfo, String signature)

                            throws JSONException

Parameters Description Throws
jsonPurchaseInfo String jSONException
signature String

Public Methods

 

Description Usage
boolean equals(object o) boolean gg.now.billingclient.api.Purchase.equals (Object o)
String getOrderId() – Returns unique identifier for transaction String gg.now.billingclient.api.Purchase.getOrderId()
String getOriginalJson() – Returns a JSON containing details of the purchase order. Detailed here. String gg.now.billingclient.api.Purchase.getOriginalJson()
String getPackageName() – Returns the application package from which the purchase originated String gg.now.billingclient.api.Purchase.getPackageName()
long getPurchaseTime() – Returns the time of purchase long gg.now.billingclient.api.Purchase.getPurchaseTime()
String getPurchaseToken() – Returns the unique identifier purchase token String gg.now.billingclient.api.Purchase.getPurchaseToken()
String getSignature() – Returns the string containing the purchase signature signed using developer’s private key String gg.now.billingclient.api.Purchase.getSignature()
String getSku() – Returns Product ID String gg.now.billingclient.api.Purchase.getSku()
int hashCode() int gg.now.billingclient.api.Purchase.hashCode()
boolean isAutoRenewing() – Returns if the purchase is auto-renewing. boolean gg.now.billingclient.api.Purchase.isAutoRenewing()
String getSubscriptionPeriod() – Returns the Subscription period, specified in ISO 8601 format. String gg.now.billingclient.api.Purchase.getSubscriptionPeriod()
long getExpiryTimeMillis() – Returns subscription expiry time in milliseconds. long gg.now.billingclient.api.Purchase.getExpiryTimeMillis()
long getSubscriptionPurchaseDateMillis() – Returns subscription purchase date. long gg.now.billingclient.api.Purchase.getSubscriptionPurchaseDateMillis()
String getSubscriptionStatus() – Returns the subscription status – defined here. String gg.now.billingclient.api.Purchase.getSubscriptionStatus()
boolean isAcknowledged() – Returns whether the purchase has been acknowledged. boolean gg.now.billingclient.api.Purchase.isAcknowledged()
String toString() String gg.now.billingclient.api.Purchase.toString()
String getDeveloperPayload() – A developer-specified string that contains supplemental information about an order. String gg.now.billingclient.api.Purchase.getDeveloperPayload()

getOriginalJson() Response

The following is the expected response for getOriginalJson().

Important Information

  • Some fields in this response are returned only for subscription purchases and will be omitted for one-time products.
 {
   "productId": "coin_2000",
   "purchaseTime": 1770103123400,
   "developerPayload": "<developerPayload here>",
   "purchaseToken": "<purchaseToken here>.",
   "orderId": "1-2026020111116395992244",
   "packageName": "gg.now.sample.app",

   "subscriptionStatus": "CANCELLED",
   "subscriptionPeriod": "P1W",
   "expiryTimeMillis": 1755505803000,
   "subscriptionPurchaseDateMillis": 1754901003000,
   "isAcknowledged": false,
   "autoRenewing": true
 }

Response Params

The following are response params associated with getOriginalJson().

Params Type Description
productId string Unique identifier of the purchased product or subscription.
purchaseTime int Time at which the purchase was completed, in milliseconds since epoch (UTC).
developerPayload string Optional developer-defined metadata associated with the purchase.
purchaseToken string Token representing the purchase. This token must be sent to your backend for purchase verification.

Note: now.gg purchase tokens typically start with -nowgg-.
orderId string Unique order identifier associated with the transaction.
packageName string App package name for which the purchase occurred.
subscriptionStatus string Current status of the subscription.

Only for subscriptions.

Example: ACTIVE, CANCELLED, EXPIRED.
subscriptionPeriod string Subscription duration in ISO-8601 format.

Only for subscriptions.

Example: P1W (1 week), P1M (1 month).
expiryTimeMillis int Time at which the subscription expires, in milliseconds since epoch (UTC).

Only for subscriptions.
subscriptionPurchaseDateMillis int Time when the subscription was originally purchased, in milliseconds since epoch (UTC).

Only for subscriptions.
isAcknowledged boolean Indicates whether the subscription purchase has been acknowledged.

Only for subscriptions.
autoRenewing boolean Indicates whether the subscription is set to automatically renew.

Only for subscriptions.

getSubscriptionStatus Definition

Possible Returns Description
PENDING The order has been created, but the payment is pending.
EXPIRED The subscription renewal has failed.
ACTIVE Payment has been completed, and the subscription is active.
DELETED The developer has deleted the subscription from nowStudio.
CANCELLED The user has cancelled the subscription.

×
Text copied to clipboard
Link copied to clipbord
Questions? Please reach out to us at dev-support@now.gg