Пример #1
0
        public void TestCreateSubscriptionPlan()
        {
            Decimal amount = new Decimal(111.11);

            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.NEW_API_KEY, Constants.NEW_MERCHANT_ID);

            Plan request = new Plan();

            request.Name             = "Plan Mono Gold";
            request.Amount           = amount;
            request.RepeatEvery      = 1;
            request.RepeatUnit       = "month";
            request.RetryTimes       = 2;
            request.StatusAfterRetry = "cancelled";
            request.TrialDays        = 30;

            request = openpayAPI.PlanService.Create(request);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Id);
            Assert.IsNotNull(request.CreationDate);
            Assert.IsNotNull(request.Name);
            //Assert.AreEqual("Plan Mono Gold", request.Name);
            Assert.AreEqual("active", request.Status);
        }
        public void TestListSubscriptions()
        {
            OpenpayAPI          openpayAPI    = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            List <Subscription> subscriptions = openpayAPI.SubscriptionService.List(customer_id);

            Assert.IsTrue(subscriptions.Count > 0);
        }
Пример #3
0
        public void TestChargeToMerchantWithPointsBig()
        {
            ChargeRequest request = new ChargeRequest();

            request.Method        = "card";
            request.Card          = GetCardInfo();
            request.Description   = "Testing from .Net with new card";
            request.Amount        = new Decimal(29.99);
            request.UseCardPoints = true;

            Customer customer = new Customer();

            customer.Name        = "Openpay";
            customer.LastName    = "Test";
            customer.PhoneNumber = "1234567890";
            customer.Email       = "*****@*****.**";

            request.Customer = customer;

            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Charge     charge     = openpayAPI.ChargeService.Create(request);

            Assert.IsNotNull(charge);
            Assert.IsNotNull(charge.Id);
            Assert.IsNotNull(charge.CardPoints);
            Assert.AreEqual(charge.CardPoints.Amount, new Decimal(22.5));

            Charge charge2 = openpayAPI.ChargeService.Get(charge.Id);

            Assert.IsNotNull(charge2);
            Assert.IsNotNull(charge2.CardPoints);
            Assert.AreEqual(charge.Id, charge2.Id);
            Assert.AreEqual(charge.Amount, charge2.Amount);
            Assert.AreEqual(charge2.CardPoints.Amount, new Decimal(22.5));
        }
Пример #4
0
        public void TestFeeAndRefund()
        {
            string  customerId        = "ar2btmquidjhykdaztp6";
            Decimal amount            = new Decimal(11);
            string  description       = "comisión de .Net de " + amount;
            string  refundDescription = "reembolso de comisión de .Net de " + amount;

            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.NEW_API_KEY, Constants.NEW_MERCHANT_ID);

            FeeRequest feeRequest = new FeeRequest();

            feeRequest.CustomerId  = customerId;
            feeRequest.Description = description;
            feeRequest.Amount      = amount;

            Fee fee = openpayAPI.FeeService.Create(feeRequest);

            Assert.IsNotNull(fee);
            Assert.IsNotNull(fee.Id);
            Assert.IsNotNull(fee.CreationDate);
            Assert.AreEqual("completed", fee.Status);

            Fee refundFee = openpayAPI.FeeService.Refund(fee.Id, refundDescription);

            Assert.IsNotNull(refundFee);
            Assert.IsNotNull(refundFee.Id);
            Assert.IsNotNull(refundFee.CreationDate);
            Assert.AreEqual("completed", refundFee.Status);
        }
Пример #5
0
        public void TestDetails_NoInfo()
        {
            OpenpayAPI         api  = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID, false);
            List <Transaction> list = api.OpenpayFeesService.Details(2012, 03, "charged", null);

            Assert.AreEqual(0, list.Count);
        }
Пример #6
0
        public void TesTransferCreate()
        {
            OpenpayAPI      openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            TransferRequest request    = new TransferRequest();

            request.CustomerId  = "acjpcdct4tbyemirw7zo";
            request.Amount      = 11.0m;
            request.Description = "Transfer Testing";

            Transfer transfer = openpayAPI.TransferService.Create(customer_id, request);

            Assert.IsNotNull(transfer.Id);
            Assert.IsNotNull(transfer.CreationDate);

            Transfer transferGet = openpayAPI.TransferService.Get(customer_id, transfer.Id);

            Assert.AreEqual(transfer.Amount, transferGet.Amount);
            Assert.IsNull(transferGet.OrderId);

            Assert.IsNotNull(transferGet.CreationDate);
            Assert.IsNotNull(transferGet.CustomerId);
            Assert.IsNotNull(transferGet.Description);
            Assert.IsNotNull(transferGet.Method);
            Assert.IsNotNull(transferGet.OperationType);
            Assert.IsNotNull(transferGet.Status);
        }
        public void TestListSubscriptions()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Plan       plan       = new Plan();

            plan.Name             = "Tv";
            plan.Amount           = 89.99m;
            plan.RepeatEvery      = 1;
            plan.RepeatUnit       = "month";
            plan.StatusAfterRetry = "unpaid";
            plan.TrialDays        = 0;
            plan = openpayAPI.PlanService.Create(plan);

            Card card = new Card();

            card.CardNumber      = "345678000000007";
            card.HolderName      = "Juanito Pérez Nuñez";
            card.Cvv2            = "1234";
            card.ExpirationMonth = "01";
            card.ExpirationYear  = DateTime.Now.AddYears(2).Year.ToString().Substring(2);

            Subscription subscription = new Subscription();

            subscription.PlanId = plan.Id;
            subscription.Card   = card;
            subscription        = openpayAPI.SubscriptionService.Create(customer_id, subscription);

            List <Subscription> subscriptions = openpayAPI.PlanService.Subscriptions(plan.Id);

            Assert.AreEqual(1, subscriptions.Count);

            openpayAPI.SubscriptionService.Delete(customer_id, subscription.Id);
            openpayAPI.PlanService.Delete(plan.Id);
        }
Пример #8
0
        public void TestChargeToCustomer_AndCapture()
        {
            String     customer_id = "adyytoegxm6boiusecxm";
            OpenpayAPI openpayAPI  = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);

            ChargeRequest request = new ChargeRequest();

            request.Method      = "card";
            request.SourceId    = "kwkoqpg6fcvfse8k8mg2";
            request.Description = "Testing from .Net";
            request.Amount      = new Decimal(9.99);
            request.Capture     = false;

            Charge charge = openpayAPI.ChargeService.Create(customer_id, request);

            Assert.IsNotNull(charge);
            Assert.IsNotNull(charge.Id);
            Assert.IsNotNull(charge.CreationDate);
            Assert.AreEqual("in_progress", charge.Status);

            Charge chargeCompleted = openpayAPI.ChargeService.Capture(customer_id, charge.Id, null);

            Assert.IsNotNull(chargeCompleted);
            Assert.AreEqual("completed", chargeCompleted.Status);
            Assert.AreEqual(charge.Amount, chargeCompleted.Amount);
        }
Пример #9
0
        public void TestPayoutAsCustomer_CreateCard()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Card       card       = new Card();

            card.CardNumber = "4111111111111111";
            card.BankCode   = "002";
            card.HolderName = "Payout User";


            PayoutRequest request = new PayoutRequest();

            request.Method      = "card";
            request.Card        = card;
            request.Amount      = 5.5m;
            request.Description = "Payout test";
            Payout payout = openpayAPI.PayoutService.Create(customer_id, request);

            Assert.IsNotNull(payout.Id);
            Assert.IsNotNull(payout.CreationDate);
            Assert.IsNotNull(payout.Card);
            Assert.IsNull(payout.BankAccount);

            Payout payoutGet = openpayAPI.PayoutService.Get(customer_id, payout.Id);

            Assert.AreEqual(payout.Amount, payoutGet.Amount);
        }
