diff --git a/apps/backend/src/api/api.module.ts b/apps/backend/src/api/api.module.ts
index c2101d58..e7f9386e 100644
--- a/apps/backend/src/api/api.module.ts
+++ b/apps/backend/src/api/api.module.ts
@@ -27,6 +27,7 @@ import { PublicController } from '@gitroom/backend/api/routes/public.controller'
import { RootController } from '@gitroom/backend/api/routes/root.controller';
import { TrackService } from '@gitroom/nestjs-libraries/track/track.service';
import { ShortLinkService } from '@gitroom/nestjs-libraries/short-linking/short.link.service';
+import { Nowpayments } from '@gitroom/nestjs-libraries/crypto/nowpayments';
const authenticatedController = [
UsersController,
@@ -65,6 +66,7 @@ const authenticatedController = [
IntegrationManager,
TrackService,
ShortLinkService,
+ Nowpayments,
],
get exports() {
return [...this.imports, ...this.providers];
diff --git a/apps/backend/src/api/routes/billing.controller.ts b/apps/backend/src/api/routes/billing.controller.ts
index fb8cfb25..5added0d 100644
--- a/apps/backend/src/api/routes/billing.controller.ts
+++ b/apps/backend/src/api/routes/billing.controller.ts
@@ -8,6 +8,7 @@ import { ApiTags } from '@nestjs/swagger';
import { GetUserFromRequest } from '@gitroom/nestjs-libraries/user/user.from.request';
import { NotificationService } from '@gitroom/nestjs-libraries/database/prisma/notifications/notification.service';
import { Request } from 'express';
+import { Nowpayments } from '@gitroom/nestjs-libraries/crypto/nowpayments';
@ApiTags('Billing')
@Controller('/billing')
@@ -15,7 +16,8 @@ export class BillingController {
constructor(
private _subscriptionService: SubscriptionService,
private _stripeService: StripeService,
- private _notificationService: NotificationService
+ private _notificationService: NotificationService,
+ private _nowpayments: Nowpayments
) {}
@Get('/check/:id')
@@ -24,10 +26,7 @@ export class BillingController {
@Param('id') body: string
) {
return {
- status: await this._stripeService.checkSubscription(
- org.id,
- body
- ),
+ status: await this._stripeService.checkSubscription(org.id, body),
};
}
@@ -39,7 +38,13 @@ export class BillingController {
@Req() req: Request
) {
const uniqueId = req?.cookies?.track;
- return this._stripeService.subscribe(uniqueId, org.id, user.id, body, org.allowTrial);
+ return this._stripeService.subscribe(
+ uniqueId,
+ org.id,
+ user.id,
+ body,
+ org.allowTrial
+ );
}
@Get('/portal')
@@ -106,4 +111,9 @@ export class BillingController {
body.subscription
);
}
+
+ @Get('/crypto')
+ async crypto(@GetOrgFromRequest() org: Organization) {
+ return this._nowpayments.createPaymentPage(org.id);
+ }
}
diff --git a/apps/backend/src/api/routes/public.controller.ts b/apps/backend/src/api/routes/public.controller.ts
index 604178fb..4a5c342a 100644
--- a/apps/backend/src/api/routes/public.controller.ts
+++ b/apps/backend/src/api/routes/public.controller.ts
@@ -10,6 +10,7 @@ import { Request, Response } from 'express';
import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
import { getCookieUrlFromDomain } from '@gitroom/helpers/subdomain/subdomain.management';
import { AgentGraphInsertService } from '@gitroom/nestjs-libraries/agent/agent.graph.insert.service';
+import { Nowpayments } from '@gitroom/nestjs-libraries/crypto/nowpayments';
@ApiTags('Public')
@Controller('/public')
@@ -18,7 +19,8 @@ export class PublicController {
private _agenciesService: AgenciesService,
private _trackService: TrackService,
private _agentGraphInsertService: AgentGraphInsertService,
- private _postsService: PostsService
+ private _postsService: PostsService,
+ private _nowpayments: Nowpayments
) {}
@Post('/agent')
async createAgent(@Body() body: { text: string; apiKey: string }) {
@@ -120,4 +122,13 @@ export class PublicController {
track: uniqueId,
});
}
+
+ @Post('/crypto/:path')
+ async cryptoPost(
+ @Body() body: any,
+ @Param('path') path: string
+ ) {
+ console.log('cryptoPost', body, path);
+ return this._nowpayments.processPayment(path, body);
+ }
}
diff --git a/apps/frontend/src/components/billing/main.billing.component.tsx b/apps/frontend/src/components/billing/main.billing.component.tsx
index 5e01720b..f51befba 100644
--- a/apps/frontend/src/components/billing/main.billing.component.tsx
+++ b/apps/frontend/src/components/billing/main.billing.component.tsx
@@ -26,6 +26,7 @@ import { useUtmUrl } from '@gitroom/helpers/utils/utm.saver';
import { useTolt } from '@gitroom/frontend/components/layout/tolt.script';
import { useTrack } from '@gitroom/react/helpers/use.track';
import { TrackEnum } from '@gitroom/nestjs-libraries/user/track.enum';
+import { PurchaseCrypto } from '@gitroom/frontend/components/billing/purchase.crypto';
export interface Tiers {
month: Array<{
@@ -502,6 +503,7 @@ export const MainBillingComponent: FC<{
))}
+