payment chargeback notifications#1109
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR adds Telegram notifications for payment chargebacks by implementing a handler for Stripe's Key Changes:
The notification message includes all relevant dispute details: project info, tenancy ID, Stripe account, dispute ID, amount, reason, status, associated charge/payment intent IDs, timestamp, and live mode indicator. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Stripe
participant WebhookRoute as Stripe Webhook Handler
participant TelegramLib as Telegram Library
participant StripeAPI as Stripe API
participant Database
participant TelegramAPI as Telegram API
Stripe->>WebhookRoute: charge.dispute.created event
WebhookRoute->>WebhookRoute: Extract mockData from event
WebhookRoute->>WebhookRoute: Check event.type === "charge.dispute.created"
WebhookRoute->>TelegramLib: getTelegramConfig("chargebacks")
TelegramLib->>TelegramLib: Read STACK_TELEGRAM_BOT_TOKEN
TelegramLib->>TelegramLib: Read STACK_TELEGRAM_CHAT_ID_CHARGEBACKS
alt Config not available
TelegramLib-->>WebhookRoute: null
WebhookRoute-->>Stripe: Return early (200 OK)
else Config available
TelegramLib-->>WebhookRoute: {botToken, chatId}
WebhookRoute->>WebhookRoute: Validate event.account exists
WebhookRoute->>StripeAPI: getTenancyForStripeAccountId(accountId, mockData)
StripeAPI->>StripeAPI: Retrieve account metadata
StripeAPI-->>WebhookRoute: Tenancy object
WebhookRoute->>WebhookRoute: buildChargebackMessage()
WebhookRoute->>WebhookRoute: Format dispute details
WebhookRoute->>TelegramLib: sendTelegramMessage({botToken, chatId, message})
TelegramLib->>TelegramAPI: POST to api.telegram.org/sendMessage
TelegramAPI-->>TelegramLib: Response
alt Telegram request failed
TelegramLib-->>WebhookRoute: Throw StackAssertionError
else Success
TelegramLib-->>WebhookRoute: Success
WebhookRoute-->>Stripe: 200 OK {received: true}
end
end
|
<!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md -->
|
📝 Documentation updates detected! New suggestion: Document invoice listing feature |
Note
Adds invoice visibility and chargeback alerts, and persists invoice data from Stripe.
GET /payments/invoices/{customer_type}/{customer_id}with cursor pagination; returnsstatus,amount_total,hosted_invoice_url,created_at_millislistInvoices(+ React hook) and sharedinvoicestypes; integrates into template client app cachesSubscriptionInvoicegainsstatus,amountTotal,hostedInvoiceUrl(migration + Prisma schema)invoice.*;upsertStripeInvoicepersists invoices; handlecharge.dispute.createdand send Telegram notifications; stricter handling of unknown events; safer invoice line accesslib/telegramwithgetTelegramConfigandsendTelegramMessage;init-script-callbackmigrated to use itWritten by Cursor Bugbot for commit 706ba96. This will update automatically on new commits. Configure here.