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(core): addition of shipping address details in payment intent #5112

Merged
merged 49 commits into from
Jul 8, 2024

Conversation

prajjwalkumar17
Copy link
Contributor

@prajjwalkumar17 prajjwalkumar17 commented Jun 25, 2024

Type of Change

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

Description

Adds a new column in Payment Intent for storing shipping address details(Encrypted)
Screenshot 2024-06-25 at 12 18 20 PM

Additional Changes

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

The Db Migration:

ALTER TABLE payment_intent ADD COLUMN IF NOT EXISTS shipping_details BYTEA DEFAULT NULL;

Motivation and Context

How did you test it?

The testing scenarios and flow is as follow:

1. Payment Create

curl --location 'https://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: xxxxxx' \
--data-raw '{
    "amount": 6540,
    "currency": "EUR",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id":"uiuiuiui",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "13.232.74.226",
            "user_agent": "amet irure esse"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "NL",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}'
The new field should be added in DB in Payment Intent table, named as shipping_details.

2. Payment Update

curl --location 'https://localhost:8080/payments/pay_rVW7YpmSmeRvDA0T0pW3' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: xxxxx' \
--data-raw '{
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "10",
            "card_exp_year": "2035",
            "card_holder_name": "John Doe",
            "card_cvc": "123"
        }
    },
        "shipping": {
        "address": {
            "line1": "1467",
            "line2": "delhi",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "IN",
            "first_name": "pk",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "email": "[email protected]"
}'
The new field should be added in DB in Payment Intent table, named as shipping_details.

3. Payment Confirm

curl --location 'https://localhost:8080/payments/pay_rVW7YpmSmeRvDA0T0pW3/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: xxxxxx' \
--data-raw '{
    "email": "[email protected]",
     "shipping": {
        "address": {
            "line1": "1467",
            "line2": "dumka"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "[email protected]"
    },
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "4000003920000003",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_cvc": "123"
        }
    }
}'
The new field should be added in DB in Payment Intent table, named as shipping_details.

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

@prajjwalkumar17 prajjwalkumar17 added A-core Area: Core flows C-feature Category: Feature request or enhancement labels Jun 25, 2024
@prajjwalkumar17 prajjwalkumar17 added this to the June 2024 Release milestone Jun 25, 2024
@prajjwalkumar17 prajjwalkumar17 self-assigned this Jun 25, 2024
@prajjwalkumar17 prajjwalkumar17 requested review from a team as code owners June 25, 2024 06:49
@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Jun 25, 2024
@bernard-eugine bernard-eugine removed this from the June 2024 Release milestone Jul 1, 2024
lsampras
lsampras previously approved these changes Jul 5, 2024
Base automatically changed from feat/business_address_in_payment_intent to main July 5, 2024 13:33
@likhinbopanna likhinbopanna dismissed lsampras’s stale review July 5, 2024 13:33

The base branch was changed.

create_encrypted_data(
key_store,
payment_data.address.get_payment_billing().cloned(),
)
Copy link
Member

Choose a reason for hiding this comment

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

create another function which will take the data and encrypt it, and rename this function to indicate that this encrypts optional data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure this will be taken up in the very next PR.

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jul 8, 2024
Merged via the queue into main with commit 2d31d38 Jul 8, 2024
11 checks passed
@Gnanasundari24 Gnanasundari24 deleted the feat/shipping_address_details_in_payment_intent branch July 8, 2024 10:09
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-feature Category: Feature request or enhancement M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants