Esempio n. 1
0
        private async Task <Models.DTO.PagamentoPage> CreatePay(Models.DTO.PagamentoPage pay, string _id, string UserId, Repository.MongoRep mongoRep, string plan)
        {
            Wirecard.WirecardClient WC = null;
            WC = await SetAmbiente(WC);

            var OrderId = Guid.NewGuid().ToString();

            try
            {
                pay.OrderId          = OrderId;
                pay.Usuario.Telefone = Helper.ApenasNumeros(pay.Usuario.Telefone);

                var usuario = pay.Usuario;

                var sub = await CreateSignature(new Address()
                {
                    City         = usuario.City,
                    Complement   = usuario.Complement,
                    District     = usuario.District,
                    Street       = usuario.Street,
                    StreetNumber = usuario.Number,
                    ZipCode      = usuario.PostalCode.Replace("-", ""),
                    State        = usuario.State,
                    Country      = "BRA"
                }, new Credit_Card
                {
                    Holder_Name      = pay.Usuario.Nome,
                    Number           = pay.cardNumber,
                    Expiration_Year  = pay.expirationYear,
                    Expiration_Month = pay.expirationMonth
                }, usuario.Cpf, usuario.DataNascimento, usuario.Email, usuario.Nome + " " + usuario.Sobrenome, usuario.Ddd, usuario.Telefone, plan, OrderId, _id);

                //var cliente = await CriarClienteAsync(pay.Usuario, OrderId, WC);
                //var pedido = await CriarPedidoAsync(pay, cliente.Id, WC);
                //var pagamento = await CriarPagamentoAsync(cliente, pedido, pay, WC);

                //pay.customerResponse = cliente;
                //pay.orderResponse = pedido;
                //pay.paymentResponse = pagamento;

                if (sub != null && ((sub.Alerts != null) && (sub.Alerts.Count() > 0)))
                {
                    var resultAlerts = JsonConvert.SerializeObject(sub.Alerts).ToString();
                    var repMongo     = new Repository.MongoRep("", _settings, "");
                    await repMongo.GravarOne <string>("Pagamento: {" + sub.Code + "}" + resultAlerts);

                    sub.Alerts = null;
                }

                pay.subscriptionResponse = sub;
                return(pay);
            }
            catch (Exception ex)
            {
                var text = ex.Message.ToString();
                return(null);
            }
        }
Esempio n. 2
0
        public async Task <SubscriptionResponse> CreateSignature(Address address, Credit_Card creditCard, string cpf, DateTime birth,
                                                                 string email, string fullname, string phone_area_code, string phone_number, string codePlan, string id, string clientId)
        {
            try
            {
                Wirecard.WirecardClient WC = null;
                WC = await SetAmbiente(WC);

                var birthdate_day   = birth.Day.ToString();
                var birthdate_month = birth.Month.ToString();
                var birthdate_year  = birth.Year.ToString();

                var subscriber = await WC.Signature.CreateSubscriptions(new SubscriptionRequest()
                {
                    Plan = new Plan()
                    {
                        Name = codePlan,
                        Code = codePlan
                    },
                    Code           = id,
                    Payment_Method = "CREDIT_CARD",
                    Customer       = new Customer()
                    {
                        Email           = email,
                        Phone_Number    = phone_number,
                        Phone_Area_Code = phone_area_code,
                        FullName        = creditCard.Holder_Name,
                        Address         = address,
                        BirthDate       = birth.ToString("dd/MM/YYYY"),
                        Phone           = new Phone()
                        {
                            AreaCode    = phone_area_code,
                            CountryCode = "55",
                            Number      = phone_number
                        },
                        Billing_Info = new Billing_Info()
                        {
                            Credit_Card = creditCard
                        },
                        Code            = clientId,
                        Cpf             = cpf,
                        BirthDate_Day   = Convert.ToInt32(birthdate_day),
                        BirthDate_Month = birthdate_month,
                        BirthDate_Year  = Convert.ToInt32(birthdate_year)
                    }
                }, true);

                return(subscriber);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 3
0
        private async Task <Wirecard.WirecardClient> SetAmbiente(Wirecard.WirecardClient WC)
        {
            var token = "";
            var chave = "";

            ambiente = Environments.PRODUCTION;
            token    = _appSettings.TokenMOIP;
            chave    = _appSettings.ChaveMOIP;
#if DEBUG
            //ambiente = Environments.SANDBOX;
            //token = "I6TNGJK392BZNFOWJNM0BLPR9MDHUUTS";
            //chave = "JZCWSVK7JLTEWBP7ANLMI0TM2IPYNH4CYZQH7YZZ";
#endif
            WC = new Wirecard.WirecardClient(ambiente, token, chave);

            return(WC);
        }
Esempio n. 4
0
        private static Wirecard.WirecardClient SetAmbiente(Wirecard.WirecardClient WC)
        {
            var token = "";
            var chave = "";

            ambiente = Environments.PRODUCTION;
            token    = "TE4ZG2UYZJ3GOPQ8KPFMJV9Y2QKS2CHB";
            chave    = "NVNSCOEIJORVLF2WB4OKVZ2URHXW6KYY8TLUXR7Z";
            //token = _appSettings.TokenMOIP;
            //chave = _appSettings.ChaveMOIP;
#if DEBUG
            //ambiente = Environments.SANDBOX;
            //token = "I6TNGJK392BZNFOWJNM0BLPR9MDHUUTS";
            //chave = "JZCWSVK7JLTEWBP7ANLMI0TM2IPYNH4CYZQH7YZZ";
#endif
            WC = new Wirecard.WirecardClient(ambiente, token, chave);

            return(WC);
        }
Esempio n. 5
0
        public async Task <PlanResponse> criarPlano(string code, string name, string description, int amount)
        {
            Wirecard.WirecardClient WC = null;
            WC = await SetAmbiente(WC);

            try
            {
                var newPlan = new PlanRequest()
                {
                    Code        = code,
                    Name        = name,
                    Description = description,
                    Amount      = amount,
                    Interval    = new Interval()
                    {
                        Unit   = (code.Contains("year") ? "YEAR":"MONTH"),
                        Length = 1
                    },
                    Payment_Method = "CREDIT_CARD"
                };

                var plan = await WC.Signature.CreatePlan(newPlan);

                var planNew = new PlanResponse()
                {
                    Code           = code,
                    Name           = name,
                    Description    = description,
                    Amount         = amount,
                    Payment_Method = "CREDIT_CARD"
                };
                var repMongo = new Repository.MongoRep("", _settings, "");
                await repMongo.GravarOne <PlanResponse>(planNew);

                return(plan);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }