Wearable OnlyWearable OnlyAfter a user makes a purchase, especially for consumable or subscription items, it's crucial to acknowledge that purchase. This tells the payment system that you have successfully delivered the purchased item or service to the user, and prevents the purchase from being automatically refunded.
purchaseToken: The unique identifier associated with the purchase requiring acknowledgment. This token is received as part of the Purchase object.
Returns: A Promise that resolves with a PurchaseResult object that tells if the purchase has been successfully acknowledged, canceled by the user, or if an error occurred.
Throws: A Error if the purchase has already been acknowledged, there's no network connection,
or the service is unavailable.
Wearable OnlyCloses the connection to the payment service. It's good practice to call this method when you're finished with commerce operations or when your Lens is being closed to free up resources. There is no return value, and it doesn't throw exceptions, as it handles its own finalization.
Returns the name of this object's type.
Returns true if the object matches or derives from the passed in type.
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Wearable OnlyStarts the process for a user to buy a specific product. It will typically open a user interface where the user can confirm their purchase and enter payment details.
productId: The unique identifier of the product you want the user to purchase.
Returns: A Promise that resolves to a PurchaseResult object. This object indicates whether the purchase flow was successfully launched, canceled by the user, or if an error occurred.
Throws: A Error if the product is not found, the user's payment method is invalid, there's no network
connection, or the service is unavailable.
Wearable OnlyAllows you to retrieve detailed information about specific products from the commerce platform. You provide a list of product IDs, and it returns all available details for those products, such as display name, description, and price.
productIds: An array of strings, where each string is a unique identifier for a product you want to query.
Returns: A Promise that resolves to an array of Product objects. Each object in the array contains comprehensive details about a product. If a product ID is not found, it might not be included in the returned array, or an error might be thrown.
Throws: A Error if a product is not found, there's no network connection, or the service is unavailable.
Wearable OnlyAllows you to check the user's ownership or purchase status for products of a specific category. For example, you can use it to see all "non-consumable" items the user has purchased. It's useful for verifying if a user has already bought certain items or to retrieve details of their existing purchases based on how the product is classified.
productType: The type of products you want to look up, like "non-consumable"
Returns: A list of Purchase objects that represent all transactions for products of the specified type. If no purchases of that type are found, the list will be empty. If there's a problem connecting to the service, it will show an error.
Wearable OnlyFetches a record of all purchases the user has made previously. This is particularly useful for ensuring that users retain access to products they've already bought, especially for non-consumable items or subscriptions. It can also help verify past transactions.
Returns: A Promise that resolves to an array of Purchase objects. Each object in the array represents a past transaction.
Throws: An Error if there's no network connection or if the service is unavailable.
Wearable OnlyInitiates a connection to the payment service, which is a necessary first step before you can perform any commerce-related operations like querying products or launching purchase flows.
Returns: A Promise that resolves with no value when the connection is successfully established.
Throws: A Error if there's no network connection or if the payment service is temporarily unavailable.
You should handle these errors to provide appropriate feedback to the user.
The primary interface for interacting with the commerce system within a Lens. Once built and configured using the CommerceKitModule, its methods are used to perform all key commerce operations. This includes initiating connections to the payment service, querying details about products, launching purchase flows for users, checking a user's purchase history, and acknowledging completed purchases.
See
Returned By: CommerceKitModule#createClient