private void HandleConfirmPurchase() { if (Order != null) { var payRequest = new PayForPurchaseRequest() { OrderId = Order.OrderId, ProviderName = string.Format("Title{0}", PlayFabSettings.TitleId), Currency = "GO" }; PlayFabClientAPI.PayForPurchase(payRequest, (payResult) => { //Here we should add to the inventory locally in the game and then confirm the purchase. //But for now we are just going to confirm the purchase. var confirmRequest = new ConfirmPurchaseRequest() { OrderId = payResult.OrderId }; PlayFabClientAPI.ConfirmPurchase(confirmRequest, (confirmResult) => { Debug.Log("Purchase was completed."); Order = null; WindowManager.SendEvent("Store"); }, PlayFabErrorHandler.HandlePlayFabError); }, PlayFabErrorHandler.HandlePlayFabError); } }
//########################################################################################################### // PayForPurchase Purchase //########################################################################################################### public void onPayForPurchase() { PayForPurchaseRequest payRequest = new PayForPurchaseRequest(); payRequest.Currency = Currency; payRequest.ProviderName = ProviderName; payRequest.OrderId = OrderID; Debug.Log("onPayForPurchase"); PlayFabClientAPI.PayForPurchase(payRequest, onPurchaseResult, onPurchaseError); }
/// <summary> /// Callback retrieved when an (real money) order on PlayFab's servers has been initiated. /// Here the payment request for the order is being sent off, triggering native overlays. /// </summary> public virtual void OnPurchaseStarted(StartPurchaseResult result) { orderId = result.OrderId; currentProduct = result.Contents[0].ItemId; PayForPurchaseRequest request = new PayForPurchaseRequest() { OrderId = orderId, ProviderName = storeId, Currency = "RM" }; PlayFabClientAPI.PayForPurchase(request, OnPurchaseResult, OnPurchaseFailed); }
void S() { var a = new StartPurchaseRequest { }; var b = new PayForPurchaseRequest { }; var c = new ConfirmPurchaseRequest { }; }
private static void StartPurchaseCallback(StartPurchaseResult result) { foreach (var payment in result.PaymentOptions) { if (payment.Currency == "RM") { continue; } var request = new PayForPurchaseRequest { Currency = payment.Currency, OrderId = result.OrderId, ProviderName = payment.ProviderName }; PlayFabClientAPI.PayForPurchase(request, PayForPurchaseCallback, null); return; // Successful } // Failed to purchase items Debug.LogError("Failed to purchase items"); // TODO: Add more info about items that failed }
//overriding the payment request with Facebook-specific return type and transaction id. private void OnPurchaseResult(IPayResult result) { if (result.ResultDictionary == null || result.ResultDictionary.Count == 0) { return; } if (!result.ResultDictionary.ContainsKey("payment_id")) { return; } PayForPurchaseRequest request = new PayForPurchaseRequest() { OrderId = orderId, ProviderName = storeId, Currency = "RM", ProviderTransactionId = result.ResultDictionary["payment_id"].ToString() }; PlayFabClientAPI.PayForPurchase(request, OnPurchaseResult, OnPurchaseFailed); }