Пример #10
0
        public void TestPayoutAsMerchant_CreateBankAccount()
        {
            OpenpayAPI  openpayAPI  = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            BankAccount bankAccount = new BankAccount();

            bankAccount.CLABE      = "012298026516924616";
            bankAccount.HolderName = "Testing";

            PayoutRequest request = new PayoutRequest();

            request.Method      = "bank_account";
            request.BankAccount = bankAccount;
            request.Amount      = 8.5m;
            request.Description = "Payout test";
            Payout payout = openpayAPI.PayoutService.Create(request);

            Assert.IsNotNull(payout.Id);
            Assert.IsNotNull(payout.CreationDate);
            Assert.IsNotNull(payout.BankAccount);

            Payout payoutGet = openpayAPI.PayoutService.Get(payout.Id);

            Assert.AreEqual(payout.Amount, payoutGet.Amount);
            Assert.AreEqual(payout.BankAccount.CLABE, payoutGet.BankAccount.CLABE);
        }
Пример #11
0
        public void TestPayoutAsCustomer_CreateWithNewBankAccount()
        {
            OpenpayAPI  openpayAPI  = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            BankAccount bankAccount = new BankAccount();

            bankAccount.CLABE      = "012212000000000019";
            bankAccount.HolderName = "Testing";

            bankAccount = openpayAPI.BankAccountService.Create(customer_id, bankAccount);

            PayoutRequest request = new PayoutRequest();

            request.Method        = "bank_account";
            request.DestinationId = bankAccount.Id;
            request.Amount        = 8.5m;
            request.Description   = "Payout test";
            Payout payout = openpayAPI.PayoutService.Create(customer_id, request);

            Assert.IsNotNull(payout.Id);
            Assert.IsNotNull(payout.CreationDate);
            Assert.IsNotNull(payout.BankAccount);

            Payout payoutGet = openpayAPI.PayoutService.Get(customer_id, payout.Id);

            Assert.AreEqual(payout.Amount, payoutGet.Amount);
            Assert.AreEqual(payout.BankAccount.CLABE, payoutGet.BankAccount.CLABE);

            openpayAPI.BankAccountService.Delete(customer_id, bankAccount.Id);
        }
Пример #12
0
        public List <Card> obneterTargetasPorPkCliente1()
        {
            List <Card>   cards = new List <Card>();
            TarjetasModel aux;

            try
            {
                ClientesModel cliente = new ClientesModel();
                cliente.PK = PK_CLIENTE;
                cliente.getClienteByPk();
                if (Resources.DEVELOP.ToUpper().Equals("TRUE"))
                {
                    api = new OpenpayAPI(Resources.SK_OPEN_PAY_DEV, Resources.ID_OPEN_PAY_DEV, false);
                }
                else
                {
                    api = new OpenpayAPI(Resources.SK_OPEN_PAY, Resources.ID_OPEN_PAY, true);
                }

                SearchParams request = new SearchParams();
                //request.CreationGte = new DateTime(2100, 5, 1);
                //request.CreationLte = new DateTime(2014, 5, 15);
                //request.Offset = 0;
                request.Limit = 100;
                cards         = api.CardService.List(cliente.OPENID, request);
            }
            catch (Exception e) {
                LogModel.registra("Error al obtener tarjetas", e.ToString());
            }
            return(cards);
        }
        public void TestAlipayRedirectCharge()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.NEW_API_KEY, Constants.NEW_MERCHANT_ID);

            SearchParams    searh     = new SearchParams();
            List <Customer> customers = openpayAPI.CustomerService.List(searh);
            Customer        customer  = customers[0];

            customer.ExternalId = null;

            ChargeRequest request = new ChargeRequest();

            request.Method      = "alipay";
            request.Description = "Testing Alipay redirect from .Net";
            request.Amount      = new Decimal(1110.00);
            request.Customer    = customer;
            request.RedirectUrl = "http://www.openpay.mx/index.html";

            Charge charge = openpayAPI.ChargeService.Create(request);

            Assert.IsNotNull(charge);
            Assert.IsNotNull(charge.Id);
            Assert.IsNotNull(charge.CreationDate);
            Assert.IsNotNull(charge.DueDate);
            Assert.AreEqual("charge_pending", charge.Status);
            Console.WriteLine("Url: " + charge.PaymentMethod.Url);
            Console.WriteLine("Due Date: " + charge.DueDate);
        }
        public void TestCreateAndUpdate()
        {
            OpenpayAPI   openpayAPI   = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            string       plan_id      = "pxs6fx3asdaa7xg3ray4";
            Subscription subscription = new Subscription();

            subscription.PlanId = plan_id;
            subscription.CardId = "kwkoqpg6fcvfse8k8mg2";
            subscription        = openpayAPI.SubscriptionService.Create(customer_id, subscription);
            Assert.IsNotNull(subscription.Card);

            Card card = new Card();

            card.CardNumber      = "5105105105105100";
            card.HolderName      = "Juanito Pérez Nuñez";
            card.Cvv2            = "123";
            card.ExpirationMonth = "01";
            card.ExpirationYear  = "17";

            subscription.Card = card;
            subscription      = openpayAPI.SubscriptionService.Update(customer_id, subscription);
            Assert.IsNotNull(subscription.Card);
            int cardLength = card.CardNumber.Length;

            Assert.AreEqual("510510XXXXXX5100", subscription.Card.CardNumber);

            Subscription subscriptionGet = openpayAPI.SubscriptionService.Get(customer_id, subscription.Id);

            Assert.AreEqual(subscription.TrialEndDate, subscriptionGet.TrialEndDate);
        }
Пример #15
0
        public void TestChargeToMerchantAndGetByOrderId()
        {
            Random        random  = new Random();
            ChargeRequest request = new ChargeRequest();

            request.Method      = "card";
            request.Card        = GetCardInfo();
            request.OrderId     = random.Next(0, 10000000).ToString();
            request.Description = "Testing from .Net with new card";
            request.Amount      = new Decimal(9.99);

            Customer customer = new Customer();

            customer.Name        = "Openpay";
            customer.LastName    = "Test";
            customer.PhoneNumber = "1234567890";
            customer.Email       = "*****@*****.**";

            request.Customer = customer;

            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Charge     charge     = openpayAPI.ChargeService.Create(request);

            Assert.IsNotNull(charge);

            SearchParams search = new SearchParams();

            search.OrderId = request.OrderId;
            List <Charge> charges = openpayAPI.ChargeService.List(search);

            Assert.AreEqual(1, charges.Count);
            Assert.AreEqual(charge.Id, charges[0].Id);
        }
Пример #16
0
        public void TestList()
        {
            OpenpayAPI  openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            List <Plan> plans      = openpayAPI.PlanService.List();

            Assert.IsTrue(plans.Count > 0);
        }
Пример #17
0
        public void TestRedirectCharge()
        {
            string customerExternaiId = "monos003_customer001";

            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.NEW_API_KEY, Constants.NEW_MERCHANT_ID);

            SearchParams searh = new SearchParams();

            searh.ExternalId = customerExternaiId;
            List <Customer> customers = openpayAPI.CustomerService.List(searh);
            Customer        customer  = customers[0];

            customer.ExternalId = null;

            ChargeRequest request = new ChargeRequest();

            request.Method          = "card";
            request.Description     = "Testing redirect from .Net";
            request.Amount          = new Decimal(111.00);
            request.DeviceSessionId = "sah2e76qfdqa72ef2e2q";
            request.Customer        = customer;
            request.Confirm         = false;
            request.SendEmail       = true;
            request.RedirectUrl     = "http://www.openpay.mx/index.html";

            Charge charge = openpayAPI.ChargeService.Create(request);

            Assert.IsNotNull(charge);
            Assert.IsNotNull(charge.Id);
            Assert.IsNotNull(charge.CreationDate);
            Assert.AreEqual("charge_pending", charge.Status);
            Console.WriteLine("Url: " + charge.PaymentMethod.Url);
        }
        /*CODMANINI-ADD*/
        public string PagarOpenPay(Spartane.Core.Classes.Detalle_Pagos_Pacientes_OpenPay.Detalle_Pagos_Pacientes_OpenPay entity)
        {
            string sReturnValue = string.Empty;

            try
            {
                string     apiKey     = ConfigurationManager.AppSettings["openpay_apikey_private"];
                string     merchantId = ConfigurationManager.AppSettings["openpay_id"];
                bool       production = ConfigurationManager.AppSettings["openpay_env"] == "production";
                OpenpayAPI openpayAPI = new OpenpayAPI(apiKey, merchantId, production);

                Customer customer = new Customer();
                customer.Name        = entity.Nombre;
                customer.LastName    = entity.Apellidos;
                customer.PhoneNumber = entity.Telefono;
                customer.Email       = entity.Email;

                ChargeRequest request = new ChargeRequest();
                request.Method          = "card";
                request.SourceId        = entity.TokenID;
                request.Description     = entity.Concepto;
                request.Amount          = Convert.ToDecimal(entity.Importe);
                request.DeviceSessionId = entity.DeviceID;
                request.Customer        = customer;

                Charge charge = openpayAPI.ChargeService.Create(request);
                sReturnValue = charge.Authorization;
            }
            catch (Exception ex)
            {
                sReturnValue = "-1";
            }
            return(sReturnValue);
        }
Пример #19
0
        public void TestCustomer_CreateAndDeleteWithAddress()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Customer   customer   = new Customer();

            customer.Name                = "Net Client";
            customer.LastName            = "C#";
            customer.Email               = "*****@*****.**";
            customer.Address             = new Address();
            customer.Address.Line1       = "line 1";
            customer.Address.PostalCode  = "12355";
            customer.Address.City        = "Queretaro";
            customer.Address.CountryCode = "MX";
            customer.Address.State       = "Queretaro";

            customer = openpayAPI.CustomerService.Create(customer);
            Assert.IsNotNull(customer);
            Assert.IsNotNull(customer.Address);
            Assert.IsFalse(String.IsNullOrEmpty(customer.Id));
            Assert.AreEqual("Net Client", customer.Name);

            openpayAPI.CustomerService.Delete(customer.Id);

            try
            {
                openpayAPI.CustomerService.Get(customer.Id);
                Assert.Fail("No deberia existir");
            }
            catch (OpenpayException e)
            {
                Assert.IsNotNull(e.Description);
            }
        }
        public void TestAsCustomer_CreateGetDelete()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);

            List <BankAccount> accounts = openpayAPI.BankAccountService.List(customer_id);

            foreach (BankAccount account in accounts)
            {
                openpayAPI.BankAccountService.Delete(customer_id, account.Id);
            }

            BankAccount bankAccount = new BankAccount();

            bankAccount.CLABE      = "012212000000000006";
            bankAccount.HolderName = "Testing";
            BankAccount bankAccountCreated = openpayAPI.BankAccountService.Create(customer_id, bankAccount);

            Assert.IsNotNull(bankAccountCreated.Id);
            Assert.IsNull(bankAccountCreated.Alias);
            Assert.AreEqual("012XXXXXXXXXX00006", bankAccountCreated.CLABE);

            BankAccount bankAccountGet = openpayAPI.BankAccountService.Get(customer_id, bankAccountCreated.Id);

            Assert.AreEqual("012XXXXXXXXXX00006", bankAccountGet.CLABE);

            accounts = openpayAPI.BankAccountService.List(customer_id);
            Assert.AreEqual(1, accounts.Count);

            openpayAPI.BankAccountService.Delete(customer_id, bankAccountGet.Id);

            accounts = openpayAPI.BankAccountService.List(customer_id);
            Assert.AreEqual(0, accounts.Count);
        }
        public void TestReport_ReportDetails_ChargedAdjustments()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            PayoutReportDetailSearchParams search = new PayoutReportDetailSearchParams("charged_adjustments");
            List <Transaction>             detail = openpayAPI.PayoutReportService.Detail("tro7nlbckqqdecep7par", search);

            Assert.AreEqual(0, detail.Count);
        }
        public void TestReport_ReportSummary()
        {
            OpenpayAPI    openpayAPI    = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            PayoutSummary payoutSummary = openpayAPI.PayoutReportService.Get("tro7nlbckqqdecep7par");

            Assert.AreEqual(payoutSummary.In, new Decimal(87969.1));
            Assert.AreEqual(payoutSummary.Out, new Decimal(8767.23));
        }
Пример #23
0
 public void Configuration(IAppBuilder app)
 {
     ConfigureAuth(app);
     _usuariosManager = new AplicacionUsuariosManager();
     _servicioEmail   = new ServicioEmail();
     _baseUrl         = "https://www.mercampo.mx";
     api = new OpenpayAPI("sk_6f55e32ca0b74855b4ec592a56f5c152", "m4tpnfpemahz4tgdvadb");
 }
Пример #24
0
 public void Configuration(IAppBuilder app)
 {
     ConfigureAuth(app);
     _usuariosManager = new AplicacionUsuariosManager();
     _servicioEmail   = new ServicioEmail();
     _baseUrl         = "https://www.mercampo.mx";
     api = new OpenpayAPI("sk_f4ff6c6ddfb04f6d817e5a1e49c759dd", "mkvaxqzeaclhhptjqtd4", true);
 }
        public PaymentModel CreateTDCPayment(PaymentModel payment)
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(PrivateKey, MerchantId);

            openpayAPI.Production = IsProductionEnvironment;

            try
            {
                Customer customer = openpayAPI.CustomerService.Get(payment.ClientId);

                ChargeRequest request = new ChargeRequest
                {
                    Method          = PaymentMethod.CARD,
                    SourceId        = payment.TokenId,
                    Amount          = payment.Amount,
                    OrderId         = payment.OrderId,
                    Description     = payment.Description,
                    DeviceSessionId = payment.DeviceSessionId,
                    Customer        = customer,
                    Use3DSecure     = payment.Use3DSecure,
                    RedirectUrl     = payment.RedirectUrl
                };

                Charge charge = openpayAPI.ChargeService.Create(request);

                payment.Id              = charge.Id;
                payment.DueDate         = request.DueDate;
                payment.Status          = charge.Status;
                payment.TransactionType = charge.TransactionType;
                payment.PaymentCardURL  = DashboardURL + "/spei-pdf/" + MerchantId + "/" + charge.Id;
                payment.ResultData      = charge.ToJson();
                payment.ChargeSuccess   = true;

                if (charge.PaymentMethod != null /*&& charge.PaymentMethod.Type == "redirect"*/)
                {
                    payment.PaymentMethod = new PaymentMethodModel
                    {
                        Type        = charge.PaymentMethod.Type,
                        BankName    = charge.PaymentMethod.BankName,
                        Clabe       = charge.PaymentMethod.CLABE,
                        Reference   = charge.PaymentMethod.Reference,
                        Name        = charge.PaymentMethod.Name,
                        Agreement   = Agreement,
                        RedirectUrl = charge.PaymentMethod.Url
                    };
                }
            }
            catch (OpenpayException ex)
            {
                payment.ChargeSuccess  = false;
                payment.ResultCode     = ex.ErrorCode;
                payment.ResultData     = ex.Description;
                payment.ResultCategory = ex.Category;
            }

            return(payment);
        }
