Skip to content

Can't access content of hosted_page #40

Description

@ayushjaipuriyar
  async acknowledge(id: string): Promise<User> {
    try {
      const result = await this.chargebee.hosted_page.retrieve(id).request();
      this.logger.debug(`${JSON.stringify(result)}`);
      const hosted_page: HostedPage = result?.hosted_page;
      this.logger.debug(`${JSON.stringify(hosted_page)}`);
      if (
        hosted_page.type === 'checkout_new' &&
        hosted_page.state === 'succeeded'
      ) {
        const customer: Customer = result?.customer;
        const invoice: Invoice = result?.invoice;
        const subscription: Subscription = result?.subscription;
        if (!customer && !subscription && !invoice) {
          throw new InternalServerErrorException(
            'There is no data for the given hosted page',
          );
        }
        this.logger.debug(
          `customer: ${JSON.stringify(customer)},invoice: ${JSON.stringify(
            invoice,
          )},subscription:${JSON.stringify(subscription)}`,
        );
        await this.subscriptionService.save(subscription);
        await this.transactionService.saveTransaction({
          customer_id: customer.id,
          subscription_id: subscription.id,
          gateway: customer.payment_method.gateway,
          hosted_page_id: id,
          invoices: [invoice ? invoice : null],
        });
        await this.chargebee.hosted_page.acknowledge(id).request();
      }
      return await this.userService.getUserById(result.customer.id);
    } catch (error) {
      this.logger.error(
        `Something went wrong while retrieving hosted page: ${error.message}`,
        error.stack,
      );
      throw new InternalServerErrorException(
        'Something went wrong while acknowledging hosted page',
      );
    }
  }

there is no content in hosted_page

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions