You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_8 (already cloned)
- Base commit: 9045eb5b65c21ee0c9746ee591b5f00bbce3b890
- Task ID: juspay__hyperswitch-8262
- Version: v1.114.0
TASK DESCRIPTION: Bug: feat(core): consume card details from billing connectors and first error codes and store them in payment intent table
Consume the card network and card iin from billing connectors and add them ton payment intent feature metadata
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
The following details are needed to be stored in the payment intent feature metadata as a part of transaction monitoring system for revenue recovery.
- Card Network
- Card Issuer
- First Payment Gateway Error Code
- First Network Error Code
- First Network Advice Code
These will be constant through out the lifecycle of the payment intent in revenue recovery system. We need to use these parameters further in revenue recovery system. We need this as training data and need these while Deciding optimal time for the retry.
These information is stored in payment intent because this information will be constant throughout for payment intent and this information cannot be populated every time we retry this payment.
Additional Changes
- This PR modifies the API contract
- This PR modifies the database schema
- This PR modifies application configuration/environment variables
Motivation and Context
How did you test it?
Can be tested by following the steps mentioned in this PR: #7461. Here are the test results:
{ "redirect_response": null, "search_tags": null, "apple_pay_recurring_details": null, "payment_revenue_recovery_metadata": { "total_retry_count": 2, "payment_connector_transmission": "ConnectorCallUnsuccessful", "billing_connector_id": "mca_MWigDQEKB7Du4L9YqeSe", "active_attempt_payment_connector_id": "mca_PY26kh9v0Kiu1hd7lTzL", "billing_connector_payment_details": { "payment_processor_token": "card_1RXkE8RpLdtbmMLFiOTVtzLI", "connector_customer_id": "cus_SSfYcZWkulAsCG" }, "payment_method_type": "card", "payment_method_subtype": "credit", "connector": "stripe", "invoice_next_billing_time": "2025-07-15 18:30:00.0", "card_network": "Visa", "card_issuer": null, "first_payment_attempt_pg_error_code": "card_declined", "first_payment_attempt_network_decline_code": "card_declined", "first_payment_attempt_network_advice_code": "card_declined" } }Or
Run this Curl by filling our:
curl --location 'http://localhost:8080/v2/payments/create-intent' \ --header 'Content-Type: application/json' \ --header 'x-profile-id: Profile_id' \ --header 'Authorization: api-key=api-key' \ --header 'api-key: apikey' \ --data-raw '{ "amount_details": { "order_amount": 100, "currency": "USD" }, "capture_method":"manual", "authentication_type": "no_three_ds", "billing": { "address": { "first_name": "John", "last_name": "Dough" }, "email": "example@example.com" }, "shipping": { "address": { "first_name": "John", "last_name": "Dough", "city": "Karwar", "zip": "581301", "state": "Karnataka" }, "email": "example@example.com" }, "feature_metadata": { "payment_revenue_recovery_metadata": { "total_retry_count": 2, "payment_connector_transmission": "ConnectorCallUnsuccessful", "billing_connector_id": "bca_12345", "active_attempt_payment_connector_id": "pca_67890", "billing_connector_payment_details": { "payment_processor_token": "tok_abcdef123456", "connector_customer_id": "cust_98765" }, "payment_method_type": "card", "payment_method_subtype": "credit", "connector": "stripe", "invoice_next_billing_time": "2025-06-12T15:00:00Z", "billing_connector_payment_method_details": { "type": "Card", "value": { "card_network": "Visa", "card_issuer": "HDFC Bank" } }, "first_payment_attempt_pg_error_code": "PG001", "first_payment_attempt_network_decline_code": "ND002", "first_payment_attempt_network_advice_code": "AD003" } } }'This is the expected response
{ "id": "12345_pay_019763e442877b72aaa3b0a5304b2c4e", "status": "requires_payment_method", "amount_details": { "order_amount": 100, "currency": "USD", "shipping_cost": null, "order_tax_amount": null, "external_tax_calculation": "skip", "surcharge_calculation": "skip", "surcharge_amount": null, "tax_on_surcharge": null }, "client_secret": "cs_019763e442ad7ff1b735ca04e9810f2c", "profile_id": "pro_jhWJnFzJZ4tDqxGRrSbX", "merchant_reference_id": null, "routing_algorithm_id": null, "capture_method": "manual", "authentication_type": "no_three_ds", "billing": { "address": { "city": null, "country": null, "line1": null, "line2": null, "line3": null, "zip": null, "state": null, "first_name": "John", "last_name": "Dough" }, "phone": null, "email": "example@example.com" }, "shipping": { "address": { "city": "Karwar", "country": null, "line1": null, "line2": null, "line3": null, "zip": "581301", "state": "Karnataka", "first_name": "John", "last_name": "Dough" }, "phone": null, "email": "example@example.com" }, "customer_id": null, "customer_present": "present", "description": null, "return_url": null, "setup_future_usage": "on_session", "apply_mit_exemption": "Skip", "statement_descriptor": null, "order_details": null, "allowed_payment_method_types": null, "metadata": null, "connector_metadata": null, "feature_metadata": { "redirect_response": null, "search_tags": null, "apple_pay_recurring_details": null, "payment_revenue_recovery_metadata": { "total_retry_count": 2, "payment_connector_transmission": "ConnectorCallUnsuccessful", "billing_connector_id": "bca_12345", "active_attempt_payment_connector_id": "pca_67890", "billing_connector_payment_details": { "payment_processor_token": "tok_abcdef123456", "connector_customer_id": "cust_98765" }, "payment_method_type": "card", "payment_method_subtype": "credit", "connector": "stripe", "billing_connector_payment_method_details": { "type": "Card", "value": { "card_network": "Visa", "card_issuer": "HDFC Bank" } }, "invoice_next_billing_time": "2025-06-12T15:00:00.000Z", "first_payment_attempt_pg_error_code": "PG001", "first_payment_attempt_network_decline_code": "ND002", "first_payment_attempt_network_advice_code": "AD003" } }, "payment_link_enabled": "Skip", "payment_link_config": null, "request_incremental_authorization": "default", "expires_on": "2025-06-12T11:41:33.123Z", "frm_metadata": null, "request_external_three_ds_authentication": "Skip" }Check the DB for feature metadata and verify the data.
Sample log:
Checklist
- I formatted the code
cargo +nightly fmt --all - I addressed lints thrown by
cargo clippy - I reviewed the submitted code
- I added unit tests for my changes where possible
Summary by CodeRabbit
- New Features
- Added support for capturing and displaying additional card metadata, including card network, card issuer, and card ISIN, in payment and revenue recovery data.
- Enhanced error reporting by including detailed error codes from the first payment attempt, such as payment gateway error codes, network decline codes, and advice codes.
- Bug Fixes
- Improved propagation and mapping of card and error information across payment and revenue recovery processes.
- Chores
- Updated internal processes to fetch and enrich card issuer information asynchronously during revenue recovery operations.
CRITICAL INSTRUCTIONS - WORK FAST AND EFFICIENTLY:
-
Create DENSE, ACTION-FOCUSED todos IMMEDIATELY
- Make todos specific and actionable
- Focus on HIGH-IMPACT actions only
- 5-8 todos maximum - be surgical, not exhaustive
-
Execute aggressively:
- Use bash commands to search efficiently
- Read multiple related files in quick succession
- Make ALL related changes in one edit
- Skip unnecessary exploration
-
File operations:
- All repo files: './repos/hyperswitch_pool_8/'
- Use targeted edits over whole file rewrites
-
NO TESTING UNLESS CRITICAL:
- Focus on making the actual code changes
- Only test if explicitly required
-
Maximize information density:
- Each turn should accomplish significant work
- Batch file reads when examining related code
- Use search commands to locate code quickly
EFFICIENCY IS CRITICAL. Make substantial progress every turn.
Assistant
I'll help you implement this feature to consume card details from billing connectors and store them in payment intent table. Let me start by creating a structured plan for this task.
Assistant
I'll start by exploring the codebase to understand how payment intents and feature metadata are currently structured, and where we need to make changes to add the card network and card iin details from billing connectors.
First, let me examine the payment intent structure and feature metadata:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →