inapp-purchase for dpage

This commit is contained in:
2026-04-06 12:28:38 +03:30
parent f5cc00ccba
commit 9f0390901f
4 changed files with 50 additions and 11 deletions
@@ -778,7 +778,7 @@ export class InvoicesService {
queryRunner = this.dataSource.createQueryRunner(),
) {
let transactionStarted = false;
try {
try {
if (!queryRunner.isTransactionActive) {
await queryRunner.connect();
await queryRunner.startTransaction();
@@ -806,7 +806,7 @@ export class InvoicesService {
const purpose = invoice.purpose
if (purpose == InvoicePurpose.UPGRADE) {
// This is an upgrade - update subscription with the new plan
const upgradePlan = invoiceItem.plan!;
@@ -903,7 +903,7 @@ export class InvoicesService {
if (userSubscription.plan.service.slug?.toLowerCase().includes('dpage')) {
try {
this.logger.log(`Calling external API for dpage setup: subscription ${userSubscription.id}`);
console.log('userSubscription.plan.count',userSubscription.plan.count)
console.log('userSubscription.plan.count', userSubscription.plan.count)
await this.dpageService.createDpageAccount({
danakSubscriptionId: userSubscription.id,
name: userSubscription.businessName,
@@ -946,6 +946,16 @@ export class InvoicesService {
await this.walletsService.createSupportPlanTransaction(invoice.totalPrice, userWallet.id, queryRunner);
await this.addNotifyForWalletDeduction(invoice, user, userWallet, WalletMessage.SUPPORT_PLAN_WALLET_TRANSFER);
//
} else if (invoice.isExternal) {
if (invoice.items[0]?.name == 'purchase_new_catalogue') {
// call dpage api
const businessId = invoice.externalBusinessId
if (!businessId) {
throw new BadRequestException("business id not found")
}
const count = invoice.items[0].count
this.dpageService.finishPurchaseCatalogue(businessId, count)
}
} else {
await this.walletsService.createInvoiceTransaction(invoice.totalPrice, userWallet.id, queryRunner);
await this.addNotifyForWalletDeduction(invoice, user, userWallet, WalletMessage.INVOICE_WALLET_TRANSFER);