Skip to content

payment/feat: add Stripe card details to Charge webhook type and interface#1322

Open
ClaudeWeb wants to merge 1 commit into
mainfrom
payment/feat/stripe-card-details-in-payment-transaction
Open

payment/feat: add Stripe card details to Charge webhook type and interface#1322
ClaudeWeb wants to merge 1 commit into
mainfrom
payment/feat/stripe-card-details-in-payment-transaction

Conversation

@ClaudeWeb
Copy link
Copy Markdown

@ClaudeWeb ClaudeWeb commented Jun 2, 2026

Summary

  • Add PaymentMethodDetails and ChargeCardDetails types to Stripe/Types/Webhook.hs to parse payment_method_details.card from Stripe charge webhook events
  • Add CardDetails type to Interface/Events/Types.hs and cardDetails field to the interface Charge type
  • Update mkChargeObject in Interface/Stripe.hs to map Stripe card data to the interface CardDetails

Problem

Stripe sends card details (brand, last4, exp_month, exp_year, country, fingerprint, funding) inside payment_method_details.card in all charge.* webhook events. The Stripe.Charge type was missing this field, so it was silently dropped during JSON parsing and never reached the domain layer — leaving all card columns in PaymentTransaction as Nothing.

Test plan

  • Deploy and send a test Stripe charge.succeeded webhook with a card payment
  • Verify the Events.Charge received by the handler has non-null cardDetails
  • See companion PR in nammayatri/nammayatri where mkChargeOrderTxn consumes cardDetails

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Payment charge events now include detailed card information (card brand, issuing country, expiry month/year, fingerprint, funding type, and masked card number).
    • Enhanced webhook processing to automatically extract and include card metadata in charge payloads.

…rface

Parse payment_method_details.card from Stripe charge webhooks and thread
card data (brand, last4, funding, country, exp_month, exp_year, fingerprint)
through the Events.Charge interface type so consumers can populate
PaymentTransaction card fields instead of hardcoding Nothing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d9db07f5-ae06-4e74-8e24-08068e5365d3

📥 Commits

Reviewing files that changed from the base of the PR and between 1e3abfa and 2a2d8ac.

📒 Files selected for processing (3)
  • lib/mobility-core/src/Kernel/External/Payment/Interface/Events/Types.hs
  • lib/mobility-core/src/Kernel/External/Payment/Interface/Stripe.hs
  • lib/mobility-core/src/Kernel/External/Payment/Stripe/Types/Webhook.hs

Walkthrough

This PR extends Stripe charge event handling to capture and surface card metadata. It introduces a CardDetails type to the event contract, adds corresponding PaymentMethodDetails structures to Stripe webhook parsing, and implements conversion logic to extract card details from webhooks and populate charge events.

Changes

Stripe Card Details Event Enhancement

Layer / File(s) Summary
Event Types Contract
lib/mobility-core/src/Kernel/External/Payment/Interface/Events/Types.hs
New CardDetails record captures card brand, country, fingerprint, funding, expiry month/year, and last4. Charge record extended with optional cardDetails field.
Stripe Webhook Data Structures
lib/mobility-core/src/Kernel/External/Payment/Stripe/Types/Webhook.hs
New PaymentMethodDetails type with optional card field added to webhook Charge record, enabling JSON parsing of embedded card information from Stripe payloads.
Stripe to Event Conversion
lib/mobility-core/src/Kernel/External/Payment/Interface/Stripe.hs
mkChargeObject updated to extract card details from payment_method_details. New mkCardDetails helper converts Stripe.ChargeCardDetails to Events.CardDetails, mapping expiry fields and forwarding remaining attributes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • khuzema786
  • Vignesh-772

Poem

A rabbit hops through Stripe's card details so fine,
Payment methods dance in JSON's design,
From webhook to charge, the metadata flows,
Card brands and countries in records now glow,
Expiry and fingerprints—secrets bestow! 🐰💳

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding Stripe card details to the Charge webhook type and interface, which aligns with all three modified files that collectively implement this feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch payment/feat/stripe-card-details-in-payment-transaction

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant