Skip to content

fix(router): skip external three_ds flow for recurring payments#5730

Merged
Gnanasundari24 merged 2 commits intomainfrom
fix-netcetera-recurring-issue
Aug 28, 2024
Merged

fix(router): skip external three_ds flow for recurring payments#5730
Gnanasundari24 merged 2 commits intomainfrom
fix-netcetera-recurring-issue

Conversation

@sai-harsha-vardhan
Copy link
Contributor

@sai-harsha-vardhan sai-harsha-vardhan commented Aug 28, 2024

Type of Change

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

Description

bug - when request_external_three_ds_authentication is sent as true in payments request of recurring payments, it's trying to attempt 3ds flow which is not expected.

This PR adds the check to skip external three_ds flow for recurring payments

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?

Tested Manually
Recurring payment by sending request_external_three_ds_authentication as true shouldn't trigger 3ds and get succeeded
CURL

curl --location '{{BASE_URL}}/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: {{API_KEY}}' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "request_external_three_ds_authentication": true,
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "stripecustomer1",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
    "off_session": true,
    "recurring_details": {
        "type": "payment_method_id",
        "data": "pm_FlLpGGF93oVD4WUX6tAV"
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IE",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IE",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

Response

{
    "payment_id": "pay_MYwAc1NBPeaBHvgakmzW",
    "merchant_id": "merchant_1724782675",
    "status": "succeeded",
    "amount": 6540,
    "net_amount": 6540,
    "amount_capturable": 0,
    "amount_received": 6540,
    "connector": "cybersource",
    "client_secret": "pay_MYwAc1NBPeaBHvgakmzW_secret_wYpJydgvmbyiQaDjsofF",
    "created": "2024-08-28T07:25:40.303Z",
    "currency": "USD",
    "customer_id": "stripecustomer1",
    "customer": {
        "id": "stripecustomer1",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": null,
            "payment_checks": {
                "avs_response": {
                    "code": "Y",
                    "codeRaw": "Y"
                },
                "card_verification": null
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "IE",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "IE",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "stripecustomer1",
        "created_at": 1724829940,
        "expires": 1724833540,
        "secret": "epk_fb4bd40b725740f59b357a57c2f21920"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7248299409806056403955",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_MYwAc1NBPeaBHvgakmzW_1",
    "payment_link": null,
    "profile_id": "pro_zGfYrQKyOZRjxswLnB0y",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_Qdp5YlekaMnvGA8j90mu",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-08-28T07:40:40.303Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_FlLpGGF93oVD4WUX6tAV",
    "payment_method_status": "active",
    "updated": "2024-08-28T07:25:41.684Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null
}

image

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

@sai-harsha-vardhan sai-harsha-vardhan added A-core Area: Core flows C-bug Category: Bug labels Aug 28, 2024
@sai-harsha-vardhan sai-harsha-vardhan self-assigned this Aug 28, 2024
@sai-harsha-vardhan sai-harsha-vardhan requested review from a team as code owners August 28, 2024 07:43
@semanticdiff-com
Copy link

semanticdiff-com bot commented Aug 28, 2024

Review changes with SemanticDiff.

Analyzed 5 of 6 files.

Overall, the semantic diff is 32% smaller than the GitHub diff.

Filename Status
crates/router/src/core/payments.rs Unsupported file format
✔️ crates/router/src/core/payments/helpers.rs 57.14% smaller
✔️ crates/router/src/core/payments/operations.rs Analyzed
✔️ crates/router/src/core/payments/operations/payment_confirm.rs Analyzed
✔️ crates/router/src/core/payments/operations/payment_create.rs Analyzed
✔️ crates/api_models/src/payments.rs Analyzed

}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Eq, PartialEq)]
Copy link
Member

Choose a reason for hiding this comment

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

We can derive Copy on this as well.

&mut payment_data,
eligible_connectors,
mandate_type,
mandate_type.clone(),
Copy link
Member

Choose a reason for hiding this comment

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

And then we can remove the clone here.

hrithikesh026
hrithikesh026 previously approved these changes Aug 28, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Aug 28, 2024
Merged via the queue into main with commit 64836ba Aug 28, 2024
@Gnanasundari24 Gnanasundari24 deleted the fix-netcetera-recurring-issue branch August 28, 2024 10:10
pixincreate added a commit that referenced this pull request Aug 28, 2024
* 'main' of github.com:juspay/hyperswitch:
  feat(connector): [FISERVEMEA] Integrate cards (#5672)
  ci(cypress): Add routing testcases (#5571)
  fix(router): skip external three_ds flow for recurring payments (#5730)
  refactor(customer_v2): fixed customer_v2 create panic issue (#5699)
  feat(user_roles): support switch for new hierarchy (#5692)
  refactor(router): add domain type for merchant_connector_account id (#5685)
  refactor(cypress_tests): handle api keys check in api key list call (#5719)
  feat(connector): [NEXIXPAY] Add template code (#5684)
  refactor(connector): [itau] refactor error reason and code mapping for itau (#5718)
  fix(core): fix merchant connector account create for v2  (#5716)
  chore(version): 2024.08.28.0
  fix(routing): fix routing routes to deserialise correctly (#5724)
  feat(euclid): add a new variant in payment type i.e ppt_mandate (#5681)
  feat(core): Add mTLS certificates for each request (#5636)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core flows C-bug Category: Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants