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

Add subscription change proflex settings #833

Merged
merged 1 commit into from
May 7, 2024
Merged

Conversation

smagdicatrecurly
Copy link
Contributor

Adds proration_settings to subscription attributes.

@smagdicatrecurly smagdicatrecurly added the V2 V2 Client label May 3, 2024
Test/SubscriptionTest.cs Outdated Show resolved Hide resolved
Test/SubscriptionTest.cs Outdated Show resolved Hide resolved
@btruncali1
Copy link

Just confirming this is for SubscriptionChange only right? They aren't able to create a new subscription with these settings?

@smagdicatrecurly
Copy link
Contributor Author

Thats correct. This feature allows a merchant to decide how they want to charge or credit a customer when a subscription is changed after the start of a billing cycle.

var chargeInvoice = invoices.FirstOrDefault(invoice => invoice.Type == "charge");
var creditInvoice = invoices.FirstOrDefault(invoice => invoice.Type == "credit");

Assert.Equal(0, chargeInvoice.SubtotalInCents);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added assertions to check proration settings applied to charges and credits here.

@smagdicatrecurly smagdicatrecurly force-pushed the proration_settings branch 2 times, most recently from db37eef to 7df73d4 Compare May 7, 2024 14:06

/// <summary>
/// Proration behavior to be applied to charges for the subscription change.
/// Can be set to FullAmount, ProratedAmount, or None.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, you don't need to document "can be set to...".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was helpful when hovering over that property on SubscriptionChange but if its not a common pattern to do this I can remove that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it as a pattern actually to note the possible values.

Screen Shot 2024-05-07 at 12 56 29 Screen Shot 2024-05-07 at 12 56 52

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's fine for value types, such as NetTerms, but we and the consumer have access to the literal enum values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got it. Right.

Library/SubscriptionChange.cs Show resolved Hide resolved
{
xmlWriter.WriteStartElement("proration_settings");

if (ProrationSettings.Charge != null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for adding null safety here.

plan.Create();
PlansToDeactivateOnDispose.Add(plan);

var plan2 = new Plan(GetMockPlanCode(), GetMockPlanName())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not critical, but you could make this test leaner by just changing UnitAmountInCents on the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping to see BOTH credits and charges by changing the plan.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fair.

@csampson csampson merged commit 2efb4dd into v2 May 7, 2024
3 checks passed
@csampson csampson deleted the proration_settings branch May 7, 2024 22:27
recurly-integrations pushed a commit that referenced this pull request May 8, 2024
[Full Changelog](1.17.38...1.18.0)

**Merged Pull Requests**

- Add subscription change proflex settings [#833](#833) ([smagdicatrecurly](https://github.com/smagdicatrecurly))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants