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(core): remove merchant return url from router_data #6895

Merged
merged 6 commits into from
Dec 24, 2024

Conversation

swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented Dec 19, 2024

Type of Change

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

Description

  • remove merchant return url from router_data
  • We are not using merchant return url at the connectors, we should always send our return url to the connectors

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?

  1. Create Merchant Account
  2. Create API KEY
  3. Create Adyen Connector
curl --location 'http://localhost:8080/account/merchant_1734600412/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "adyen",
    "connector_account_details": {
        "auth_type": "BodyKey",
        "api_key": "_____",
        "key1": "JuspayDEECOM",
        "api_secret": "_____"
    },
    "test_mode": false,
    "disabled": false,
    "business_country": "US",
    "business_label": "default",
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "AmericanExpress",
                        "Discover",
                        "Interac",
                        "JCB",
                        "Mastercard",
                        "Visa",
                        "DinersClub",
                        "UnionPay",
                        "RuPay"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "AmericanExpress",
                        "Discover",
                        "Interac",
                        "JCB",
                        "Mastercard",
                        "Visa",
                        "DinersClub",
                        "UnionPay",
                        "RuPay"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_debit",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "bacs",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }    
    ],
    "metadata": {
        "endpoint_prefix" : ""
    },
    "connector_webhook_details": {
        "merchant_secret": "BE8E89E2CC5A5EB3886777B5BB7874A183E13D03D398691FD4951C228CD642A3"
    }
}'
  1. Create a card 3ds payment (do not pass return_url in request)
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ____' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "payment_method": "card",
    "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
            "card_number": "371449635398431",
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "card_cvc": "7373"
        }
    },
    "routing": {
        "type": "single",
        "data": "adyen"
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "browser_info": {
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 30,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "127.0.0.1" 
    },
    "profile_id": "pro_hxKnAPSvuLjWAWSRJM0Z"
}'

Resposne

{
    "payment_id": "pay_475MU5SwDmns4g1sKQPA",
    "merchant_id": "merchant_1734600412",
    "status": "requires_customer_action",
    "amount": 6540,
    "net_amount": 6540,
    "shipping_cost": null,
    "amount_capturable": 6540,
    "amount_received": null,
    "connector": "adyen",
    "client_secret": "pay_475MU5SwDmns4g1sKQPA_secret_zR6U5K20HAuquEy8LQjH",
    "created": "2024-12-19T09:30:18.304Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "8431",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "371449",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": null,
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_475MU5SwDmns4g1sKQPA/merchant_1734600412/pay_475MU5SwDmns4g1sKQPA_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "StripeCustomer",
        "created_at": 1734600618,
        "expires": 1734604218,
        "secret": "epk_b77f25570c644f6da13059eb3e435742"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "PDWZFPKPZXTQ7RT5",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "PDWZFPKPZXTQ7RT5",
    "payment_link": null,
    "profile_id": "pro_hxKnAPSvuLjWAWSRJM0Z",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_R1OpUF3Rw5wg2p0mT00r",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-12-19T09:45:18.304Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 30,
        "ip_address": "127.0.0.1",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-12-19T09:30:18.782Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Complete authentication using redirection_url.
5. Do psync

curl --location 'http://localhost:8080/payments/pay_475MU5SwDmns4g1sKQPA' \
--header 'Accept: application/json' \
--header 'api-key: _'

Response

{
    "payment_id": "pay_475MU5SwDmns4g1sKQPA",
    "merchant_id": "merchant_1734600412",
    "status": "succeeded",
    "amount": 6540,
    "net_amount": 6540,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6540,
    "connector": "adyen",
    "client_secret": "pay_475MU5SwDmns4g1sKQPA_secret_zR6U5K20HAuquEy8LQjH",
    "created": "2024-12-19T09:30:18.304Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "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": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "8431",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "371449",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": null,
    "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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "PDWZFPKPZXTQ7RT5",
    "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_475MU5SwDmns4g1sKQPA_1",
    "payment_link": null,
    "profile_id": "pro_hxKnAPSvuLjWAWSRJM0Z",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_R1OpUF3Rw5wg2p0mT00r",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-12-19T09:45:18.304Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 30,
        "ip_address": "127.0.0.1",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-12-19T09:30:32.072Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Note: We have to check if 3ds flow is getting redirected properly, it means in case of 3ds after authentication, it should get redirected to url which we provide in confirm.

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

@swangi-kumari swangi-kumari added A-core Area: Core flows C-refactor Category: Refactor labels Dec 19, 2024
@swangi-kumari swangi-kumari self-assigned this Dec 19, 2024
@swangi-kumari swangi-kumari requested review from a team as code owners December 19, 2024 10:20
Copy link

semanticdiff-com bot commented Dec 19, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/connector/iatapay/transformers.rs  93% smaller
  crates/hyperswitch_connectors/src/connectors/boku/transformers.rs  75% smaller
  crates/router/src/connector/opennode/transformers.rs  32% smaller
  crates/router/src/connector/stripe/transformers.rs  31% smaller
  crates/diesel_models/src/payment_intent.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/bitpay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/coinbase/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/zen/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/utils.rs  0% smaller
  crates/hyperswitch_domain_models/src/payments/payment_intent.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_data.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_data_v2/flow_common_types.rs  0% smaller
  crates/router/src/connector/adyen/transformers.rs  0% smaller
  crates/router/src/connector/klarna/transformers.rs  0% smaller
  crates/router/src/connector/nuvei/transformers.rs  0% smaller
  crates/router/src/connector/payme/transformers.rs  0% smaller
  crates/router/src/connector/paypal/transformers.rs  0% smaller
  crates/router/src/connector/trustpay/transformers.rs  0% smaller
  crates/router/src/connector/utils.rs  0% smaller
  crates/router/src/core/authentication/transformers.rs  0% smaller
  crates/router/src/core/fraud_check/flows/checkout_flow.rs  0% smaller
  crates/router/src/core/fraud_check/flows/fulfillment_flow.rs  0% smaller
  crates/router/src/core/fraud_check/flows/record_return.rs  0% smaller
  crates/router/src/core/fraud_check/flows/sale_flow.rs  0% smaller
  crates/router/src/core/fraud_check/flows/transaction_flow.rs  0% smaller
  crates/router/src/core/mandate/utils.rs  0% smaller
  crates/router/src/core/payments/helpers.rs  0% smaller
  crates/router/src/core/payments/operations/payment_response.rs  0% smaller
  crates/router/src/core/payments/transformers.rs  0% smaller
  crates/router/src/core/relay/utils.rs  0% smaller
  crates/router/src/core/unified_authentication_service/utils.rs Unsupported file format
  crates/router/src/core/utils.rs  0% smaller
  crates/router/src/core/webhooks/utils.rs  0% smaller
  crates/router/src/services/conversion_impls.rs  0% smaller
  crates/router/src/types.rs  0% smaller
  crates/router/src/types/api/verify_connector.rs  0% smaller
  crates/router/tests/connectors/aci.rs  0% smaller
  crates/router/tests/connectors/cashtocode.rs  0% smaller
  crates/router/tests/connectors/cryptopay.rs  0% smaller
  crates/router/tests/connectors/iatapay.rs  0% smaller
  crates/router/tests/connectors/opennode.rs  0% smaller
  crates/router/tests/connectors/payme.rs  0% smaller
  crates/router/tests/connectors/square.rs  0% smaller
  crates/router/tests/connectors/stax.rs  0% smaller
  crates/router/tests/connectors/utils.rs  0% smaller

@@ -1902,7 +1902,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
status: api_models::enums::IntentStatus::foreign_from(
payment_data.payment_attempt.status,
),
return_url: router_data.return_url.clone(),
return_url: None,
Copy link
Member

Choose a reason for hiding this comment

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

once verify that we are updating the return_url if it is sent in the confirm request. You can remove this field as well if it is not being used in other places

Copy link
Contributor Author

@swangi-kumari swangi-kumari Dec 23, 2024

Choose a reason for hiding this comment

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

yes we are updating the return_url if it is sent in confirm request.

Narayanbhat166
Narayanbhat166 previously approved these changes Dec 20, 2024
Narayanbhat166
Narayanbhat166 previously approved these changes Dec 20, 2024
SanchithHegde
SanchithHegde previously approved these changes Dec 20, 2024
apoorvdixit88
apoorvdixit88 previously approved these changes Dec 20, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Dec 24, 2024
Merged via the queue into main with commit c5717a8 Dec 24, 2024
25 of 27 checks passed
@Gnanasundari24 Gnanasundari24 deleted the remove-merchant-url branch December 24, 2024 11:53
pixincreate added a commit to Ankesh2004/hyperswitch that referenced this pull request Dec 26, 2024
…r-verifyurl-in-redirection-handler

* 'main' of github.com:juspay/hyperswitch: (444 commits)
  ci: add tests that make use of locker (juspay#6735)
  chore(version): 2024.12.26.1
  fix(router): populate `profile_id` in for the HeaderAuth of v1 (juspay#6936)
  docs(openapi): update /relay request example (juspay#6942)
  chore(version): 2024.12.26.0
  fix(payments_list): handle same payment/attempt ids for different merchants (juspay#6917)
  refactor(core): remove merchant return url from `router_data` (juspay#6895)
  feat(router): add endpoint for listing connector features  (juspay#6612)
  fix(wasm): remove chasenet from jpmorgan wasm as ChaseNet doesn’t exist in PMT (juspay#6927)
  fix(cors): expose all headers set by application in `access-control-expose-headers` header value (juspay#6877)
  chore(version): 2024.12.24.0
  feat(cypress): valdiate `error_code` and `error_message` and make it visible in `reports` (juspay#6913)
  fix(wasm): remove extra space from wasm for payment_method_type of JPMorgan (juspay#6923)
  fix(wasm): fix feature dependencies in `connector_configs` crate for WASM builds  (juspay#6832)
  feat(router): add /retrieve api for relay (juspay#6918)
  feat(core): implemented platform merchant account (juspay#6882)
  feat(payments_v2): add payment method list endpoint (juspay#6805)
  fix(connector): [Cybersource] fix the required fields for wallet mandate payments (juspay#6911)
  chore(version): 2024.12.23.0
  feat(connector): [JPMORGAN] add Payment flows for cards (juspay#6668)
  ...
pixincreate added a commit to Ankesh2004/hyperswitch that referenced this pull request Dec 26, 2024
…r-verifyurl-in-redirection-handler

* 'main' of github.com:juspay/hyperswitch: (444 commits)
  ci: add tests that make use of locker (juspay#6735)
  chore(version): 2024.12.26.1
  fix(router): populate `profile_id` in for the HeaderAuth of v1 (juspay#6936)
  docs(openapi): update /relay request example (juspay#6942)
  chore(version): 2024.12.26.0
  fix(payments_list): handle same payment/attempt ids for different merchants (juspay#6917)
  refactor(core): remove merchant return url from `router_data` (juspay#6895)
  feat(router): add endpoint for listing connector features  (juspay#6612)
  fix(wasm): remove chasenet from jpmorgan wasm as ChaseNet doesn’t exist in PMT (juspay#6927)
  fix(cors): expose all headers set by application in `access-control-expose-headers` header value (juspay#6877)
  chore(version): 2024.12.24.0
  feat(cypress): valdiate `error_code` and `error_message` and make it visible in `reports` (juspay#6913)
  fix(wasm): remove extra space from wasm for payment_method_type of JPMorgan (juspay#6923)
  fix(wasm): fix feature dependencies in `connector_configs` crate for WASM builds  (juspay#6832)
  feat(router): add /retrieve api for relay (juspay#6918)
  feat(core): implemented platform merchant account (juspay#6882)
  feat(payments_v2): add payment method list endpoint (juspay#6805)
  fix(connector): [Cybersource] fix the required fields for wallet mandate payments (juspay#6911)
  chore(version): 2024.12.23.0
  feat(connector): [JPMORGAN] add Payment flows for cards (juspay#6668)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows api-v2 C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants