public static async Task <(bool, string)> BuyItem(Session session, string Param1, string Param2, string Param3, string Param4) { var ShopItemId = int.Parse(Param1); var ShopId = int.Parse(Param2); var reply = await ShopManager.BuyItem(session, ShopItemId, ShopId); return(true, string.Empty); }
public override async Task BuyItem(BuyItemRequest request, IServerStreamWriter <BuyItemReply> responseStream, ServerCallContext context) { var session = await context.GetSession(); if (session == null) { await responseStream.WriteAsync(new BuyItemReply() { Code = ErrorCode.LostSession }); return; } var reply = new BuyItemReply(); (reply.Code, reply.Item, reply.AccountGoods) = await ShopManager.BuyItem(session, request.ShopItemId, request.ShopId); await responseStream.WriteAsync(reply); }
public override async Task <PurchaseInAppReplay> PurchaseInApp(PurchaseInAppRequest request, ServerCallContext context) { try { var session = await context.GetSession(); if (session == null) { return(new PurchaseInAppReplay() { Code = ErrorCode.LostSession }); } var(validated, receiptChecker) = await InAppPurchase.IsValidPurchase(request); if (validated == false || receiptChecker == null) { return(new PurchaseInAppReplay() { Code = ErrorCode.WrongParam }); } // todo : ProductId로 상점 아이템을 찾아 구매 처리함 (receiptChecker.ProductId) var reply = new PurchaseInAppReplay(); (reply.Code, reply.Item, reply.AccountGoods) = await ShopManager.BuyItem(session, 34, 4); return(reply); } catch (Exception ex) { Log.Error($"PurchaseInApp {ex.ToString()}"); return(new PurchaseInAppReplay() { Code = ErrorCode.WrongParam }); } }