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(events): add hashed customer_email and feature_metadata #5220

Merged
merged 7 commits into from
Jul 5, 2024

Conversation

tsdk02
Copy link
Contributor

@tsdk02 tsdk02 commented Jul 5, 2024

Type of Change

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

Description

  • Implemented hashing of customer_email using blake3::hash, and added this to PaymentIntent kafka events
  • Enabled search using customer_email filter in dashboard globalsearch as well
  • Added feature_metadata with search_tags for dashboard globalsearch

Additional Changes

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

Motivation and Context

Hashing of customer_email helps in masking of data to help protect privacy

How did you test it?

Tested it using Postman curls:

  • Made a payment with the customer_email and search_tags in feature_metadata set
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_IG9ateOUhGE0KLFEItNN1tsJXcr5M62N7zlbtOlUtStTfPpzSomswbQa4aO2k1B4' \
--data-raw '{
  "amount": 6540,
  "currency": "INR",
  "confirm": true,
  "capture_method": "automatic",
  "capture_on": "2022-09-10T10:11:12Z",
  "amount_to_capture": 6540,
  "customer_id": "StripeCustomer",
  "email": "test@hyperswitch.com",
  "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": "card",
  "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"
    }
  },
  "billing": {
    "address": {
      "line1": "1467",
      "line2": "Harrison Street",
      "line3": "Harrison Street",
      "city": "San Fransico",
      "state": "California",
      "zip": "94122",
      "country": "US",
      "first_name": "joseph",
      "last_name": "Doe"
    },
    "phone": {
      "number": "8056594427",
      "country_code": "+91"
    }
  },
  "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"
    },
    "phone": {
      "number": "8056594427",
      "country_code": "+91"
    }
  },
  "statement_descriptor_name": "joseph",
  "statement_descriptor_suffix": "JS",
  "feature_metadata": {
    "search_tags": ["dubai", "tokyo"]
  },
  "metadata": {
    "data2": "camel",
    "new_customer": "true",
    "login_date": "2019-09-10T10:11:12Z"
  }
}'
  • Hit the analytics/v1/search with the following curl:
curl --location 'http://localhost:8080/analytics/v1/search' \
--header 'Accept: */*' \
--header 'Accept-Language: en-US,en;q=0.9' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Origin: http://localhost:9000' \
--header 'Referer: http://localhost:9000/' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Site: same-site' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' \
--header 'api-key: hyperswitch' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiNGU2ZWVhYzEtMWVjNi00ZWQyLWJhY2YtMDUzOTFiZGE3YjI1IiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzE5OTA0MzA1Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcyMDI3MTg0NSwib3JnX2lkIjoib3JnX0c4Zk85a09UTXl1OHBXUEVQSUcwIn0.2Pdjr1w82ImWbccLcAthHzJ8LU959xSHRZ5PrJCFtoE' \
--header 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--data-raw '{
    "query": "merchant_1719904305",
    "filters": {
        "currency": [
            "INR"
        ],
        "customer_email": [
            "test@hyperswitch.com"
        ]
    }
}'

You should be able to get the results in the payment_intents index

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

@tsdk02 tsdk02 self-assigned this Jul 5, 2024
@tsdk02 tsdk02 requested review from a team as code owners July 5, 2024 11:47
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jul 5, 2024
lsampras
lsampras previously approved these changes Jul 5, 2024
@tsdk02 tsdk02 added C-feature Category: Feature request or enhancement A-Analytics labels Jul 5, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 5, 2024
@lsampras lsampras removed this pull request from the merge queue due to a manual request Jul 5, 2024
@tsdk02 tsdk02 dismissed stale reviews from ShivanshMathurJuspay and lsampras via 0cd4cb0 July 5, 2024 13:47
@likhinbopanna likhinbopanna enabled auto-merge July 5, 2024 14:56
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 5, 2024
Merged via the queue into main with commit ae2a34e Jul 5, 2024
11 checks passed
@likhinbopanna likhinbopanna deleted the add_customer_to_events branch July 5, 2024 15:26
pixincreate added a commit that referenced this pull request Jul 8, 2024
…ify-cypress

* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.07.08.0
  fix(connector): [adyen] remove browser info for mit and [paypal] add refund key in headers (#5225)
  chore(version): 2024.07.06.0
  feat(router): Pass the shipping email whenever the billing details are included in the session token response (#5228)
  fix(cypress): fix metadata missing while creating connector if not in auth (#5215)
  refactor: fix unit and documentation tests (#4754)
  feat(events): add hashed customer_email and feature_metadata (#5220)
  feat(events): Add payment metadata to hyperswitch-payment-intent-events (#5170)
  fix(analytics): using HashSet to represent the returned metrics (#5179)
  feat(core): billing_details inclusion in Payment Intent (#5090)
  feat(router): pass fields to indicate if the customer address details to be connector from wallets (#5210)
  fix(refunds): Add aliases on refund status for backwards compatibility (#5216)
  Feat(connector): [BRAINTREE] Implement Card Mandates (#5204)
Narayanbhat166 pushed a commit that referenced this pull request Jul 8, 2024
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analytics C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(events): add payment feature metadata & customer email to the payment intent events
5 participants