Beispiel #1
0
        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
                });
            }
        }