juspay / hyperswitch

An open source payments switch written in Rust to make payments fast, reliable and affordable
https://hyperswitch.io/
Apache License 2.0
12.09k stars 1.27k forks source link

feat(core): billing_details inclusion in Payment Intent #5090

Closed prajjwalkumar17 closed 2 months ago

prajjwalkumar17 commented 3 months ago

Type of Change

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

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": "example@example.com"
    },
    "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": "example@example.com"
    },
    "email": "payme2@example.com"
}'
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": "guest@example.com",
     "billing": {
        "address": {
            "line1": "1467",
            "line2": "dumka"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "example@example.com"
    },
    "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