Skip to content

Conversation

prajjwalkumar17
Copy link
Member

@prajjwalkumar17 prajjwalkumar17 commented Jun 24, 2024

Type of Change

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

Description

Adds a new column in Payment Intent for storing billing address details(Encrypted)
Screenshot 2024-07-05 at 12 06 21 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 billing_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 'http://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"
        }
    },
    "billing": {
        "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 billing_details.

2. Payment Update

curl --location 'http://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"
        }
    },
        "billing": {
        "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 billing_details.

3. Payment Confirm

curl --location 'http://localhost:8080/payments/pay_rVW7YpmSmeRvDA0T0pW3/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: xxxxxx' \
--data-raw '{
    "email": "[email protected]",
     "billing": {
        "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 billing_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 M-database-changes Metadata: This PR involves database schema changes labels Jun 24, 2024
@prajjwalkumar17 prajjwalkumar17 added this to the June 2024 Release milestone Jun 24, 2024
@prajjwalkumar17 prajjwalkumar17 self-assigned this Jun 24, 2024
@prajjwalkumar17 prajjwalkumar17 requested review from a team as code owners June 24, 2024 04:39
Narayanbhat166
Narayanbhat166 previously approved these changes Jul 4, 2024
@prajjwalkumar17 prajjwalkumar17 requested a review from a team as a code owner July 5, 2024 04:15
@prajjwalkumar17 prajjwalkumar17 changed the title feat(core): billing_address_details inclusion in Payment Intent feat(core): billing_details inclusion in Payment Intent Jul 5, 2024
Comment on lines +224 to +231
let billing_details: Option<Address> = billing_address.as_ref().map(From::from);
payment_intent.billing_details = billing_details
.clone()
.async_and_then(|_| async {
create_encrypted_data(key_store, billing_details.clone()).await
})
.await;

Copy link
Contributor

Choose a reason for hiding this comment

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

here we are updating payment_intent in get trackers, and in other places we are updating payment_intent in update trackers. This can be made consistent

@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 5, 2024
Merged via the queue into main with commit ec01788 Jul 5, 2024
@likhinbopanna likhinbopanna deleted the feat/business_address_in_payment_intent branch July 5, 2024 13:33
pixincreate added a commit that referenced this pull request Jul 8, 2024
…ify-cypress

* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2024.07.08.0
  fix(connector): [adyen] remove browser info for mit and [paypal] add refund key in headers (#5225)
  chore(version): 2024.07.06.0
  feat(router): Pass the shipping email whenever the billing details are included in the session token response (#5228)
  fix(cypress): fix metadata missing while creating connector if not in auth (#5215)
  refactor: fix unit and documentation tests (#4754)
  feat(events): add hashed customer_email and feature_metadata (#5220)
  feat(events): Add payment metadata to hyperswitch-payment-intent-events (#5170)
  fix(analytics): using HashSet to represent the returned metrics (#5179)
  feat(core): billing_details inclusion in Payment Intent (#5090)
  feat(router): pass fields to indicate if the customer address details to be connector from wallets (#5210)
  fix(refunds): Add aliases on refund status for backwards compatibility (#5216)
  Feat(connector): [BRAINTREE] Implement Card Mandates (#5204)
Narayanbhat166 pushed a commit that referenced this pull request Jul 8, 2024
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
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