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

feat(payment_methods): receive card_holder_name in confirm flow when using token for payment #2982

Merged
merged 5 commits into from
Nov 28, 2023

Conversation

Chethan-rao
Copy link
Contributor

@Chethan-rao Chethan-rao commented Nov 25, 2023

Type of Change

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

Description

Currently, even though card_holder_name was empty, /confirm would occur without any error. But few connectors require card_holder_name to be sent.
This PR includes changes for adding new object CardToken in payment_method_data object which can be used to send the card_holder_name during /confirm flow along with the token.
The token will fetch the stored card from locker. If this response has a card_holder_name, then it proceeds as usual without any error. Else it will check whether any CardToken object inside payment_method_data is sent or not. If not then error is thrown, if present then we update the card object received from locker to include the card_holder_name passed in CardToken during /confirm flow

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 with saving the card. pass card_holder_name empty while saving
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_u67d5zdpJVfHQ5jRhWXNg5F0Wy8MhzG2STAeHBhIKJowJJxAuVtvwhB2lsL427C8' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "setup_future_usage": "on_session",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "",
            "card_cvc": "123"
        }
    },
    "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"
        }
    },
    "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": "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"
    },
    "business_label": "default",
    "business_country": "US"
}'
  1. Do list_customer_payment_method to get the payment_token
  2. Now when you use that token to do payment again, you will get below error

image

  1. Now pass the payment_method_data object passing the card_holder_name here along with token in confirm call
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_u67d5zdpJVfHQ5jRhWXNg5F0Wy8MhzG2STAeHBhIKJowJJxAuVtvwhB2lsL427C8' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer",
    "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_type": "credit",
    "payment_token": "token_PLmf9CALewF4hxRSCkC4",
    "payment_method_data": {
        "card_token": {
            "card_holder_name": "Joseph"
        }
    },
    "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"
        }
    },
    "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": "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"
    },
    "business_label": "default",
    "business_country": "US"
}'

If you see the response from confirm call, the payment_method_data object will have the card_holder_name passed above

image

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
  • I added a CHANGELOG entry if applicable

@Chethan-rao Chethan-rao added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-payment-methods Area: Payment Methods labels Nov 25, 2023
@Chethan-rao Chethan-rao added this to the November 2023 Release milestone Nov 25, 2023
@Chethan-rao Chethan-rao self-assigned this Nov 25, 2023
@Chethan-rao Chethan-rao requested review from a team as code owners November 25, 2023 14:20
@Chethan-rao Chethan-rao added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 25, 2023
@Chethan-rao Chethan-rao requested a review from a team November 28, 2023 10:26
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 28, 2023
Merged via the queue into main with commit e7ad3a4 Nov 28, 2023
10 of 12 checks passed
@Gnanasundari24 Gnanasundari24 deleted the get_card_token_data branch November 28, 2023 11:10
@Chethan-rao Chethan-rao restored the get_card_token_data branch November 28, 2023 11:14
lsampras pushed a commit that referenced this pull request Nov 28, 2023
…n using token for payment (#2982)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
@SanchithHegde SanchithHegde deleted the get_card_token_data branch December 3, 2023 17:28
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Dec 3, 2023
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-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

[FEATURE] receive card_holder_name in confirm flow when using token for payment
6 participants