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(core): structure of split payments #6706

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

Conversation

swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented Dec 1, 2024

Type of Change

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

Description

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 Merchant Account
  2. Create API KEY
  3. Create Stripe Connector
curl --location 'http://localhost:8080/account/merchant_1733139894/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-feature: integ-custom' \
--header 'api-key: ______' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "stripe",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key": "_______"
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "payment_method_type": "klarna",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "affirm",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "afterpay_clearpay",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_debit",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ]
}'

I. Direct Charges

  1. Create charge on a Payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: ______' \
--data '{
    "amount": 200,
    "profile_id": "pro_zxqGZoX7GWtERcmSiOKz",
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "amount_to_capture": 200,
    "customer_id": "cust_no_pm",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "payment_method": "card",
    "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "12",
            "card_exp_year": "34",
            "card_holder_name": "joseph Doe",
            "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"
        }
    },
    "split_payments": {
        "stripe_split_payment": {
            "charge_type": "direct",
            "application_fees": 100,
            "transfer_account_id": "acct_1PDftAIhl7EEkW0O"
        }
    }
}'

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

@swangi-kumari swangi-kumari added A-core Area: Core flows C-refactor Category: Refactor labels Dec 1, 2024
@swangi-kumari swangi-kumari self-assigned this Dec 1, 2024
@swangi-kumari swangi-kumari requested review from a team as code owners December 1, 2024 19:17
Copy link

semanticdiff-com bot commented Dec 1, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/connector/stripe/transformers.rs  87% smaller
  crates/router/src/core/refunds/validator.rs  83% smaller
  crates/router/src/connector/stripe.rs  66% smaller
  crates/router/src/core/payments/helpers.rs  64% smaller
  crates/diesel_models/src/payment_intent.rs  61% smaller
  crates/diesel_models/src/refund.rs  58% smaller
  crates/api_models/src/refunds.rs  54% smaller
  crates/hyperswitch_domain_models/src/payments/payment_intent.rs  50% smaller
  api-reference-v2/openapi_spec.json  42% smaller
  crates/router/src/core/refunds/transformers.rs  42% smaller
  api-reference/openapi_spec.json  40% smaller
  crates/router/src/core/payments/operations/payment_create.rs  40% smaller
  crates/router/src/core/payments/transformers.rs  33% smaller
  crates/hyperswitch_domain_models/src/payments.rs  18% smaller
  crates/router/src/core/refunds.rs  16% smaller
  crates/hyperswitch_domain_models/src/router_request_types.rs  11% smaller
  crates/openapi/src/openapi.rs  9% smaller
  crates/openapi/src/openapi_v2.rs  9% smaller
  crates/router/src/core/utils.rs  8% smaller
  crates/api_models/src/payments.rs  5% smaller
  crates/router/src/core/payments/types.rs  2% smaller
  crates/api_models/src/enums.rs  0% smaller
  crates/common_enums/src/enums.rs  0% smaller
  crates/common_utils/src/types.rs  0% smaller
  crates/diesel_models/src/schema.rs  0% smaller
  crates/diesel_models/src/schema_v2.rs  0% smaller
  crates/router/src/db/refund.rs  0% smaller
  crates/router/src/types.rs  0% smaller
  crates/router/src/types/api/verify_connector.rs  0% smaller
  crates/router/src/utils/user/sample_data.rs  0% smaller
  crates/router/tests/connectors/utils.rs  0% smaller
  migrations/2024-11-22-091336_add_split_payments_in_payment_intent/down.sql Unsupported file format
  migrations/2024-11-22-091336_add_split_payments_in_payment_intent/up.sql Unsupported file format
  migrations/2024-11-28-103344_add_split_refunds/down.sql Unsupported file format
  migrations/2024-11-28-103344_add_split_refunds/up.sql Unsupported file format

@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Dec 1, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 2, 2024
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-refactor Category: Refactor M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant