Skip to content

Conversation

awasthi21
Copy link
Contributor

@awasthi21 awasthi21 commented Dec 4, 2024

Type of Change

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

Description

Added a check to update payment_attempt.payment_method_data only when additional_payment_method is present; otherwise, the existing payment_method_data will remain unchanged.

Additional Changes

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

Motivation and Context

How did you test it?

Request
Create

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_LjRfdy51O1zg0ToyQvxKdxvyIIlqkA8Wdle3E5IKgnmx6MOge4eTO0wwlFuMuJVk' \
--data-raw '{
    "amount": 7940,
    "currency": "USD",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 7940,
    "customer_id": "StripeCustomer1",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://duck.com",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX",
            "last_name":"Awasthi"
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        }
    },
    "request_external_three_ds_authentication": true,
    "statement_descriptor_name": "joseph",
    "setup_future_usage":"off_session",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'

Response

{
    "payment_id": "pay_gWpsds25BQSquNkzS5pn",
    "merchant_id": "postman_merchant_GHAction_94974b9b-c4fe-430c-8e7e-bebcb4587ff1",
    "status": "requires_payment_method",
    "amount": 7940,
    "net_amount": 7940,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_gWpsds25BQSquNkzS5pn_secret_vKGvrNiWvfLHvvbvD8G4",
    "created": "2024-12-06T07:47:52.592Z",
    "currency": "USD",
    "customer_id": "StripeCustomer1",
    "customer": {
        "id": "StripeCustomer1",
        "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": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": null,
    "payment_method_data": null,
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": "Awasthi"
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "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": "StripeCustomer1",
        "created_at": 1733471272,
        "expires": 1733474872,
        "secret": "epk_e1d9f4f992624661aea4102d44294663"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_OwNt2o4QxQASUYHxjnEN",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": null,
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-12-06T08:02:52.592Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-12-06T07:47:52.611Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Confirm

curl --location 'http://localhost:8080/payments/pay_gWpsds25BQSquNkzS5pn/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_8902abf13c3945a3923030db6692a0cf' \
--data '{
    "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": "115.99.183.2"
    },
    "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"
          }
    },
    "client_secret": "pay_gWpsds25BQSquNkzS5pn_secret_vKGvrNiWvfLHvvbvD8G4",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            
            "card_number": "4929251897047956", 
            
            
            
            
            
            
            
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    }
}'
Response
{
    "payment_id": "pay_gWpsds25BQSquNkzS5pn",
    "merchant_id": "postman_merchant_GHAction_94974b9b-c4fe-430c-8e7e-bebcb4587ff1",
    "status": "requires_customer_action",
    "amount": 7940,
    "net_amount": 7940,
    "shipping_cost": null,
    "amount_capturable": 7940,
    "amount_received": null,
    "connector": "cybersource",
    "client_secret": "pay_gWpsds25BQSquNkzS5pn_secret_vKGvrNiWvfLHvvbvD8G4",
    "created": "2024-12-06T07:47:52.592Z",
    "currency": "USD",
    "customer_id": "StripeCustomer1",
    "customer": {
        "id": "StripeCustomer1",
        "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": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "7956",
            "card_type": "CREDIT",
            "card_network": "Visa",
            "card_issuer": "Barclays Bank",
            "card_issuing_country": "UNITEDKINGDOM",
            "card_isin": "492925",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": null,
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_xySRww7RCQgDnmoS8hmI",
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": "Awasthi"
        },
        "phone": {
            "number": "123456789",
            "country_code": "12"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "three_ds_invoke",
        "three_ds_data": {
            "three_ds_authentication_url": "http://localhost:8080/payments/pay_gWpsds25BQSquNkzS5pn/3ds/authentication",
            "three_ds_authorize_url": "http://localhost:8080/payments/pay_gWpsds25BQSquNkzS5pn/postman_merchant_GHAction_94974b9b-c4fe-430c-8e7e-bebcb4587ff1/authorize/cybersource",
            "three_ds_method_details": {
                "three_ds_method_key": "threeDSMethodData",
                "three_ds_method_data_submission": true,
                "three_ds_method_data": "eyJ0aHJlZURTTWV0aG9kTm90aWZpY2F0aW9uVVJMIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS8zZHMtbWV0aG9kLW5vdGlmaWNhdGlvbi11cmwiLCJ0aHJlZURTU2VydmVyVHJhbnNJRCI6ImI3ZGQ4ZmJhLWZkMDAtNDhiNi04MGIyLTUyZTY1MDE0MTg3NSJ9",
                "three_ds_method_url": "https://3dss-pp-prev-ndm.acquiring.test.netcetera.com/acs/3ds-method"
            },
            "poll_config": {
                "poll_id": "external_authentication_pay_gWpsds25BQSquNkzS5pn",
                "delay_in_secs": 2,
                "frequency": 5
            },
            "message_version": "2.2.0",
            "directory_server_id": "A000000003"
        }
    },
    "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": null,
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_OwNt2o4QxQASUYHxjnEN",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_reFVfeVoQUwUMrTVC79R",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": {
        "authentication_flow": null,
        "electronic_commerce_indicator": null,
        "status": "pending",
        "ds_transaction_id": "b7dd8fba-fd00-48b6-80b2-52e650141875",
        "version": "2.2.0",
        "error_code": null,
        "error_message": null
    },
    "external_3ds_authentication_attempted": true,
    "expires_on": "2024-12-06T08:02:52.592Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "115.99.183.2",
        "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",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-12-06T07:48:31.317Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

List Customer Payment Methods

curl --location 'http://localhost:8080/customers/StripeCustomer1/payment_methods' \
--header 'Accept: application/json' \
--header 'api-key: dev_LjRfdy51O1zg0ToyQvxKdxvyIIlqkA8Wdle3E5IKgnmx6MOge4eTO0wwlFuMuJVk'
{
    "customer_payment_methods": [
        {
            "payment_token": "token_mP6JuKKFxrPYmdld57Ao",
            "payment_method_id": "pm_Mv5Op5HBqg2Cc034tQ4m",
            "customer_id": "StripeCustomer1",
            "payment_method": "card",
            "payment_method_type": "credit",
            "payment_method_issuer": "Barclays Bank",
            "payment_method_issuer_code": null,
            "recurring_enabled": false,
            "installment_payment_enabled": false,
            "payment_experience": [
                "redirect_to_url"
            ],
            "card": {
                "scheme": "Visa",
                "issuer_country": "UNITEDKINGDOM",
                "last4_digits": "7956",
                "expiry_month": "10",
                "expiry_year": "25",
                "card_token": null,
                "card_holder_name": "PiX Awasthi",
                "card_fingerprint": null,
                "nick_name": null,
                "card_network": "Visa",
                "card_isin": "492925",
                "card_issuer": "Barclays Bank",
                "card_type": "CREDIT",
                "saved_to_locker": true
            },
            "metadata": null,
            "created": "2024-12-06T07:49:01.171Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": true,
            "last_used_at": "2024-12-06T07:49:01.171Z",
            "default_payment_method_set": true,
            "billing": {
                "address": {
                    "city": "San Fransico",
                    "country": "US",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "PiX",
                    "last_name": "Awasthi"
                },
                "phone": {
                    "number": "123456789",
                    "country_code": "12"
                },
                "email": null
            }
        }
    ],
    "is_guest_customer": 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

@awasthi21 awasthi21 added the A-core Area: Core flows label Dec 4, 2024
@awasthi21 awasthi21 self-assigned this Dec 4, 2024
@awasthi21 awasthi21 requested a review from a team as a code owner December 4, 2024 10:45
Copy link

semanticdiff-com bot commented Dec 4, 2024

Review changes with  SemanticDiff

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

.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to encode additional pm data")?;
// Only set `payment_attempt.payment_method_data` if `additional_pm_data_from_locker` is not None
if additional_pm_data_from_locker.is_some() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do if let Some here instead?

@awasthi21 awasthi21 changed the title fix/pmd_getting_overrided fix(core): card_network details Missing in Customer Payment Methods List for External 3DS Authentication Payments Dec 4, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Dec 6, 2024
Merged via the queue into main with commit 15f873b Dec 6, 2024
23 of 26 checks passed
@likhinbopanna likhinbopanna deleted the 7694-bug-card-network-missing-in-customer-payment-methods-list-for-external-3ds-authentication-payments branch December 6, 2024 08:50
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.

4 participants