calcom/cal.diy · critical · Error

PaymentCreationFailure

PaymentCreationFailure

Error message

payment_not_created_error

What it means

Catch-all thrown by AlbyPaymentService.create() when anything in the create flow fails: booking not found, missing lightning address, LightningAddress.fetch/requestInvoice network error, or prisma.payment.create failure. The original error is logged via log.error with the bookingId and safeStringify(error); only the generic ErrorCode.PaymentCreationFailure ('payment_not_created_error') is re-thrown.

Source

Thrown at packages/app-store/alby/lib/PaymentService.ts:91

          externalId: invoice.paymentRequest,
          currency: payment.currency,
          data: Object.assign(
            {},
            { invoice: { ...invoice, isPaid: false } }
          ) as unknown as Prisma.InputJsonValue,
          fee: 0,
          refunded: false,
          success: false,
        },
      });

      if (!paymentData) {
        throw new Error();
      }
      return paymentData;
    } catch (error) {
      log.error("Alby: Payment could not be created", bookingId, safeStringify(error));
      throw new Error(ErrorCode.PaymentCreationFailure);
    }
  }
  async update(): Promise<Payment> {
    throw new Error("Method not implemented.");
  }
  async refund(): Promise<Payment> {
    throw new Error("Method not implemented.");
  }

  async collectCard(
    _payment: Pick<Prisma.PaymentUncheckedCreateInput, "amount" | "currency">,
    _bookingId: number,
    _bookerEmail: string,
    _paymentOption: PaymentOption
  ): Promise<Payment> {
    throw new Error("Method not implemented");
  }
  chargeCard(

View on GitHub (pinned to 176037d0af)

Solutions

  1. Check server logs for 'Alby: Payment could not be created' - it contains the real underlying error.
  2. Confirm the Alby credential key parses (call isSetupAlready()) before invoking create.
  3. Verify the bookingId exists and the configured lightning address is reachable.
  4. Distinguish the root cause (network vs DB vs config) from the log before retrying.

Example fix

// before
async create(payment, bookingId) {
  try { /* ... */ } catch (error) {
    throw new Error(ErrorCode.PaymentCreationFailure);
  }
}

// after - fail fast on the two known precondition failures
if (!booking) throw new Error('Alby: booking not found for id ' + bookingId);
if (!this.credentials?.account_lightning_address)
  throw new Error('Alby: lightning address not configured');
Defensive patterns

Strategy: try-catch

Validate before calling

if (!service.isSetupAlready()) {
  // credentials did not parse; abort before calling create
}

Type guard

const isPaymentCreationFailure = (e: unknown) =>
  e instanceof Error && e.message === ErrorCode.PaymentCreationFailure;

Try / catch

try {
  await service.create(payment, bookingId);
} catch (e) {
  if (isPaymentCreationFailure(e)) {
    // read server log 'Alby: Payment could not be created' for the real cause
  }
}

Prevention

When it happens

Trigger: Alby/lightning network down; the user's lightning address unreachable; bookingId invalid; DB write constraint violation (e.g. uid collision); credentials parsed to null in the constructor so account_lightning_address is undefined.

Common situations: Alby API outage; credentials not fully set up (constructor's safeParse failed -> this.credentials null); DB unique-constraint collision on the generated uid; booking deleted between request and create.

Related errors


AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12). Data as JSON: /api/errors/e343f5b72419bfe6. Report an issue: GitHub.