Skip to content

feat(stripe): webhook endpoint and one-off reconciliation#240

Open
Tarunkumar0601 wants to merge 5 commits into
frappe:developfrom
aerele:feat/stripe-webhooks-reconciliation
Open

feat(stripe): webhook endpoint and one-off reconciliation#240
Tarunkumar0601 wants to merge 5 commits into
frappe:developfrom
aerele:feat/stripe-webhooks-reconciliation

Conversation

@Tarunkumar0601

Copy link
Copy Markdown

Adds a signed Stripe webhook endpoint as the authoritative backstop for reconciling payments server-to-server.

  • Signature-verified endpoint (checks every configured account's secret → multi-account)
  • Stripe Webhook Log doctype: audit trail + idempotency ledger (unique stripe_event_id)
  • Event router (stripe_reconcile.py) with idempotent handlers
  • One-off reconciliation on payment_intent.succeeded (reuses the shared finaliser)
  • Always returns 200 once logged, so a business failure doesn't trigger endless retries

Ensures payments reconcile even if the customer never returns to the site. Depends on feat/stripe-customers-saved-cards.

Backport Needed: V15 & V16

@Tarunkumar0601 Tarunkumar0601 marked this pull request as ready for review July 1, 2026 10:34
@mergify

mergify Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown

Confidence Score: 3/5

The Hosted Checkout path creates unbounded orphaned Integration Requests on retries, and the ERPNext settlement import is unguarded against version drift.

Two incomplete fixes in the new code: the orphan-IR problem was solved for embedded checkout but not for the new hosted checkout flow, and the get_existing_payment_entry import has no version guard. Both affect the core payment reconciliation path.

stripe_settings.py (create_checkout_session) and settle_payment_request.

Reviews (28): Last reviewed commit: "feat(stripe): webhook endpoint and one-o..." | Re-trigger Greptile

Comment thread payments/payment_gateways/stripe_subscription_sync.py
Comment thread payments/payment_gateways/doctype/stripe_settings/__init__.py
Comment thread payments/payment_gateways/doctype/stripe_settings/stripe_settings.py Outdated
Comment thread payments/payment_gateways/stripe_subscription_sync.py
Comment thread payments/payment_gateways/stripe_subscription_sync.py
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from 2b8fff3 to 8c9b945 Compare July 1, 2026 14:10
Comment thread payments/payment_gateways/stripe_utils.py Outdated
Comment thread payments/templates/pages/stripe_checkout.py
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch 2 times, most recently from 1193e93 to e3e967e Compare July 1, 2026 16:12
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch 4 times, most recently from 5625163 to d423355 Compare July 2, 2026 06:54
Comment thread payments/payment_gateways/stripe_reconcile.py
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from d423355 to 917965e Compare July 2, 2026 07:16
Comment thread payments/payment_gateways/doctype/stripe_settings/__init__.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from 917965e to 8679386 Compare July 2, 2026 10:17
Comment thread payments/templates/includes/stripe_checkout.js
Comment thread payments/templates/includes/stripe_checkout.js
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch 2 times, most recently from 2c5925e to 877a839 Compare July 2, 2026 12:19
Comment thread payments/payment_gateways/stripe_utils.py Outdated
Comment thread payments/payment_gateways/stripe_reconcile.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from 877a839 to 04a6e33 Compare July 2, 2026 13:06
Comment thread payments/utils/utils.py
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from 04a6e33 to 760b548 Compare July 3, 2026 05:44
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from 760b548 to f0cf329 Compare July 3, 2026 06:02
Comment thread payments/payment_gateways/stripe_utils.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from f0cf329 to 617d15a Compare July 3, 2026 06:20
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch 2 times, most recently from 27ae54d to 41fb1f3 Compare July 3, 2026 07:36
Comment thread payments/payment_gateways/stripe_utils.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch 3 times, most recently from 96ea5c1 to 77c4595 Compare July 3, 2026 08:39
Comment thread payments/payment_gateways/doctype/stripe_settings/__init__.py
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch 2 times, most recently from 6bbaa73 to 52d8806 Compare July 3, 2026 09:45
Comment thread payments/payment_gateways/doctype/stripe_settings/stripe_settings.json Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from 52d8806 to b8a5501 Compare July 8, 2026 17:04
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from b8a5501 to fbaf89c Compare July 8, 2026 17:26
Comment thread payments/payment_gateways/stripe_reconcile.py
Comment thread payments/templates/pages/stripe_checkout.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from fbaf89c to f2c7d67 Compare July 9, 2026 06:30
Comment thread payments/payment_gateways/stripe_utils.py Outdated
Comment thread payments/payment_gateways/stripe_utils.py Outdated
Comment thread payments/payment_gateways/stripe_utils.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from f2c7d67 to 80bc117 Compare July 9, 2026 08:43
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-webhooks-reconciliation branch from 80bc117 to 27b0755 Compare July 9, 2026 09:03
billing_interval_count = cint(billing_interval_count) or 1
if billing_interval_count == 1:
recurrence = _("per {0}").format(_(billing_interval))
else:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still this is not resolved.
use PHRASES = {"Day": _("daily"), "Week": _("weekly"), "Month": _("monthly"), "Year": _("yearly")}
recurrence = PHRASES.get(billing_interval, "") if billing_interval_count == 1
else _("every {0} {1}").format(billing_interval_count, {"Day": _("days"), ...}.get(billing_interval, ""))

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants