Skip to content

refactor: Abstract stripe API calls into their own modules#728

Merged
apetkov98 merged 15 commits intopodkrepi-bg:masterfrom
sashko9807:refactor/stripe-module
Apr 9, 2026
Merged

refactor: Abstract stripe API calls into their own modules#728
apetkov98 merged 15 commits intopodkrepi-bg:masterfrom
sashko9807:refactor/stripe-module

Conversation

@sashko9807
Copy link
Copy Markdown
Member

@sashko9807 sashko9807 commented Apr 9, 2026

This pull request introduces a new StripeApiClient gateway class to centralize and standardize all Stripe API interactions in the codebase. It updates the Stripe integration to ensure every Stripe SDK call goes through this gateway, improving maintainability, testability, and permission management. The PR also refactors tests and documentation to reflect this new structure.

Stripe integration improvements:

  • Added the StripeApiClient class (apps/api/src/stripe/stripe-api-client.ts) as a single gateway for all Stripe SDK calls, enabling centralized permission probing, logging, and error handling. All direct Stripe SDK calls should now go through this class.
  • Updated the Stripe module (apps/api/src/stripe/stripe.module.ts) to provide StripeApiClient as a dependency, ensuring it is available for injection throughout the application. [1] [2]

Test refactoring:

  • Refactored tests in stripe.controller.spec.ts, recurring-donation.controller.spec.ts, and stripe-payment.service.spec.ts to use a deep mock of StripeApiClient instead of mocking the Stripe SDK directly. This ensures tests are aligned with the new gateway and simplifies mocking Stripe calls. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Developer documentation:

  • Greatly expanded and clarified the Stripe testing instructions in TESTING.md, including first-time setup, recommended use of restricted keys, and a new workflow for verifying required permissions using the gateway. [1] [2]

These changes make Stripe integration more robust, easier to audit, and safer to extend.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

✅ Tests will run for this PR. Once they succeed it can be merged.

@sashko9807 sashko9807 changed the title refactor: Abstract stripe API calls into their own modules @sashko9807 refactor: Abstract stripe API calls into their own modules Apr 9, 2026
@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Apr 9, 2026
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Apr 9, 2026
@apetkov98 apetkov98 merged commit ecb0a9c into podkrepi-bg:master Apr 9, 2026
9 of 10 checks passed
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