Skip to content

fix(core): payments - map billing first and last name to card holder name#6791

Merged
likhinbopanna merged 4 commits intomainfrom
6790-map-billing-name-to-card-holder-name
Dec 10, 2024
Merged

fix(core): payments - map billing first and last name to card holder name#6791
likhinbopanna merged 4 commits intomainfrom
6790-map-billing-name-to-card-holder-name

Conversation

@kashif-m
Copy link
Contributor

@kashif-m kashif-m commented Dec 10, 2024

Type of Change

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

Description

This PR contains below changes

  1. Map billing's first and last name to card holder's name
  2. Preserve card holder's name across different data models (API / domain / vault)

Additional Changes

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

Motivation and Context

This helps in preserving the card holder name being persisted in HyperSwitch systems. And also helps populate card holder name from billing details.

How did you test it?

Things to validate

  • Card holder name in payments response when payment_method_data.card.card_holder_name is not passed should be same as billing's first and last name
  • Card holder name in payments response in not mapped to card's nick_name
1. Do not pass card_holder_name but pass billing's first and last name

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_JsjDHPxfr4RiMUmrbwwZ5n0Uq9Ks9GJMTkLXZSFSjrWwA0IvsLs9bIZaOoGBY0jL' \
    --data-raw '{"amount":100,"currency":"USD","confirm":true,"capture_method":"automatic","capture_on":"2022-09-10T10:11:12Z","customer_id":"cus_Mv8zajfpTRYwUCqiJFxD","email":"guest@example.com","name":"John Doe","phone":"999999999","profile_id":"pro_ZIDJAkA2jtoxZVFYk93j","phone_country_code":"+65","description":"Its my first payment request","authentication_type":"no_three_ds","return_url":"https://hyperswitch.io","setup_future_usage":"off_session","customer_acceptance":{"acceptance_type":"online","accepted_at":"1963-05-03T04:07:52.723Z","online":{"ip_address":"127.0.0.1","user_agent":"amet irure esse"}},"connector":["worldpay"],"payment_method":"card","payment_method_data":{"card":{"card_number":"4871049999999910","card_exp_month":"03","card_exp_year":"2030","card_cvc":"737"},"billing":{"address":{"first_name":"John","last_name":"Doe"}}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US","first_name":"John","last_name":"US"}},"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","metadata":{"udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"},"browser_info":{"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","language":"en-US","color_depth":32,"screen_height":1117,"screen_width":1728,"time_zone":-330,"java_enabled":true,"java_script_enabled":true}}'

Response

{"payment_id":"pay_vman2BErys3hnUGb9Ig8","merchant_id":"merchant_1733811790","status":"succeeded","amount":100,"net_amount":100,"shipping_cost":null,"amount_capturable":0,"amount_received":100,"connector":"worldpay","client_secret":"pay_vman2BErys3hnUGb9Ig8_secret_EoNgrJyOLNiYhwUFRZV5","created":"2024-12-10T14:10:31.909Z","currency":"USD","customer_id":"cus_Mv8zajfpTRYwUCqiJFxD","customer":{"id":"cus_Mv8zajfpTRYwUCqiJFxD","name":"John Doe","email":"guest@example.com","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":"off_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"9910","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"487104","card_extended_bin":null,"card_exp_month":"03","card_exp_year":"2030","card_holder_name":"John Doe","payment_checks":null,"authentication_data":null},"billing":{"address":{"city":null,"country":null,"line1":null,"line2":null,"line3":null,"zip":null,"state":null,"first_name":"John","last_name":"Doe"},"phone":null,"email":null}},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"US","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":"John","last_name":"US"},"phone":null,"email":null},"order_details":null,"email":"guest@example.com","name":"John Doe","phone":"999999999","return_url":"https://hyperswitch.io/","authentication_type":"no_three_ds","statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","next_action":null,"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":{"customer_id":"cus_Mv8zajfpTRYwUCqiJFxD","created_at":1733839831,"expires":1733843431,"secret":"epk_66e0c3159094461cabefb14d0a889a12"},"manual_retry_allowed":false,"connector_transaction_id":"eyJrIjoiazNhYjYzMiIsImxpbmtWZXJzaW9uIjoiNS4wLjAifQ==.sN:g8wd64bwkbrp0md+bPxcanBnk2zLdsIqSa1pR99GGg8fCNQpPLoWNslSzWNPFBM5Tpa8tW7EFI5onKINsgChMHeJVoeH2lrBWCRyjZYT6h+lbqfJa+1BSoKFSY8HLFgs6J9vT5SQ7QHQV0J6AcoGK6sQ5gX8RMd3JKUZsPH0CpZY8cZeCeMgt1ol:GABqQG6u+T:u3sfHv3ezSOJxioRTixsThPEhzFW4ZZ6mObj3CK0rnFndcM0swvZMqgQwSEj5tBsydfzM4XKX20O6Nme96ha9twqxTSQIfr1rtl9V3q7fw3w5O9UZT4vQi9BMyCcaHkWSD:RbCWCcmiQqa4cyiErJraj4BSbdS7ZL9q:0CfTCrAhezB3ww52Bj:XQSr3pE8npmajEFGaImRr4Ag==","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":null,"reference_id":"07143c6f-72aa-46f3-bd17-68e7c199c534","payment_link":null,"profile_id":"pro_ZIDJAkA2jtoxZVFYk93j","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_Q01nLt4b2s8faHDohJhd","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2024-12-10T14:25:31.909Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","color_depth":32,"java_enabled":true,"screen_width":1728,"accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","screen_height":1117,"java_script_enabled":true},"payment_method_id":"pm_L3UJVmg9vt6xPQA7uDvm","payment_method_status":"active","updated":"2024-12-10T14:10:33.477Z","charges":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":"https://try.access.worldpay.com/tokens/eyJrIjoxLCJkIjoiUnhPMjNDYXVvNm5WTGxGNVl2S25VU2FhT2dONGRKc1UweUx4eXRGYzRNcz0ifQ"}
2. Pass card nickname, and ensure it's not populated in card holder's name

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_JsjDHPxfr4RiMUmrbwwZ5n0Uq9Ks9GJMTkLXZSFSjrWwA0IvsLs9bIZaOoGBY0jL' \
    --data-raw '{"amount":100,"currency":"USD","confirm":true,"capture_method":"automatic","capture_on":"2022-09-10T10:11:12Z","customer_id":"cus_Mv8zajfpTRYwUCqiJFxD","email":"guest@example.com","name":"John Doe","phone":"999999999","profile_id":"pro_ZIDJAkA2jtoxZVFYk93j","phone_country_code":"+65","description":"Its my first payment request","authentication_type":"no_three_ds","return_url":"https://hyperswitch.io","setup_future_usage":"off_session","customer_acceptance":{"acceptance_type":"online","accepted_at":"1963-05-03T04:07:52.723Z","online":{"ip_address":"127.0.0.1","user_agent":"amet irure esse"}},"connector":["worldpay"],"payment_method":"card","payment_method_data":{"card":{"card_number":"4871049999999910","card_exp_month":"03","card_exp_year":"2030","card_cvc":"737","nick_name":"JD"},"billing":{"address":{"first_name":"John","last_name":"Doe"}}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US","first_name":"John","last_name":"US"}},"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","metadata":{"udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"},"browser_info":{"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","language":"en-US","color_depth":32,"screen_height":1117,"screen_width":1728,"time_zone":-330,"java_enabled":true,"java_script_enabled":true}}'

Response

{"payment_id":"pay_Y5KTQy51zE67uQhyChDC","merchant_id":"merchant_1733811790","status":"succeeded","amount":100,"net_amount":100,"shipping_cost":null,"amount_capturable":0,"amount_received":100,"connector":"worldpay","client_secret":"pay_Y5KTQy51zE67uQhyChDC_secret_rXB9yw3GsVm8S0wk1Nnj","created":"2024-12-10T14:12:54.223Z","currency":"USD","customer_id":"cus_Mv8zajfpTRYwUCqiJFxD","customer":{"id":"cus_Mv8zajfpTRYwUCqiJFxD","name":"John Doe","email":"guest@example.com","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":"off_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"9910","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"487104","card_extended_bin":null,"card_exp_month":"03","card_exp_year":"2030","card_holder_name":"John Doe","payment_checks":null,"authentication_data":null},"billing":{"address":{"city":null,"country":null,"line1":null,"line2":null,"line3":null,"zip":null,"state":null,"first_name":"John","last_name":"Doe"},"phone":null,"email":null}},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"US","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":"John","last_name":"US"},"phone":null,"email":null},"order_details":null,"email":"guest@example.com","name":"John Doe","phone":"999999999","return_url":"https://hyperswitch.io/","authentication_type":"no_three_ds","statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","next_action":null,"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":{"customer_id":"cus_Mv8zajfpTRYwUCqiJFxD","created_at":1733839974,"expires":1733843574,"secret":"epk_fd60bfafe3764b6ea94da4396b09c8b0"},"manual_retry_allowed":false,"connector_transaction_id":"eyJrIjoiazNhYjYzMiIsImxpbmtWZXJzaW9uIjoiNS4wLjAifQ==.sN:g8wd64bwkbrp0md+bPxcanBnk2zLdsIqSa1pR99GGg8fCNQpPLoWNslSzWNPFBM5Tpa8tW7EFI5onKINsgChMHeJVoeH2lrBWCRyjZYT6h+lbqfJa+1BSoKFSY8HLFUqZSBZ0lug6WfPPLhsR2H:6JqUT+977VTVnViilTjsCpZY8cZeCeMgt1ol:GABqQG6u+T:u3sfHv3ezSOJxioRTixsThPEhzFW4ZZ6mObj3CK0rnFndcM0swvZMqgQwSEj5tBsydfzM4XKX20O6Nme96ha9twqxTSQIfr1rtl9V3q7fw3w5O9UZT4vQi9BMyCcaHkWSD:RbCWCcmiQqa8NweeRyh5uOn91N7bZADs8z7mXC2bAdn8tKAJPgGKoxgj0i4qlotcwr6WMoCa4FPg==","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":null,"reference_id":"5e1c9264-1c98-4998-b889-5e6304402361","payment_link":null,"profile_id":"pro_ZIDJAkA2jtoxZVFYk93j","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_Q01nLt4b2s8faHDohJhd","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2024-12-10T14:27:54.223Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","color_depth":32,"java_enabled":true,"screen_width":1728,"accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","screen_height":1117,"java_script_enabled":true},"payment_method_id":"pm_vxcX7jjErcnGZSkzE6pO","payment_method_status":"active","updated":"2024-12-10T14:12:56.901Z","charges":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":"https://try.access.worldpay.com/tokens/eyJrIjoxLCJkIjoiUnhPMjNDYXVvNm5WTGxGNVl2S25VU2FhT2dONGRKc1UweUx4eXRGYzRNcz0ifQ"}

