From 9a47168e1cb0d5b5ebcd6cb9763d477b45fe2f60 Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Tue, 20 Jan 2026 22:16:34 +0100 Subject: [PATCH 1/4] feat(bank): add Yapeal EUR manual bank account CH8383019496938261612 --- .../1768943778000-AddYapealEurManualBank.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 migration/1768943778000-AddYapealEurManualBank.js diff --git a/migration/1768943778000-AddYapealEurManualBank.js b/migration/1768943778000-AddYapealEurManualBank.js new file mode 100644 index 0000000000..2c1d596aeb --- /dev/null +++ b/migration/1768943778000-AddYapealEurManualBank.js @@ -0,0 +1,29 @@ +/** + * @typedef {import('typeorm').MigrationInterface} MigrationInterface + * @typedef {import('typeorm').QueryRunner} QueryRunner + */ + +/** + * @class + * @implements {MigrationInterface} + */ +module.exports = class AddYapealEurManualBank1768943778000 { + name = 'AddYapealEurManualBank1768943778000' + + /** + * @param {QueryRunner} queryRunner + */ + async up(queryRunner) { + await queryRunner.query(` + INSERT INTO "bank" ("name", "iban", "bic", "currency", "receive", "send", "sctInst", "amlEnabled", "assetId") + VALUES ('Yapeal', 'CH8383019496938261612', 'YAPECHZ2', 'EUR', 0, 1, 0, 1, 405) + `); + } + + /** + * @param {QueryRunner} queryRunner + */ + async down(queryRunner) { + await queryRunner.query(`DELETE FROM "bank" WHERE "iban" = 'CH8383019496938261612'`); + } +} From 1ce6f77f88cb7f1e0e73bfd41e16a98f9549705c Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Tue, 20 Jan 2026 22:21:36 +0100 Subject: [PATCH 2/4] feat(yapeal): add subscription management endpoints for admin --- .../controllers/yapeal-webhook.controller.ts | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/integration/bank/controllers/yapeal-webhook.controller.ts b/src/integration/bank/controllers/yapeal-webhook.controller.ts index 5fd28de571..dfcbc7d1c1 100644 --- a/src/integration/bank/controllers/yapeal-webhook.controller.ts +++ b/src/integration/bank/controllers/yapeal-webhook.controller.ts @@ -1,12 +1,20 @@ -import { Body, Controller, ForbiddenException, Headers, Post } from '@nestjs/common'; -import { ApiExcludeEndpoint, ApiTags } from '@nestjs/swagger'; +import { Body, Controller, Delete, ForbiddenException, Get, Headers, Param, Post, UseGuards } from '@nestjs/common'; +import { AuthGuard } from '@nestjs/passport'; +import { ApiExcludeEndpoint, ApiBearerAuth, ApiTags } from '@nestjs/swagger'; +import { RoleGuard } from 'src/shared/auth/role.guard'; +import { UserRole } from 'src/shared/auth/user-role.enum'; import { Config } from 'src/config/config'; import { YapealWebhookService } from '../services/yapeal-webhook.service'; +import { YapealSubscription } from '../dto/yapeal.dto'; +import { YapealService } from '../services/yapeal.service'; @ApiTags('Bank') @Controller('bank/yapeal') export class YapealWebhookController { - constructor(private readonly yapealWebhookService: YapealWebhookService) {} + constructor( + private readonly yapealWebhookService: YapealWebhookService, + private readonly yapealService: YapealService, + ) {} @Post('webhook') @ApiExcludeEndpoint() @@ -29,4 +37,30 @@ export class YapealWebhookController { throw new ForbiddenException('Invalid API key'); } } + + // --- SUBSCRIPTION MANAGEMENT (Admin only) --- // + + @Get('subscription') + @ApiBearerAuth() + @ApiExcludeEndpoint() + @UseGuards(AuthGuard(), RoleGuard(UserRole.ADMIN)) + async getSubscriptions(): Promise { + return this.yapealService.getTransactionSubscriptions(); + } + + @Post('subscription/:iban') + @ApiBearerAuth() + @ApiExcludeEndpoint() + @UseGuards(AuthGuard(), RoleGuard(UserRole.ADMIN)) + async createSubscription(@Param('iban') iban: string): Promise { + return this.yapealService.createTransactionSubscription(iban); + } + + @Delete('subscription/:iban') + @ApiBearerAuth() + @ApiExcludeEndpoint() + @UseGuards(AuthGuard(), RoleGuard(UserRole.ADMIN)) + async deleteSubscription(@Param('iban') iban: string): Promise { + return this.yapealService.deleteTransactionSubscription(iban); + } } From 4f71f9e2cdab667c20ef72670d983887b6b8ae3c Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Wed, 21 Jan 2026 10:15:18 +0100 Subject: [PATCH 3/4] fix(migration): make bank insert idempotent --- migration/1768943778000-AddYapealEurManualBank.js | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/1768943778000-AddYapealEurManualBank.js b/migration/1768943778000-AddYapealEurManualBank.js index 2c1d596aeb..d389d08921 100644 --- a/migration/1768943778000-AddYapealEurManualBank.js +++ b/migration/1768943778000-AddYapealEurManualBank.js @@ -15,6 +15,7 @@ module.exports = class AddYapealEurManualBank1768943778000 { */ async up(queryRunner) { await queryRunner.query(` + IF NOT EXISTS (SELECT 1 FROM "bank" WHERE "iban" = 'CH8383019496938261612') INSERT INTO "bank" ("name", "iban", "bic", "currency", "receive", "send", "sctInst", "amlEnabled", "assetId") VALUES ('Yapeal', 'CH8383019496938261612', 'YAPECHZ2', 'EUR', 0, 1, 0, 1, 405) `); From f897b98a213fd9fefecf4449f1c9c6f264d74f1f Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Wed, 21 Jan 2026 10:19:02 +0100 Subject: [PATCH 4/4] chore: remove migration (already inserted manually) --- .../1768943778000-AddYapealEurManualBank.js | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 migration/1768943778000-AddYapealEurManualBank.js diff --git a/migration/1768943778000-AddYapealEurManualBank.js b/migration/1768943778000-AddYapealEurManualBank.js deleted file mode 100644 index d389d08921..0000000000 --- a/migration/1768943778000-AddYapealEurManualBank.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @typedef {import('typeorm').MigrationInterface} MigrationInterface - * @typedef {import('typeorm').QueryRunner} QueryRunner - */ - -/** - * @class - * @implements {MigrationInterface} - */ -module.exports = class AddYapealEurManualBank1768943778000 { - name = 'AddYapealEurManualBank1768943778000' - - /** - * @param {QueryRunner} queryRunner - */ - async up(queryRunner) { - await queryRunner.query(` - IF NOT EXISTS (SELECT 1 FROM "bank" WHERE "iban" = 'CH8383019496938261612') - INSERT INTO "bank" ("name", "iban", "bic", "currency", "receive", "send", "sctInst", "amlEnabled", "assetId") - VALUES ('Yapeal', 'CH8383019496938261612', 'YAPECHZ2', 'EUR', 0, 1, 0, 1, 405) - `); - } - - /** - * @param {QueryRunner} queryRunner - */ - async down(queryRunner) { - await queryRunner.query(`DELETE FROM "bank" WHERE "iban" = 'CH8383019496938261612'`); - } -}