Skip to content
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

refactor(router): add revenue_recovery_metadata to payment intent in diesel and api model for v2 flow #7176

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

NISHANTH1221
Copy link

@NISHANTH1221 NISHANTH1221 commented Feb 3, 2025

Type of Change

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

Description

Adds the following fields to the api and diesel models Feature meta data

retry_count: Total number of billing connector + recovery retries for a payment intent.

payment_connector_transmission: It's supposed to tell if the payment_connector has been called or not.

billing_connector_id: To update the invoice at billing connector.

active_attempt_payment_connector_id : Process tracker needs payment merchant connector account id to schedule the retry attempt.

billing_connector_mit_token_details: MIT related information given by billing connector contains two fields.
1. customer_id : Customer Id of the customer in billing connector
2. payment_processor_token : The token used by the payment processor to retry the payment.

payment_method_type: This represents payment Method type like Card,Crypto,Mandate etc..

payment_method_subtype : This represents the subtype of the payment method like Credit, CryptoCurrency etc..

Note This PR closes #7177

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?

Create Intent Request

   curl --location 'http://localhost:8080/v2/payments/create-intent' \
--header 'api-key: dev_7iySXObGOGY3S9g2OgXlwnQIYJACCsn72FDRXcs6lNlSpheMRHD8bzg0WcUpb9KL' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_vxOhrwYLpaKZXp6llHo1' \
--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":{
        "revenue_recovery_metadata" : {
            "retry_count": 3,
            "payment_connector_transmission" : true,
            "billing_connector_id" : "test12345678",
            "active_attempt_payment_connector_id" : "test123456",
            "billing_connector_mit_token_details":{
                "payment_processor_token":"payment_12312466363",
                "connector_customer_id" : "customer_id123"
            },
            "payment_method_type" : "card",
            "payment_method_subtype": "credit"
        }
    }
}'

create-intent response

{
    "id": "12345_pay_0194cccc5bdd74f0bcd98e2fe0800208",
    "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": "12345_pay_0194cccc5bdd74f0bcd98e2fe0800208_secret_0194cccc5bf17ac3b8513527e11145c5",
    "profile_id": "pro_vxOhrwYLpaKZXp6llHo1",
    "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,
        "revenue_recovery_metadata": {
            "retry_count": 3,
            "payment_connector_transmission": true,
            "billing_connector_id": "test12345678",
            "active_attempt_payment_connector_id": "test123456",
            "billing_connector_mit_token_details": {
                "payment_processor_token": "payment_12312466363",
                "connector_customer_id": "customer_id123"
            },
            "payment_method_type": "card",
            "payment_method_subtype": "credit"
        }
    },
    "payment_link_enabled": "Skip",
    "payment_link_config": null,
    "request_incremental_authorization": "default",
    "expires_on": "2025-02-03T17:27:12.529Z",
    "frm_metadata": null,
    "request_external_three_ds_authentication": "Skip"
}

get intent response

{
    "id": "12345_pay_0194cccc5bdd74f0bcd98e2fe0800208",
    "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": "12345_pay_0194cccc5bdd74f0bcd98e2fe0800208_secret_0194cccc5bf17ac3b8513527e11145c5",
    "profile_id": "pro_vxOhrwYLpaKZXp6llHo1",
    "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,
        "revenue_recovery_metadata": {
            "retry_count": 3,
            "payment_connector_transmission": true,
            "billing_connector_id": "test12345678",
            "active_attempt_payment_connector_id": "test123456",
            "billing_connector_mit_token_details": {
                "payment_processor_token": "payment_12312466363",
                "connector_customer_id": "customer_id123"
            },
            "payment_method_type": "card",
            "payment_method_subtype": "credit"
        }
    },
    "payment_link_enabled": "Skip",
    "payment_link_config": null,
    "request_incremental_authorization": "default",
    "expires_on": "2025-02-03T17:27:12.529Z",
    "frm_metadata": null,
    "request_external_three_ds_authentication": "Skip"
}

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

@NISHANTH1221 NISHANTH1221 requested a review from a team as a code owner February 3, 2025 17:31
Copy link

semanticdiff-com bot commented Feb 3, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/openapi/src/openapi_v2.rs  8% smaller
  api-reference-v2/openapi_spec.json  0% smaller
  crates/api_models/src/payments.rs  0% smaller
  crates/diesel_models/src/types.rs  0% smaller
  crates/hyperswitch_domain_models/src/lib.rs  0% smaller

@NISHANTH1221 NISHANTH1221 self-assigned this Feb 4, 2025
@@ -6651,6 +6651,9 @@ pub struct FeatureMetadata {
pub search_tags: Option<Vec<HashedString<WithType>>>,
/// Recurring payment details required for apple pay Merchant Token
pub apple_pay_recurring_details: Option<ApplePayRecurringDetails>,
/// revenue recovery data for payment intent
#[cfg(feature = "v2")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move the feature flag on a struct level instead of it being on a field level

crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Show resolved Hide resolved
crates/diesel_models/src/types.rs Outdated Show resolved Hide resolved
crates/diesel_models/src/types.rs Outdated Show resolved Hide resolved
crates/diesel_models/src/types.rs Outdated Show resolved Hide resolved
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor(router): add revenue_recovery_metadata to payment intent in diesel and api model for v2 flow
4 participants