Skip to content

feat(core): Add support for UPI #36

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

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

feat(core): Add support for UPI #36

wants to merge 2 commits into from

Conversation

ImSagnik007
Copy link
Contributor

@ImSagnik007 ImSagnik007 commented Jun 3, 2025

Description

Added support for UPI

Motivation and Context

Additional Changes

  • This PR modifies the API contract
  • This PR modifies application configuration/environment variables

How did you test it?

UPI Collect:

{
  "amount": 1000,
  "minor_amount": 1000,
  "currency": "INR",
  "email":"[email protected]",
  "payment_method": "UPI",
  "payment_method_data": {
    "upi": {
            "upi_collect": {
                "vpa_id": "abc@ybl"
            }
        }
  } ,
  "connector_request_reference_id": "ref_12345",
  "auth_type": "THREE_DS",
  "address": {
    "billing": {
      "phone": {
        "number": "1234567890",
        "country_code": "+1"
      },
    "email":"[email protected]"

    }
  },
  "request_incremental_authorization": false,
  "enrolled_for_3ds": true,
  "browser_info": {
      "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
      "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
      "language": "en-US",
      "color_depth": 24,
      "screen_height": 1080,
      "screen_width": 1920,
      "java_enabled": false
    }
}

Response:

{
    "resource_id": {
        "connector_transaction_id": "pay_Qio9rAa1OPrnj8"
    },
    "status": "AUTHENTICATION_PENDING",
    "next_action": {
        "wait_screen_info": {
            "display_from_timestamp": "1750282258350047000",
            "display_to_timestamp": "1750282558350047000",
            "poll_config": {
                "delay_in_secs": 5,
                "frequency": 5
            }
        }
    }
}

@ImSagnik007 ImSagnik007 requested review from a team as code owners June 3, 2025 09:22
#[derive(Default, Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "snake_case")]
pub enum UpiAction {
#[default]
Copy link
Member

Choose a reason for hiding this comment

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

why is default required?

authentication_channel,
}),
_ => {
// If the payment method is not card, we assume no authentication is required
Copy link
Member

Choose a reason for hiding this comment

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

This sounds sketchy

@@ -433,9 +441,9 @@ pub struct RazorpayPsyncResponse {
pub id: String,
pub entity: String,
pub amount: i64,
pub base_amount: i64,
pub base_amount: Option<i64>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not making this as MinorUnit?

@ImSagnik007 ImSagnik007 force-pushed the upi_support branch 2 times, most recently from f6291bf to 79d4488 Compare June 18, 2025 21:49
Ok(RazorpayPaymentRequest {
amount,
currency,
receipt: uuid::Uuid::new_v4().to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

here we should use item.router_data.connector_request_reference_id instead of generating a random id as we will loose track of it.

@@ -433,9 +451,9 @@ pub struct RazorpayPsyncResponse {
pub id: String,
pub entity: String,
pub amount: i64,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub amount: i64,
pub amount: MinorUnit,

pub currency: String,
pub base_currency: String,
pub base_currency: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub base_currency: Option<String>,
pub base_currency: Option<enums::Currency>,

Make this change at all the places

/// Frequency of the poll
pub frequency: u16,
}

#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct RazorpayErrorResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

Razorpay returns varying error formats (e.g. string or JSON), handle them using a enum.

pub method: PaymentMethodType,
pub card: PaymentMethodSpecificData,
#[serde(flatten)]
pub payment_method_specific_data: PaymentMethodSpecificData,
pub authentication: Option<AuthenticationDetails>,
pub browser: Option<BrowserInfo>,
pub ip: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub ip: String,
pub ip: Option<String>,

referer and user_agent is also an optional field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants