Example #1
0
        public void OnGet(string id)
        {
            RequestInfo = RequestStorage.FindById(id);
            var downloadName = RequestInfo.Name.Replace(" ", "_") + "-levepo-terms.pdf";

            TempData["Embed"] = "<object id=\"pdf\" type=\"application/pdf\" data=\"data:application/pdf;base64,"
                                + RequestInfo.Documents.First().Data
                                + "\" width=\"100%\" height=\"100%\">alt : <a href=\"" + downloadName + "\">test.pdf</a></object>";
        }
        private string AllocateSuffix()
        {
            var count = RequestStorage.Get <int>(FieldAttributeType) + 1;

            AssertAttribsQuantityAllowed(count);

            RequestStorage.Set(FieldAttributeType, count);
            return(count == 1 ? string.Empty : char.ConvertFromUtf32(95 + count)); // single lowercase letter from latin alphabet or an empty string
        }
        internal void GiveHandler(TransactionProtocol message, ConnectionParam connection)
        {
            if (string.IsNullOrWhiteSpace(message.Transaction) == false)
            {
                ErrorHandler(message, connection);
            }
            var task   = RequestStorage.GetInstance().GetTransaction();
            var buffer = ConvertToByteArray(task);

            connection.Socket.Send(buffer);
        }
        private string AllocateSuffix()
        {
            var count = RequestStorage.Get <int>(AttributeWeakId);

            if (!RequestStorage.Get <bool>(AttributeFullId)) // attributes of the same TypeId should be filtered out at this stage from outside, so
            {                                                // the only reason we still encounter duplicates means, they are applied in separate models (e.g. collection processing) - adapters names differentiation should be avoided
                count++;
                RequestStorage.Set(AttributeFullId, true);
            }
            AssertAttribsQuantityAllowed(count);
            RequestStorage.Set(AttributeWeakId, count);
            return(count == 1 ? string.Empty : char.ConvertFromUtf32(95 + count)); // single lowercase letter from latin alphabet or an empty string
        }
        internal void AddHandler(TransactionProtocol message, ConnectionParam connection)
        {
            if (string.IsNullOrWhiteSpace(message.Request_id) || string.IsNullOrWhiteSpace(message.Sender_id) ||
                string.IsNullOrWhiteSpace(message.Transaction))
            {
                ErrorHandler(message, connection);
                return;
            }
            var request_storage = RequestStorage.GetInstance();

            request_storage.AddTransaction(message);
            var connection_storage = ConnectionStorage.GetInstance();

            connection_storage.AddConnection(connection, message.Request_id);
        }
        private async System.Threading.Tasks.Task UpdateRequestListAsync(bool refresh)
        {
            if (refresh)
            {
                HttpClient client = await HttpUtil.GetAuthorizedHttpClientAsync();

                foreach (RequestInfo request in RequestStorage.FindAll())
                {
                    var requestInfoResponse = client.GetAsync($"{Startup.Configuration["Api:SignApi:Url"]}/request/{request.Id}?includeDocs=true").Result;
                    if (requestInfoResponse.IsSuccessStatusCode)
                    {
                        string requestInfoBody = await requestInfoResponse.Content.ReadAsStringAsync();

                        RequestStorage.Upsert(JsonConvert.DeserializeObject <RequestInfo>(requestInfoBody));
                    }
                }
            }
            SignRequest = RequestStorage.FindAll();
        }
        public async System.Threading.Tasks.Task PostAsync([FromBody] RequestInfo requestInfo)
        {
            if (requestInfo.State.Equals("COMPLETED"))
            {
                // Fetch the signed document if the request is completed
                HttpClient client = await HttpUtil.GetAuthorizedHttpClientAsync();

                var requestInfoResponse = client.GetAsync($"{Startup.Configuration["Api:SignApi:Url"]}/request/{requestInfo.Id}?includeDocs=true").Result;
                if (requestInfoResponse.IsSuccessStatusCode)
                {
                    string requestInfoBody = await requestInfoResponse.Content.ReadAsStringAsync();

                    RequestStorage.Upsert(JsonConvert.DeserializeObject <RequestInfo>(requestInfoBody));
                }
            }
            else
            {
                RequestStorage.Upsert(requestInfo);
            }
        }
