Skip to content

fix(revenue_recovery): Populate payment method data in record attempt flow for V2 #8886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: redis_manipulation
Choose a base branch
from

Conversation

srujanchikke
Copy link
Contributor

@srujanchikke srujanchikke commented Aug 9, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

In revenue recovery flow, when process tracker picks task , it records internal attempt first and then triggers proxy payments. Previously only customer id and psp token is required to make payment. Since recovery ml model needs all othe parameter, This PR adds support for populating payment method data in internal and external attempts .
Attempts are created in 3 scenarios

  1. when external attempt is triggered by billing connectors(like chargebee,recurly) via webhooks
  2. when external attempt is created by custom billing api
  3. process trackers executes execute_workflow.
    These 3 scenarios are covered in this PR .

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Create payment via custom billing api, use this pr testcases #8838

  1. payment method data in both external and internal attempts in DB.
  2. Internal payment attempts via worldpay should be succe succeeded dded
{
    "amount_details": {
        "order_amount": 100,
        "currency": "USD"
    },
    "merchant_reference_id": "4444",
    "billing_merchant_connector_id" : "{{mca_id}}",
    "payment_merchant_connector_id": "mca_mOBlRqcT7KPPUlEBugqv",
    "error": {
        "code": "card_declined",
        "message": "Your card was declined.",
        "network_advice_code": null,
        "network_decline_code": "01",
        "network_error_message": "generic_decline"
    },
    "billing": {
        "address": {
            "first_name": "John",
            "last_name": "Dough"
        },
        "email": "[email protected]"
    },
    "attempt_status": "failure",
    "payment_method_type": "card",
    "payment_method_sub_type": "credit",
    "transaction_created_at": "2025-06-20T10:11:12Z",
    "connector_customer_id": "cus_0001",
    "connector_transaction_id": "id35987asdaaddfse",
    "primary_processor_payment_method_token": "5454540204265454",
    "action": "schedule_failed_payment",
    "billing_started_at": "2025-07-31T10:11:12Z",
    "payment_method_units": {
        "2871855923280002": {
            "card": {
                "expiry_month": "12",
                "expiry_year": "25",
                "last_four_digits": "0008",
                "card_issuer": "Chase",
                "card_network" :"visa"
            }
        }
    }
}

How did you test it?

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

@srujanchikke srujanchikke self-assigned this Aug 9, 2025
Copy link

semanticdiff-com bot commented Aug 9, 2025

@srujanchikke srujanchikke changed the base branch from main to redis_manipulation August 9, 2025 12:19
@srujanchikke srujanchikke changed the title fix(revenue recovery): Populate payment method data in record attempt flow for V2 fix(revenue_recovery): Populate payment method data in record attempt flow for V2 Aug 10, 2025
@srujanchikke srujanchikke marked this pull request as ready for review August 10, 2025 18:17
@srujanchikke srujanchikke requested review from a team as code owners August 10, 2025 18:17
@srujanchikke srujanchikke added C-bug Category: Bug api-v2 labels Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-v2 C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant