public void SetWebProxy_DoesNotThrowUriException() { Configuration configuration = new Configuration( Environment.DEVELOPMENT, "integration_merchant_id", "integration_public_key", "integration_private_key" ); configuration.WebProxy = new WebProxy("http://localhost:3000"); BraintreeService service = new BraintreeService(configuration); try { service.Get(service.MerchantPath() + "/non-existent-route"); Assert.Fail("Should have thrown exception"); } catch (System.UriFormatException) { Assert.Fail("Setting WebProxy should not throw a URI exception"); } catch (NotFoundException) { // expected } }
public void All_ReturnsAllAddOns() { string addOnId = string.Format("dotnet_add_on{0}", 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 ( delegate(AddOn a) { return(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); }
public static void Escrow(BraintreeService service, string transactionId) { NodeWrapper response = new NodeWrapper(service.Put(service.MerchantPath() + "/transactions/" + transactionId + "/escrow")); Assert.IsTrue(response.IsSuccess()); }
public static void SettlementDecline(BraintreeService service, string transactionId) { NodeWrapper response = new NodeWrapper(service.Put(service.MerchantPath() + "/transactions/" + transactionId + "/settlement_decline")); Assert.IsTrue(response.IsSuccess()); }
private void MakePastDue(Subscription subscription, int numberOfDays) { BraintreeService service = new BraintreeService(gateway.Configuration); NodeWrapper response = new NodeWrapper(service.Put(service.MerchantPath() + "/subscriptions/" + subscription.Id + "/make_past_due?days_past_due=" + numberOfDays)); Assert.IsTrue(response.IsSuccess()); }
public Result <PaymentMethodNonce> Create(string token) { var response = new NodeWrapper(service.Post(service.MerchantPath() + "/payment_methods/" + token + "/nonces")); return(new ResultImpl <PaymentMethodNonce>(response, gateway)); }
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"); }