Example #8
0
        public void AddTransactionTest()
        {
            var transaction = new Transaction()
            {
                owner_card_id     = "gafdwaaw",
                aditional_comment = "gadwad",
                transactionType   = API_Transaction.Enums.TransactionType.Authorization,
                ccy = "MDL",
                transaction_summ = 1234
            };
            var sender = new TransactionProtocol()
            {
                Type_message = API_Transaction.Enums.TypeMessage.add,
                Transaction  = JsonConvert.SerializeObject(transaction),
                Request_id   = "51231254",
                Sender_id    = "5123124",
            };

            // var manager = new ApiManager();
            RequestStorage.GetInstance().AddTransaction(sender);

            var test_response = RequestStorage.GetInstance().GetTransaction();
        }
 private void ResetSuffixAllocation()
 {
     RequestStorage.Remove(AttributeWeakId);
 }
        public async System.Threading.Tasks.Task OnPostAsync()
        {
            Image image = new Image(ImageDataFactory.Create(@"wwwroot\images\levepo.png"));

            image.ScaleToFit(1700, 1000);
            image.SetHorizontalAlignment(HorizontalAlignment.CENTER);
            image.SetWidth(200);
            using (MemoryStream dest = new MemoryStream())
            {
                var writer   = new PdfWriter(dest);
                var pdf      = new PdfDocument(writer);
                var document = new Document(pdf);
                document.Add(new Paragraph(new Text("Levepo Terms and Conditions (\"Terms\")")
                                           .SetBold()
                                           .SetFontSize(28)
                                           .SetTextAlignment(TextAlignment.CENTER)
                                           .SetHorizontalAlignment(HorizontalAlignment.CENTER)));
                document.Add(new Paragraph(""));
                document.Add(image);
                document.Add(new Paragraph(""));
                document.Add(new Paragraph("Please read these Terms and Conditions (\"Terms\", \"Terms and Conditions\") carefully before using the https://levepo.azurewebsites.com website (the \"Service\") operated by Levepo (\"us\", \"we\", or \"our\")."));
                document.Add(new Paragraph(""));
                document.Add(new Paragraph("\"" + NewCustomer.Name + "\" access to and use of the Service is conditioned on your acceptance of and compliance with these Terms. These Terms apply to all visitors, users and others who access or use the Service."));
                document.Add(new Paragraph(""));
                document.Add(new Paragraph(new Text("By accessing or using the Service you agree to be bound by these Terms. If you disagree with any part of the terms then you may not access the Service.").SetBold()));
                document.Add(new Paragraph(""));
                document.Add(new Paragraph(new Text("Purchases").SetBold()));
                document.Add(new Paragraph(""));
                document.Add(new Paragraph("If you wish to purchase any product or service made available through the Service (\"Purchase\"), you may be asked to supply certain information relevant to your Purchase including, without limitation, your name, email address, delivery address and social security number"));
                document.Add(new Paragraph(""));
                document.Add(new Paragraph(new Text("Subscriptions").SetBold()));
                document.Add(new Paragraph(""));
                document.Add(new Paragraph("Some parts of the Service are billed on a subscription basis (\"Subscription(s)\"). You will be billed in advance on a recurring and periodic basis (\"Billing Cycle\"). Billing cycles are set either on a monthly or annual basis, depending on the type of subscription plan you select when purchasing a Subscription."));
                document.Add(new Paragraph(""));
                document.Add(new Paragraph(new Text("Changes")).SetBold());
                document.Add(new Paragraph(""));
                document.Add(new Paragraph("We reserve the right, at our sole discretion, to modify or replace these Terms at any time. If a revision is material we will try to provide at least 30 (change this) days' notice prior to any new terms taking effect. What constitutes a material change will be determined at our sole discretion."));
                document.Add(new Paragraph(""));
                document.Add(new Paragraph(new Text("Contact Us").SetBold()));
                document.Add(new Paragraph(""));
                document.Add(new Paragraph("If you have any questions about these Terms, please contact us."));
                document.Close();

                var base64String = Convert.ToBase64String(dest.ToArray());

                List <DocumentInfo> documents = new List <DocumentInfo>
                {
                    new DocumentInfo()
                    {
                        Name = NewCustomer.Name,
                        Data = base64String
                    }
                };

                List <Signer> signers = new List <Signer>();
                Signer        s       = new Signer()
                {
                    Method      = NewCustomer.AuthenticationMethod,
                    SignerEmail = NewCustomer.Email
                };

                signers.Add(s);

                var signatureRequest = new SignatureRequest()
                {
                    OnBehalfOf  = "Levepo",
                    Name        = $"'{NewCustomer.Name}' Terms and Conditions",
                    ResponseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/api/callback",
                    Signers     = signers,
                    SignBefore  = 0,
                    Documents   = documents
                };

                if (NewCustomer.AuthenticationMethod.Equals("SE_BANKID"))
                {
                    signatureRequest.ViewProtected = false;
                }

                HttpClient client = await HttpUtil.GetAuthorizedHttpClientAsync();

                MemoryStream ms = new MemoryStream();
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(SignatureRequest));
                ser.WriteObject(ms, signatureRequest);
                byte[] json = ms.ToArray();
                ms.Close();

                var    content      = new StringContent(Encoding.UTF8.GetString(json, 0, json.Length), Encoding.UTF8, "application/json");
                var    response     = client.PostAsync($"{Startup.Configuration["Api:SignApi:Url"]}/request", content).Result;
                string responseBody = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    RequestId = JsonConvert.DeserializeObject <RequestInfo>(responseBody).Id;
                    var requestInfoResponse = client.GetAsync($"{Startup.Configuration["Api:SignApi:Url"]}/request/{RequestId}?includeDocs=true").Result;
                    if (requestInfoResponse.IsSuccessStatusCode)
                    {
                        string requestInfoBody = await requestInfoResponse.Content.ReadAsStringAsync();

                        RequestStorage.Upsert(JsonConvert.DeserializeObject <RequestInfo>(requestInfoBody));
                    }
                }
                else
                {
                    ErrorResponse = JsonConvert.DeserializeObject <ErrorResponse>(responseBody);
                    if (ErrorResponse == null)
                    {
                        ErrorResponse = new ErrorResponse
                        {
                            ErrorCode    = $"{response.StatusCode}",
                            ErrorMessage = responseBody
                        };
                    }
                }
                ClearResult = false;
            }
        }
Example #11
0
        public ActionResult GetById(string id)
        {
            var request = RequestStorage.FindById(id);

            return(Json(request));
        }
Example #12
0
 public void OnPost()
 {
     RequestStorage.Drop();
 }
Example #13
0
 public void OnGet()
 {
     Count = RequestStorage.Count();
 }