Cypress test cases - Stripe
Screenshot 2024-12-10 at 8 02 35 PM

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

…name

(cherry picked from commit dc7c02b63f2832bc4e85c789f093876c3db5ae8e)
@kashif-m kashif-m requested review from a team as code owners December 10, 2024 12:50
@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 10, 2024

jarnura
jarnura previously approved these changes Dec 10, 2024
Copy link
Contributor

@ThisIsMani ThisIsMani left a comment

Choose a reason for hiding this comment

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

Dashboard specific changes looks fine.

ThisIsMani
ThisIsMani previously approved these changes Dec 10, 2024
@kashif-m kashif-m requested a review from a team as a code owner December 10, 2024 14:27
@kashif-m kashif-m self-assigned this Dec 10, 2024
@kashif-m kashif-m added C-bug Category: Bug A-payments Area: payments labels Dec 10, 2024
@likhinbopanna
Copy link
Contributor

@kashif-m Can you make the for the other connectors also ?

@likhinbopanna likhinbopanna added this pull request to the merge queue Dec 10, 2024
Merged via the queue into main with commit c3b22cf Dec 10, 2024
@likhinbopanna likhinbopanna deleted the 6790-map-billing-name-to-card-holder-name branch December 10, 2024 16:42
kashif-m added a commit that referenced this pull request Dec 12, 2024
…name (#6791)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
kashif-m added a commit that referenced this pull request Dec 12, 2024
…name (#6791)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
(cherry picked from commit c3b22cf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-payments Area: payments C-bug Category: Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] card nickname is populated using card holder name

5 participants