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

refactor(address): change address to domain address in application #6608

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

Narayanbhat166
Copy link
Member

@Narayanbhat166 Narayanbhat166 commented Nov 19, 2024

Type of Change

  • Refactoring

Description

A new type has been added to the domain models called Address. This type has been used in the application everywhere where we use address.

Motivation and Context

How did you test it?

  • Create a payment by passing the billing and shipping address
curl --location 'http://localhost:8080/v2/payments/create-intent' \
--header 'api-key: dev_WnAruI89ADcHyYBIs7qWS0DHCkpfcfBma1ubv4mWLK9CoaUCKaVbYvAQUEKycCO0' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_U0hvw0D9plClPdsoS1Gj' \
--data-raw '{
    "amount_details": {
        "order_amount": 100,
        "currency": "USD"
    },
    "billing": {
        "address": {
            "first_name": "John",
            "last_name": "Dough"
        },
        "email": "[email protected]"
    },
    "shipping": {
        "address": {
            "first_name": "John",
            "last_name": "Dough",
            "city": "Karwar",
            "zip": "581301",
            "state": "Karnataka"
        },
        "email": "[email protected]"
    }
}'
{
    "id": "12345_pay_01936eb3d8f27892b0fc10f02351516c",
    "status": "requires_payment_method",
    "amount_details": {
        "order_amount": 100,
        "currency": "USD",
        "shipping_cost": null,
        "order_tax_amount": null,
        "external_tax_calculation": "skip",
        "surcharge_calculation": "skip",
        "surcharge_amount": null,
        "tax_on_surcharge": null
    },
    "client_secret": "12345_pay_01936eb3d8f27892b0fc10f02351516c_secret_01936eb3d8f379e3ab40edeedf17445d",
    "profile_id": "pro_U0hvw0D9plClPdsoS1Gj",
    "merchant_reference_id": null,
    "routing_algorithm_id": null,
    "capture_method": "automatic",
    "authentication_type": "no_three_ds",
    "billing": {
        "address": {
            "city": null,
            "country": null,
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": null,
            "state": null,
            "first_name": "John",
            "last_name": "Dough"
        },
        "phone": null,
        "email": "[email protected]"
    },
    "shipping": {
        "address": {
            "city": "Karwar",
            "country": null,
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": "581301",
            "state": "Karnataka",
            "first_name": "John",
            "last_name": "Dough"
        },
        "phone": null,
        "email": "[email protected]"
    },
    "customer_id": null,
    "customer_present": "Present",
    "description": null,
    "return_url": null,
    "setup_future_usage": "on_session",
    "apply_mit_exemption": "Skip",
    "statement_descriptor": null,
    "order_details": null,
    "allowed_payment_method_types": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "payment_link_enabled": "Skip",
    "payment_link_config": null,
    "request_incremental_authorization": "default",
    "expires_on": "2024-11-27T17:53:20.531Z",
    "frm_metadata": null,
    "request_external_three_ds_authentication": "Skip"
}
  • Ensure that the billing address and shipping address are returned as expected

  • confirm the payment with payment method billing address

curl --location 'http://localhost:8080/v2/payments/12345_pay_01936ecc441b75819e855e842cc399fc/confirm-intent' \
--header 'x-client-secret: 12345_pay_01936ecc441b75819e855e842cc399fc_secret_01936ecc441c7c03a3cd39377ec07227' \
--header 'x-profile-id: pro_6Kx6DNIEgnKROYJ8ja9j' \
--header 'Content-Type: application/json' \
--header 'api-key: pk_dev_d088fde71ce44ae3b8deb6786c6a747e' \
--data '{
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "01",
            "card_exp_year": "25",
            "card_holder_name": "John Doe",
            "card_cvc": "100"
        },
        "billing": {
            "address": {
                "first_name": "John"
            }
        }
    },
    "payment_method_type": "card",
    "payment_method_subtype": "credit"
}'
{
    "id": "12345_pay_01936ecc441b75819e855e842cc399fc",
    "status": "succeeded",
    "amount": {
        "order_amount": 100,
        "currency": "USD",
        "shipping_cost": null,
        "order_tax_amount": null,
        "external_tax_calculation": "skip",
        "surcharge_calculation": "skip",
        "surcharge_amount": null,
        "tax_on_surcharge": null,
        "net_amount": 100,
        "amount_to_capture": null,
        "amount_capturable": 0,
        "amount_captured": null
    },
    "connector": "stripe",
    "client_secret": "12345_pay_01936ecc441b75819e855e842cc399fc_secret_01936ecc441c7c03a3cd39377ec07227",
    "created": "2024-11-27T18:05:00.828Z",
    "payment_method_data": {
        "billing": {
            "address": {
                "city": null,
                "country": null,
                "line1": null,
                "line2": null,
                "line3": null,
                "zip": null,
                "state": null,
                "first_name": "John",
                "last_name": null
            },
            "phone": null,
            "email": null
        }
    },
    "payment_method_type": "card",
    "payment_method_subtype": "credit",
    "next_action": null,
    "connector_transaction_id": "pi_3QPpbrD5R7gDAGff0I2xElva",
    "connector_reference_id": null,
    "merchant_connector_id": "mca_UNBvyDd9IHGPWPC3ORf5",
    "browser_info": null,
    "error": null
}
  • Ensure that the payment method billing address are returned as sent in the request

  • Retrieve the payment

curl --location 'http://localhost:8080/v2/payments/12345_pay_01936ecc441b75819e855e842cc399fc' \
--header 'x-profile-id: pro_6Kx6DNIEgnKROYJ8ja9j' \
--header 'api-key: dev_NoVyI0VIpxPwRC3NgYzQ7PFkhxex0bWSXrgDLHZZwu1seej1jhoNs22s0QDJBflS' \
--data ''
{
    "id": "12345_pay_01936ecc441b75819e855e842cc399fc",
    "status": "succeeded",
    "amount": {
        "order_amount": 100,
        "currency": "USD",
        "shipping_cost": null,
        "order_tax_amount": null,
        "external_tax_calculation": "skip",
        "surcharge_calculation": "skip",
        "surcharge_amount": null,
        "tax_on_surcharge": null,
        "net_amount": 100,
        "amount_to_capture": null,
        "amount_capturable": 0,
        "amount_captured": null
    },
    "connector": "stripe",
    "client_secret": "12345_pay_01936ecc441b75819e855e842cc399fc_secret_01936ecc441c7c03a3cd39377ec07227",
    "created": "2024-11-27T18:05:00.828Z",
    "payment_method_data": {
        "billing": {
            "address": {
                "city": null,
                "country": null,
                "line1": null,
                "line2": null,
                "line3": null,
                "zip": null,
                "state": null,
                "first_name": "John",
                "last_name": null
            },
            "phone": null,
            "email": null
        }
    },
    "payment_method_type": "card",
    "payment_method_subtype": "credit",
    "connector_transaction_id": "pi_3QPpbrD5R7gDAGff0I2xElva",
    "connector_reference_id": null,
    "merchant_connector_id": "mca_UNBvyDd9IHGPWPC3ORf5",
    "browser_info": null,
    "error": null,
    "shipping": {
        "address": {
            "city": "Karwar",
            "country": null,
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": "581301",
            "state": "Karnataka",
            "first_name": "John",
            "last_name": "Dough"
        },
        "phone": null,
        "email": "[email protected]"
    },
    "billing": {
        "address": {
            "city": null,
            "country": null,
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": null,
            "state": null,
            "first_name": "John",
            "last_name": "Dough"
        },
        "phone": null,
        "email": "[email protected]"
    }
}

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

@Narayanbhat166 Narayanbhat166 added the C-refactor Category: Refactor label Nov 19, 2024
@Narayanbhat166 Narayanbhat166 self-assigned this Nov 19, 2024
Copy link

semanticdiff-com bot commented Nov 19, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/connector/paypal/transformers.rs  89% smaller
  crates/router/src/core/payout_link.rs  85% smaller
  crates/router/src/core/payments/operations/payment_confirm.rs  82% smaller
  crates/router/src/core/payments/operations/payment_create.rs  82% smaller
  crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs  82% smaller
  crates/router/src/connector/utils.rs  77% smaller
  crates/router/src/compatibility/stripe/payment_intents/types.rs  74% smaller
  crates/router/src/connector/adyen/transformers.rs  73% smaller
  crates/router/src/connector/wellsfargo/transformers.rs  73% smaller
  crates/router/src/connector/riskified/transformers/api.rs  71% smaller
  crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs  69% smaller
  crates/hyperswitch_domain_models/src/address.rs  67% smaller
  crates/router/src/core/payouts.rs  66% smaller
  crates/router/src/types/transformers.rs  64% smaller
  crates/router/src/connector/gocardless/transformers.rs  58% smaller
  crates/router/src/core/payment_methods.rs  56% smaller
  crates/router/src/connector/cybersource/transformers.rs  45% smaller
  crates/router/tests/connectors/dlocal.rs  43% smaller
  crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs  41% smaller
  crates/router/tests/connectors/airwallex.rs  32% smaller
  crates/router/tests/connectors/multisafepay.rs  32% smaller
  crates/router/tests/connectors/wise.rs  32% smaller
  crates/router/tests/connectors/worldline.rs  32% smaller
  crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs  32% smaller
  crates/router/tests/connectors/adyen.rs  32% smaller
  crates/router/src/connector/netcetera/netcetera_types.rs  22% smaller
  crates/router/src/core/payments/transformers.rs  17% smaller
  crates/hyperswitch_domain_models/src/payments.rs  16% smaller
  crates/hyperswitch_domain_models/src/payments/payment_attempt.rs  15% smaller
  crates/router/tests/connectors/utils.rs  11% smaller
  crates/router/src/connector/wise/transformers.rs  4% smaller
  crates/hyperswitch_domain_models/src/router_request_types.rs  1% smaller
  crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs  1% smaller
  crates/router/tests/connectors/globalpay.rs  1% smaller
  api-reference-v2/openapi_spec.json  0% smaller
  crates/api_models/src/payments.rs  0% smaller
  crates/common_enums/src/enums.rs  0% smaller
  crates/hyperswitch_connectors/src/utils.rs  0% smaller
  crates/hyperswitch_domain_models/src/payment_address.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_request_types/authentication.rs  0% smaller
  crates/router/src/connector/bankofamerica/transformers.rs  0% smaller
  crates/router/src/connector/bluesnap/transformers.rs  0% smaller
  crates/router/src/connector/klarna/transformers.rs  0% smaller
  crates/router/src/core/authentication.rs  0% smaller
  crates/router/src/core/authentication/transformers.rs  0% smaller
  crates/router/src/core/payment_methods/surcharge_decision_configs.rs  0% smaller
  crates/router/src/core/payments.rs  0% smaller
  crates/router/src/core/payments/operations/payment_confirm_intent.rs  0% smaller
  crates/router/src/core/payments/operations/payment_get.rs  0% smaller
  crates/router/src/core/payments/operations/payment_response.rs  0% smaller
  crates/router/src/core/payments/operations/tax_calculation.rs  0% smaller
  crates/router/src/core/payments/routing.rs  0% smaller
  crates/router/src/core/payments/tokenization.rs  0% smaller
  crates/router/src/core/utils.rs  0% smaller
  crates/router/src/core/webhooks/incoming_v2.rs  0% smaller
  crates/router/src/types.rs  0% smaller
  crates/router/tests/connectors/aci.rs  0% smaller
  crates/router/tests/connectors/bitpay.rs  0% smaller
  crates/router/tests/connectors/bluesnap.rs  0% smaller
  crates/router/tests/connectors/cashtocode.rs  0% smaller
  crates/router/tests/connectors/coinbase.rs  0% smaller
  crates/router/tests/connectors/cryptopay.rs  0% smaller
  crates/router/tests/connectors/cybersource.rs  0% smaller
  crates/router/tests/connectors/forte.rs  0% smaller
  crates/router/tests/connectors/iatapay.rs  0% smaller
  crates/router/tests/connectors/opennode.rs  0% smaller
  crates/router/tests/connectors/payeezy.rs  0% smaller
  crates/router/tests/connectors/payme.rs  0% smaller
  crates/router/tests/connectors/trustpay.rs  0% smaller

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 21, 2024
Base automatically changed from add_address_for_v2 to main November 26, 2024 09:10
@Narayanbhat166 Narayanbhat166 marked this pull request as ready for review November 27, 2024 18:12
@Narayanbhat166 Narayanbhat166 requested review from a team as code owners November 27, 2024 18:12
@Narayanbhat166 Narayanbhat166 requested review from a team as code owners November 27, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-refactor Category: Refactor M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants