diff --git a/backend/src/modules/billing/billing.service.ts b/backend/src/modules/billing/billing.service.ts index 4aef657..d6f706f 100644 --- a/backend/src/modules/billing/billing.service.ts +++ b/backend/src/modules/billing/billing.service.ts @@ -65,7 +65,7 @@ export class BillingService { ); if (result.mode === 'redirect') { - payment.tx_ref = result.providerRef; + payment.tx_ref = result.providerRef || null; payment.meta = { redirect_url: result.redirectUrl }; await this.payments.save(payment); return { paymentId: payment.id, redirectUrl: result.redirectUrl }; @@ -89,10 +89,10 @@ export class BillingService { throw new BadRequestException('Unexpected charge mode'); } - async submitBankTransfer(tenantId: string, amount: number, currency: string, imageFile: Express.Multer.File) { - if (!imageFile) throw new BadRequestException('Receipt image is required'); + async submitBankTransfer(tenantId: string, amount: number, currency: string, imageFile: any) { + if (!imageFile || !imageFile.buffer) throw new BadRequestException('Receipt image is required'); - const imageUrl = await this.storage.upload(imageFile, `transfers/${tenantId}`); + const imageUrl = await this.storage.save(tenantId, 'transfers', imageFile.buffer, imageFile.originalname || ''); const payment = await this.payments.save( this.payments.create({ diff --git a/backend/src/modules/billing/tenant-billing.controller.ts b/backend/src/modules/billing/tenant-billing.controller.ts index 5c6074c..f942718 100644 --- a/backend/src/modules/billing/tenant-billing.controller.ts +++ b/backend/src/modules/billing/tenant-billing.controller.ts @@ -41,7 +41,7 @@ export class TenantBillingController { submitTransfer( @CurrentUser() user: AuthUser, @Body() body: { amount: number; currency?: string }, - @UploadedFile() receipt: Express.Multer.File, + @UploadedFile() receipt: any, ) { return this.billing.submitBankTransfer(user.tenantId, body.amount, body.currency || 'JOD', receipt); }