Class PurchaseService
The service responsible for ordering products, fetching previous purchases and validating product entitlements.
Implements
Inherited Members
Namespace: UnityEngine .Purchasing
Assembly: Unity.Purchasing.dll
Syntax
public class PurchaseService : IPurchaseService
Properties
Apple
Apple Specific Purchase Extensions
Declaration
public IAppleStoreExtendedPurchaseService? Apple { get; }
Property Value
Type | Description |
---|---|
IApple |
Google Specific Purchase Extensions
Declaration
public IGooglePlayStoreExtendedPurchaseService? Google { get; }
Property Value
Type | Description |
---|---|
IGoogle |
Methods
AddCheckEntitlementAction(Action<Entitlement>?)
Add an action to be called when a check for product entitlement is complete.
Declaration
public void AddCheckEntitlementAction(Action<Entitlement>? checkEntitlementAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Entitlement> | checkEntitlementAction | The action to be added to the list of callbacks. |
AddConfirmedOrderUpdatedAction(Action<ConfirmedOrder>?)
Add an action to be called when product orders are confirmed.
Declaration
public void AddConfirmedOrderUpdatedAction(Action<ConfirmedOrder>? updatedAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Confirmed |
updatedAction | The action to be added to the list of callbacks. |
AddFetchPurchasesFailedAction(Action<PurchasesFetchFailureDescription>?)
Add an action to be called when an attempt to fetch previous purchases has failed.
Declaration
public void AddFetchPurchasesFailedAction(Action<PurchasesFetchFailureDescription>? failedAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Purchases |
failedAction | The action to be added to the list of callbacks. |
AddFetchedPurchasesAction(Action<Orders>?)
Add an action to be called when previous purchases are fetched.
Declaration
public void AddFetchedPurchasesAction(Action<Orders>? updatedAction)
Parameters
AddPendingOrderUpdatedAction(Action<PendingOrder>?)
Add an action to be called when products are ordered.
Declaration
public void AddPendingOrderUpdatedAction(Action<PendingOrder>? updatedAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Pending |
updatedAction | The action to be added to the list of callbacks. |
AddPurchaseDeferredAction(Action<DeferredOrder>?)
Add an action to be called when products orders are deferred.
Declaration
public void AddPurchaseDeferredAction(Action<DeferredOrder>? deferredAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Deferred |
deferredAction | The action to be added to the list of callbacks. |
AddPurchaseFailedAction(Action<FailedOrder>?)
Add an action to be called when products orders fail.
Declaration
public void AddPurchaseFailedAction(Action<FailedOrder>? failedAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Failed |
failedAction | The action to be added to the list of callbacks. |
ConfirmOrder(PendingOrder)
Confirm a pending order. Can run asynchronously.
Be sure to first register callbacks via AddConfirmedOrderUpdatedAction
and AddPurchaseFailedAction
.
Declaration
public void ConfirmOrder(PendingOrder order)
Parameters
Type | Name | Description |
---|---|---|
Pending |
order | The pending order to confirm. |
FetchPurchases()
Fetch pre-existing purchases. Can run asynchronously.
Be sure to first register callbacks via AddFetchedPurchasesAction
and AddFetchPurchasesFailedAction
.
Declaration
public void FetchPurchases()
GetPurchases()
Gets an observable collection of the purchases fetched, confirmed and ordered.
Declaration
public ReadOnlyObservableCollection<Order> GetPurchases()
Returns
Type | Description |
---|---|
Read |
The read-only observable collection of all purchases made. |
IsProductEntitled(Product)
Check if a Product has been entitled.
Declaration
public void IsProductEntitled(Product product)
Parameters
Type | Name | Description |
---|---|---|
Product | product | The Product to check for entitlements. |
Purchase(ICart)
Purchase a cart. Can run asynchronously.
Be sure to first register callbacks via AddPendingOrderUpdatedAction
and AddPurchaseFailedAction
.
Declaration
public void Purchase(ICart cart)
Parameters
Type | Name | Description |
---|---|---|
ICart | cart | The cart to purchase. |
PurchaseProduct(Product)
Purchase a product. Can run asynchronously.
Be sure to first register callbacks via AddPendingOrderUpdatedAction
and AddPurchaseFailedAction
.
Declaration
public void PurchaseProduct(Product product)
Parameters
Type | Name | Description |
---|---|---|
Product | product | The Product to purchase. |
RemoveCheckEntitlementAction(Action<Entitlement>?)
Remove an action to be called when a check for product entitlement is complete.
Declaration
public void RemoveCheckEntitlementAction(Action<Entitlement>? checkEntitlementAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Entitlement> | checkEntitlementAction | The action to be added to the list of callbacks. |
RemoveConfirmedOrderUpdatedAction(Action<ConfirmedOrder>?)
Remove an action to be called when product orders are confirmed.
Declaration
public void RemoveConfirmedOrderUpdatedAction(Action<ConfirmedOrder>? updatedAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Confirmed |
updatedAction | The action to be removed from the list of callbacks. |
RemoveFetchPurchasesFailedAction(Action<PurchasesFetchFailureDescription>?)
Remove an action to be called when an attempt to fetch previous purchases has failed.
Declaration
public void RemoveFetchPurchasesFailedAction(Action<PurchasesFetchFailureDescription>? failedAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Purchases |
failedAction | The action to be removed from the list of callbacks. |
RemoveFetchedPurchasesAction(Action<Orders>?)
Remove an action to be called when previous purchases are fetched.
Declaration
public void RemoveFetchedPurchasesAction(Action<Orders>? updatedAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Orders> | updatedAction | The action to be removed from the list of callbacks. |
RemovePendingOrderUpdatedAction(Action<PendingOrder>?)
Remove an action to be called when products are ordered.
Declaration
public void RemovePendingOrderUpdatedAction(Action<PendingOrder>? updatedAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Pending |
updatedAction | The action to be removed from the list of callbacks. |
RemovePurchaseFailedAction(Action<FailedOrder>?)
Remove an action to be called when products orders fail.
Declaration
public void RemovePurchaseFailedAction(Action<FailedOrder>? failedAction)
Parameters
Type | Name | Description |
---|---|---|
Action<Failed |
failedAction | The action to be removed from the list of callbacks. |
RestoreTransactions(Action<bool, string?>)
Initiate a request to restore previously made purchases.
Declaration
public void RestoreTransactions(Action<bool, string?> callback)
Parameters
Type | Name | Description |
---|---|---|
Action<bool, string> | callback | Action will be called when the request to restore transactions comes back. The bool will be true if it was successful or false if it was not. The string is an optional error message. |
RestoreTransactionsInternal(Action<bool, string?>)
Declaration
protected virtual void RestoreTransactionsInternal(Action<bool, string?> callback)