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

feat(core): add support to external 3ds authentication for co-badged cards #7274

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

Conversation

sai-harsha-vardhan
Copy link
Contributor

@sai-harsha-vardhan sai-harsha-vardhan commented Feb 15, 2025

Type of Change

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

Description

  1. send the entire card_data in pre-authentication request data to connector flows, this would allow connector flows to use card_number, card_network to send it forward
  2. forward scheme_id to netcetera during pre-auth call for co-badged cards

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

  1. Use co-badged card (4010061700000021) for performing external three ds payment, In confirm call (pre-authenticate) request to netcetera schemeId should be sent
    CURL
curl --location '{{BASE_URL}}/payments/{{PAYMENT_ID}}/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: {{API_KEY}}' \
--header 'Accept-Language: da, en-GB;q=0.8, en;q=0.7' \
--data '{
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "4010061700000021",
            "card_exp_month": "01",
            "card_exp_year": "2099",
            "card_holder_name": "John Smith",
            "card_cvc": "100",
            "card_network": "Visa"
        },
        "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "CA",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        },
         "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    }
    },
    "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": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "125.0.0.1"
    }
}'

Response

{
    "payment_id": "pay_EDvFhaCDpRw4V5A3Y1Ef",
    "merchant_id": "merchant_1740147344",
    "status": "requires_customer_action",
    "amount": 1040,
    "net_amount": 1140,
    "shipping_cost": 100,
    "amount_capturable": 1140,
    "amount_received": null,
    "connector": "cybersource",
    "client_secret": "pay_EDvFhaCDpRw4V5A3Y1Ef_secret_pA9o2rFGSRQyu46xKYnM",
    "created": "2025-02-24T15:48:16.921Z",
    "currency": "USD",
    "customer_id": "test-sai1",
    "customer": {
        "id": "test-sai1",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0021",
            "card_type": null,
            "card_network": "Visa",
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "401006",
            "card_extended_bin": null,
            "card_exp_month": "01",
            "card_exp_year": "2099",
            "card_holder_name": "John Smith",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "CA",
                "first_name": "John",
                "last_name": "Doe"
            },
            "phone": {
                "number": "8056594427",
                "country_code": "+91"
            },
            "email": null
        }
    },
    "payment_token": "token_XFxK1XgDGkZSoXcLYwzS",
    "shipping": null,
    "billing": null,
    "order_details": [
        {
            "brand": null,
            "amount": 0,
            "category": null,
            "quantity": 1,
            "tax_rate": null,
            "product_id": null,
            "product_name": "Apple iphone 15",
            "product_type": null,
            "sub_category": null,
            "product_img_link": null,
            "product_tax_code": null,
            "total_tax_amount": null,
            "requires_shipping": null
        }
    ],
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "three_ds_invoke",
        "three_ds_data": {
            "three_ds_authentication_url": "http://localhost:8080/payments/pay_EDvFhaCDpRw4V5A3Y1Ef/3ds/authentication",
            "three_ds_authorize_url": "http://localhost:8080/payments/pay_EDvFhaCDpRw4V5A3Y1Ef/merchant_1740147344/authorize/cybersource",
            "three_ds_method_details": {
                "three_ds_method_key": "threeDSMethodData",
                "three_ds_method_data_submission": true,
                "three_ds_method_data": "eyJ0aHJlZURTTWV0aG9kTm90aWZpY2F0aW9uVVJMIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS8zZHMtbWV0aG9kLW5vdGlmaWNhdGlvbi11cmwiLCJ0aHJlZURTU2VydmVyVHJhbnNJRCI6ImRkM2RlMGEwLTRjMWUtNDU4ZS05OTJhLTAxNTA4YjBhYTRhNSJ9",
                "three_ds_method_url": "https://ndm-prev.3dss-non-prod.cloud.netcetera.com/acs/3ds-method"
            },
            "poll_config": {
                "poll_id": "external_authentication_pay_EDvFhaCDpRw4V5A3Y1Ef",
                "delay_in_secs": 2,
                "frequency": 5
            },
            "message_version": "2.3.1",
            "directory_server_id": "A000000003"
        }
    },
    "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": null,
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {},
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": {
            "order_category": "pay"
        }
    },
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_ztzdQ3yBJoa9tDcHWTlu",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_9WSwa3qBFtWAw2UshuwN",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": {
        "authentication_flow": null,
        "electronic_commerce_indicator": null,
        "status": "pending",
        "ds_transaction_id": "dd3de0a0-4c1e-458e-992a-01508b0aa4a5",
        "version": "2.3.1",
        "error_code": null,
        "error_message": null
    },
    "external_3ds_authentication_attempted": true,
    "expires_on": "2025-02-24T16:03:16.921Z",
    "fingerprint": null,
    "browser_info": {
        "os_type": null,
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "125.0.0.1",
        "os_version": null,
        "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,
        "device_model": null,
        "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,
        "accept_language": "da, en-GB;q=0.8, en;q=0.7",
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-02-24T15:48:26.223Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": "manual"
}

image

  1. Use non co-badged card (5306889942833340) for external 3ds payment
    CURL
curl --location 'localhost:8080/payments/pay_i0EzkndDMybdDVnWQSa7/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_efmJopOc2l8zVCdDRY3WF9DX1nFttmHghsVa9mNqHIjXynsWmmDTTv9eSYbuOGHt' \
--header 'Accept-Language: da, en-GB;q=0.8, en;q=0.7' \
--data '{
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "5306889942833340",
            "card_exp_month": "01",
            "card_exp_year": "2099",
            "card_holder_name": "John Smith",
            "card_cvc": "100",
            "card_network": "Visa"
        },
        "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "CA",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        },
         "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    }
    },
    "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": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "125.0.0.1"
    },
    "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "125.0.0.1",
                "user_agent": "amet irure esse"
            }
        }
}'

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-connector-integration Area: Connector integration A-core Area: Core flows C-feature Category: Feature request or enhancement labels Feb 15, 2025
@sai-harsha-vardhan sai-harsha-vardhan self-assigned this Feb 15, 2025
@sai-harsha-vardhan sai-harsha-vardhan requested review from a team as code owners February 15, 2025 13:06
Copy link
Contributor

@ShankarSinghC ShankarSinghC left a comment

Choose a reason for hiding this comment

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

Nit: Can you also mention in the PR description why we are passing the entire card data instead of just the card number?

@likhinbopanna likhinbopanna added this pull request to the merge queue Feb 25, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration A-core Area: Core flows C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants