/// <summary>
        /// Get All Payments Service
        /// </summary>
        /// <returns></returns>
        public async Task <PaymentsResponse> GetAll()
        {
            try
            {
                /////We Assume Here we can take the violtion id and go to the payment portal
                ///to insure this transaction has been paid successfully and get the payment Transcti.on Id
                var dbViolations = await _db.Violation.Include("Violator").Include("Fine").Where(vio => vio.IsPaid).ToListAsync();

                if (dbViolations.Count > 0)
                {
                    PaymentsResponse response = new PaymentsResponse();
                    response.PaymentResponse = new List <PaymentResponse>();

                    foreach (var item in dbViolations)
                    {
                        ViolatorResponse violarorResponse = new ViolatorResponse
                        {
                            FineAmount = item.Fine.FineAmount,
                            FineName   = item.Fine.FineName,
                            IsPaid     = item.IsPaid,
                            IssueDate  = item.IssueDate,
                            Issuer     = item.Issuer,
                            Location   = item.Location,
                            Notes      = item.Notes,
                            Violator   = item.Violator
                        };
                        response.PaymentResponse.Add(new PaymentResponse()
                        {
                            Violator      = violarorResponse,
                            PaymentDate   = DateTime.Now,
                            TransactionId = new Guid().ToString()
                        });
                    }
                    response.Message = Helper.GetResponseMessage(200);
                    return(response);
                }
                else
                {
                    return(new PaymentsResponse
                    {
                        Message = Helper.GetResponseMessage(402)
                    });
                }
            }
            catch (Exception ex)
            {
                return(new PaymentsResponse
                {
                    Message = Helper.GetResponseMessage(500)
                });
            }
        }
예제 #2
0
        private void ShowPaymentStatus(PaymentsResponse paymentResult)
        {
            var message = paymentResult.ResultCode;

            if (paymentResult.ResultCode == "Authorised")
            {
                message += $" ({paymentResult.PspReference})";
            }
            else if (!string.IsNullOrWhiteSpace(paymentResult.RefusalReasonCode))
            {
                message += $" - {paymentResult.RefusalReason} ({paymentResult.RefusalReasonCode})";
            }
            RunOnUiThread(() => Snackbar.Make(layout, message, Snackbar.LengthLong).Show());
        }
예제 #3
0
        public async Task <IActionResult> PaymentHistory(bool paymentSuccessful)
        {
            var client          = new HttpClient();
            var user            = db.AspNetUsers.Where(i => i.Email == User.Identity.Name).FirstOrDefault();
            var paymentsHistory = await client.GetAsync($"{Globals.Globals.end_point_payment}{user.UserName}").Result.Content.ReadAsStringAsync();

            var creditsHistory = await client.GetAsync($"{Globals.Globals.end_point_payments_credits}{user.UserName}").Result.Content.ReadAsStringAsync();

            dynamic          json_data = JsonConvert.DeserializeObject(paymentsHistory);
            PaymentsResponse response  = JsonConvert.DeserializeObject <PaymentsResponse>(json_data.ToString());

            dynamic      json_data_credits = JsonConvert.DeserializeObject(creditsHistory);
            CreditCounts credits           = JsonConvert.DeserializeObject <CreditCounts>(json_data_credits.ToString());

            ViewBag.Balance  = response.AccountBalance;
            ViewBag.Payments = response.Payments;
            ViewBag.credits  = credits;

            return(View());
        }
예제 #4
0
        void HandleRedirect(PaymentsResponse paymentResult)
        {
            redirectComponent = Com.Adyen.Checkout.Redirect.RedirectComponent.Provider.Get(this) as Com.Adyen.Checkout.Redirect.RedirectComponent;
            redirectComponent.Observe(this, new RedirectComponentObserver {
                Changed = data =>
                {
                    var paymentData = data.Details.GetString("paymentData");
                    var details     = data.Details.GetJSONObject("details");
                    var paRes       = details.GetString("PaRes");
                    var md          = details.GetString("MD");

                    Android.Util.Log.Debug("ObserverImpl", $"paymentData: {paymentData}");
                    Task.Run(async() =>
                    {
                        var result = await DemoBackend.GetPaymentDetails(paRes, md, paymentData);
                        ShowPaymentStatus(result);
                    });
                }
            });

            redirectComponent.HandleAction(this, paymentResult.Action.AsRedirectAction());
        }
예제 #5
0
        static void ValidatePayment()
        {
            Configuration.Secret     = File.ReadAllText("../../../../../SECRET").Trim();
            Configuration.ReceiverId = Int32.Parse(File.ReadAllText("../../../../../RECEIVER_ID").Trim());
            String notificationToken = File.ReadAllText("../../../../../NOTIFICATION_TOKEN").Trim();

            PaymentsApi a = new PaymentsApi();

            try
            {
                PaymentsResponse r = a.PaymentsGet(notificationToken);

                System.Console.WriteLine("PAYMENT_ID: " + r.PaymentId);
                System.Console.WriteLine("TRANSACTION_ID: " + r.TransactionId);
                System.Console.WriteLine("AMOUNT: " + r.Amount);
                System.Console.WriteLine("CURRENCY: " + r.Currency);
                System.Console.WriteLine("STATUS: " + r.Status);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            System.Console.Read();
        }
예제 #6
0
        public async Task <IActionResult> Dashboard()
        {
            ViewBag.title = "Dashboard";

            var user = db.AspNetUsers.Where(i => i.Email == User.Identity.Name).FirstOrDefault();

            ViewBag.Role = user.Role;

            var client = new HttpClient();

            //notifications
            //var notifications_read = await client.GetAsync($"{Globals.Globals.end_point_countReadNotificationsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var notifications_un_read = await client.GetAsync($"{Globals.Globals.end_point_countUnReadNotificationsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var notifications_total = await client.GetAsync($"{Globals.Globals.end_point_countAllNotificationsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();

            ViewBag.notifications_read    = 0;
            ViewBag.notifications_un_read = 0;
            ViewBag.notifications_total   = 0;


            //products
            //var products_active = await client.GetAsync($"{Globals.Globals.end_point_countAllActiveProductsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var products_in_active = await client.GetAsync($"{Globals.Globals.end_point_countAllInActiveProductsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var products_total = await client.GetAsync($"{Globals.Globals.end_point_countAllProductsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();

            ViewBag.products_active    = 0;
            ViewBag.products_in_active = 0;
            ViewBag.products_total     = 0;


            //transactions and payments
            //var payment_history = await client.GetAsync($"{Globals.Globals.end_point_countAllPaymentHistoryForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var transaction_history = await client.GetAsync($"{Globals.Globals.end_point_countAllTransactionHistoryForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();

            ViewBag.payment_history     = 0;
            ViewBag.transaction_history = 0;

            //feedback
            // read_feedback = await client.GetAsync($"{Globals.Globals.end_point_countAllReadFeedBackForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var un_read_feedback = await client.GetAsync($"{Globals.Globals.end_point_countAllUnReadFeedBackForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();

            ViewBag.read_feedback    = 0;
            ViewBag.un_read_feedback = 0;


            if (ViewBag.Role == 1)
            {
                return(RedirectToAction("PrincipalDashboard"));
            }
            else if (ViewBag.Role == 2)
            {
                return(RedirectToAction("ExaminerTasks"));
            }

            //var user = db.AspNetUsers.Where(i => i.Email == User.Identity.Name).FirstOrDefault();
            //var client = new HttpClient();
            //var res = await client.GetAsync($"{Globals.Globals.end_point_get_company_applications}").Result.Content.ReadAsStringAsync();
            //db.Dispose();
            //dynamic json_data = JsonConvert.DeserializeObject(res);

            //var data = json_data.data.value;
            //List<mCompany> enqs = JsonConvert.DeserializeObject<List<mCompany>>(data.ToString());


            //List<mCompanyInfor> Summary = new List<mCompanyInfor>();
            //int p = 1;

            //foreach (mCompany item in enqs)
            //{
            //    mCompanyInfor items = new mCompanyInfor();

            //    items.Application_Ref = item.CompanyInfo.Application_Ref;
            //    items.RegNumber = item.CompanyInfo.RegNumber;
            //    items.AppliedBy = item.CompanyInfo.AppliedBy;
            //    items.Name = item.CompanyInfo.Name;
            //    items.No_Of_Directors = item.CompanyInfo.No_Of_Directors;
            //    //items.Objective = item.CompanyInfo.Objective;
            //    items.Date_Of_Application = item.CompanyInfo.Date_Of_Application;
            //    items.Type = item.CompanyInfo.Type;
            //    items.Status = item.CompanyInfo.Status;

            //    Summary.Add(items);
            //    if (p ==3 )
            //    {
            //        //break;
            //    }
            //    p++;
            //}

            //List<mCompanyInfor> rejesteredCompanies = Summary.Where(q => q.AppliedBy == user.UserName).ToList();
            //List<mCompanyInfor> pendingCompanies = Summary.Where(q => q.Status == "Pending").ToList();
            //ViewBag.title = "Summary of Companies";
            //ViewBag.datasource = rejesteredCompanies;
            //ViewBag.companyApplication = pendingCompanies;

            //var resp = await client.GetAsync($"{Globals.Globals.end_point_get_name_searches_by_user_v1}?UserID={user.Email}").Result.Content.ReadAsStringAsync();
            //json_data = JsonConvert.DeserializeObject(resp);

            //data = json_data.data.value;
            //List<mSearch> nameSearches = JsonConvert.DeserializeObject<List<mSearch>>(data.ToString());
            //List<mSearchInfo> nameSearchSummary = new List<mSearchInfo>();

            //foreach(mSearch search in nameSearches)
            //{
            //    nameSearchSummary.Add(search.searchInfo);
            //}

            //ViewBag.nameSearches = nameSearchSummary;
            var resp = await client.GetAsync($"{Globals.Globals.end_point_get_name_searches_by_user_v1}?UserID={user.UserName}").Result.Content.ReadAsStringAsync();

            dynamic json_data = JsonConvert.DeserializeObject(resp);

            var            data         = json_data.data.value;
            List <mSearch> nameSearches = JsonConvert.DeserializeObject <List <mSearch> >(data.ToString());


            List <mSearchInfo> nameSearchSummary = new List <mSearchInfo>();

            foreach (mSearch search in nameSearches)
            {
                nameSearchSummary.Add(search.searchInfo);
            }
            nameSearchSummary    = nameSearchSummary.OrderByDescending(z => z.SearchRef).ToList();
            ViewBag.nameSearches = nameSearchSummary;

            var responsey = await client.GetAsync($"{Globals.Globals.end_point_get_company_application_by_user_id}?UserID={user.UserName}").Result.Content.ReadAsStringAsync();

            dynamic json_dataa = JsonConvert.DeserializeObject(responsey);
            var     dataa      = json_dataa.data.value;
            List <mCompanyResponse> companyApplications = JsonConvert.DeserializeObject <List <mCompanyResponse> >(dataa.ToString());

            companyApplications = companyApplications.OrderByDescending(x => x.companyInfo.Date_Of_Application).ToList();


            var paymentsHistory = await client.GetAsync($"{Globals.Globals.end_point_payment}{user.UserName}").Result.Content.ReadAsStringAsync();

            var creditsHistory = await client.GetAsync($"{Globals.Globals.end_point_payments_credits}{user.UserName}").Result.Content.ReadAsStringAsync();

            dynamic          hist_data = JsonConvert.DeserializeObject(paymentsHistory);
            PaymentsResponse response  = JsonConvert.DeserializeObject <PaymentsResponse>(hist_data.ToString());

            dynamic      json_data_credits = JsonConvert.DeserializeObject(creditsHistory);
            CreditCounts credits           = JsonConvert.DeserializeObject <CreditCounts>(json_data_credits.ToString());

            int paymentsCount = response.Payments.Count();

            if (paymentsCount > 3)
            {
                List <PaymentDto> newPayments = new List <PaymentDto>();
                for (int i = 0; i < 3; i++)
                {
                    newPayments.Add(response.Payments[response.Payments.Count - (i + 1)]);
                }
                response.Payments = newPayments;
            }

            var regEntitiesSummaryResponse = await client.GetAsync($"{Globals.Globals.service_end_point}/{user.UserName}/RegisteredEntities").Result.Content.ReadAsStringAsync();

            dynamic regEntitiesSummaryJson;
            List <RegisteredEntitySummary> entitiesSummary = new List <RegisteredEntitySummary>();

            try
            {
                regEntitiesSummaryJson = JsonConvert.DeserializeObject(regEntitiesSummaryResponse);
                entitiesSummary        = JsonConvert.DeserializeObject <List <RegisteredEntitySummary> >(regEntitiesSummaryJson.ToString());
            }
            catch (Exception ex)
            {
            }



            ViewBag.Balance  = response.AccountBalance;
            ViewBag.Payments = response.Payments;
            ViewBag.credits  = credits;
            if (entitiesSummary.Count > 0)
            {
                ViewBag.RegEntitiesSummary = entitiesSummary;
            }

            ViewBag.EntityApplications = companyApplications;
            List <Queries> query = new List <Queries>();

            foreach (var item in companyApplications)
            {
                var query1 = context.Queries
                             .Where(q => q.applicationRef == item.companyInfo.Application_Ref && q.status == "Pending")
                             .ToList();
                foreach (var query1item in query1)
                {
                    query.Add(query1item);
                }
            }
            ViewBag.Queries = query;

            return(View());
        }
        /// <summary>
        /// Gets payments - the combined result of invoices and payment requests
        /// </summary>
        public async Task <PaymentsResponse> GetByPaymentsFilter(
            string merchantId,
            PaymentType type,
            IReadOnlyList <InvoiceStatus> statuses,
            PaymentsFilterPeriod period,
            string searchText,
            int?take
            )
        {
            var dates = period.GetDates();

            searchText = searchText?.Trim();

            Task <PayInvoice.Client.Models.Invoice.GetByPaymentsFilterResponse>         invoicesTask        = null;
            Task <PayInternal.Client.Models.PaymentRequest.GetByPaymentsFilterResponse> paymentRequestsTask = null;

            if (type == PaymentType.All || type == PaymentType.Invoice)
            {
                invoicesTask = _payInvoiceClient.GetByPaymentsFilterAsync(
                    merchantId,
                    statuses.Select(_ => _.ToString()),
                    dates.DateFrom,
                    dates.DateTo,
                    searchText,
                    take);
            }

            var isOnlyInvoices = statuses.Count == 1 && statuses.First() == InvoiceStatus.Draft;

            if ((type == PaymentType.All || type == PaymentType.Api) &&
                !isOnlyInvoices)
            {
                var paymentRequestStatuses = new List <PaymentRequestStatus>();
                var processingErrors       = new List <PaymentRequestProcessingError>();

                foreach (var invoiceStatus in statuses)
                {
                    var converted = invoiceStatus.ToPaymentRequestStatus();

                    if (converted.PaymentRequestStatus == PaymentRequestStatus.None)
                    {
                        continue;
                    }

                    if (!paymentRequestStatuses.Contains(converted.PaymentRequestStatus))
                    {
                        paymentRequestStatuses.Add(converted.PaymentRequestStatus);
                    }

                    if (converted.ProcessingErrors == null)
                    {
                        continue;
                    }

                    foreach (var processingError in converted.ProcessingErrors)
                    {
                        if (processingError == PaymentRequestProcessingError.None)
                        {
                            continue;
                        }

                        if (!processingErrors.Contains(processingError))
                        {
                            processingErrors.Add(processingError);
                        }
                    }
                }

                paymentRequestsTask = _payInternalClient.GetByPaymentsFilterAsync(
                    merchantId,
                    paymentRequestStatuses.Select(_ => _.ToString()),
                    processingErrors.Select(_ => _.ToString()),
                    dates.DateFrom,
                    dates.DateTo,
                    take);
            }

            var result = new PaymentsResponse
            {
                HasAnyPayment = true
            };

            switch (type)
            {
            case PaymentType.All:
                if (invoicesTask != null || paymentRequestsTask != null)
                {
                    await Task.WhenAll(invoicesTask ?? Task.CompletedTask, paymentRequestsTask ?? Task.CompletedTask);

                    var payments = Mapper.Map <List <Payment> >(invoicesTask?.Result.Invoices);
                    if (paymentRequestsTask != null)
                    {
                        payments.AddRange(Mapper.Map <List <Payment> >(paymentRequestsTask?.Result.PaymeentRequests));
                    }

                    result.Payments        = payments.OrderByDescending(x => x.CreatedDate).ToList();
                    result.HasMorePayments = (invoicesTask?.Result.HasMoreInvoices ?? false) ||
                                             (paymentRequestsTask?.Result.HasMorePaymentRequests ?? false);
                }

                break;

            case PaymentType.Invoice:
                if (invoicesTask != null)
                {
                    var invoicesTaskResponse = await invoicesTask;

                    result.Payments        = Mapper.Map <List <Payment> >(invoicesTaskResponse.Invoices);
                    result.HasMorePayments = invoicesTaskResponse.HasMoreInvoices;
                }

                break;

            case PaymentType.Api:
                if (paymentRequestsTask != null)
                {
                    var paymentRequestsTaskResponse = await paymentRequestsTask;

                    result.Payments        = Mapper.Map <List <Payment> >(paymentRequestsTaskResponse.PaymeentRequests);
                    result.HasMorePayments = paymentRequestsTaskResponse.HasMorePaymentRequests;
                }

                break;
            }

            foreach (var payment in result.Payments)
            {
                payment.SettlementAsset = await _lykkeAssetsResolver.TryGetAssetAsync(payment.SettlementAssetId);
            }

            if (result.Payments.Count == 0 &&
                type == PaymentType.All &&
                statuses.Count == 0 &&
                period != PaymentsFilterPeriod.AllTime &&
                string.IsNullOrEmpty(searchText))
            {
                var hasAnyInvoiceTask        = _payInvoiceClient.HasAnyInvoiceAsync(merchantId);
                var hasAnyPaymentRequestTask = _payInternalClient.HasAnyPaymentRequestAsync(merchantId);

                await Task.WhenAll(hasAnyInvoiceTask, hasAnyPaymentRequestTask);

                result.HasAnyPayment = hasAnyInvoiceTask.Result || hasAnyPaymentRequestTask.Result;
            }

            return(result);
        }