public void Create_WithDescriptorValidation()
{
TestPlan plan = PlanFixture.PLAN_WITHOUT_TRIAL;
SubscriptionRequest request = new SubscriptionRequest
{
PaymentMethodToken = creditCard.Token,
PlanId = plan.Id,
Descriptor = new DescriptorRequest
{
Name = "badcompanyname12*badproduct12",
Phone = "%bad4445555",
Url = "12345678901234"
}
};
Result<Subscription> result = gateway.Subscription.Create(request);
Assert.IsFalse(result.IsSuccess());
Assert.AreEqual(
ValidationErrorCode.DESCRIPTOR_NAME_FORMAT_IS_INVALID,
result.Errors.ForObject("Subscription").ForObject("Descriptor").OnField("Name")[0].Code
);
Assert.AreEqual(
ValidationErrorCode.DESCRIPTOR_PHONE_FORMAT_IS_INVALID,
result.Errors.ForObject("Subscription").ForObject("Descriptor").OnField("Phone")[0].Code
);
Assert.AreEqual(
ValidationErrorCode.DESCRIPTOR_URL_FORMAT_IS_INVALID,
result.Errors.ForObject("Subscription").ForObject("Descriptor").OnField("Url")[0].Code
);
}