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

fix(payments): populate payment_method_type in payment_attempt for cards #6519

Merged
merged 7 commits into from
Nov 13, 2024

Conversation

kashif-m
Copy link
Contributor

@kashif-m kashif-m commented Nov 8, 2024

Type of Change

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

Description

Described in #6512

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 us attach payment_method_type for card BINs present in cards_info table

How did you test it?

Locally.

1. Create a card payment without payment_method_type

cURL

curl --location 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_DDq72QAk6IpUy0tf6kjmjpC78VaaeI2YnbSwJwnhcTp4KQvDkSkswTbo6b3nm9cJ' \
    --data-raw '{"amount":6500,"currency":"USD","confirm":true,"capture_method":"automatic","capture_on":"2022-09-10T10:11:12Z","customer_id":"cus_sH6s3hf1uukqvYlAGkj5_4","email":"[email protected]","name":"John Doe","phone":"999999999","profile_id":"pro_OLl8NlVXBaGHHE51KdLc","phone_country_code":"+65","description":"Its my first payment request","authentication_type":"no_three_ds","return_url":"https://hyperswitch.io","setup_future_usage":"on_session","customer_acceptance":{"acceptance_type":"offline","accepted_at":"1963-05-03T04:07:52.723Z","online":{"ip_address":"127.0.0.1","user_agent":"amet irure esse"}},"connector":["stripe"],"payment_method":"card","payment_method_data":{"card":{"card_number":"5555555555554444","card_exp_month":"08","card_exp_year":"2025","card_holder_name":"John 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":"John"}},"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":30,"screen_height":1117,"screen_width":1728,"time_zone":-330,"java_enabled":true,"java_script_enabled":true}}'

Response (it should have payment_method_type in response)

{"payment_id":"pay_zqseTAFEnWA0ULs52UQf","merchant_id":"merchant_1731047637","status":"succeeded","amount":6500,"net_amount":6500,"shipping_cost":null,"amount_capturable":0,"amount_received":6500,"connector":"stripe","client_secret":"pay_zqseTAFEnWA0ULs52UQf_secret_34nMjYSlYfGLXfXT2Rcw","created":"2024-11-08T09:17:11.158Z","currency":"USD","customer_id":"cus_sH6s3hf1uukqvYlAGkj5_4","customer":{"id":"cus_sH6s3hf1uukqvYlAGkj5_4","name":"John Doe","email":"[email protected]","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":"on_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"4444","card_type":"CREDIT","card_network":"Mastercard","card_issuer":"MASTERCARD INTERNATIONAL","card_issuing_country":"BRAZIL","card_isin":"555555","card_extended_bin":null,"card_exp_month":"08","card_exp_year":"2025","card_holder_name":null,"payment_checks":{"cvc_check":"pass","address_line1_check":"pass","address_postal_code_check":"pass"},"authentication_data":null},"billing":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":null},"phone":null,"email":null},"order_details":null,"email":"[email protected]","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":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":{"customer_id":"cus_sH6s3hf1uukqvYlAGkj5_4","created_at":1731057431,"expires":1731061031,"secret":"epk_1c7b82eafc41493ea4614cd4d2355551"},"manual_retry_allowed":false,"connector_transaction_id":"pi_3QIoJXD5R7gDAGff0XBhiGcW","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":null,"reference_id":"pi_3QIoJXD5R7gDAGff0XBhiGcW","payment_link":null,"profile_id":"pro_OLl8NlVXBaGHHE51KdLc","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_IN8H4cI4P0upvMUfgoLq","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2024-11-08T09:32:11.158Z","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":30,"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":null,"payment_method_status":null,"updated":"2024-11-08T09:17:12.667Z","charges":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null}
2. Create a card payment with incorrect payment_method_type

cURL

curl --location 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_DDq72QAk6IpUy0tf6kjmjpC78VaaeI2YnbSwJwnhcTp4KQvDkSkswTbo6b3nm9cJ' \
    --data-raw '{"amount":6500,"currency":"USD","confirm":true,"capture_method":"automatic","capture_on":"2022-09-10T10:11:12Z","customer_id":"cus_sH6s3hf1uukqvYlAGkj5_4","email":"[email protected]","name":"John Doe","phone":"999999999","profile_id":"pro_OLl8NlVXBaGHHE51KdLc","phone_country_code":"+65","description":"Its my first payment request","authentication_type":"no_three_ds","return_url":"https://hyperswitch.io","setup_future_usage":"on_session","customer_acceptance":{"acceptance_type":"offline","accepted_at":"1963-05-03T04:07:52.723Z","online":{"ip_address":"127.0.0.1","user_agent":"amet irure esse"}},"connector":["stripe"],"payment_method":"card","payment_method_type":"debit","payment_method_data":{"card":{"card_number":"5555555555554444","card_exp_month":"08","card_exp_year":"2025","card_holder_name":"John 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":"John"}},"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":30,"screen_height":1117,"screen_width":1728,"time_zone":-330,"java_enabled":true,"java_script_enabled":true}}'