Пример #26
0
        public bool agregarTarjeta()
        {
            try
            {
                ClientesModel cliente = new ClientesModel();
                cliente.PK = PK_CLIENTE;
                cliente.getClienteByPk();
                if (!String.IsNullOrEmpty(cliente.OPENID))
                {
                    if (Resources.DEVELOP.ToUpper().Equals("TRUE"))
                    {
                        api = new OpenpayAPI(Resources.SK_OPEN_PAY_DEV, Resources.ID_OPEN_PAY_DEV, false);
                    }
                    else
                    {
                        api = new OpenpayAPI(Resources.SK_OPEN_PAY, Resources.ID_OPEN_PAY, true);
                    }

                    Card request = new Card();
                    request.TokenId         = ID_TARJETA;
                    request.DeviceSessionId = DEVICE_SESSION_ID;
                    request = api.CardService.Create(cliente.OPENID, request);
                    MARCA   = request.Brand;
                    MARCA   = request.CardNumber;
                    card    = request;
                    return(!String.IsNullOrEmpty(request.Brand));
                }

                /*
                 * string sql = "INSERT INTO TARJETAS_CLIENTES(PK_CLIENTE,ID_TARJETA,DIGITOS,MARCA)" +
                 *           "VALUES (@PK_CLIENTE,@ID_TARJETA,@DIGITOS,@MARCA)";
                 * db.PreparedSQL(sql);
                 * db.command.Parameters.AddWithValue("@PK_CLIENTE", PK_CLIENTE);
                 * db.command.Parameters.AddWithValue("@ID_TARJETA", ID_TARJETA);
                 * db.command.Parameters.AddWithValue("@DIGITOS", request.CardNumber);
                 * db.command.Parameters.AddWithValue("@MARCA", request.Brand);
                 * PK = db.executeId();
                 * if (!string.IsNullOrEmpty(PK)) {
                 *  return true;
                 * }
                 */
            }
            catch (OpenpayException e1)
            {
                string error1 = e1.ToString();
                LogModel.registra("error al agregar tajera Openpay ", error1);
                ERROR = ErroresOpenPayModel.error(e1.ErrorCode);
            }
            catch (Exception e)
            {
                string error = e.ToString();
                LogModel.registra("error al agregar tajera", error);
            }
            return(false);
        }
Пример #27
0
        public void TesTransferList()
        {
            OpenpayAPI   openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            SearchParams filters    = new SearchParams();

            filters.CreationLte = new DateTime(2014, 1, 8);
            filters.Amount      = 10.0m;
            List <Transfer> transfers = openpayAPI.TransferService.List(customer_id, filters);

            Assert.AreEqual(2, transfers.Count);
        }
        // [TestMethod]
        public void TestAsMerchant_CreateGetDelete()
        {
            OpenpayAPI openpayAPI      = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            string     bank_account_id = "bypzo1cstk5xynsuzjxo";

            BankAccount bankAccountGet = openpayAPI.BankAccountService.Get(bank_account_id);

            Assert.AreEqual("012XXXXXXXXXX24616", bankAccountGet.CLABE);

            openpayAPI.BankAccountService.Delete(bankAccountGet.Id);
        }
Пример #29
0
        public void TestCustomer_List()
        {
            SearchParams search = new SearchParams();

            search.Limit = 3;
            OpenpayAPI      openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            List <Customer> customers  = openpayAPI.CustomerService.List(search);

            Assert.IsNotNull(customers);
            Assert.AreEqual(3, customers.Count);
        }
Пример #30
0
        public void TesFeeList()
        {
            OpenpayAPI   openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            SearchParams filters    = new SearchParams();

            filters.CreationLte = new DateTime(2014, 1, 8);
            filters.Amount      = 6.0m;
            List <Fee> transfers = openpayAPI.FeeService.List(filters);

            Assert.AreEqual(3, transfers.Count);
        }