Skip to content

Issue 3385: Extract stripe module - #3386

Merged
portuu3 merged 16 commits into
developfrom
nikolai/ISSUE_3385-Extract-stripe-module
Jun 26, 2025
Merged

Issue 3385: Extract stripe module#3386
portuu3 merged 16 commits into
developfrom
nikolai/ISSUE_3385-Extract-stripe-module

Conversation

@santail

@santail santail commented Jun 10, 2025

Copy link
Copy Markdown
Contributor

Issue tracking

Context behind the change

#3385

It was decided to extract payment providers specific logic to separate module as abstraction and Stripe service implementing it. It would be easily to replace Stripe with any other service which should implement respective abstract class.

Now payment service operates with payment provider abstraction.

hmt.users::stripe_customer_id table column was renamed to payment_provider_id

How has this been tested?

Services are covered with unit tests. Some tests were extended, some were added or adjusted.
Verified on local environment by walking through new job creation flow in job-creator.

Release plan

Update env variable names:

PAYMENT_PROVIDER_SECRET_KEY
PAYMENT_PROVIDER_APP_NAME
PAYMENT_PROVIDER_APP_VERSION
PAYMENT_PROVIDER_APP_INFO_URL
PAYMENT_PROVIDER_API_VERSION

Potential risks; What to monitor; Rollback plan

@vercel

vercel Bot commented Jun 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
faucet-frontend ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2025 6:54am
faucet-server ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2025 6:54am
human-app ⬜️ Skipped (Inspect) Jun 26, 2025 6:54am
human-dashboard-frontend ⬜️ Skipped (Inspect) Jun 26, 2025 6:54am
staking-dashboard ⬜️ Skipped (Inspect) Jun 26, 2025 6:54am

@santail
santail force-pushed the nikolai/ISSUE_3385-Extract-stripe-module branch from a00394d to dd80b6e Compare June 11, 2025 20:29
@vercel
vercel Bot temporarily deployed to Preview – staking-dashboard June 11, 2025 20:29 Inactive
@vercel
vercel Bot temporarily deployed to Preview – human-dashboard-frontend June 11, 2025 20:29 Inactive
@vercel
vercel Bot temporarily deployed to Preview – human-app June 11, 2025 20:29 Inactive
@santail
santail requested a review from portuu3 June 11, 2025 20:31
@santail
santail marked this pull request as ready for review June 11, 2025 20:32
@vercel
vercel Bot temporarily deployed to Preview – human-dashboard-frontend June 12, 2025 05:54 Inactive
@vercel
vercel Bot temporarily deployed to Preview – staking-dashboard June 12, 2025 05:54 Inactive
@vercel
vercel Bot temporarily deployed to Preview – human-app June 12, 2025 05:54 Inactive
@portuu3
portuu3 requested a review from flopez7 June 12, 2025 12:27

@flopez7 flopez7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After discussing this with @portuu3, we agreed we should change the approach from creating a separate Stripe module to using an abstract class for the payment provider instead. This way, we can keep general logic in PaymentService and have the Stripe-specific implementation that extend the abstract class. We’re already using this pattern in other parts of the project, like email service with sendgrid in the reputation oracle. This way is easier to maintain or switch providers in the future.

For this, we would define an abstract base class for payment providers that contains any shared logic (if needed) and the abstract methods for the provider-specific actions (like creating a customer, creating an invoice or processing a payment). The Stripe implementation would simply extend this abstract class and provide the Stripe-specific logic. This keeps the PaymentService decoupled from any single provider and makes it straightforward to add or switch payment providers later, since all common code is in one place and each provider only needs to implement the unique parts.

@flopez7 flopez7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Move provider implementation into a dedicated folder inside payment, e.g. modules/payment/providers/stripe.provider.ts
  • Place the abstract class in modules/payment/providers/payment-provider.abstract.ts
  • Generalize provider method names in the abstract class so they are not Stripe-specific. For example, avoid names like createSetupIntent or handlePaymentIntent unless they are generic enough for all providers.

flopez7

This comment was marked as duplicate.

flopez7

This comment was marked as duplicate.

@vercel
vercel Bot temporarily deployed to Preview – human-app June 17, 2025 22:08 Inactive
@vercel
vercel Bot temporarily deployed to Preview – staking-dashboard June 17, 2025 22:08 Inactive
@vercel
vercel Bot temporarily deployed to Preview – human-dashboard-frontend June 17, 2025 22:08 Inactive
@santail
santail requested a review from flopez7 June 18, 2025 06:11

@flopez7 flopez7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should use camelCase for all interface property names to follow TypeScript and JavaScript conventions. Please update all internal references

Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts Outdated
Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts Outdated
Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts Outdated
Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts Outdated
Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts Outdated
Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts Outdated
Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts Outdated
Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts Outdated
Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts Outdated

@portuu3 portuu3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For all the cases where @flopez7 is asking you to change from snake_case to camelCase, you should probably use some kind of intermediate interfaces between the payment service and the provider

Comment thread packages/apps/job-launcher/server/src/common/enums/payment.ts
@vercel
vercel Bot temporarily deployed to Preview – human-app June 18, 2025 22:20 Inactive
@vercel
vercel Bot temporarily deployed to Preview – human-dashboard-frontend June 18, 2025 22:20 Inactive
@vercel
vercel Bot temporarily deployed to Preview – staking-dashboard June 18, 2025 22:20 Inactive
Comment thread packages/apps/job-launcher/server/src/modules/payment/payment.service.ts Outdated
Comment thread packages/apps/job-launcher/server/src/modules/payment/fixtures.ts
Comment thread .gitignore Outdated

@portuu3 portuu3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In order to fully encapsulate it:

@vercel
vercel Bot temporarily deployed to Preview – human-app June 23, 2025 09:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – staking-dashboard June 23, 2025 09:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – human-dashboard-frontend June 23, 2025 09:45 Inactive
@santail
santail requested review from flopez7 and portuu3 June 23, 2025 09:50
flopez7
flopez7 previously approved these changes Jun 23, 2025
Comment thread packages/apps/job-launcher/server/.env.example
@vercel
vercel Bot temporarily deployed to Preview – human-dashboard-frontend June 26, 2025 06:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – staking-dashboard June 26, 2025 06:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – human-app June 26, 2025 06:54 Inactive
@portuu3
portuu3 merged commit 6806b17 into develop Jun 26, 2025
13 checks passed
@portuu3
portuu3 deleted the nikolai/ISSUE_3385-Extract-stripe-module branch June 26, 2025 06:58
@portuu3 portuu3 mentioned this pull request Jun 26, 2025
16 tasks
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.

3 participants