hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

feat(api): add browser information in payments response

Open Narayanbhat166 opened this issue 1 year ago • 0 comments

Type of Change

  • [x] New feature

Description

This Pr will add browser_information in the PaymentsResponse. This also removes the request that was used in generating the response

Additional Changes

  • [x] This PR modifies the API contract

Motivation and Context

How did you test it?

  • Create a payment and check the browser information in response.
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_Qh3geeUMKaIWSojyasQbnkCEWOHwR0QBeKbm0xtVIOiF0nshEyUY9xevwNAOnmp8' \
--data-raw '{
    "amount": 6969,
    "currency": "USD",
    "confirm": true,
    "name": "John Dough",
    "capture_method": "automatic",
    "phone": "999999999",
    "phone_country_code": "+65",
    "customer_id": "cus_PAxm0MeCGM5TowgDKPc9",
    "email": "[email protected]",
    "setup_future_usage": "on_session",
    "description": "Its my fourth payment request",
    "authentication_type": "no_three_ds",
    "payment_method": "card",
    "routing": {
        "type": "single",
        "data": {
            "connector": "stripe"
        }
    },
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        }
    },
    "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": "127.0.0.1"
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrisoff Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "Narayan",
            "last_name": "Doe"
        },
        "email": "[email protected]"
    },
    "statement_descriptor_name": "hola",
    "statement_descriptor_suffix": "JS"
}
  • Check for browser_info field in the response
{
   "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": "127.0.0.1"
    }
}

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
  • [ ] I added a CHANGELOG entry if applicable

Narayanbhat166 avatar Mar 05 '24 10:03 Narayanbhat166