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): refactor ctp flow to fetch mca_id and get the connector creds instead of connector_name #6859

Conversation

sahkal
Copy link
Contributor

@sahkal sahkal commented Dec 17, 2024

Type of Change

  • Refactoring

Description

refactor ctp flow to fetch mca_id and get the connector creds instead of connector_name

How did you test it?

Add config to make the merchant eligible for authentication service

curl --location 'http://localhost:8080/configs/' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "key": "merchants_eligible_for_authentication_service",
    "value": "[\"sahkal\", \"cewqcewc\", \"dqwdwljildwduoqwhduwqcqwjd\"]"
}'

Create merchant connector account for Ctp_mastercard

curl --location 'http://localhost:8080/account/dqwdwljildwduoqwhduwqcqwjd/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '
{
    "connector_type": "authentication_processor",
    "connector_name": "ctp_mastercard",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key": "API-KEY"
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "business_country": "US",
    "business_label": "default",
     "metadata": {
    "dpa_id": "b6e06cc6-3018-4c4c-bbf5-9fb232615090",
    "dpa_name": "TestMerchant",
    "locale": "en_AU",
    "card_brands": ["mastercard", "visa"],
    "acquirer_bin": "545301",
    "acquirer_merchant_id": "SRC3DS",
    "merchant_category_code": "0001",
    "merchant_country_code": "US"
  }
}
'

Adyen

curl --location 'http://localhost:8080/account/dqwdwljildwduoqwhduwqcqwjd/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": "SignatureKey",
        "api_key": "API-KEY",
        "key1": "KEY-1",
        "api_secret": "API-SECRET"
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "city": "NY",
        "unit": "245",
        "live_endpoint_prefix": "vsfbjh"
    },
    "connector_webhook_details": {
        "merchant_secret": "MERCHANT SECRET"
    },
    "business_country": "US",
    "business_label": "default"
}
'

update business profile with ctp_mastercard mca_id

curl --location 'http://localhost:8080/account/dqwdwljildwduoqwhduwqcqwjd/business_profile/pro_KCTRv8sFQfC0r65CZxrn' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "is_click_to_pay_enabled": true,
    "authentication_product_ids": {"click_to_pay": "mca_XAXUpel8ABbpoGNF8lGz"}
}'

do payments create

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_fQsdc9JbERQ7CWvmguo84XDROuXOD1oK9sdfCJXOko3SossoI4zdxpJkOIPmojwn' \
--data '{
    "amount": 1130,
    "currency": "USD",
    "confirm": false,
    "return_url": "https://hyperswitch.io"
    }   
'

do payments confirm

curl --location 'http://localhost:8080/payments/pay_Ft9Ke5Lun924OCJa7yll/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_1f712ac5fd7f4d8c91da6a627862a4f0' \
--data '
{
    
      "payment_method": "card",
    "payment_method_type": "debit",
    "client_secret": "pay_Ft9Ke5Lun924OCJa7yll_secret_po1FVW5adQWFolWJUhMb",
    "ctp_service_details" : {
        "merchant_transaction_id": "0a4e0d3.34f4a04b.803eb38b0a56f082296538d4a70c064a6b320639",
        "correlation_id": "34f4a04b.bcd1ac39-e0f3-479e-b3ee-703ade0c66dc",
        "x_src_flow_id" : "34f4a04b.bcd1ac39-e0f3-479e-b3ee-703ade0c66dc.1727438793"
    },
    "browser_info": {
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "color_depth": 24,
        "java_enabled":true,
        "java_script_enabled": true,
        "language": "en-GB",
        "screen_height":  1440,
        "screen_width": 2560,
        "time_zone": -330,
        "user_agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36"
    }
}'

Expected Response

{
    "payment_id": "pay_Ft9Ke5Lun924OCJa7yll",
    "merchant_id": "dqwdwljildwduoqwhduwqcqwjd",
    "status": "failed",
    "amount": 1130,
    "net_amount": 1130,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "adyen",
    "client_secret": "pay_Ft9Ke5Lun924OCJa7yll_secret_po1FVW5adQWFolWJUhMb",
    "created": "2024-12-18T13:00:47.663Z",
    "currency": "USD",
    "customer_id": null,
    "customer": null,
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "card",
    "payment_method_data": null,
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "return_url": "https://hyperswitch.io/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": "2",
    "error_message": "Refused",
    "unified_code": "UE_9000",
    "unified_message": "Something went wrong",
    "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": true,
    "connector_transaction_id": "KN8X64SH6PRRVS65",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_KCTRv8sFQfC0r65CZxrn",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_L6N77PiH3BI2BTPwkZPL",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-12-18T13:15:47.663Z",
    "fingerprint": null,
    "browser_info": {
        "language": "en-GB",
        "time_zone": -330,
        "ip_address": "::1",
        "user_agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 2560,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 1440,
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-12-18T13:04:08.461Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

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

@sahkal sahkal added A-core Area: Core flows C-refactor Category: Refactor labels Dec 17, 2024
@sahkal sahkal added this to the December 2024 Release milestone Dec 17, 2024
@sahkal sahkal self-assigned this Dec 17, 2024
@sahkal sahkal marked this pull request as ready for review December 17, 2024 10:55
@sahkal sahkal requested review from a team as code owners December 17, 2024 10:55
…2-refactor-refactor-ctp-flow-to-fetch-mca_id-and-get-the-connector-creds-instead-of-connector_name
@sahkal sahkal requested a review from SanchithHegde December 18, 2024 12:56
@sahkal sahkal requested a review from a team as a code owner December 18, 2024 13:12
@sahkal sahkal added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Dec 20, 2024
@sahkal sahkal requested review from jarnura and removed request for a team and deepanshu-iiitu December 20, 2024 07:45
crates/api_models/src/admin.rs Outdated Show resolved Hide resolved
crates/common_types/src/payments.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/admin.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments.rs Outdated Show resolved Hide resolved
@sahkal sahkal requested a review from jarnura December 20, 2024 10:26
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jan 6, 2025
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Jan 15, 2025
crates/api_models/src/admin.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments/helpers.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments.rs Outdated Show resolved Hide resolved
crates/router/src/core/payments/helpers.rs Outdated Show resolved Hide resolved
@sahkal sahkal requested a review from SanchithHegde January 15, 2025 11:53
@likhinbopanna likhinbopanna added this pull request to the merge queue Jan 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 16, 2025
…_id-and-get-the-connector-creds-instead-of-connector_name
@SanchithHegde SanchithHegde merged commit e9fcfc4 into main Jan 20, 2025
17 of 20 checks passed
@SanchithHegde SanchithHegde deleted the 7862-refactor-refactor-ctp-flow-to-fetch-mca_id-and-get-the-connector-creds-instead-of-connector_name branch January 20, 2025 12:02
sai-harsha-vardhan added a commit that referenced this pull request Jan 20, 2025
…ctor creds instead of connector_name (#6859)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Sai Harsha Vardhan <56996463+sai-harsha-vardhan@users.noreply.github.com>
pixincreate added a commit that referenced this pull request Jan 20, 2025
…urce-inconsistency

* 'main' of github.com:juspay/hyperswitch:
  refactor(payment-link): use shouldRemoveBeforeUnloadEvents flag for handling removal of beforeunload events through SDK (#7072)
  refactor(router): refactor ctp flow to fetch mca_id and get the connector creds instead of connector_name (#6859)
sahkal added a commit that referenced this pull request Jan 22, 2025
…ctor creds instead of connector_name (#6859)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Sai Harsha Vardhan <56996463+sai-harsha-vardhan@users.noreply.github.com>
pixincreate added a commit that referenced this pull request Jan 24, 2025
…d-memory-cache

* 'main' of github.com:juspay/hyperswitch: (38 commits)
  fix(cypress): uncaught exceptions thrown by `hyperswitch.io` (#7092)
  ci(workflows): Add code coverage reporting for v2 (#6884)
  chore(version): 2025.01.23.0
  refactor: [CYBERSOURCE, BANKOFAMERICA, WELLSFARGO] Move code to crate hyperswitch_connectors (#6908)
  Documentation edits made through Mintlify web editor
  chore: enable 128-column-tables feature for diesel crate (#6857)
  feat(connector): [ADYEN ] Consume transaction id for PaymentsPreProcessing error (#7061)
  chore(version): 2025.01.22.0
  feat(routing): Integrate global success rates (#6950)
  feat(email): Add mailhog by default in docker-compose for local smtp server (#6869)
  refactor: check allowed payment method types in enabled options (#7019)
  feat(router): add payment method-specific features to connector feature list (#6963)
  Refactor: Customer email and browser Information (#7034)
  feat(connectors): fiuu,novalnet,worldpay - extend NTI flows (#6946)
  fix(cypress): address cybersource redirection inconsistency (#7057)
  chore(version): 2025.01.21.0
  refactor(payment-link): use shouldRemoveBeforeUnloadEvents flag for handling removal of beforeunload events through SDK (#7072)
  refactor(router): refactor ctp flow to fetch mca_id and get the connector creds instead of connector_name (#6859)
  chore(version): 2025.01.20.0
  fix(relay): populate connector metadata in the refunds flow (#7045)
  ...
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-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants