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(payment_methods): card_network and card_scheme should be consistent #6849

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

Sakilmostak
Copy link
Contributor

@Sakilmostak Sakilmostak commented Dec 16, 2024

Type of Change

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

Description

In customer payment method list api, card scheme and card network are showing different value for co-branded card it they are saved with both the network, to fix this issue, both these fields are now fetching the data from the card locker

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?

Tested through Postam:

  • Create a MCA(Checkout):
  • Create a payment with co-branded card with network at Visa:
{
    "amount": 1043,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "{{customer_id}}",
    "email": "[email protected]",
    "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_data": {
        "card": {
            "card_number": "4010061700000021",
            "card_exp_month": "01",
            "card_exp_year": "99",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123",
            "card_network": "Visa",
            "nick_name": "Sakil"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "setup_future_usage": "on_session",
    "customer_acceptance": {
        "acceptance_type": "online",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "125.0.0.1",
            "user_agent": "amet irure esse"
        }
    }
}
  • Do a customer payment method list, the response should be following:
{
    "customer_payment_methods": [
        {
            "payment_token": "token_I8i8KGuFhF4KSxQHFePi",
            "payment_method_id": "pm_3D4MneEjvgweeRyfyiBv",
            "customer_id": "cus_4hPhaiDFxK9W0qUpOGkq",
            "payment_method": "card",
            "payment_method_type": null,
            "payment_method_issuer": null,
            "payment_method_issuer_code": null,
            "recurring_enabled": false,
            "installment_payment_enabled": false,
            "payment_experience": [
                "redirect_to_url"
            ],
            "card": {
                "scheme": "Visa",
                "issuer_country": null,
                "last4_digits": "0021",
                "expiry_month": "01",
                "expiry_year": "99",
                "card_token": null,
                "card_holder_name": "joseph Doe",
                "card_fingerprint": null,
                "nick_name": "Sakil",
                "card_network": "Visa",
                "card_isin": "401006",
                "card_issuer": null,
                "card_type": null,
                "saved_to_locker": true
            },
            "metadata": null,
            "created": "2024-12-16T10:20:59.201Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": true,
            "last_used_at": "2024-12-16T10:20:59.201Z",
            "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": "joseph",
                    "last_name": "Doe"
                },
                "phone": null,
                "email": null
            }
        }
    ],
    "is_guest_customer": false
}
  • Create a payment again with co-branded card but with network as CartesBancaires:
{
    "amount": 1043,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "{{customer_id}}",
    "email": "[email protected]",
    "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_data": {
        "card": {
            "card_number": "4010061700000021",
            "card_exp_month": "01",
            "card_exp_year": "99",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123",
            "card_network": "CartesBancaires",
            "nick_name": "Sakil"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "setup_future_usage": "on_session",
    "customer_acceptance": {
        "acceptance_type": "online",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "125.0.0.1",
            "user_agent": "amet irure esse"
        }
    }
}
  • Do a customer payment method list call, the response should be:
{
    "customer_payment_methods": [
        {
            "payment_token": "token_I8i8KGuFhF4KSxQHFePi",
            "payment_method_id": "pm_3D4MneEjvgweeRyfyiBv",
            "customer_id": "cus_4hPhaiDFxK9W0qUpOGkq",
            "payment_method": "card",
            "payment_method_type": null,
            "payment_method_issuer": null,
            "payment_method_issuer_code": null,
            "recurring_enabled": false,
            "installment_payment_enabled": false,
            "payment_experience": [
                "redirect_to_url"
            ],
            "card": {
                "scheme": "CartesBancaires",
                "issuer_country": null,
                "last4_digits": "0021",
                "expiry_month": "01",
                "expiry_year": "99",
                "card_token": null,
                "card_holder_name": "joseph Doe",
                "card_fingerprint": null,
                "nick_name": "Sakil",
                "card_network": "CartesBancaires",
                "card_isin": "401006",
                "card_issuer": null,
                "card_type": null,
                "saved_to_locker": true
            },
            "metadata": null,
            "created": "2024-12-16T10:20:59.201Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": true,
            "last_used_at": "2024-12-16T10:20:59.201Z",
            "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": "joseph",
                    "last_name": "Doe"
                },
                "phone": null,
                "email": null
            }
        }
    ],
    "is_guest_customer": false
}

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

@Sakilmostak Sakilmostak added A-core Area: Core flows C-bug Category: Bug labels Dec 16, 2024
@Sakilmostak Sakilmostak added this to the December 2024 Release milestone Dec 16, 2024
@Sakilmostak Sakilmostak self-assigned this Dec 16, 2024
@Sakilmostak Sakilmostak requested a review from a team as a code owner December 16, 2024 11:31
Copy link

semanticdiff-com bot commented Dec 16, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/diesel_models/src/payment_method.rs  0% smaller
  crates/router/src/core/payment_methods/cards.rs  0% smaller
  crates/router/src/core/payments/tokenization.rs  0% smaller

Chethan-rao
Chethan-rao previously approved these changes Dec 17, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Dec 17, 2024
Merged via the queue into main with commit 5c4de8a Dec 17, 2024
18 of 19 checks passed
@Gnanasundari24 Gnanasundari24 deleted the fix_card_scheme_consistency branch December 17, 2024 14:16
pixincreate added a commit that referenced this pull request Dec 18, 2024
…ete-pm

* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.12.18.0
  fix(payment_methods): card_network and card_scheme should be consistent (#6849)
  fix(core): Populate off_session based on payments request (#6855)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants