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

Refactor: update Stripe subscription model decorator to use subscription model methods directly #7696

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jonwaldstein
Copy link
Contributor

@jonwaldstein jonwaldstein commented Jan 24, 2025

Resolves #

Description

This pull request includes changes to the SubscriptionModelDecorator class and its related tests to simplify the code and improve maintainability. The most important changes include the removal of unused imports, updating methods to use model methods, and refactoring the test cases.

Code simplification and maintainability improvements:

Affects

The logic for handling the Stripe subscription webhook listener InvoicePaymentSucceeded

  • shouldCreateRenewal
  • handleRenewal
  • shouldEndSubscription

Visuals

N/A

Testing Instructions

QA

  • Setup Stripe webhooks and create subscription
  • Trigger webhook event to create renewal (InvoicePaymentSucceeded)

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

@jonwaldstein jonwaldstein changed the title refactor: update decorator to use model methods Refactor: update decorator to use model methods Jan 24, 2025
@jonwaldstein jonwaldstein marked this pull request as ready for review January 24, 2025 19:11
@jonwaldstein jonwaldstein changed the title Refactor: update decorator to use model methods Refactor: update Stripe subscription model decorator to use subscription model methods directly Jan 24, 2025

// create renewal
Donation::create([
$this->subscription->createRenewal([
'amount' => Money::fromDecimal(
Copy link
Contributor

Choose a reason for hiding this comment

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

@jonwaldstein It makes me wonder... In Stripe, is it possible for a renewal to have a different value from the subscription? In which scenarios it can happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@glaubersilva that's a great question! Ideally there should not be a different value from the subscription in Give. My train of thought here was to use Stripe as the source of truth in case there is a different value - so we are recording the actual paid amount. The 2 scenarios where this would be possible (yet, very unlikely) are:

  1. The subscription was somehow updated in Stripe and not in Give
  2. The amount was recorded wrong in Give

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants