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): use existing field value of nick_name in db if not sent during request #5105

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

Chethan-rao
Copy link
Contributor

@Chethan-rao Chethan-rao commented Jun 24, 2024

Type of Change

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

Description

When a card is saved with nick_name during 1st time, if the same card is being saved next time with no nick_name, the nick_name field is being null. This is because we are only relying on request's nick_name field. We should first infer the value from the request. If not present/sent in request, we fallback to the existing field value in db.

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?

  1. Make a payment and save a card. Pass the nick_name field in request while saving for the 1st time.
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_5sLv9sGxz1Dd0t45aORnPOpJ66ir3zsqKHrPTFBixrtgHeH7sqjsEcYPH2RCHK7u' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "cus_7vwiqZ0f12yHJ18QlPba",
    "business_country": "US",
    "business_label": "default",
    "email": "guest@example.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_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "04",
            "card_exp_year": "36",
            "card_holder_name": "John",
            "nick_name": "Rick",
            "card_cvc": "123"
        }
    },
    "payment_method": "card",
    "payment_method_type": "credit",
    "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": "8056594430",
            "country_code": "+91"
        }
    },
    "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"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "customer_acceptance": {
        "acceptance_type": "online"
    }
}'
  1. Hit list customer payment methods and verify whether nick_name field is present in response.
  2. Make another payment with same card but different metadata (ex - expiry) and don't pass nick_name this time.
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_5sLv9sGxz1Dd0t45aORnPOpJ66ir3zsqKHrPTFBixrtgHeH7sqjsEcYPH2RCHK7u' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "cus_7vwiqZ0f12yHJ18QlPba",
    "business_country": "US",
    "business_label": "default",
    "email": "guest@example.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_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "04",
            "card_exp_year": "46",
            "card_holder_name": "John",
            "card_cvc": "123"
        }
    },
    "payment_method": "card",
    "payment_method_type": "credit",
    "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": "8056594430",
            "country_code": "+91"
        }
    },
    "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"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "customer_acceptance": {
        "acceptance_type": "online"
    }
}'
  1. Hit list customer payment method and ensure that nick_name is still present in response

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

@Chethan-rao Chethan-rao added C-bug Category: Bug S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-payment-methods Area: Payment Methods labels Jun 24, 2024
@Chethan-rao Chethan-rao added this to the June 2024 Release milestone Jun 24, 2024
@Chethan-rao Chethan-rao self-assigned this Jun 24, 2024
@Chethan-rao Chethan-rao requested a review from a team as a code owner June 24, 2024 13:07
@Chethan-rao Chethan-rao changed the title fix(payment_methods): use existing field value of nick_name in db if not sent during request fix(payment_methods): use existing field value of nick_name in db if not sent during request Jun 24, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 25, 2024
Merged via the queue into main with commit ea74f3e Jun 25, 2024
15 checks passed
@likhinbopanna likhinbopanna deleted the fix-nick-name-field branch June 25, 2024 10:12
pixincreate added a commit that referenced this pull request Jun 28, 2024
…ay/hyperswitch into iatapay-through-hyperswitch-cypress

* 'iatapay-through-hyperswitch-cypress' of github.com:juspay/hyperswitch:
  feat(router): skip apple pay session call if the browser is not Safari (#5136)
  fix(opensearch): show search results only if user has access permission to the index  (#5097)
  chore(version): 2024.06.27.0
  feat(users): add endpoint for terminate auth select (#5135)
  feat(users): implemented openidconnect (#5124)
  feat(router): add payments manual-update api (#5045)
  fix(docs): open-api fix for payment response (#5103)
  refactor(connector): [AdyenPlatform]Throw 4xx instead of 5xx for source_balance_account (#4990)
  feat: realtime user analytics (#5098)
  refactor(connector): added amount conversion framework for cashtocode (#4857)
  feat(email): Add `auth_id` in email types and send `auth_id` in email URLs (#5120)
  refactor(connector): add amount framework to payme & Trustpay with googlePay, ApplePay for bluesnap, Noon & Trustpay (#4833)
  fix(connector): [BOA/CYBS] make risk information message optional (#5107)
  chore(version): 2024.06.25.1
  fix(router): skip serialize if none for assurance_details_required in googlepay session response (#5118)
  refactor: separate DB queries and HTML creation for payout links (#4967)
  feat(router): updated `last_used_at` field for apple pay and google pay for CITs (#5087)
  fix(payment_methods): use existing field value of `nick_name` in db if not sent during request (#5105)
  chore(version): 2024.06.25.0
pixincreate added a commit that referenced this pull request Jun 28, 2024
…ay/hyperswitch into refactor-error-handling-in-cypress

* 'iatapay-through-hyperswitch-cypress' of github.com:juspay/hyperswitch:
  chore: clean up
  feat(router): skip apple pay session call if the browser is not Safari (#5136)
  fix(opensearch): show search results only if user has access permission to the index  (#5097)
  chore(version): 2024.06.27.0
  feat(users): add endpoint for terminate auth select (#5135)
  feat(users): implemented openidconnect (#5124)
  feat(router): add payments manual-update api (#5045)
  fix(docs): open-api fix for payment response (#5103)
  refactor(connector): [AdyenPlatform]Throw 4xx instead of 5xx for source_balance_account (#4990)
  feat: realtime user analytics (#5098)
  refactor(connector): added amount conversion framework for cashtocode (#4857)
  feat(email): Add `auth_id` in email types and send `auth_id` in email URLs (#5120)
  refactor(connector): add amount framework to payme & Trustpay with googlePay, ApplePay for bluesnap, Noon & Trustpay (#4833)
  fix(connector): [BOA/CYBS] make risk information message optional (#5107)
  chore(version): 2024.06.25.1
  fix(router): skip serialize if none for assurance_details_required in googlepay session response (#5118)
  refactor: separate DB queries and HTML creation for payout links (#4967)
  feat(router): updated `last_used_at` field for apple pay and google pay for CITs (#5087)
  fix(payment_methods): use existing field value of `nick_name` in db if not sent during request (#5105)
  chore(version): 2024.06.25.0
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-payment-methods Area: Payment Methods C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FIX] use existing field value of nick_name in db if not sent during request
5 participants