-
Notifications
You must be signed in to change notification settings - Fork 44
Issue 3385: Extract stripe module #3386
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f249590
Extract Stripe service as a separate module
6c11458
Cover with basic tests
12649f7
Rename column "hmt"."users":"stripe_customer_id"
86bfcc5
Adjust tests
036c874
Code cleanup
8acb30b
Ignore Idea config
96df96b
Extract payment provider with stripe implementation
f948646
Move files to proper packages
bb3dfd5
Reduce PaymentProvide abstract methods number
0eed15e
Fix tests
44a77c4
Code cleanup
d0dfbd3
Restore StripePaymentStatus and adjust tests
6e2f1a8
Use test fixtures
44d7635
Simplify fetching default payment method. Adjust tests
aa47178
Rename stripe configuration service to generic conf service
fee1d97
Add missing env
portuu3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/apps/job-launcher/server/src/common/config/payment-provider-config.service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { Injectable } from '@nestjs/common'; | ||
| import { ConfigService } from '@nestjs/config'; | ||
|
|
||
| @Injectable() | ||
| export class PaymentProviderConfigService { | ||
| constructor(private configService: ConfigService) {} | ||
|
|
||
| /** | ||
| * The secret key used for authenticating requests to the payment providers API. | ||
| * Required | ||
| */ | ||
| get secretKey(): string { | ||
| return this.configService.getOrThrow<string>('PAYMENT_PROVIDER_SECRET_KEY'); | ||
| } | ||
|
|
||
| /** | ||
| * The version of the payment providers to use for requests. | ||
| * Default: '2022-11-15' | ||
| */ | ||
| get apiVersion(): string { | ||
| return this.configService.get<string>( | ||
| 'PAYMENT_PROVIDER_API_VERSION', | ||
| '2022-11-15', | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * The name of the application interacting with the payment providers API. | ||
| * Default: 'Fortune' | ||
| */ | ||
| get appName(): string { | ||
| return this.configService.get<string>( | ||
| 'PAYMENT_PROVIDER_APP_NAME', | ||
| 'Fortune', | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * The version of the application interacting with the payment providers API. | ||
| * Default: '0.0.1' | ||
| */ | ||
| get appVersion(): string { | ||
| return this.configService.get<string>( | ||
| 'PAYMENT_PROVIDER_APP_VERSION', | ||
| '0.0.1', | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * The URL of the application's information page. | ||
| * Default: 'https://hmt.ai' | ||
| */ | ||
| get appInfoURL(): string { | ||
| return this.configService.get<string>( | ||
| 'PAYMENT_PROVIDER_APP_INFO_URL', | ||
| 'https://hmt.ai', | ||
| ); | ||
| } | ||
| } |
50 changes: 0 additions & 50 deletions
50
packages/apps/job-launcher/server/src/common/config/stripe-config.service.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...job-launcher/server/src/database/migrations/1749498615107-RenameStripeCustomerIdColumn.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class RenameStripeCustomerIdColumn1749498615107 implements MigrationInterface { | ||
|
|
||
| name = 'RenameStripeCustomerIdColumn1749498615107'; | ||
|
|
||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE "hmt"."users" | ||
| RENAME COLUMN "stripe_customer_id" TO "payment_provider_id" | ||
| `); | ||
| await queryRunner.query(` | ||
| ALTER TABLE "hmt"."users" | ||
| RENAME CONSTRAINT "UQ_5ffbe395603641c29e8ce9b4c97" TO "UQ_721ffe5f6051eb5c6ac35321213" | ||
| `); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE "hmt"."users" | ||
| RENAME CONSTRAINT "UQ_721ffe5f6051eb5c6ac35321213" TO "UQ_5ffbe395603641c29e8ce9b4c97" | ||
| `); | ||
| await queryRunner.query(` | ||
| ALTER TABLE "hmt"."users" | ||
| RENAME COLUMN "payment_provider_id" TO "stripe_customer_id" | ||
| `); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/apps/job-launcher/server/src/modules/payment/payment.interface.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,60 @@ | ||
| import { PaymentEntity } from './payment.entity'; | ||
| import { PaymentStatus, VatType } from '../../common/enums/payment'; | ||
|
|
||
| export interface ListResult { | ||
| entities: PaymentEntity[]; | ||
| itemCount: number; | ||
| } | ||
|
|
||
| export interface PaymentMethod { | ||
| id: string; | ||
| brand: string; | ||
| last4: string; | ||
| expMonth: number; | ||
| expYear: number; | ||
| default: boolean; | ||
| } | ||
|
|
||
| export interface BillingAddress { | ||
| line1?: string; | ||
| city?: string; | ||
| country?: string; | ||
| postalCode?: string; | ||
| } | ||
|
|
||
| export interface CustomerData { | ||
| email: string; | ||
| name?: string; | ||
| address?: BillingAddress; | ||
| defaultPaymentMethod?: string; | ||
| } | ||
|
|
||
| export interface TaxId { | ||
| id: string; | ||
| type: VatType; | ||
| value: string; | ||
| } | ||
|
|
||
| export interface Invoice { | ||
| id: string; | ||
| paymentId: string | null; | ||
| status?: string; | ||
| amountDue: number; | ||
| currency: string; | ||
| } | ||
|
|
||
| export interface CardSetup { | ||
| customerId: string; | ||
| paymentMethod: string; | ||
| } | ||
|
|
||
| export interface PaymentData { | ||
| customer: string; | ||
| id: string; | ||
| clientSecret: string | null; | ||
| status: PaymentStatus | null; | ||
| amount: number; | ||
| amountReceived: number; | ||
| currency: string; | ||
| latestCharge: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.