hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

feat: added client_source, client_version in payment_attempt from payments confirm request headers

Open vsrivatsa-edinburgh opened this issue 9 months ago • 0 comments

Type of Change

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

Description

Added client_source, client_version in payment_attempt from PaymentsConfirm request headers Both the above columns are of Option<String> type. Can be used to collect information from client request headers - X-Client-Source and X-Client-Version

Additional Changes

  • [ ] This PR modifies the API contract
  • [x] This PR modifies the database schema
  • [ ] This PR modifies application configuration/environment variables

Motivation and Context

closes https://github.com/juspay/hyperswitch/issues/4656

How did you test it?

  1. Create a payment intent. Pass confirm: false curl --location 'localhost:8080/payments' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: some_api_key' \ --data-raw '{ "amount": 6540, "currency": "USD", "confirm" : false, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "amount_to_capture": 6540, "customer_id": "cus_udst2tfldj6upmye2reztkmm4i", "email": "[email protected]", "name": "John Doe", "phone": "999999999", "phone_country_code": "+65", "description": "Its my first payment request", "authentication_type": "no_three_ds", "payment_method": "card", "payment_method_data": { "card": { "card_number": "4242424242424242", "card_exp_month": "10", "card_exp_year": "35", "card_holder_name": "John Doe", "card_cvc": "123" } }, "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" } }'

  2. Confirm the payment, pass the X_CLIENT_VERSION and X_CLIENT_SOURCE headers curl --location 'localhost:8080/payments/pay_YleHqfzluDmuEX7394l7/confirm' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: some_api_key' \ --data '{}'

  3. Check the values in the client_version and client_source columns for the payment Screenshot 2024-05-16 at 7 08 41 PM

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

vsrivatsa-edinburgh avatar May 15 '24 14:05 vsrivatsa-edinburgh