{"record":{"id":"e343f5b72419bfe6","repo":"calcom/cal.diy","slug":"paymentcreationfailure","errorCode":"PaymentCreationFailure","errorMessage":"payment_not_created_error","messagePattern":"payment_not_created_error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/app-store/alby/lib/PaymentService.ts","lineNumber":91,"sourceCode":"          externalId: invoice.paymentRequest,\n          currency: payment.currency,\n          data: Object.assign(\n            {},\n            { invoice: { ...invoice, isPaid: false } }\n          ) as unknown as Prisma.InputJsonValue,\n          fee: 0,\n          refunded: false,\n          success: false,\n        },\n      });\n\n      if (!paymentData) {\n        throw new Error();\n      }\n      return paymentData;\n    } catch (error) {\n      log.error(\"Alby: Payment could not be created\", bookingId, safeStringify(error));\n      throw new Error(ErrorCode.PaymentCreationFailure);\n    }\n  }\n  async update(): Promise<Payment> {\n    throw new Error(\"Method not implemented.\");\n  }\n  async refund(): Promise<Payment> {\n    throw new Error(\"Method not implemented.\");\n  }\n\n  async collectCard(\n    _payment: Pick<Prisma.PaymentUncheckedCreateInput, \"amount\" | \"currency\">,\n    _bookingId: number,\n    _bookerEmail: string,\n    _paymentOption: PaymentOption\n  ): Promise<Payment> {\n    throw new Error(\"Method not implemented\");\n  }\n  chargeCard(","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/packages/app-store/alby/lib/PaymentService.ts#L73-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check server logs for 'Alby: Payment could not be created' - it contains the real underlying error.","Confirm the Alby credential key parses (call isSetupAlready()) before invoking create.","Verify the bookingId exists and the configured lightning address is reachable.","Distinguish the root cause (network vs DB vs config) from the log before retrying."],"exampleFix":"// before\nasync create(payment, bookingId) {\n  try { /* ... */ } catch (error) {\n    throw new Error(ErrorCode.PaymentCreationFailure);\n  }\n}\n\n// after - fail fast on the two known precondition failures\nif (!booking) throw new Error('Alby: booking not found for id ' + bookingId);\nif (!this.credentials?.account_lightning_address)\n  throw new Error('Alby: lightning address not configured');","handlingStrategy":"try-catch","validationCode":"if (!service.isSetupAlready()) {\n  // credentials did not parse; abort before calling create\n}","typeGuard":"const isPaymentCreationFailure = (e: unknown) =>\n  e instanceof Error && e.message === ErrorCode.PaymentCreationFailure;","tryCatchPattern":"try {\n  await service.create(payment, bookingId);\n} catch (e) {\n  if (isPaymentCreationFailure(e)) {\n    // read server log 'Alby: Payment could not be created' for the real cause\n  }\n}","preventionTips":["Call isSetupAlready() before create() to fail fast on bad credentials.","Verify the bookingId exists and the lightning address is reachable before invoicing.","Preserve the original error in logs (already done) so the generic re-throw is debuggable."],"tags":["alby","payment","lightning-network","catch-all"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}