StoreKitManager¶
Inherits: RefCounted < Object
Manages StoreKit interactions such as requesting products, purchasing, and restoring purchases.
Description¶
This class handles the core StoreKit functionality. It provides methods to fetch product information from the App Store, initiate purchases,
restore previous purchases and be notified of the current status of the purchase upon startup.
Once you instantiate this class, connect to the the transaction_updated signal to
get notification related to the status of your purchases - these are delivered to notify
your application of what products your user is entitled to at startup. If you are using
Apple’s PurchaseIntent, you will also want to connect to the purchase_intent.
The transaction_updated is only raised for verified transactions.
Apple also supports unverified transactions, those are posted to the unverified_transaction_updated signal
and in addition to the transaction they contains a status code from the VerificationError.
After you have set up your signals, you are ready to receive those events.
In addition, when you call the purchase() or purchase_with_options() you will
want to setup a handler for the purchase_completed signal which is raised in
response to different events during the purchasing.
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() 🔗
There is currently no description for this method. Please help us by contributing one!