Skip to content

Conversation

Aishwariyaa-Anand
Copy link
Contributor

Type of Change

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

Description

  • Accept merchant_connector_credentials in the Request Body of Refunds create and retrieve
  • Add a new POST endpoint refunds_retrieve_with_gateway_creds

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?

  • Create Payment
curl --location 'http://localhost:8080/v2/payments' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_MZ7No2Au2o91fUbrWj08' \
--header 'X-Merchant-Id: cloth_seller_J3hxNSDRUbwimfSoYeEg' \
--data-raw '{
    "amount_details": {
        "order_amount": 100,
        "currency": "INR"
    },
    "merchant_connector_details": {
        "connector_name": "razorpay",
        "merchant_connector_creds": {
            "auth_type": "BodyKey",
            "api_key": "_",
            "key1": "_"
        }
    },
    "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_0197a0d312d471e0ba69036052e92244",
    "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-24T07:24:36.954Z",
    "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_Qkwwc2ZlELc25m",
    "connector_reference_id": null,
    "merchant_connector_id": null,
    "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": 1750749880460394000,
        "display_to_timestamp": 1750750180460394000,
        "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,
    "merchant_reference_id": null
}
  • Psync
curl --location 'http://localhost:8080/v2/payments/12345_pay_0197a0d312d471e0ba69036052e92244' \
--header 'x-profile-id: pro_MZ7No2Au2o91fUbrWj08' \
--header 'x-merchant-id: cloth_seller_J3hxNSDRUbwimfSoYeEg' \
--header 'Content-Type: application/json' \
--data '{
    "merchant_connector_details": {
        "connector_name": "razorpay",
        "merchant_connector_creds": {
            "auth_type": "BodyKey",
            "api_key": "_",
            "key1": "_"
        }
    },
    "force_sync" : true
}'

Response

{
    "id": "12345_pay_0197a0d312d471e0ba69036052e92244",
    "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": null,
    "connector": "razorpay",
    "created": "2025-06-24T07:24:36.954Z",
    "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_Qkwwc2ZlELc25m",
    "connector_reference_id": null,
    "merchant_connector_id": null,
    "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,
    "merchant_reference_id": null
}
  • Create Refund
curl --location 'http://localhost:8080/v2/refunds' \
--header 'x-merchant-id: cloth_seller_J3hxNSDRUbwimfSoYeEg' \
--header 'x-profile-id: pro_MZ7No2Au2o91fUbrWj08' \
--header 'Content-Type: application/json' \
--data '{
  "payment_id": "12345_pay_0197a0d312d471e0ba69036052e92244",
  "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"
  },
  "merchant_connector_details": {
        "connector_name": "razorpay",
        "merchant_connector_creds": {
            "auth_type": "BodyKey",
            "api_key": "_",
            "key1": "_"
        }
    }
}'

Response

{
    "id": "12345_ref_0197a0d34fb87872a8548d097294f8b4",
    "payment_id": "12345_pay_0197a0d312d471e0ba69036052e92244",
    "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-24T07:24:52.586Z",
    "updated_at": "2025-06-24T07:24:54.600Z",
    "connector": "razorpay",
    "profile_id": "pro_MZ7No2Au2o91fUbrWj08",
    "merchant_connector_id": null,
    "connector_refund_reference_id": null
}
  • Refund Retrieve
curl --location 'http://localhost:8080/v2/refunds/12345_ref_0197a0977b8e7160a7f4a2690fe4d0df' \
--header 'x-merchant-id: cloth_seller_J3hxNSDRUbwimfSoYeEg' \
--header 'x-profile-id: pro_MZ7No2Au2o91fUbrWj08' \
--header 'Content-Type: application/json' \
--data '{
    "merchant_connector_details": {
        "connector_name": "razorpay",
        "merchant_connector_creds": {
            "auth_type": "BodyKey",
            "api_key": "_",
            "key1": "_"
        }
    },
    "force_sync" : true
}'

Response

{
    "id": "12345_ref_0197a0977b8e7160a7f4a2690fe4d0df",
    "payment_id": "12345_pay_0197a097435b7813b8a4f7b6ed6968ba",
    "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-24T06:19:31.637Z",
    "updated_at": "2025-06-24T07:24:58.858Z",
    "connector": "razorpay",
    "profile_id": "pro_MZ7No2Au2o91fUbrWj08",
    "merchant_connector_id": null,
    "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

@Aishwariyaa-Anand Aishwariyaa-Anand self-assigned this Jun 24, 2025
@Aishwariyaa-Anand Aishwariyaa-Anand requested review from a team as code owners June 24, 2025 08:24
@Aishwariyaa-Anand Aishwariyaa-Anand added A-core Area: Core flows M-api-contract-changes Metadata: This PR involves API contract changes labels Jun 24, 2025
Copy link

semanticdiff-com bot commented Jun 24, 2025

@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Jun 24, 2025
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jun 24, 2025
sahkal
sahkal previously approved these changes Jun 25, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 26, 2025
Merged via the queue into main with commit b185d85 Jun 26, 2025
17 of 20 checks passed
@likhinbopanna likhinbopanna deleted the refunds-v2-tunnel branch June 26, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants