コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Ssn,RefName,NumberOfMatches,NumberOfAsHD,NumberOfAsLD,FeeHD,FeeLD,Fee,TravelKost,LateMatchStart,Alowance,TotalPayment,TournamentId,BankAccountNumber")] PaymentVerification paymentVerification)
        {
            if (id != paymentVerification.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paymentVerification);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentVerificationExists(paymentVerification.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TournamentId"] = new SelectList(_context.Tournament, "Id", "Id", paymentVerification.TournamentId);
            return(View(paymentVerification));
        }
        public async Task <PaymentVerification> PaymentVerificationAsync(PaymentVerification model)
        {
            try
            {
                string serializedUser = JsonConvert.SerializeObject(model);
                var    requestMessage = new HttpRequestMessage(HttpMethod.Post, "Home/PaymentVerificationAsync");
                requestMessage.Content = new StringContent(serializedUser);
                requestMessage.Content.Headers.ContentType
                    = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

                var response = await _httpClient.SendAsync(requestMessage);

                var responseStatusCode = response.StatusCode;
                var responseBody       = await response.Content.ReadAsStringAsync();

                var returnedUser = JsonConvert.DeserializeObject <PaymentVerification>(responseBody);

                return(returnedUser);
            }
            catch (Exception ex)
            {
                return(new PaymentVerification()
                {
                    Response = new Response(-1, ex.Message)
                });
            }
        }
コード例 #3
0
        public async Task <PaymentVerification> PaymentVerificationAsync(PaymentVerification model)
        {
            try
            {
                await Task.Delay(100);

                #region Rest Api Request

                var client  = new RestClient("https://api.zarinpal.com/pg/v4/payment/verify.json");
                var request = new RestRequest(Method.POST);
                request.AddHeader("Content-Type", "application/json");


                PaymentVerification pv = new PaymentVerification();
                pv.merchant_id = merchant_id;
                pv.authority   = model.authority;
                pv.amount      = Convert.ToInt32(model.amount * 10);


                var serializedData = JsonConvert.SerializeObject(pv);
                request.AddParameter("application/json", serializedData, ParameterType.RequestBody);
                var response        = client.Execute(request);
                var deserializeData = JsonConvert.DeserializeObject <PaymentVerification>(response.Content);
                if (deserializeData.data.code == 100)
                {
                    //_ctx ==> DatabaseContext

                    // اگر پایگاه داده وجود داشته باشد باید شماره محصول را از جدول مورد نظر پیدا کنی و
                    //کد رهگیری را در این  قسمت  قرار بدی
                    //   var order = await _ctx.Orders.Where(ord => ord.ID == model.orderid).FirstOrDefaultAsync();
                    //order.CodePeygiri = deserializeData.data.ref_id.ToString();
                    //_ctx.Orders.Update(order);
                    //_ctx.SaveChanges() > 0

                    return(new PaymentVerification()
                    {
                        Response = new Response(1, "پرداخت با موفقیت انجام شد"),
                        data = deserializeData.data
                    });
                }
                #endregion


                return(new PaymentVerification()
                {
                    Response = new Response(-1, "عملیات با موفقیت انجام نشد، دوباره تلاش کنید")
                });
            }
            catch (Exception ex)
            {
                return(new PaymentVerification()
                {
                    Response = new Response(-1, ex.Message)
                });
            }
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("Id,Ssn,RefName,NumberOfMatches,NumberOfAsHD,NumberOfAsLD,FeeHD,FeeLD,Fee,TravelKost,LateMatchStart,Alowance,TotalPayment,TournamentId,BankAccountNumber")] PaymentVerification paymentVerification)
        {
            if (ModelState.IsValid)
            {
                _context.Add(paymentVerification);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TournamentId"] = new SelectList(_context.Tournament, "Id", "Id", paymentVerification.TournamentId);
            return(View(paymentVerification));
        }