Skip to content

feat(stripe): reuse customers and save cards for off-session reuse#239

Open
Tarunkumar0601 wants to merge 4 commits into
frappe:developfrom
aerele:feat/stripe-customers-saved-cards
Open

feat(stripe): reuse customers and save cards for off-session reuse#239
Tarunkumar0601 wants to merge 4 commits into
frappe:developfrom
aerele:feat/stripe-customers-saved-cards

Conversation

@Tarunkumar0601

Copy link
Copy Markdown

Ties each payment to a reusable Stripe Customer and saves the card for later (off-session) charging.

  • get_or_create_customer(): reuses Customer.stripe_customer_id, recovers by metadata, else creates — caching the id back
  • Saves the card (setup_future_usage="off_session") so it can be charged again without the customer present
  • SetupIntent flow to save a card without charging
  • Robust against partial failures (no duplicate Stripe customers per party)

Prerequisite for subscriptions / recurring billing. Depends on feat/stripe-payment-intents-checkout.

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

Safe to merge for synchronous card payments only; async payment methods (SEPA, ACH, bank transfers) are silently never settled, and subscription price sync is broken due to a missing database column.

The synchronous card payment path (both Hosted Checkout and Embedded Elements) is well-guarded and largely correct. However, the async payment settlement path redirects buyers to the success page without ever finalising the ERPNext document — a webhook handler that the code explicitly relies on does not exist in this PR. Separately, the subscription sync writes to a database column (product_price_id on Subscription Plan) that the custom-field installer never creates, so every sync invocation logs an error and no Stripe price ID is ever persisted.

payments/payment_gateways/doctype/stripe_settings/stripe_settings.py (missing webhook endpoint for async settlement), payments/payment_gateways/stripe_subscription_sync.py + payments/utils/utils.py (product_price_id column absent from Subscription Plan custom fields)

Reviews (20): Last reviewed commit: "feat(stripe): reuse customers and save c..." | Re-trigger Greptile

Comment thread payments/payment_gateways/doctype/stripe_settings/stripe_settings.py Outdated
Comment thread payments/payment_gateways/stripe_utils.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch from 3bd83a2 to a7acee0 Compare July 1, 2026 14:10
Comment thread payments/templates/pages/stripe_checkout.py
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch from a7acee0 to 1c673c7 Compare July 1, 2026 14:51
Comment thread payments/templates/pages/stripe_checkout.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch from 1c673c7 to d07e236 Compare July 1, 2026 16:12
Comment thread payments/payment_gateways/stripe_subscription_sync.py
Comment thread payments/payment_gateways/stripe_utils.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch 2 times, most recently from 5fa9596 to 767050f Compare July 2, 2026 06:03
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch 2 times, most recently from 1a77e37 to 4f4e9eb Compare July 2, 2026 06:54
Comment thread payments/payment_gateways/stripe_subscription_sync.py
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch from 4f4e9eb to 5d265c5 Compare July 2, 2026 07:16
Comment thread payments/templates/includes/stripe_checkout.js
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch 2 times, most recently from 0ccfdfe to 5b77acc Compare July 2, 2026 11:55
Comment thread payments/payment_gateways/doctype/stripe_settings/stripe_settings.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch 2 times, most recently from 966199f to 9a7e5f9 Compare July 3, 2026 05:41
Comment thread payments/templates/pages/stripe_checkout.py
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch from 9a7e5f9 to 58169e3 Compare July 3, 2026 06:02
Comment thread payments/templates/pages/stripe_checkout.py Outdated
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch 4 times, most recently from 77af09c to 1ffd0e2 Compare July 3, 2026 08:11
Comment thread payments/templates/pages/stripe_checkout.py
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch from 1ffd0e2 to 0fe9aff Compare July 3, 2026 08:25
@Tarunkumar0601 Tarunkumar0601 force-pushed the feat/stripe-customers-saved-cards branch from 0fe9aff to 30e3095 Compare July 3, 2026 08:39
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.

1 participant