From d762c4c5a677a9694099fc4d70f5cac268ad2df9 Mon Sep 17 00:00:00 2001 From: Erin Page Date: Tue, 29 Oct 2024 12:13:12 -0500 Subject: [PATCH] [BILL-111] adds vertex_transaction_type to plan --- Library/Plan.cs | 11 ++++ .../vertex-transaction-type-show-200.xml | 41 +++++++++++++++ Test/PlanTest.cs | 50 +++++++++++++++++++ Test/Recurly.Test.csproj | 3 ++ 4 files changed, 105 insertions(+) create mode 100644 Test/Fixtures/plans/vertex-transaction-type-show-200.xml diff --git a/Library/Plan.cs b/Library/Plan.cs index fb51e32e..50a48520 100644 --- a/Library/Plan.cs +++ b/Library/Plan.cs @@ -23,6 +23,12 @@ public enum IntervalUnit public string SuccessUrl { get; set; } public string CancelUrl { get; set; } + /// + /// VertexTransactionType is one of rental,sale,lease + /// Requires feature flag and vertex integration to use + /// + public string VertexTransactionType { get; set; } + public bool? DisplayDonationAmounts { get; set; } public bool? DisplayQuantity { get; set; } public bool? DisplayPhoneNumber { get; set; } @@ -320,6 +326,10 @@ internal override void ReadXml(XmlTextReader reader) CancelUrl = reader.ReadElementContentAsString(); break; + case "vertex_transaction_type": + VertexTransactionType = reader.ReadElementContentAsString(); + break; + case "display_donation_amounts": DisplayDonationAmounts = reader.ReadElementContentAsBoolean(); break; @@ -474,6 +484,7 @@ internal override void WriteXml(XmlTextWriter xmlWriter) xmlWriter.WriteStringIfValid("description", Description); xmlWriter.WriteStringIfValid("accounting_code", AccountingCode); xmlWriter.WriteStringIfValid("setup_fee_accounting_code", SetupFeeAccountingCode); + xmlWriter.WriteStringIfValid("vertex_transaction_type", VertexTransactionType); // product revrec features (and setup fee revrec features) WriteRevRecNodes(xmlWriter); diff --git a/Test/Fixtures/plans/vertex-transaction-type-show-200.xml b/Test/Fixtures/plans/vertex-transaction-type-show-200.xml new file mode 100644 index 00000000..02daab4f --- /dev/null +++ b/Test/Fixtures/plans/vertex-transaction-type-show-200.xml @@ -0,0 +1,41 @@ +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 + + + + + silver + Silver Plan + Silver is everything but gold + http://example.com/api100_success + http://example.com/api100_cancel + false + true + false + true + wid99gets + http://example.com/terms-of-service + 100 + months + 15 + days + 6 + + 1234abcd + twrbsq39zvo5 + bwrks63lznoi + rkslzn + twrisqjjzvo5 + dlrk123lzabc + bks6noi + 2011-04-19T07:00:00Z + rental + + 1000 + 800 + + + 500 + 400 + + diff --git a/Test/PlanTest.cs b/Test/PlanTest.cs index b58cd34c..20447c0c 100644 --- a/Test/PlanTest.cs +++ b/Test/PlanTest.cs @@ -303,5 +303,55 @@ public void CheckForRevRecData() plan.SetupFeeRevenueGlAccountId.Should().Be("dlrk123lzabc"); plan.SetupFeePerformanceObligationId.Should().Be("bks6noi"); } + + [RecurlyFact(TestEnvironment.Type.Unit)] + public void CreatePlanWithVertexTransactionType() + { + var plan = new Plan(GetMockPlanCode(), GetMockPlanName()) { Description = "Test Delete" }; + plan.VertexTransactionType = "rental"; + plan.Create(); + PlansToDeactivateOnDispose.Add(plan); + + plan = Plans.Get(plan.PlanCode); + plan.CreatedAt.Should().NotBe(default(DateTime)); + plan.VertexTransactionType.Should().Be("rental"); + + // Clean up + plan.Deactivate(); + Action get = () => Plans.Get(plan.PlanCode); + get.ShouldThrow(); + } + + [RecurlyFact(TestEnvironment.Type.Unit)] + public void UpdatePlanWithVertexTransactionType() + { + var plan = new Plan(GetMockPlanCode(), GetMockPlanName()) { Description = "Test Update Plan with Ramps" }; + plan.VertexTransactionType = "rental"; + plan.Create(); + PlansToDeactivateOnDispose.Add(plan); + + plan.VertexTransactionType = "lease"; + plan.Update(); + + var updatedPlan = Plans.Get(plan.PlanCode); + updatedPlan.VertexTransactionType.Should().Be("lease"); + + // Clean up + plan.Deactivate(); + Action get = () => Plans.Get(plan.PlanCode); + get.ShouldThrow(); + } + + [RecurlyFact(TestEnvironment.Type.Unit)] + public void GetPlanWithVertexTransactionType() + { + var plan = new Plan(); + + var xmlFixture = FixtureImporter.Get(FixtureType.Plans, "vertex-transaction-type-show-200").Xml; + XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(xmlFixture)); + plan.ReadXml(reader); + + plan.VertexTransactionType.Should().Be("rental"); + } } } diff --git a/Test/Recurly.Test.csproj b/Test/Recurly.Test.csproj index ed5d1146..f3123362 100644 --- a/Test/Recurly.Test.csproj +++ b/Test/Recurly.Test.csproj @@ -224,6 +224,9 @@ Always + + Always + Always