void Awake() { EB.Debug.Log("AmazonProvider.Awake : DontDestroyOnLoad"); DontDestroyOnLoad(this); _iapService = AmazonIapV2Impl.Instance; }
public AmazonUpgrade() { this.amazonIapV2 = AmazonIapV2Impl.Instance; this.amazonIapV2.SetCurrentAndroidActivity(Game.Activity); this.amazonIapV2.AddPurchaseResponseListener(this.PurchaseResponseCallback); this.amazonIapV2.AddGetPurchaseUpdatesResponseListener(this.GetPurchaseUpdatesResponseCallback); this.CheckUpgrade(); }
void Awake() { #if AMAZON_BILLING_ENABLED // Obtain object used to interact with plugin iapService = AmazonIapV2Impl.Instance; SubscribeToEvents(); DontDestroyOnLoad(gameObject); #endif }
// Use this for initialization void Awake() { Me = this; NotificationCenter.Me.AddObserver(this, "RestorePurchase"); NotificationCenter.Me.AddObserver(this, "PurchaseItem"); isRestore = false; isRestoreItemSuccess = false; MyDebug.Log("InAppManager::Awake => isRestore? " + isRestore); #if UNITY_ANDROID && AMAZONSTORE iapService = AmazonIapV2Impl.Instance; #endif }
/// <summary> /// Notifies fullfillment after a purchase /// </summary> /// <param name="receiptID"></param> /// <returns></returns> private bool NotifyFullFillment(string receiptID) { IAmazonIapV2 iapService = AmazonIapV2Impl.Instance; // Construct object passed to operation as input NotifyFulfillmentInput request = new NotifyFulfillmentInput(); // Set input values request.ReceiptId = receiptID; request.FulfillmentResult = "FULFILLED"; // Call synchronous operation with input object iapService.NotifyFulfillment(request); return(true); }
/// <summary> /// get iaps and subs information by skus /// </summary> /// <param name="ProductIds">list of iaps to be retrieved. iap and subs are mixed</param> /// <param name="itemType">not required for amazon</param> /// <returns></returns> public async Task <List <InAppBillingProduct> > GetProductsAsync(List <string> ProductIds, ItemType itemType = ItemType.InAppPurchase) { var taskCompletionSource = new TaskCompletionSource <List <InAppBillingProduct> >(); //await Task.Delay(TimeSpan.FromMilliseconds(1));an.FromMilliseconds(1)); if (context == null) { context = AmazonIapV2Impl.Instance; } // Construct object passed to operation as input SkusInput request = new SkusInput(); request.Skus = ProductIds; // Call synchronous operation with input object string requestId = context.GetProductData(request).RequestId; // Get return value GetProductDataResponseDelegator delegator = null; delegator = new GetProductDataResponseDelegator(async response => { await Task.Run(() => { if (response.RequestId == requestId) { var result = GetProductEventHandler(response); var sucess = taskCompletionSource.TrySetResult(result); context.RemoveGetProductDataResponseListener(delegator.responseDelegate); } }); }); // Register for an event context.AddGetProductDataResponseListener(delegator.responseDelegate); return(await taskCompletionSource.Task); }
/// <summary> /// initiates a request to retrieve updates about items the customer has purchased and/or cancelled. /// </summary> /// <param name="itemType">not required for Amazon</param> /// <returns></returns> private async Task <List <PurchaseReceipt> > GetPurchaseReceipts() { var taskCompletionSource = new TaskCompletionSource <List <PurchaseReceipt> >(); if (context == null) { context = AmazonIapV2Impl.Instance; } // Construct object passed to operation as input var request = new ResetInput(); // Set input value request.Reset = true; // Call synchronous operation with input object string requestId = context.GetPurchaseUpdates(request).RequestId; // Get return value GetPurchaseUpdatesResponseDelegator delegator = null; delegator = new GetPurchaseUpdatesResponseDelegator(async response => { await Task.Run(() => { if (response.RequestId == requestId) { var receipts = GetPurchasesUpdateEventHandler(response); var sucess = taskCompletionSource.TrySetResult(receipts); //await Task.Delay(TimeSpan.FromMilliseconds(1));an.FromMilliseconds(1)); context.RemoveGetPurchaseUpdatesResponseListener(delegator.responseDelegate); } }); }); // Register for an event context.AddGetPurchaseUpdatesResponseListener(delegator.responseDelegate); return(await taskCompletionSource.Task); }
/// <summary> /// Purchase iap or sub /// </summary> /// <param name="productId">iap or sub sku to be purchased</param> /// <param name="itemType">not required for amazon</param> /// <param name="payload">not used for amazon</param> /// <param name="verifyPurchase">not used for amazon</param> /// <returns></returns> public async Task <PurchaseResult> PurchaseAsync(string productId, ItemType itemType = ItemType.InAppPurchase, string payload = null, IInAppBillingVerifyPurchase verifyPurchase = null) { if (await CheckIfUserHasActiveSubscriptionAsync(productId)) { return new PurchaseResult() { PurchaseState = PurchaseState.Purchased, Sku = productId } } ; if (context == null) { context = AmazonIapV2Impl.Instance; } //bool userOwnsSubscription = await CheckIfUserHasSubscriptionAsync(subscriptionStoreId); //if (userOwnsSubscription) //{ // Settings.IsSubscribed = true; // // Unlock all the subscription add-on features here. // return true; //} // Construct object passed to operation as input //await Task.Delay(TimeSpan.FromMilliseconds(1));an.FromMilliseconds(1)); var taskCompletionSource = new TaskCompletionSource <PurchaseResult>(); try { SkuInput request = new SkuInput(); // Set input value request.Sku = productId; // Call synchronous operation with input object string requestId = context.Purchase(request).RequestId; // Get return value PurchaseResponseDelegator delegator = null; delegator = new PurchaseResponseDelegator(async response => { await Task.Run(() => { if (response.RequestId == requestId) { var result = GetPurchaseEventHandler(response); var sucess = taskCompletionSource.TrySetResult(result); //await Task.Delay(TimeSpan.FromMilliseconds(1)); context.RemovePurchaseResponseListener(delegator.responseDelegate); } }); }); // Register for an event context.AddPurchaseResponseListener(delegator.responseDelegate); return(await taskCompletionSource.Task); } catch (Exception) { return(new PurchaseResult() { PurchaseState = PurchaseState.Failed, Sku = productId }); } }