StoreKitManager¶
Inherits: RefCounted < Object
Manages StoreKit interactions such as requesting products, purchasing, and restoring purchases.
Description¶
This class handles StoreKit product requests, purchases, restores, and transaction updates.
Create one manager when your app starts and keep it alive for the life of the app. Connect transaction_updated and unverified_transaction_updated before you call start(). start() begins the transaction listener and checks for unfinished transactions.
transaction_updated only contains verified transactions. Deliver the product, then call StoreTransaction.finish(). Make delivery idempotent because StoreKit can send an unfinished transaction again. unverified_transaction_updated contains transactions that StoreKit could not verify, plus a code from VerificationError.
StoreKit sends transactions for purchases, subscriptions, and offer-code redemptions that happen in or outside your app. If a consumable offer code is redeemed while your app is not running, start() finds it through unfinished transactions when the app next starts. Do not use fetch_current_entitlements() to recover consumables because it excludes them.
For the full setup, redemption, and test workflow, see Using Apple’s StoreKit APIs with Godot.
Methods¶
void |
|
void |
purchase(product: StoreProduct) |
void |
purchase_with_options(product: StoreProduct, options: Array) |
void |
request_products(productIds: PackedStringArray) |
void |
|
void |
start() |
Signals¶
products_request_completed(products: Array, status: int) 🔗
Emitted when a product request completes.
productsis an Array of StoreProducts (or nulls).
statusindicates success or failure.
purchase_completed(transaction: StoreTransaction, status: int, error_message: String) 🔗
Emitted when a purchase completes.
transactionis the StoreTransaction on success.
statusindicates the result (OK, cancelled, invalid product, etc.).
error_messagecontains error details if failed.
purchase_intent(product: StoreProduct) 🔗
There is currently no description for this signal. Please help us by contributing one!
restore_completed(status: int, error_message: String) 🔗
Emitted when the restore process completes. arg1 is the StoreKitStatus, and arg2 is an error message if applicable.
supscription_update(status: StoreSubscriptionInfoStatus) 🔗
There is currently no description for this signal. Please help us by contributing one!
transaction_updated(transaction: StoreTransaction) 🔗
Emitted when a transaction is updated (e.g., a subscription renews or a purchase is approved externally). transaction is the updated StoreTransaction.
You must call the finished method on the transaction once you have made sure that you have delivered the content to the user.
unverified_transaction_updated(transaction: StoreTransaction, verification_error: int) 🔗
There is currently no description for this signal. Please help us by contributing one!
Enumerations¶
enum StoreKitStatus: 🔗
StoreKitStatus OK = 0
The operation completed successfully.
StoreKitStatus INVALID_PRODUCT = 1
The product identifier is invalid.
StoreKitStatus CANCELLED = 2
The operation was cancelled.
StoreKitStatus UNVERIFIED_TRANSACTION = 3
The transaction could not be verified.
StoreKitStatus USER_CANCELLED = 4
The user cancelled the operation.
StoreKitStatus PURCHASE_PENDING = 5
The purchase is pending (e.g., waiting for parental approval).
StoreKitStatus UNKNOWN_STATUS = 6
An unknown status occurred.
enum VerificationError: 🔗
VerificationError REVOKED_CERTIFICATE = 0
The certificate chain was parsable, but was invalid due to one or more revoked certificates.
VerificationError INVALID_CERTIFICATE_CHAIN = 1
The certificate chain was parsable, but it was invalid for signing this data.
VerificationError INVALID_DEVICE_VERIFICATION = 2
The device verification properties were invalid for this device.
VerificationError INVALID_ENCODING = 3
Th JWS header and any data included in it or it’s certificate chain had an invalid encoding.
VerificationError INVALID_SIGNATURE = 4
The certificate chain was valid for signing this data, but the leaf’s public key was invalid for the JWS signature.
VerificationError MISSING_REQUIRED_PROPERTIES = 5
Either the JWS header or any certificate in the chain was missing necessary properties for verification.
VerificationError OTHER = 6
A new error code was introduced that was not previously handled.
Method Descriptions¶
void fetch_current_entitlements() 🔗
The current entitlements sequence provides the most recent transaction for each product the customer is entitled to, use this
to refresh the list of features the user is entitled to.
Specifically, it includes:
* One transaction for each non-consumable In-App Purchase
* The latest transaction for each auto-renewable subscription whose Product.SubscriptionInfo.RenewalState is either subscribed or inGracePeriod
* The latest transaction for each non-renewing subscription, including those that have ended
* Products that have been refunded or revoked by the App Store are excluded from the current entitlements, as are consumable In-App Purchases. To retrieve transactions for unfinished consumables, use the unfinished or all transaction sequences instead.
void purchase(product: StoreProduct) 🔗
Initiates the purchase of a specific product, e.g. purchase(product). This will raise the
purchase_completed signal, either to indicate that an error took place, or the status of the
purchase.
void purchase_with_options(product: StoreProduct, options: Array) 🔗
Initiates the purchase of a specific product, e.g. purchase(product), and allows you to provide additional purchase options.
This will raise the
purchase_completed signal, either to indicate that an error took place, or the status of the
purchase.
void request_products(productIds: PackedStringArray) 🔗
Requests product information for a list of product identifiers, e.g. request_products(PackedStringArray(["com.example.product1", "com.example.product2"])).
This method will raise the products_request_completed signal when the information is retrieved.
void restore_purchases() 🔗
Restores previously purchased non-consumable products and auto-renewable subscriptions. This will raise the
restore_completed signal when the product purchased have been restored.
void start() 🔗
Starts transaction and purchase-intent listeners, then checks for unfinished transactions. Connect all relevant signals before calling this method.