Skip to content

Conversation

@sahkal
Copy link
Contributor

@sahkal sahkal commented Mar 18, 2025

Type of Change

  • New feature

Description

Add visa click to pay support

Additional Changes

  • This PR modifies the API contract

Adds encypted_payload field to ctp_service_details and makes provider as a required type enum from optional string in service_details struct

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_visa

{
    "connector_type": "authentication_processor",
    "connector_name": "ctp_visa",
    "connector_account_details": {
        "auth_type": "NoKey"
    }
}
'

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_visa 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" : {
        "encypted_payload": "eyJraWQiOiJMS1hNMExOOFE2UjdMV1YxOVUwVzEzc01pYjRvNTlRRXBKelpMeVloaXZ5cmNMRWprIiwiYWxnIjoiUlMyNTYiLCJqdGkiOiJNV0V6WWpWalltRXROR0pqWlMwME56ZzFMV0ppWVdFdE56WTJZamxtWlRWa1pXRXciLCJpYXQiOjE3MzYxNDczMTF9.eyJzcmNpVHJhbnNhY3Rpb25JZCI6IjcxZjFhYjQ3LWUzZDMtYzVhNC1lOTAyLTE3OWMyYzc1ZTgwMiIsImFzc3VyYW5jZURhdGEiOnsidmVyaWZpY2F0aW9uRGF0YSI6W3sibWV0aG9kUmVzdWx0cyI6eyJ0cmFuc1N0YXR1cyI6IlkiLCJkc1RyYW5zSWQiOiI4ZGUxMzQyMy1kZTM1LTQ3ZDYtODZhZC1hZmI5OWViZTE5YmMiLCJhY3NUcmFuc0lkIjoiZGMyMGMx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SMrQFJz7ErQ7TVDEa8g3o9UfWvHy4L7Ips36taZR5XaMecaHS9dRH71lGI71Z2-m53AJ_Tcu8QXJaU5roFaKx130pM7NEjnG8wod1xjeL9STm96KfEyRf2Xk0a1SY4oVXIYol2WmTt9ZJhUbpmctZ5u-fxkpH1_-4Plx5g4tA5nZpL5VNFsyYAdUqb8XCAHGyO9buzYtLPI99too0BN_aLICfw8wJ0Jn_b0AMxk28SN9LZdS72aI7oWvVIU73cw",
        "provider": "visa"
    },
    "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
}

Reason for it being failed is ayden doesn't support click to pay in sandbox, but does support in production

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

@semanticdiff-com
Copy link

semanticdiff-com bot commented Mar 18, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs  100% smaller
  crates/common_enums/src/connector_enums.rs  66% smaller
  crates/openapi/src/openapi.rs  20% smaller
  crates/openapi/src/openapi_v2.rs  20% smaller
  crates/common_enums/src/enums.rs  12% smaller
  api-reference-v2/openapi_spec.json  12% smaller
  api-reference/openapi_spec.json  12% smaller
  crates/api_models/src/payments.rs  9% smaller
  crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs  9% smaller
  crates/router/src/core/unified_authentication_service.rs  6% smaller
  config/development.toml Unsupported file format
  config/docker_compose.toml Unsupported file format
  crates/connector_configs/src/connector.rs  0% smaller
  crates/connector_configs/toml/development.toml Unsupported file format
  crates/connector_configs/toml/production.toml Unsupported file format
  crates/connector_configs/toml/sandbox.toml Unsupported file format
  crates/hyperswitch_domain_models/src/configs.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs  0% smaller
  crates/router/src/core/admin.rs  0% smaller
  crates/router/src/core/payments.rs  0% smaller
  crates/router/src/core/unified_authentication_service/types.rs  0% smaller
  crates/router/src/core/unified_authentication_service/utils.rs Unsupported file format
  crates/router/src/types/api.rs  0% smaller
  crates/router/src/types/api/authentication.rs  0% smaller
  crates/router/src/types/transformers.rs  0% smaller
  loadtest/config/development.toml Unsupported file format
  scripts/add_connector.sh Unsupported file format

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Mar 18, 2025
@sahkal sahkal changed the title 8841 feature add visa click to pay support feat(core): Add visa click to pay support Mar 19, 2025
@sahkal sahkal self-assigned this Mar 19, 2025
@sahkal sahkal added the A-core Area: Core flows label Mar 19, 2025
@sahkal sahkal added this to the February 2025 Release milestone Mar 19, 2025
@sahkal sahkal added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Mar 19, 2025
@sahkal sahkal marked this pull request as ready for review March 19, 2025 17:49
@sahkal sahkal requested review from a team as code owners March 19, 2025 17:49
@sahkal sahkal requested a review from SanchithHegde March 26, 2025 15:09
SanchithHegde
SanchithHegde previously approved these changes Mar 26, 2025
@sahkal sahkal requested a review from SanchithHegde March 27, 2025 03:45
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu left a comment

Choose a reason for hiding this comment

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

Connector changes look good

SanchithHegde
SanchithHegde previously approved these changes Mar 27, 2025
@likhinbopanna likhinbopanna enabled auto-merge March 27, 2025 11:25
@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 27, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 28, 2025
Merged via the queue into main with commit 9e5e6be Mar 28, 2025
16 of 20 checks passed
@likhinbopanna likhinbopanna deleted the 8841-feature-add-visa-click-to-pay-support branch March 28, 2025 08:31
@hyperswitch-bot hyperswitch-bot bot removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core flows M-api-contract-changes Metadata: This PR involves API contract changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants