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); }
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 = "17"; 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); }
public void TestList() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); List<Plan> plans = openpayAPI.PlanService.List(); Assert.IsTrue(plans.Count > 0); }
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); }
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 TestWebhooks_Create_Get_Verify_Get_List_Delete() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); Webhook webhook = new Webhook(); webhook.Url = "http://postcatcher.in/catchers/54ed226514a1a60300001ab8"; webhook.AddEventType("charge.refunded"); webhook.AddEventType("charge.failed"); Webhook webhookCreated = openpayAPI.WebhooksService.Create(webhook); Assert.IsNotNull(webhookCreated.Id); Assert.IsNotNull(webhookCreated.Status); Assert.AreEqual("verified", webhookCreated.Status); Webhook webhookGet = openpayAPI.WebhooksService.Get(webhookCreated.Id); Assert.IsNotNull(webhookGet.Id); Assert.IsNotNull(webhookGet.Status); Assert.AreEqual("verified", webhookGet.Status); Assert.AreEqual(2, webhookGet.EventTypes.Count); //openpayAPI.WebhooksService.Verify(webhookGet.Id, this.GetVerificationCode(webhookGet.Url)); webhookGet = openpayAPI.WebhooksService.Get(webhookCreated.Id); Assert.IsNotNull(webhookGet.Id); Assert.IsNotNull(webhookGet.Status); Assert.AreEqual("verified", webhookGet.Status); Assert.AreEqual(2, webhookGet.EventTypes.Count); List<Webhook> webhooksList = openpayAPI.WebhooksService.List(); Assert.AreEqual(2, webhooksList.Count); openpayAPI.WebhooksService.Delete(webhookGet.Id); }
public void TestPayoutAsCustomer_CreateWithNewBankAccount() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); BankAccount bankAccount = new BankAccount(); bankAccount.CLABE = "012298026516924616"; 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); }
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); }
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); }
public void TestDetails_Pagination_NoInfo() { OpenpayAPI api = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID, false); PaginationParams pagination = new PaginationParams(); pagination.Limit = 5; pagination.Offset = 5; List<Transaction> list = api.OpenpayFeesService.Details(2012, 03, "charged", pagination); Assert.AreEqual(0, list.Count); }
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); }
public void TestUpdatePlan() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); Plan plan = openpayAPI.PlanService.Get("pxs6fx3asdaa7xg3ray4"); Random rnd = new Random(); string newName = plan.Name + rnd.Next(0, 10); plan.Name = newName; Plan plantUpdated = openpayAPI.PlanService.Update(plan); Assert.AreEqual(newName, plantUpdated.Name); }
// [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); }
public void TestCustomer_Get() { string customer_id = "adyytoegxm6boiusecxm"; OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); Customer customer = openpayAPI.CustomerService.Get(customer_id); Assert.IsNotNull(customer); Assert.IsNotNull(customer.Name); Assert.IsNotNull(customer.Store); Assert.IsNotNull(customer.CreationDate); Assert.IsNull(customer.Address); Assert.IsTrue(customer.Balance.CompareTo(8499.00M) > 0); }
public void TestCustomer_CreateAndDelete() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); Customer customer = new Customer(); customer.Name = "Net Client"; customer.Email = "*****@*****.**"; customer = openpayAPI.CustomerService.Create(customer); Assert.IsNotNull(customer); Assert.IsNotNull(customer.Store); Assert.IsFalse(String.IsNullOrEmpty(customer.Id)); openpayAPI.CustomerService.Delete(customer.Id); }
public void TestSummary_NoInfo() { OpenpayAPI api = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID, false); OpenpayFeesSummary summary = api.OpenpayFeesService.Summary (2012, 03); Assert.AreEqual(Decimal.Zero, summary.Charged); Assert.AreEqual(Decimal.Zero,summary.ChargedTax); Assert.AreEqual(Decimal.Zero,summary.ChargedAdjustments); Assert.AreEqual(Decimal.Zero,summary.ChargedAdjustmentsTax); Assert.AreEqual(Decimal.Zero,summary.Refunded); Assert.AreEqual(Decimal.Zero,summary.RefundedTax); Assert.AreEqual(Decimal.Zero,summary.RefundedAdjustments); Assert.AreEqual(Decimal.Zero,summary.RefundedAdjustmentsTax); Assert.AreEqual(Decimal.Zero,summary.Total); }
public void TestChargeToCustomerWithCard() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); ChargeRequest request = new ChargeRequest(); request.Method = "card"; request.Card = GetCardInfo(); request.Description = "Testing from .Net"; request.Amount = new Decimal(9.99); Charge charge = openpayAPI.ChargeService.Create("adyytoegxm6boiusecxm", request); Assert.IsNotNull(charge); Assert.IsNotNull(charge.Id); Assert.IsNotNull(charge.CreationDate); Assert.AreEqual("completed", charge.Status); }
public void TesFeeCreate() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); FeeRequest request = new FeeRequest(); request.CustomerId = customer_id; request.Amount = 7.0m; request.Description = "Fee Testing"; Fee fee = openpayAPI.FeeService.Create(request); Assert.IsNotNull(fee.Id); Assert.IsNotNull(fee.CreationDate); Assert.IsNotNull(fee.CustomerId); Assert.IsNotNull(fee.Description); Assert.IsNotNull(fee.Method); Assert.IsNotNull(fee.OperationType); Assert.IsNotNull(fee.Status); }
public void TestCard_CreateAsCustomer() { string customer_id = "adyytoegxm6boiusecxm"; Card card = new Card(); card.CardNumber = "4111111111111111"; card.HolderName = "Juanito Pérez Nuñez"; card.Cvv2 = "123"; card.ExpirationMonth = "01"; card.ExpirationYear = "17"; card.DeviceSessionId = "120938475692htbssd"; OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); card = openpayAPI.CardService.Create(customer_id, card); Assert.IsNotNull(card.Id); openpayAPI.CardService.Delete(customer_id, card.Id); }
public void TestCard_CreateAsMerchant() { Card card = new Card(); card.CardNumber = "4111111111111111"; card.HolderName = "Juanito Pérez Nuñez"; card.Cvv2 = "123"; card.ExpirationMonth = "01"; card.ExpirationYear = "17"; card.DeviceSessionId = "120938475692htbssd3"; OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); card = openpayAPI.CardService.Create(card); Assert.IsNotNull(card.Id); Assert.IsNotNull(card.CreationDate); Assert.IsNull(card.Cvv2); openpayAPI.CardService.Delete(card.Id); }
public void TestCreateGeDelete() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); Plan plan = new Plan(); plan.Name = "Tv"; plan.Amount = 99.99m; plan.RepeatEvery = 1; plan.RepeatUnit = "month"; plan.StatusAfterRetry = "unpaid"; plan.TrialDays = 0; Plan planCreated = openpayAPI.PlanService.Create(plan); Assert.IsNotNull(planCreated.Id); Assert.IsNotNull(planCreated.CreationDate); Assert.AreEqual("active", planCreated.Status); Plan planGet = openpayAPI.PlanService.Get(planCreated.Id); Assert.AreEqual(planCreated.Name, planGet.Name); openpayAPI.PlanService.Delete(planCreated.Id); }
public void TestAsCustomer_CreateGetDelete() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); BankAccount bankAccount = new BankAccount(); bankAccount.CLABE = "012298026516924616"; bankAccount.HolderName = "Testing"; BankAccount bankAccountCreated = openpayAPI.BankAccountService.Create(customer_id, bankAccount); Assert.IsNotNull(bankAccountCreated.Id); Assert.IsNull(bankAccountCreated.Alias); Assert.AreEqual("012XXXXXXXXXX24616", bankAccountCreated.CLABE); BankAccount bankAccountGet = openpayAPI.BankAccountService.Get(customer_id, bankAccountCreated.Id); Assert.AreEqual("012XXXXXXXXXX24616", bankAccountGet.CLABE); List<BankAccount> accounts = openpayAPI.BankAccountService.List(customer_id); Assert.AreEqual(1, accounts.Count); openpayAPI.BankAccountService.Delete(customer_id, bankAccountGet.Id); }
public void TestCard_Get() { string customer_id = "adyytoegxm6boiusecxm"; string card_id = "kwkoqpg6fcvfse8k8mg2"; OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); try { openpayAPI.CardService.Get(card_id); Assert.Fail("La tarjeta no deberia existir."); } catch (OpenpayException e) { Assert.AreEqual(1005, e.ErrorCode); Card card = openpayAPI.CardService.Get(customer_id, card_id); Assert.AreEqual(card_id, card.Id); List<Card> cards = openpayAPI.CardService.List(customer_id); Assert.IsNotNull(cards); Assert.AreEqual(1, cards.Count); } }
public void TestCreateSubscription() { 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 = "4242424242424242"; card.HolderName = "Juanito Pérez Nuñez"; card.Cvv2 = "123"; card.ExpirationMonth = "01"; card.ExpirationYear = "17"; Subscription subscription = new Subscription(); subscription.PlanId = plan.Id; subscription.Card = card; subscription = openpayAPI.SubscriptionService.Create(customer_id, subscription); Assert.IsNotNull(subscription.Id); Assert.IsNotNull(subscription.CreationDate); Assert.AreEqual(false, subscription.CancelAtPeriodEnd); Assert.IsNotNull(subscription.ChargeDate); Assert.AreEqual(1, subscription.CurrentPeriod); Assert.IsNotNull(subscription.PeriodEndDate); //Assert.IsNull(subscription.TrialEndDate); Assert.IsNotNull(subscription.PlanId); Assert.IsNotNull(subscription.Status); Assert.AreEqual(customer_id, subscription.CustomerId); Assert.IsNotNull(subscription.PlanId); Assert.IsNotNull(subscription.Card); openpayAPI.SubscriptionService.Delete(customer_id, subscription.Id); openpayAPI.PlanService.Delete(plan.Id); }
public void TestChargeToCustomerWithCard_metdatata_USD() { OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); ChargeRequest request = new ChargeRequest(); request.Method = "card"; request.Card = GetCardInfo(); request.Description = "Testing from .Net"; request.Amount = new Decimal(9.99); request.Metadata = new Dictionary<string, string> (); request.Metadata.Add ("test_key1", "pruebas"); request.Metadata.Add ("test_key2", "123456"); request.Currency = "USD"; Charge charge = openpayAPI.ChargeService.Create("adyytoegxm6boiusecxm", request); Assert.IsNotNull(charge); Assert.IsNotNull(charge.Id); Assert.IsNotNull(charge.CreationDate); Assert.AreEqual("completed", charge.Status); Assert.IsNotNull(charge.Metadata); Assert.IsNotNull(charge.ExchangeRate); }
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 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); }
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); }
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); }
public void TestUpdate() { Random rnd = new Random(); string newName = "New name " + rnd.Next(0, 500); string customer_id = "adyytoegxm6boiusecxm"; OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID); Customer customer = openpayAPI.CustomerService.Get(customer_id); customer.Name = newName; customer = openpayAPI.CustomerService.Update(customer); Assert.IsNotNull(customer); Assert.IsNotNull(customer.Name); Assert.AreEqual(newName, customer.Name); }