hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

refactor(request_body): Added FRM data in payment request

Open swetasharma03 opened this issue 9 months ago • 1 comments

Type of Change

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

Description

Added FRM data in payment request for connector Adyen

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?

Screenshot 2025-03-26 at 6 00 22 PM
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_1tUvTWvHj4yX8wc3kkROOR01P8ikqRzDkcj3ZUdcpLmTjhkuW6f7LPj1s7RhO3Nc' \
--data-raw '{
    "amount": 100,
    "currency": "USD",
    "confirm": true,
    "payment_link": false,
    "capture_on": "2029-09-10T10:11:12Z",
    "amount_to_capture": 100,
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "payment_method_data": {
        "card": {
            "card_number": "4917610000000000",
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_cvc": "737",
            "card_network": "Visa"
        },
        "billing": {
            "address": {
                "line1": "1467",
                "line2": "CA",
                "city": "San Fransico",
                "state": "California",
                "zip": "94122",
                "country": "US",
                "first_name": "Sweta",
                "last_name": "Sharma"
            },
            "email": "[email protected]",
            "phone": {
                "number": "9999999999",
                "country_code": "+91"
            }
        }
    },
    "email": "[email protected]",
    "payment_method": "card",
    "payment_method_type": "credit",
    "browser_info": {
        "color_depth": 24,
        "java_enabled": true,
        "java_script_enabled": true,
        "language": "en-GB",
        "screen_height": 720,
        "screen_width": 1280,
        "time_zone": -330,
        "ip_address": "208.127.127.193",
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"
    },
    "metadata": {
        "device_fingerprint": "abc123devicefingerprint2",
        "riskdata.basket.item1.itemID": "1234567890",
        "riskdata.basket.item1.productTitle": "Wireless Bluetooth Headphones",
        "riskdata.basket.item1.amountPerItem": "79.99",
        "riskdata.basket.item1.currency": "USD",
        "riskdata.basket.item1.upc": "012345678901",
        "riskdata.basket.item1.brand": "BrandX",
        "riskdata.basket.item1.manufacturer": "BrandX Manufacturing Inc.",
        "riskdata.basket.item1.category": "Electronics",
        "riskdata.basket.item1.quantity": "1",
        "riskdata.basket.item1.color": "Black",
        "riskdata.basket.item1.size": "One Size",
        "riskdata.deviceCountry": "US",
        "riskdata.houseNumberorName": "1234",
        "riskdata.accountCreationDate": "2015-08-01",
        "riskdata.affiliateChannel": "Online Store",
        "riskdata.avgOrderValue": "120.50",
        "riskdata.deliveryMethod": "Standard Shipping",
        "riskdata.emailName": "swetasharma",
        "riskdata.emailDomain": "example.com",
        "riskdata.lastOrderDate": "2024-12-25",
        "riskdata.merchantReference": "ORD12345XYZ",
        "riskdata.paymentMethod": "Visa",
        "riskdata.promotionName": "Holiday Sale",
        "riskdata.secondaryPhoneNumber": "9876543210",
        "riskdata.timefromLogintoOrder": "15 minutes",
        "riskdata.totalSessionTime": "45 minutes",
        "riskdata.totalAuthorizedAmountInLast30Days": "500.00",
        "riskdata.totalOrderQuantity": "10",
        "riskdata.totalLifetimeValue": "1500.00",
        "riskdata.visitsMonth": "8",
        "riskdata.visitsWeek": "3",
        "riskdata.visitsYear": "30",
        "riskdata.shipToName": "Sweta Sharma",
        "riskdata.first8charactersofAddressLine1Zip": "94122",
        "riskdata.affiliateOrder": false
    },
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "CA",
            "zip": "94122",
            "state": "California",
            "first_name": "Sweta",
            "last_name": "Sharma"
        },
        "phone": {
            "number": "9999999999",
            "country_code": "+91"
        },
        "email": "[email protected]"
    }
}'

Response

{
    "payment_id": "pay_4RPSha2liSpcRUJNA6cj",
    "merchant_id": "merchant_1742923962",
    "status": "requires_customer_action",
    "amount": 100,
    "net_amount": 100,
    "shipping_cost": null,
    "amount_capturable": 100,
    "amount_received": null,
    "connector": "adyen",
    "client_secret": "pay_4RPSha2liSpcRUJNA6cj_secret_oaNtTvAFxiHxCk0GxifB",
    "created": "2025-03-26T06:24:55.256Z",
    "currency": "USD",
    "customer_id": null,
    "customer": {
        "id": null,
        "name": "John Doe",
        "email": "[email protected]",
        "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": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0000",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "491761",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "Sweta Sharma",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "CA",
                "line3": null,
                "zip": "94122",
                "state": "California",
                "first_name": "Sweta",
                "last_name": "Sharma"
            },
            "phone": {
                "number": "9999999999",
                "country_code": "+91"
            },
            "email": "[email protected]"
        }
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "CA",
            "line3": null,
            "zip": "94122",
            "state": "California",
            "first_name": "Sweta",
            "last_name": "Sharma"
        },
        "phone": {
            "number": "9999999999",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "billing": null,
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_4RPSha2liSpcRUJNA6cj/merchant_1742923962/pay_4RPSha2liSpcRUJNA6cj_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "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": "G8Z7RX4G8BCDCQV5",
    "frm_message": null,
    "metadata": {
         "device_fingerprint": "abc123devicefingerprint2",
        "riskdata.basket.item1.itemID": "1234567890",
        "riskdata.basket.item1.productTitle": "Wireless Bluetooth Headphones",
        "riskdata.basket.item1.amountPerItem": "79.99",
        "riskdata.basket.item1.currency": "USD",
        "riskdata.basket.item1.upc": "012345678901",
        "riskdata.basket.item1.brand": "BrandX",
        "riskdata.basket.item1.manufacturer": "BrandX Manufacturing Inc.",
        "riskdata.basket.item1.category": "Electronics",
        "riskdata.basket.item1.quantity": "1",
        "riskdata.basket.item1.color": "Black",
        "riskdata.basket.item1.size": "One Size",
        "riskdata.deviceCountry": "US",
        "riskdata.houseNumberorName": "1234",
        "riskdata.accountCreationDate": "2015-08-01",
        "riskdata.affiliateChannel": "Online Store",
        "riskdata.avgOrderValue": "120.50",
        "riskdata.deliveryMethod": "Standard Shipping",
        "riskdata.emailName": "swetasharma",
        "riskdata.emailDomain": "example.com",
        "riskdata.lastOrderDate": "2024-12-25",
        "riskdata.merchantReference": "ORD12345XYZ",
        "riskdata.paymentMethod": "Visa",
        "riskdata.promotionName": "Holiday Sale",
        "riskdata.secondaryPhoneNumber": "9876543210",
        "riskdata.timefromLogintoOrder": "15 minutes",
        "riskdata.totalSessionTime": "45 minutes",
        "riskdata.totalAuthorizedAmountInLast30Days": "500.00",
        "riskdata.totalOrderQuantity": "10",
        "riskdata.totalLifetimeValue": "1500.00",
        "riskdata.visitsMonth": "8",
        "riskdata.visitsWeek": "3",
        "riskdata.visitsYear": "30",
        "riskdata.shipToName": "Sweta Sharma",
        "riskdata.first8charactersofAddressLine1Zip": "94122",
        "riskdata.affiliateOrder": false
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "G8Z7RX4G8BCDCQV5",
    "payment_link": null,
    "profile_id": "pro_9AiAESD5MrUBnko9THxG",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_vtrNcsyy5demMast3m1e",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-03-26T06:39:55.256Z",
    "fingerprint": null,
    "browser_info": {
        "language": "en-GB",
        "time_zone": -330,
        "ip_address": "208.127.127.193",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1280,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 720,
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-03-26T06:24:57.280Z",
    "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",
    "issuer_error_code": null,
    "issuer_error_message": null
}

Checklist

  • [x] I formatted the code cargo +nightly fmt --all
  • [x] I addressed lints thrown by cargo clippy
  • [x] I reviewed the submitted code
  • [ ] I added unit tests for my changes where possible

swetasharma03 avatar Mar 25 '25 07:03 swetasharma03

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs  2% smaller

semanticdiff-com[bot] avatar Mar 25 '25 07:03 semanticdiff-com[bot]