Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

IStore

interface in UnityEngine.Purchasing.Extension

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual

Descripción

The public interface of an underlying store system (e.g. Google Play or Apple App Store) typically exposed to Unity IAP extending its in app purchasing platform support.

Unity IAP is extensible, supporting registration of store systems through IPurchasingModule implementations shared with Unity IAP via a ConfigurationBuilder during initialization.

A sample store class:

#pragma strict
// Purchases always succeed at the sample store
internal class SampleStore implements IStore {
	public const var Name: String = "samplestore";
	private var m_Biller: IStoreCallback;
	private var m_PurchasedProducts: List.<String> = new List.<String>();
	public function Initialize(biller: IStoreCallback) {
		m_Biller = biller;
	}
	public function RetrieveProducts(productDefinitions: ReadOnlyCollection.<ProductDefinition>) {
		var products = new List.<ProductDescription>();
		for (var product in productDefinitions) {
			var metadata = new ProductMetadata("$123.45", "Fake title for " + product.id, "Fake description", "USD", 123.45m);
			products.Add(new ProductDescription(product.storeSpecificId, metadata));
		}
		m_Biller.OnProductsRetrieved(products);
	}
	public function Purchase(product: ProductDefinition, developerPayload: String) {
		// Keep track of non consumables.
		if (product.type != ProductType.Consumable) {
			m_PurchasedProducts.Add(product.storeSpecificId);
		}
		m_Biller.OnPurchaseSucceeded(product.storeSpecificId, "{ \"this\" : \"is a fake receipt\" }", Guid.NewGuid().ToString());
	}
	public function FinishTransaction(product: ProductDefinition, transactionId: String) {
	}
}
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using UnityEngine.Purchasing;
using UnityEngine.Purchasing.Extension;

// Purchases always succeed at the sample store internal class SampleStore : IStore { public const string Name = "samplestore"; private IStoreCallback m_Biller; private List<string> m_PurchasedProducts = new List<string>();

public void Initialize(IStoreCallback biller) { m_Biller = biller; }

public void RetrieveProducts(ReadOnlyCollection<ProductDefinition> productDefinitions) { var products = new List<ProductDescription>(); foreach (var product in productDefinitions) { var metadata = new ProductMetadata("$123.45", "Fake title for " + product.id, "Fake description", "USD", 123.45m); products.Add(new ProductDescription(product.storeSpecificId, metadata)); } m_Biller.OnProductsRetrieved(products); }

public void Purchase(ProductDefinition product, string developerPayload) { // Keep track of non consumables. if (product.type != ProductType.Consumable) { m_PurchasedProducts.Add(product.storeSpecificId); } m_Biller.OnPurchaseSucceeded(product.storeSpecificId, "{ \"this\" : \"is a fake receipt\" }", Guid.NewGuid().ToString()); }

public void FinishTransaction(ProductDefinition product, string transactionId) { } }

Funciones Públicas

FinishTransactionCalled by Unity IAP when a transaction has been recorded.
InitializeInitialize the store.
PurchaseHandle a purchase request from a user.
RetrieveProductsFetch the latest product metadata, including purchase receipts, asynchronously with results returned via IStoreCallback.