Skip to content

Conversation

Chethan-rao
Copy link
Contributor

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

Type of Change

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

Description

This PR provides support for passing card_cvc inside payment_method_data object along with payment_token during confirm call.
During /confirm, you can pass the card_cvc either in the root level of request or in payment_method_data as below

"payment_method_data": {
     "card_token": {
        "card_cvc": "456"
    }
},

We'll be deprecating the card_cvc field in root level later

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. Create a payment and save the card
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Mc1ONjiws7dsQFyiBG3SvkYRPtezHFnFoYmaL6j0oKXBUV1Od9JPsCl1N9t6glKD' \
--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": "26",
            "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. Hit list_customer_payment_method api to get the payment_token for the card saved due to above request.
  2. Now use the above token and pass card_cvc either in root level or in payment_method_data as below
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Mc1ONjiws7dsQFyiBG3SvkYRPtezHFnFoYmaL6j0oKXBUV1Od9JPsCl1N9t6glKD' \
--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_token": "token_5jbOoOvbxurophTnr1Q0",
    "payment_method_data": {
        "card_token": {
            "card_cvc": "456"
        }
    },
    "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"
}'

For testing purpose, i logged the card_cvc passed

Screenshot 2023-11-30 at 7 00 39 PM

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 S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-payment-methods Area: Payment Methods C-refactor Category: Refactor labels Nov 30, 2023
@Chethan-rao Chethan-rao added this to the November 2023 Release milestone Nov 30, 2023
@Chethan-rao Chethan-rao self-assigned this Nov 30, 2023
@Chethan-rao Chethan-rao requested review from a team as code owners November 30, 2023 13:42
@Chethan-rao Chethan-rao marked this pull request as draft November 30, 2023 18:54
@Chethan-rao Chethan-rao force-pushed the move-card-cvc-to-token-data branch from a5f31ae to 7881989 Compare November 30, 2023 19:20
@Chethan-rao Chethan-rao marked this pull request as ready for review November 30, 2023 19:25
@Chethan-rao Chethan-rao force-pushed the move-card-cvc-to-token-data branch from 7881989 to 47fda3e Compare November 30, 2023 19:38
@Chethan-rao Chethan-rao force-pushed the move-card-cvc-to-token-data branch from 47fda3e to 714ab73 Compare November 30, 2023 19:39
Copy link
Member

@SanchithHegde SanchithHegde left a comment

Choose a reason for hiding this comment

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

We'll be deprecating the card_cvc field in root level later

If deprecating the field, you can mark it deprecated in the OpenAPI spec as well, then remove the field entirely on a later date.

@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Dec 4, 2023
@likhinbopanna likhinbopanna added this pull request to the merge queue Dec 4, 2023
Merged via the queue into main with commit 3ce04ab Dec 4, 2023
@likhinbopanna likhinbopanna deleted the move-card-cvc-to-token-data branch December 4, 2023 07:23
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-refactor Category: Refactor
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

4 participants