calcom/cal.diy · error · Error

PaymentCreationFailure

PaymentCreationFailure

Error message

payment_not_created_error

What it means

Generic catch-all in `PaymentService.create()`: any error during invoice creation/persistence is logged via `log.error(... safeStringify(error))` and re-thrown as `new Error(ErrorCode.PaymentCreationFailure)` whose value is the string `"payment_not_created_error"`. The original cause is only in logs, not in the thrown error. `getServerErrorFromUnknown` maps this ErrorCode to a 500-class response.

Source

Thrown at packages/app-store/btcpayserver/lib/PaymentService.ts:150

        fee: 0,
        success: false,
        refunded: false,
        data: Object.assign(
          {},
          {
            invoice: {
              ...invoiceResponse,
              isPaid: false,
              attendee: { name: bookerName, email: bookerEmail },
            },
          }
        ),
      });
      if (!paymentData) throw new Error("Failed to store Payment data");
      return paymentData;
    } catch (error) {
      log.error("BTCPay server: 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("BTCPay Server does not support automatic refunds for Bitcoin payments");
  }

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

View on GitHub (pinned to 176037d0af)

Solutions

  1. Read the server logs for the `log.error("BTCPay server: Payment could not be created", bookingId, ...)` line — the original error is there.
  2. Confirm the BTCPay server URL, store id, and API key in the credential are valid and reachable.
  3. If the inner cause is `"Failed to store Payment data"`, inspect the `createPayment`/repository call and the data passed to it.
  4. Preserve the cause via `throw new Error(ErrorCode.PaymentCreationFailure, { cause: error })` so callers can diagnose without logs.

Example fix

// before
} catch (error) {
  log.error("BTCPay server: Payment could not be created", bookingId, safeStringify(error));
  throw new Error(ErrorCode.PaymentCreationFailure);
}

// after
} catch (error) {
  log.error("BTCPay server: Payment could not be created", bookingId, safeStringify(error));
  throw new Error(ErrorCode.PaymentCreationFailure, { cause: error });
}
Defensive patterns

Strategy: try-catch

Type guard

function isPaymentCreationFailure(e: unknown): boolean {
  return e instanceof Error && e.message === "payment_not_created_error";
}

Try / catch

try {
  await paymentService.create();
} catch (e) {
  if (e instanceof Error && e.message === ErrorCode.PaymentCreationFailure) {
    // surface a checkout-retryable error to the user; log full cause
  }
  throw e;
}

Prevention

When it happens

Trigger: BTCPay invoice creation API call fails (network, auth, validation), the subsequent `bookingPaymentRepository`/payment-store write returns falsy (`!paymentData` triggers `"Failed to store Payment data"` caught here), a Zod schema parse fails on the invoice response, or any exception inside the try block.

Common situations: BTCPay Server unreachable during checkout; malformed invoice response after a BTCPay upgrade; DB write failure; expired/invalid BTCPay API key used by the payment service; the explicit `if (!paymentData) throw new Error("Failed to store Payment data")` being the inner cause.

Related errors


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