Skip to content

Conversation

swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented Jul 4, 2024

Type of Change

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

Description

  1. Add a new connector RazorPay
  2. Implement UPI payment method for RazorPay connector
  3. Implement Payments, Psync, Refund and Rsync flow.
  4. Dynamic field changes
  5. Wasm changes for Razorpay

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. MCA
{
    "connector_type": "fiz_operations",
    "connector_name": "razorpay",
     "connector_account_details": {
        "auth_type": "MultiAuthKey",
        "api_key": "",
        "key1": "",
        "api_secret": "",
        "key2": ""
    },

    "test_mode": false,
    "disabled": false,
     "payment_methods_enabled": [
        {
            "payment_method": "upi",
            "payment_method_types": [
                {
                    "payment_method_type": "upi_collect",
                    "payment_experience": "redirect_to_url",
                    "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"
    },
    "connector_webhook_details": {
        "merchant_secret": "dce1d767-7c28-429c-b0fe-9e0b9e91f962"
    },
    "business_country": "US",
    "business_label": "food"
}

  1. Create a UPI payment
{
  "amount": 5000,
  "currency": "INR",
  "confirm": true,
  "capture_method": "automatic",
  "capture_on": "2022-09-10T10:11:12Z",
  "amount_to_capture": 5000,
  "customer_id": "IatapayCustomer",
  "email": "[email protected]",
  "name": "John Doe",
  "phone": "999999999",
  "phone_country_code": "+1",
  "description": "Its my first payment request",
  "authentication_type": "no_three_ds",
  "return_url": "https://google.com",
  "payment_method": "upi",
  "payment_method_type": "upi_collect",
  "payment_method_data": {
    "upi": {
      "upi_collect": {
      "vpa_id": "9490419802@ybl"
      }
    }
  },
  "billing": {
    "address": {
      "line1": "1467",
      "line2": "Harrison Street",
      "line3": "Harrison Street",
      "city": "San Fransico",
      "state": "California",
      "zip": "94122",
      "country": "IN",
      "first_name": "joseph",
      "last_name": "Doe"
    },
    "phone": {
      "number": "8056594427",
      "country_code": "+91"
    }
  },
  "shipping": {
    "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"
    }
  },
  "statement_descriptor_name": "joseph",
  "statement_descriptor_suffix": "JS",
  "metadata": {
    "udf1": "value1",
    "new_customer": "true",
    "login_date": "2019-09-10T10:11:12Z"
  }
}

Response

{
    "payment_id": "pay_PDVLuuHW55p6F88Okhzt",
    "merchant_id": "merchant_1720168290",
    "status": "processing",
    "amount": 5000,
    "net_amount": 5000,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "razorpay",
    "client_secret": "pay_PDVLuuHW55p6F88Okhzt_secret_39DkG40Hl69JThCdaaWP",
    "created": "2024-07-05T11:34:08.746Z",
    "currency": "INR",
    "customer_id": "IatapayCustomer",
    "customer": {
        "id": "IatapayCustomer",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "upi",
    "payment_method_data": {
        "upi": {},
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "IN",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "upi_collect",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "IatapayCustomer",
        "created_at": 1720179248,
        "expires": 1720182848,
        "secret": "epk_cc3aa6ea418047cf8157111d65ddfc3d"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pay_OUw5ZSngJNtugG",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_PDVLuuHW55p6F88Okhzt_1",
    "payment_link": null,
    "profile_id": "pro_npE5WqUAZPrmyBy3LAP7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_kvq5ZF1P97WNOLYmXoY9",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-07-05T11:49:08.746Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-07-05T11:34:12.620Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null
}
  1. Do psync
curl --location 'http://localhost:8080/payments/{paymnet_id}?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: {}'

Response

{
    "payment_id": "pay_PDVLuuHW55p6F88Okhzt",
    "merchant_id": "merchant_1720168290",
    "status": "succeeded",
    "amount": 5000,
    "net_amount": 5000,
    "amount_capturable": 0,
    "amount_received": 5000,
    "connector": "razorpay",
    "client_secret": "pay_PDVLuuHW55p6F88Okhzt_secret_39DkG40Hl69JThCdaaWP",
    "created": "2024-07-05T11:34:08.746Z",
    "currency": "INR",
    "customer_id": "IatapayCustomer",
    "customer": {
        "id": "IatapayCustomer",
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "999999999",
        "phone_country_code": "+1"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "upi",
    "payment_method_data": {
        "upi": {},
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "IN",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "upi_collect",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "pay_OUw5ZSngJNtugG",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_PDVLuuHW55p6F88Okhzt_1",
    "payment_link": null,
    "profile_id": "pro_npE5WqUAZPrmyBy3LAP7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_kvq5ZF1P97WNOLYmXoY9",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-07-05T11:49:08.746Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-07-05T11:35:29.688Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null
}

  1. Create a Refund
{
  "payment_id": "pay_PDVLuuHW55p6F88Okhzt",
  "amount": 5000,
  "reason": "Customer returned product",
  "refund_type": "instant",
  "metadata": {
    "udf1": "value1",
    "new_customer": "true",
    "login_date": "2019-09-10T10:11:12Z"
  }
}

Response

{
    "refund_id": "ref_akdHLjC91nBG0RMAgWI9",
    "payment_id": "pay_0xDSZuiEPdiscJ1lZvzz",
    "amount": 5000,
    "currency": "INR",
    "status": "pending",
    "reason": "Customer returned product",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "error_message": null,
    "error_code": null,
    "created_at": "2024-07-05T09:34:08.282Z",
    "updated_at": "2024-07-05T09:34:08.282Z",
    "connector": "razorpay",
    "profile_id": "pro_npE5WqUAZPrmyBy3LAP7",
    "merchant_connector_id": "mca_kvq5ZF1P97WNOLYmXoY9",
    "charges": null
}

  1. Do Rsync
curl --location 'http://localhost:8080/refunds/{refund_id}' \
--header 'Accept: application/json' \
--header 'api-key: {}'

Response

{
    "refund_id": "ref_akdHLjC91nBG0RMAgWI9",
    "payment_id": "pay_0xDSZuiEPdiscJ1lZvzz",
    "amount": 5000,
    "currency": "INR",
    "status": "succeeded",
    "reason": "Customer returned product",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "error_message": null,
    "error_code": null,
    "created_at": "2024-07-05T09:34:08.282Z",
    "updated_at": "2024-07-05T09:34:08.282Z",
    "connector": "razorpay",
    "profile_id": "pro_npE5WqUAZPrmyBy3LAP7",
    "merchant_connector_id": "mca_kvq5ZF1P97WNOLYmXoY9",
    "charges": 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

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jul 4, 2024
@swangi-kumari swangi-kumari changed the title Razorpay feat(connector): [RazorPay] Add new connector and Implement payment flows for UPI payment method Jul 4, 2024
@swangi-kumari swangi-kumari added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement labels Jul 5, 2024
@swangi-kumari swangi-kumari marked this pull request as ready for review July 5, 2024 11:38
@swangi-kumari swangi-kumari requested review from a team as code owners July 5, 2024 11:38
Comment on lines 1177 to 1178
api_key="API Key"
key1 = "Merchant id"
Copy link
Contributor

Choose a reason for hiding this comment

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

The keys to Juspay should be fetched from env, should not be collected from the merchant

Ok(Self {
txn_detail_id: ref_id.to_string(),
txn_id: item.router_data.connector_request_reference_id.clone(),
payment_method_type: pm.to_string().to_uppercase(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Such fields should be enums going forward

SamraatBansal
SamraatBansal previously approved these changes Jul 9, 2024
SamraatBansal
SamraatBansal previously approved these changes Jul 9, 2024
Copy link
Contributor

@sai-harsha-vardhan sai-harsha-vardhan left a comment

Choose a reason for hiding this comment

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

Core changes LGTM

SanchithHegde
SanchithHegde previously approved these changes Jul 9, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jul 9, 2024
Merged via the queue into main with commit fdac313 Jul 9, 2024
@Gnanasundari24 Gnanasundari24 deleted the razorpay branch July 9, 2024 14:54
@kushwahashiv
Copy link

@swangi-kumari can you please provide me link to sample app which is consuming hyperswitch + UPI ? if it does not exist can you please point me to the doc which I can refer.

Thanks

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 C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants