Skip to content

Conversation

swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented May 13, 2025

Type of Change

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

Description

  • Integrate Razorpay's API directly
  • Payment Method - UPI Collect
  • Added a new flow create order
  • Added connector_request_reference_id in payment_attempt

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?

Using v2 API

  1. Create Organisation
  2. Create Merchant Account
  3. Create Business Profile
  4. Create API KEY
  5. Create Razorpay Connector
curl --location 'http://localhost:8080/v2/connector-accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-merchant-id: cloth_seller_LfNJ6bMzJarkrh2kCGbu' \
--header 'x-profile-id: pro_Y7riw0Lyz8GF7ZV778Pj' \
--header 'Authorization: admin-api-key=test_admin' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "razorpay",
     "connector_account_details": {
        "auth_type": "BodyKey",
        "api_key": "_",
        "key1": "_"
    },

    
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method_type": "upi",
            "payment_method_subtypes": [
                {
                    "payment_method_subtype": "upi_collect",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": {
                        "type" : "enable_only",
                        "list": ["INR"]
                    },
                    "accepted_countries": {
                        "type" : "enable_only",
                        "list": ["IN"]
                    },
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "city": "NY",
        "unit": "245"
    },
    "profile_id": "pro_Y7riw0Lyz8GF7ZV778Pj" 
}'
  1. Create UPI collect Payment
curl --location 'http://localhost:8080/v2/payments' \
--header 'api-key: _' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_Y7riw0Lyz8GF7ZV778Pj' \
--header 'Authorization: api-key=_' \
--data-raw '{
    "amount_details": {
        "order_amount": 100,
        "currency": "INR"
    },
    "capture_method":"automatic",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "payment_method_data": {
        "upi": {
            "upi_collect": {
                "vpa_id": "success@razorpay"
            }
        },
        "billing": {
            "address": {
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "city": "San Fransico",
                "state": "California",
                "zip": "94122",
                "country": "IN",
                "first_name": "Swangi",
                "last_name": "Kumari"
            },
            "phone": {
                "number": "8056594427",
                "country_code": "+91"
            },
            "email": "[email protected]"
        }
    },
    "payment_method_subtype": "upi_collect",
    "payment_method_type": "upi"
}'

Response

    "id": "12345_pay_0197345f8a97773399963e3616993a6d",
    "status": "requires_customer_action",
    "amount": {
        "order_amount": 100,
        "currency": "INR",
        "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
    },
    "customer_id": null,
    "connector": "razorpay",
    "created": "2025-06-03T05:59:26.106Z",
    "payment_method_data": {
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "IN",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "Swangi",
                "last_name": "Kumari"
            },
            "phone": {
                "number": "8056594427",
                "country_code": "+91"
            },
            "email": "[email protected]"
        }
    },
    "payment_method_type": "upi",
    "payment_method_subtype": "upi_collect",
    "connector_transaction_id": "pay_QccH6k6FydAlRu",
    "connector_reference_id": null,
    "merchant_connector_id": "mca_KPn3O1yDpcEjAQuGkKyY",
    "browser_info": null,
    "error": null,
    "shipping": null,
    "billing": null,
    "attempts": null,
    "connector_token_details": null,
    "payment_method_id": null,
    "next_action": {
        "type": "wait_screen_information",
        "display_from_timestamp": 1748930369789539000,
        "display_to_timestamp": 1748930669789539000,
        "poll_config": {
            "delay_in_secs": 5,
            "frequency": 5
        }
    },
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "authentication_type_applied": "no_three_ds",
    "is_iframe_redirection_enabled": null
}
  1. Psync
curl --location 'http://localhost:8080/v2/payments/12345_pay_0197345f8a97773399963e3616993a6d?force_sync=true' \
--header 'x-profile-id: pro_Y7riw0Lyz8GF7ZV778Pj' \
--header 'Authorization: api-key=_' \
--data ''

Response

{
    "id": "12345_pay_019734579f437140a230d7387ea89411",
    "status": "succeeded",
    "amount": {
        "order_amount": 100,
        "currency": "INR",
        "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": 100
    },
    "customer_id": "12345_cus_0197345793f67342a629d92ff75da55f",
    "connector": "razorpay",
    "created": "2025-06-03T05:50:47.108Z",
    "payment_method_data": {
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "IN",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "Swangi",
                "last_name": "Kumari"
            },
            "phone": {
                "number": "8056594427",
                "country_code": "+91"
            },
            "email": "[email protected]"
        }
    },
    "payment_method_type": "upi",
    "payment_method_subtype": "upi_collect",
    "connector_transaction_id": "pay_Qcc7y4GnfJNdkS",
    "connector_reference_id": null,
    "merchant_connector_id": "mca_KPn3O1yDpcEjAQuGkKyY",
    "browser_info": null,
    "error": null,
    "shipping": null,
    "billing": null,
    "attempts": null,
    "connector_token_details": null,
    "payment_method_id": null,
    "next_action": null,
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "authentication_type_applied": null,
    "is_iframe_redirection_enabled": null
}
  1. Create a Refund
curl --location 'http://localhost:8080/v2/refunds' \
--header 'x-profile-id: pro_Y7riw0Lyz8GF7ZV778Pj' \
--header 'Authorization: api-key=_' \
--header 'Content-Type: application/json' \
--header 'api-key: _' \
--data '{
  "payment_id": "12345_pay_0197346a13577d61a3a4e95699d565c1",
  "merchant_reference_id": "customer_1748931028",
  "amount": 100,
  "reason": "Customer returned product",
  "refund_type": "instant",
  "metadata": {
    "udf1": "value1",
    "new_customer": "true",
    "login_date": "2019-09-10T10:11:12Z"
  }
}'

Response

{
    "id": "12345_ref_0197346a6f2f7093a446ec2609b2d58e",
    "payment_id": "12345_pay_0197346a13577d61a3a4e95699d565c1",
    "merchant_reference_id": "customer_1748931028",
    "amount": 100,
    "currency": "INR",
    "status": "pending",
    "reason": "Customer returned product",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "error_details": {
        "code": "",
        "message": ""
    },
    "created_at": "2025-06-03T06:11:20.007Z",
    "updated_at": "2025-06-03T06:11:22.283Z",
    "connector": "razorpay",
    "profile_id": "pro_Y7riw0Lyz8GF7ZV778Pj",
    "merchant_connector_id": "mca_KPn3O1yDpcEjAQuGkKyY",
    "connector_refund_reference_id": null
}
  1. Refund Sync
curl --location 'http://localhost:8080/v2/refunds/12345_ref_0197346a6f2f7093a446ec2609b2d58e' \
--header 'Authorization: api-key=_' \
--header 'X-Profile-Id: pro_Y7riw0Lyz8GF7ZV778Pj' \
--header 'api-key: _'

Response

{
    "id": "12345_ref_0197346a6f2f7093a446ec2609b2d58e",
    "payment_id": "12345_pay_0197346a13577d61a3a4e95699d565c1",
    "merchant_reference_id": "customer_1748931028",
    "amount": 100,
    "currency": "INR",
    "status": "succeeded",
    "reason": "Customer returned product",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "error_details": {
        "code": "",
        "message": ""
    },
    "created_at": "2025-06-03T06:11:20.007Z",
    "updated_at": "2025-06-03T06:13:40.875Z",
    "connector": "razorpay",
    "profile_id": "pro_Y7riw0Lyz8GF7ZV778Pj",
    "merchant_connector_id": "mca_KPn3O1yDpcEjAQuGkKyY",
    "connector_refund_reference_id": null
}

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

Copy link

semanticdiff-com bot commented May 13, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/types/api/payments.rs  85% smaller
  crates/hyperswitch_interfaces/src/types.rs  83% smaller
  crates/hyperswitch_connectors/src/types.rs  80% smaller
  crates/hyperswitch_domain_models/src/types.rs  79% smaller
  crates/hyperswitch_connectors/src/default_implementations_v2.rs  77% smaller
  crates/payment_methods/src/configs/payment_connector_required_fields.rs  73% smaller
  crates/hyperswitch_interfaces/src/api/payments.rs  70% smaller
  crates/hyperswitch_interfaces/src/api/payments_v2.rs  58% smaller
  crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs  56% smaller
  crates/openapi/src/openapi.rs  41% smaller
  crates/openapi/src/openapi_v2.rs  41% smaller
  crates/router/src/types.rs  30% smaller
  crates/hyperswitch_connectors/src/connectors/razorpay.rs  22% smaller
  crates/router/src/core/payments/transformers.rs  18% smaller
  crates/hyperswitch_connectors/src/connectors/razorpay/transformers.rs  7% smaller
  crates/hyperswitch_connectors/src/default_implementations.rs  4% smaller
  crates/router/src/core/payments/operations/payment_confirm_intent.rs  1% smaller
  api-reference-v2/openapi_spec.json  0% smaller
  api-reference/openapi_spec.json  0% smaller
  config/config.example.toml Unsupported file format
  config/deployments/integration_test.toml Unsupported file format
  config/deployments/production.toml Unsupported file format
  config/deployments/sandbox.toml Unsupported file format
  config/development.toml Unsupported file format
  config/docker_compose.toml Unsupported file format
  config/payment_required_fields_v2.toml Unsupported file format
  crates/api_models/src/payments.rs  0% smaller
  crates/common_enums/src/connector_enums.rs  0% smaller
  crates/diesel_models/src/payment_attempt.rs  0% smaller
  crates/diesel_models/src/schema_v2.rs  0% smaller
  crates/hyperswitch_connectors/src/utils.rs  0% smaller
  crates/hyperswitch_domain_models/src/payments/payment_attempt.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_data.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_flow_types/payments.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_request_types.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_response_types.rs  0% smaller
  crates/hyperswitch_interfaces/src/api.rs  0% smaller
  crates/hyperswitch_interfaces/src/connector_integration_interface.rs Unsupported file format
  crates/router/src/compatibility/stripe/payment_intents/types.rs  0% smaller
  crates/router/src/compatibility/stripe/setup_intents/types.rs  0% smaller
  crates/router/src/core/payments.rs  0% smaller
  crates/router/src/core/payments/flows.rs  0% smaller
  crates/router/src/core/payments/flows/authorize_flow.rs  0% smaller
  crates/router/src/core/payments/operations/payment_response.rs  0% smaller
  crates/router/src/core/payments/operations/proxy_payments_intent.rs  0% smaller
  crates/router/src/types/api/verify_connector.rs  0% smaller
  crates/router/tests/connectors/utils.rs  0% smaller
  loadtest/config/development.toml Unsupported file format
  v2_migrations/2025-05-30-103514_add_connector_request_reference_id_in_payment_attempt/down.sql Unsupported file format
  v2_migrations/2025-05-30-103514_add_connector_request_reference_id_in_payment_attempt/up.sql Unsupported file format

@swangi-kumari swangi-kumari self-assigned this May 13, 2025
@swangi-kumari swangi-kumari added the A-connector-integration Area: Connector integration label May 13, 2025
@swangi-kumari swangi-kumari marked this pull request as ready for review May 13, 2025 13:25
@swangi-kumari swangi-kumari requested review from a team as code owners May 13, 2025 13:25
@swangi-kumari swangi-kumari changed the title feat(connector): Implement Razorpay UPI Intent feat(connector): Implement Razorpay UPI Collect May 14, 2025
@swangi-kumari swangi-kumari requested a review from a team as a code owner May 14, 2025 17:26
@Aishwariyaa-Anand Aishwariyaa-Anand requested a review from a team as a code owner May 28, 2025 09:16
@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Jun 2, 2025
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu left a comment

Choose a reason for hiding this comment

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

Connector changes look good.

@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 11, 2025
Merged via the queue into main with commit ee7bce0 Jun 11, 2025
23 of 28 checks passed
@likhinbopanna likhinbopanna deleted the razorpay-upi branch June 11, 2025 14:05
kashif-m pushed a commit that referenced this pull request Jun 11, 2025
Co-authored-by: Aishwariyaa Anand <[email protected]>
Co-authored-by: Aishwariyaa Anand <[email protected]>
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-connector-integration Area: Connector integration 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.

8 participants