Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] updates for upcoming Stripe API version bump #1068

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
},
}
]
}
7 changes: 5 additions & 2 deletions src/Stripe.Tests.XUnit/plans/_cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public static StripePlan GetPlan(string planName = "plan")
// Avoids parallel calls to end up with the same options (and id) twice.
lock(cacheLock)
{
if (Items.ContainsKey(planName)) return (StripePlan) Items[planName];
if (Items.ContainsKey(planName))
{
return (StripePlan) Items[planName];
}

var plan = new StripePlanService(ApiKey).Create(GetPlanCreateOptions(planName));
Items.Add(planName, plan);
Expand All @@ -29,7 +32,7 @@ public static StripePlanCreateOptions GetPlanCreateOptions(string planName = "pl
{
Amount = 1000,
Currency = "usd",
Name = Guid.NewGuid().ToString(),
Nickname = Guid.NewGuid().ToString(),
Id = Guid.NewGuid().ToString(),
Interval = StripePlanIntervals.Week
};
Expand Down
4 changes: 2 additions & 2 deletions src/Stripe.Tests.XUnit/plans/_fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public plans_fixture()
// Add a space at the end to ensure the ID is properly URL encoded
// when passed in the URL for other methods
Id = "test-plan-" + Guid.NewGuid().ToString() + " ",
Name = "plan-name",
Nickname = "plan-name",
Amount = 5000,
Currency = "usd",
Interval = "month",
};

PlanUpdateOptions = new StripePlanUpdateOptions {
Name = "plan-name-2"
Nickname = "plan-name-2"
};

var service = new StripePlanService(Cache.ApiKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public creating_and_updating_plans(plans_fixture fixture)
public void created_has_the_right_details()
{
fixture.Plan.Id.Should().Be(fixture.PlanCreateOptions.Id);
fixture.Plan.Name.Should().Be(fixture.PlanCreateOptions.Name);
fixture.Plan.Amount.Should().Be(fixture.PlanCreateOptions.Amount);
fixture.Plan.Currency.Should().Be(fixture.PlanCreateOptions.Currency);
fixture.Plan.Interval.Should().Be(fixture.PlanCreateOptions.Interval);
Expand All @@ -28,7 +27,6 @@ public void created_has_the_right_details()
public void updated_has_the_right_details()
{
fixture.PlanUpdated.Id.Should().Be(fixture.Plan.Id);
fixture.PlanUpdated.Name.Should().BeEquivalentTo(fixture.PlanUpdateOptions.Name);
}

[Fact]
Expand Down
6 changes: 0 additions & 6 deletions src/Stripe.net.Tests/plans/plan_behaviors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@ public class plan_behaviors
It should_have_the_correct_interval_count = () =>
StripePlan.IntervalCount.ShouldEqual(1);

It should_have_the_correct_name = () =>
StripePlan.Name.ShouldEqual(StripePlanCreateOptions.Name);

It should_have_the_correct_trial_period_days = () =>
StripePlan.TrialPeriodDays.ShouldEqual(StripePlanCreateOptions.TrialPeriodDays);

It should_have_a_created_date = () =>
StripePlan.Created.ShouldNotBeNull();

It should_have_the_correct_statement_descriptor = () =>
StripePlan.StatementDescriptor.ShouldEqual(StripePlanCreateOptions.StatementDescriptor);

It should_have_the_correct_live_mode = () =>
StripePlan.LiveMode.ShouldEqual(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ public static StripePlanCreateOptions Valid()
Amount = 5000,
Currency = "usd",
Interval = "month",
Name = "Test Plan",
TrialPeriodDays = 1,
Metadata = new Dictionary<string, string>
{
{ "A", "Value-A" },
{ "B", "Value-B" }
},
StatementDescriptor = "heyyyy ya!"
Product = new StripeProductCreateOptions
{
Name = "Test Plan",
StatementDescriptor = "heyyyy ya!"
}
};
}

Expand All @@ -32,7 +35,10 @@ public static StripePlanCreateOptions ThirtyDayIntervalWithFiveDollars()
Amount = 500,
Currency = "usd",
Interval = "month",
Name = "Thirty Days and Five Dollars"
Product = new StripeProductCreateOptions
{
Name = "Thirty Days and Five Dollars"
}
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ public static StripePlanUpdateOptions Valid()
{
return new StripePlanUpdateOptions()
{
Name = "Test Plan Modified",
Metadata = new Dictionary<string, string>
{
{ "A", "Value-A" },
{ "B", "Value-B" },
{ "C", "Value-C" }
},
StatementDescriptor = "heyyyy ya?"
}
};
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/Stripe.net.Tests/plans/when_updating_a_plan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@ public class when_updating_a_plan
Because of = () =>
StripePlan = _stripePlanService.Update(_createdStripePlanId, StripePlanUpdateOptions);

It should_have_the_new_name = () =>
StripePlan.Name.ShouldEqual(StripePlanUpdateOptions.Name);

It should_have_metadata = () =>
StripePlan.Metadata.Count.ShouldBeGreaterThan(0);

It should_have_correct_metadata = () =>
StripePlan.Metadata.ShouldContainOnly(StripePlanUpdateOptions.Metadata);

It should_have_the_new_statement_descriptor = () =>
StripePlan.StatementDescriptor.ShouldEqual(StripePlanUpdateOptions.StatementDescriptor);
}
}
10 changes: 5 additions & 5 deletions src/Stripe.net/Services/Plans/StripePlanCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public class StripePlanCreateOptions : StripeBaseOptions
[JsonProperty("interval_count")]
public int? IntervalCount { get; set; }

[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("product")]
public StripeProductCreateOptions Product { get; set; }

[JsonProperty("trial_period_days")]
public int? TrialPeriodDays { get; set; }

[JsonProperty("statement_descriptor")]
public string StatementDescriptor { get; set; }

[JsonProperty("metadata")]
public Dictionary<string, string> Metadata { get; set; }

[JsonProperty("nickname")]
public string Nickname { get; set; }
}
}
7 changes: 2 additions & 5 deletions src/Stripe.net/Services/Plans/StripePlanUpdateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ namespace Stripe
{
public class StripePlanUpdateOptions : StripeBaseOptions
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("nickname")]
public string Nickname { get; set; }

[JsonProperty("metadata")]
public Dictionary<string, string> Metadata { get; set; }

[JsonProperty("statement_descriptor")]
public string StatementDescriptor { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@ public class StripeProductCreateOptions : StripeProductSharedOptions
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("statement_descriptor")]
public string StatementDescriptor { get; set; }

[JsonProperty("type")]
public string type { get; set; }
}
}