Exemplo n.º 1
0
        public void All_ReturnsAllPlans()
        {
            string planToken = $"plan{new Random().Next(1000000).ToString()}";
           
            service.Post(service.MerchantPath() + "/plans/create_plan_for_tests", new PlanRequestForTests {
                BillingDayOfMonth = 1,
                BillingFrequency = 1,
                CurrencyIsoCode = "USD",
                Description = "a_test_plan",
                Id = planToken,
                Name = "dotnet_plan",
                NumberOfBillingCycles = 1,
                Price = 100.00M,
                TrialPeriod = false,
            });

            List<Plan> collection = gateway.Plan.All();
            Assert.IsNotEmpty(collection);

            Plan plan = collection.Find
            (
                p => p.Id == planToken
            );

            Assert.AreEqual("dotnet_plan", plan.Name);
            Assert.AreEqual(1, plan.BillingDayOfMonth);
            Assert.AreEqual(1, plan.BillingFrequency);
            Assert.AreEqual("USD", plan.CurrencyIsoCode);
            Assert.AreEqual("a_test_plan", plan.Description);
            Assert.AreEqual(1, plan.NumberOfBillingCycles);
            Assert.AreEqual(100.00M, plan.Price);
            Assert.AreEqual(false, plan.TrialPeriod);
        }
Exemplo n.º 2
0
        public void All_ReturnsAllAddOns()
        {
            string addOnId = $"dotnet_add_on{new Random().Next(1000000).ToString()}";
            service.Post(service.MerchantPath() + "/modifications/create_modification_for_tests", new ModificationRequestForTests {
                Amount = 100.00M,
                Description = "a test add-on",
                Id = addOnId,
                Kind = "add_on",
                Name = "add_on_name",
                NeverExpires = false,
                NumberOfBillingCycles = 12
            });

            List<AddOn> collection = gateway.AddOn.All();
            Assert.IsNotEmpty(collection);

            AddOn addOn = collection.Find
            (
                a => a.Id == addOnId
            );

            Assert.AreEqual(100.00M, addOn.Amount);
            Assert.AreEqual("a test add-on", addOn.Description);
            Assert.AreEqual(addOnId, addOn.Id);
            Assert.AreEqual("add_on", addOn.Kind);
            Assert.AreEqual("add_on_name", addOn.Name);
            Assert.AreEqual(false, addOn.NeverExpires);
            Assert.AreEqual(12, addOn.NumberOfBillingCycles);
            Assert.IsNotNull(addOn.CreatedAt);
            Assert.IsNotNull(addOn.UpdatedAt);
        }
        public void All_ReturnsAllDiscounts()
        {
            string discountId = string.Format("dotnet_discount{0}", new Random().Next(1000000).ToString());

            service.Post(service.MerchantPath() + "/modifications/create_modification_for_tests", new ModificationRequestForTests {
                Amount = 100M,
                Description = "a test discount",
                Id = discountId,
                Kind = "discount",
                Name = "discount_name",
                NeverExpires = false,
                NumberOfBillingCycles = 12
            });

            List<Discount> collection = gateway.Discount.All();
            Assert.IsNotEmpty(collection);

            Discount discount = collection.Find
            (
                delegate(Discount d)
                {
                    return d.Id == discountId;
                }
            );

            Assert.AreEqual(100M, discount.Amount);
            Assert.AreEqual("a test discount", discount.Description);
            Assert.AreEqual(discountId, discount.Id);
            Assert.AreEqual("discount", discount.Kind);
            Assert.AreEqual("discount_name", discount.Name);
            Assert.AreEqual(false, discount.NeverExpires);
            Assert.AreEqual(12, discount.NumberOfBillingCycles);
            Assert.IsNotNull(discount.CreatedAt);
            Assert.IsNotNull(discount.UpdatedAt);
        }
Exemplo n.º 4
0
        public static string Create3DSVerification(BraintreeService service, string merchantAccountId, ThreeDSecureRequestForTests request)
        {
            string      url      = "/three_d_secure/create_verification/" + merchantAccountId;
            NodeWrapper response = new NodeWrapper(service.Post(service.MerchantPath() + url, request));

            Assert.IsTrue(response.IsSuccess());
            return(response.GetString("three-d-secure-token"));
        }
Exemplo n.º 5
0
        public static string Generate3DSNonce(BraintreeService service, CreditCardRequest request)
        {
            string      url      = "/three_d_secure/create_nonce/" + MerchantAccountIDs.THREE_D_SECURE_MERCHANT_ACCOUNT_ID;
            NodeWrapper response = new NodeWrapper(service.Post(service.MerchantPath() + url, request));

            Assert.IsTrue(response.IsSuccess());
            return(response.GetString("nonce"));
        }
Exemplo n.º 6
0
        public static string CreateGrant(BraintreeGateway gateway, string merchantId, string scope)
        {
            var     service = new BraintreeService(gateway.Configuration);
            XmlNode node    = service.Post("/oauth_testing/grants", new OAuthGrantRequest {
                MerchantId = merchantId,
                Scope      = scope
            });

            return(node["code"].InnerText);
        }
Exemplo n.º 7
0
        public Result <PaymentMethodNonce> Create(string token)
        {
            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/payment_methods/" + token + "/nonces"));

            return(new ResultImpl <PaymentMethodNonce>(response, gateway));
        }
Exemplo n.º 8
0
      public static string CreateGrant(BraintreeGateway gateway, string merchantId, string scope)
      {
          var service = new BraintreeService(gateway.Configuration);
          XmlNode node = service.Post("/oauth_testing/grants", new OAuthGrantRequest {
              MerchantId = merchantId,
              Scope = scope
          });

          return node["code"].InnerText;
      }
Exemplo n.º 9
0
 public static string Create3DSVerification(BraintreeService service, string merchantAccountId, ThreeDSecureRequestForTests request)
 {
   string url = "/three_d_secure/create_verification/" + merchantAccountId;
   NodeWrapper response = new NodeWrapper(service.Post(service.MerchantPath() + url, request));
   Assert.IsTrue(response.IsSuccess());
   return response.GetString("three-d-secure-token");
 }