Response (to have correct payment_method_type in response)

{"payment_id":"pay_zqseTAFEnWA0ULs52UQf","merchant_id":"merchant_1731047637","status":"succeeded","amount":6500,"net_amount":6500,"shipping_cost":null,"amount_capturable":0,"amount_received":6500,"connector":"stripe","client_secret":"pay_zqseTAFEnWA0ULs52UQf_secret_34nMjYSlYfGLXfXT2Rcw","created":"2024-11-08T09:17:11.158Z","currency":"USD","customer_id":"cus_sH6s3hf1uukqvYlAGkj5_4","customer":{"id":"cus_sH6s3hf1uukqvYlAGkj5_4","name":"John Doe","email":"[email protected]","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":"on_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"4444","card_type":"CREDIT","card_network":"Mastercard","card_issuer":"MASTERCARD INTERNATIONAL","card_issuing_country":"BRAZIL","card_isin":"555555","card_extended_bin":null,"card_exp_month":"08","card_exp_year":"2025","card_holder_name":null,"payment_checks":{"cvc_check":"pass","address_line1_check":"pass","address_postal_code_check":"pass"},"authentication_data":null},"billing":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":null},"phone":null,"email":null},"order_details":null,"email":"[email protected]","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":"credit","connector_label":null,"business_country":null,"business_label":"default","business_sub_label":null,"allowed_payment_method_types":null,"ephemeral_key":{"customer_id":"cus_sH6s3hf1uukqvYlAGkj5_4","created_at":1731057431,"expires":1731061031,"secret":"epk_1c7b82eafc41493ea4614cd4d2355551"},"manual_retry_allowed":false,"connector_transaction_id":"pi_3QIoJXD5R7gDAGff0XBhiGcW","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":null,"reference_id":"pi_3QIoJXD5R7gDAGff0XBhiGcW","payment_link":null,"profile_id":"pro_OLl8NlVXBaGHHE51KdLc","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_IN8H4cI4P0upvMUfgoLq","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2024-11-08T09:32:11.158Z","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":30,"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":null,"payment_method_status":null,"updated":"2024-11-08T09:17:12.667Z","charges":null,"frm_metadata":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":null}

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

@kashif-m kashif-m added the A-core Area: Core flows label Nov 8, 2024
@kashif-m kashif-m self-assigned this Nov 8, 2024
@kashif-m kashif-m requested review from a team as code owners November 8, 2024 09:52
Copy link

semanticdiff-com bot commented Nov 8, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments/operations/payment_confirm.rs  58% smaller
  crates/router/src/core/payments/operations/payment_create.rs  0% smaller
  crates/router/src/core/payments/transformers.rs  0% smaller

@kashif-m kashif-m requested a review from Chethan-rao November 10, 2024 06:58
@kashif-m kashif-m linked an issue Nov 10, 2024 that may be closed by this pull request
2 tasks
Chethan-rao
Chethan-rao previously approved these changes Nov 11, 2024
srujanchikke
srujanchikke previously approved these changes Nov 11, 2024
@kashif-m kashif-m removed the request for review from Chethan-rao November 12, 2024 11:00
@likhinbopanna
Copy link
Contributor

@kashif-m Can we make cypress changes for this ?

@kashif-m
Copy link
Contributor Author

@kashif-m Can we make cypress changes for this ?

Added in a separate PR @likhinbopanna - #6550

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 13, 2024
@Gnanasundari24
Copy link
Contributor

@kashif-m Whatever you added the curl. Same you can update in cypress in seperate PR.

CC : @pranav-arjunan

Merged via the queue into main with commit 574170a Nov 13, 2024
16 of 17 checks passed
@Gnanasundari24 Gnanasundari24 deleted the 6512-payment_method_type_for_cards branch November 13, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] payment_method_type for cards is null
6 participants