Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(connector): [RazorPay] Add new connector and Implement payment flows for UPI payment method (#5200)
Swangi Kumarifdac31324110
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.jsonindex 929952e8c1..04a1083891 100644--- a/api-reference/openapi_spec.json+++ b/api-reference/openapi_spec.json@@ -7763,6 +7763,7 @@"powertranz","prophetpay","rapyd",+ "razorpay","shift4","square","stax",@@ -9757,6 +9758,12 @@"enum": ["user_date_of_birth"]+ },+ {+ "type": "string",+ "enum": [+ "user_vpa_id"+ ]}],"description": "Possible field type of required fields in payment_method_data"@@ -19468,6 +19475,7 @@"powertranz","prophetpay","rapyd",+ "razorpay","riskified","shift4","signifyd",diff --git a/config/config.example.toml b/config/config.example.tomlindex fd6e34f533..e4a15e7fb1 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -230,6 +230,7 @@ placetopay.base_url = "https://test.placetopay.com/rest/gateway"powertranz.base_url = "https://staging.ptranz.com/api/"prophetpay.base_url = "https://ccm-thirdparty.cps.golf/"rapyd.base_url = "https://sandboxapi.rapyd.net"+razorpay.base_url = "https://sandbox.juspay.in/"riskified.base_url = "https://sandbox.riskified.com/api"shift4.base_url = "https://api.shift4.com/"signifyd.base_url = "https://api.signifyd.com/"@@ -477,6 +478,9 @@ boleto = { country = "BR", currency = "BRL" }[pm_filters.volt]open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" }+[pm_filters.razorpay]+upi_collect = {country = "IN", currency = "INR"}+[pm_filters.zen]credit = { not_available_flows = { capture_method = "manual" } }debit = { not_available_flows = { capture_method = "manual" } }diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex 71b3d1f8ec..f3acbb4a85 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -74,6 +74,7 @@ placetopay.base_url = "https://test.placetopay.com/rest/gateway"powertranz.base_url = "https://staging.ptranz.com/api/"prophetpay.base_url = "https://ccm-thirdparty.cps.golf/"rapyd.base_url = "https://sandboxapi.rapyd.net"+razorpay.base_url = "https://sandbox.juspay.in/"shift4.base_url = "https://api.shift4.com/"signifyd.base_url = "https://api.signifyd.com/"riskified.base_url = "https://sandbox.riskified.com/api"@@ -287,6 +288,9 @@ sofort = { country = "AT,BE,DE,IT,NL,ES", currency = "EUR" }[pm_filters.volt]open_banking_uk = {country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL"}+[pm_filters.razorpay]+upi_collect = {country = "IN", currency = "INR"}+[pm_filters.worldpay]apple_pay.country = "AU,CN,HK,JP,MO,MY,NZ,SG,TW,AM,AT,AZ,BY,BE,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GR,GL,GG,HU,IS,IE,IM,IT,KZ,JE,LV,LI,LT,LU,MT,MD,MC,ME,NL,NO,PL,PT,RO,SM,RS,SK,SI,ES,SE,CH,UA,GB,AR,CO,CR,BR,MX,PE,BH,IL,JO,KW,PS,QA,SA,AE,CA,UM,US"google_pay.country = "AL,DZ,AS,AO,AG,AR,AU,AT,AZ,BH,BY,BE,BR,BG,CA,CL,CO,HR,CZ,DK,DO,EG,EE,FI,FR,DE,GR,HK,HU,IN,ID,IE,IL,IT,JP,JO,KZ,KE,KW,LV,LB,LT,LU,MY,MX,NL,NZ,NO,OM,PK,PA,PE,PH,PL,PT,QA,RO,RU,SA,SG,SK,ZA,ES,LK,SE,CH,TW,TH,TR,UA,AE,GB,US,UY,VN"diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 03c328294f..45a7c093ab 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -78,6 +78,7 @@ placetopay.base_url = "https://checkout.placetopay.com/rest/gateway"powertranz.base_url = "https://staging.ptranz.com/api/"prophetpay.base_url = "https://ccm-thirdparty.cps.golf/"rapyd.base_url = "https://sandboxapi.rapyd.net"+razorpay.base_url = "https://api.juspay.in"riskified.base_url = "https://wh.riskified.com/api/"shift4.base_url = "https://api.shift4.com/"signifyd.base_url = "https://api.signifyd.com/"@@ -306,6 +307,9 @@ sofort = { country = "AT,BE,DE,IT,NL,ES", currency = "EUR" }[pm_filters.volt]open_banking_uk = {country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL"}+[pm_filters.razorpay]+upi_collect = {country = "IN", currency = "INR"}+[pm_filters.worldpay]apple_pay.country = "AU,CN,HK,JP,MO,MY,NZ,SG,TW,AM,AT,AZ,BY,BE,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GR,GL,GG,HU,IS,IE,IM,IT,KZ,JE,LV,LI,LT,LU,MT,MD,MC,ME,NL,NO,PL,PT,RO,SM,RS,SK,SI,ES,SE,CH,UA,GB,AR,CO,CR,BR,MX,PE,BH,IL,JO,KW,PS,QA,SA,AE,CA,UM,US"google_pay.country = "AL,DZ,AS,AO,AG,AR,AU,AT,AZ,BH,BY,BE,BR,BG,CA,CL,CO,HR,CZ,DK,DO,EG,EE,FI,FR,DE,GR,HK,HU,IN,ID,IE,IL,IT,JP,JO,KZ,KE,KW,LV,LB,LT,LU,MY,MX,NL,NZ,NO,OM,PK,PA,PE,PH,PL,PT,QA,RO,RU,SA,SG,SK,ZA,ES,LK,SE,CH,TW,TH,TR,UA,AE,GB,US,UY,VN"diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex a08cefdb41..09ee7a4d3f 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -78,6 +78,7 @@ placetopay.base_url = "https://test.placetopay.com/rest/gateway"powertranz.base_url = "https://staging.ptranz.com/api/"prophetpay.base_url = "https://ccm-thirdparty.cps.golf/"rapyd.base_url = "https://sandboxapi.rapyd.net"+razorpay.base_url = "https://sandbox.juspay.in/"riskified.base_url = "https://sandbox.riskified.com/api"shift4.base_url = "https://api.shift4.com/"signifyd.base_url = "https://api.signifyd.com/"@@ -310,6 +311,9 @@ sofort = { country = "AT,BE,DE,IT,NL,ES", currency = "EUR" }[pm_filters.volt]open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" }+[pm_filters.razorpay]+upi_collect = {country = "IN", currency = "INR"}+[pm_filters.worldpay]apple_pay.country = "AU,CN,HK,JP,MO,MY,NZ,SG,TW,AM,AT,AZ,BY,BE,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GR,GL,GG,HU,IS,IE,IM,IT,KZ,JE,LV,LI,LT,LU,MT,MD,MC,ME,NL,NO,PL,PT,RO,SM,RS,SK,SI,ES,SE,CH,UA,GB,AR,CO,CR,BR,MX,PE,BH,IL,JO,KW,PS,QA,SA,AE,CA,UM,US"google_pay.country = "AL,DZ,AS,AO,AG,AR,AU,AT,AZ,BH,BY,BE,BR,BG,CA,CL,CO,HR,CZ,DK,DO,EG,EE,FI,FR,DE,GR,HK,HU,IN,ID,IE,IL,IT,JP,JO,KZ,KE,KW,LV,LB,LT,LU,MY,MX,NL,NZ,NO,OM,PK,PA,PE,PH,PL,PT,QA,RO,RU,SA,SG,SK,ZA,ES,LK,SE,CH,TW,TH,TR,UA,AE,GB,US,UY,VN"diff --git a/config/development.toml b/config/development.tomlindex 31a507a69a..ade64172f2 100644--- a/config/development.toml+++ b/config/development.toml@@ -225,6 +225,7 @@ placetopay.base_url = "https://test.placetopay.com/rest/gateway"powertranz.base_url = "https://staging.ptranz.com/api/"prophetpay.base_url = "https://ccm-thirdparty.cps.golf/"rapyd.base_url = "https://sandboxapi.rapyd.net"+razorpay.base_url = "https://sandbox.juspay.in/"riskified.base_url = "https://sandbox.riskified.com/api"shift4.base_url = "https://api.shift4.com/"signifyd.base_url = "https://api.signifyd.com/"@@ -336,6 +337,9 @@ cashapp = { country = "US", currency = "USD" }[pm_filters.volt]open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" }+[pm_filters.razorpay]+upi_collect = {country = "IN", currency = "INR"}+[pm_filters.adyen]google_pay = { country = "AU,NZ,JP,HK,SG,MY,TH,VN,BH,AE,KW,BR,ES,GB,SE,NO,SK,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,RO,HR,LI,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,TR,IS,CA,US", currency = "AED,ALL,AMD,ANG,AOA,ARS,AUD,AWG,AZN,BAM,BBD,BDT,BGN,BHD,BMD,BND,BOB,BRL,BSD,BWP,BYN,BZD,CAD,CHF,CLP,CNY,COP,CRC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EGP,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GYD,HKD,HNL,HTG,HUF,IDR,ILS,INR,IQD,JMD,JOD,JPY,KES,KGS,KHR,KMF,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LYD,MAD,MDL,MKD,MMK,MNT,MOP,MRU,MUR,MVR,MWK,MXN,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SEK,SGD,SHP,SLE,SOS,SRD,STN,SVC,SZL,THB,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,UYU,UZS,VES,VND,VUV,WST,XAF,XCD,XOF,XPF,YER,ZAR,ZMW" }apple_pay = { country = "AU,NZ,CN,JP,HK,SG,MY,BH,AE,KW,BR,ES,GB,SE,NO,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,LI,UA,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD" }diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex e2ac7b9ed9..b11ca00574 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -161,6 +161,7 @@ placetopay.base_url = "https://test.placetopay.com/rest/gateway"powertranz.base_url = "https://staging.ptranz.com/api/"prophetpay.base_url = "https://ccm-thirdparty.cps.golf/"rapyd.base_url = "https://sandboxapi.rapyd.net"+razorpay.base_url = "https://sandbox.juspay.in/"riskified.base_url = "https://sandbox.riskified.com/api"shift4.base_url = "https://api.shift4.com/"signifyd.base_url = "https://api.signifyd.com/"@@ -346,6 +347,9 @@ sofort = { country = "AT,BE,DE,ES,CH,NL", currency = "CHF,EUR" }[pm_filters.volt]open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" }+[pm_filters.razorpay]+upi_collect = {country = "IN", currency = "INR"}+[pm_filters.zen]credit = { not_available_flows = { capture_method = "manual" } }debit = { not_available_flows = { capture_method = "manual" } }diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rsindex 9a14475380..82db395677 100644--- a/crates/api_models/src/enums.rs+++ b/crates/api_models/src/enums.rs@@ -121,6 +121,7 @@ pub enum Connector {Powertranz,Prophetpay,Rapyd,+ Razorpay,Shift4,Square,Stax,@@ -252,6 +253,7 @@ impl Connector {| Self::Zsl| Self::Signifyd| Self::Plaid+ | Self::Razorpay| Self::Riskified| Self::Threedsecureio// | Self::Datatrans@@ -466,6 +468,7 @@ pub enum FieldType {Text,DropDown { options: Vec<String> },UserDateOfBirth,+ UserVpaId,}impl FieldType {@@ -551,6 +554,7 @@ impl PartialEq for FieldType {},) => options_self.eq(options_other),(Self::UserDateOfBirth, Self::UserDateOfBirth) => true,+ (Self::UserVpaId, Self::UserVpaId) => true,_unused => false,}}diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 08b13b1a5b..e4f671a859 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -161,6 +161,7 @@ pub enum RoutableConnectors {Powertranz,Prophetpay,Rapyd,+ Razorpay,Riskified,Shift4,Signifyd,diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rsindex 4f6238c77d..9f29693928 100644--- a/crates/connector_configs/src/connector.rs+++ b/crates/connector_configs/src/connector.rs@@ -183,6 +183,7 @@ pub struct ConnectorConfig {pub plaid: Option<ConnectorTomlConfig>,pub powertranz: Option<ConnectorTomlConfig>,pub prophetpay: Option<ConnectorTomlConfig>,+ pub razorpay: Option<ConnectorTomlConfig>,pub riskified: Option<ConnectorTomlConfig>,pub rapyd: Option<ConnectorTomlConfig>,pub shift4: Option<ConnectorTomlConfig>,@@ -312,6 +313,7 @@ impl ConnectorConfig {Connector::Placetopay => Ok(connector_data.placetopay),Connector::Plaid => Ok(connector_data.plaid),Connector::Powertranz => Ok(connector_data.powertranz),+ Connector::Razorpay => Ok(connector_data.razorpay),Connector::Rapyd => Ok(connector_data.rapyd),Connector::Riskified => Ok(connector_data.riskified),Connector::Shift4 => Ok(connector_data.shift4),diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.tomlindex d4623ba214..4e0003f857 100644--- a/crates/connector_configs/toml/development.toml+++ b/crates/connector_configs/toml/development.toml@@ -1170,6 +1170,13 @@ api_key="key"brand_id="Brand ID"destination_account_number="Destination Account Number"+[razorpay]+[razorpay.upi]+ payment_method_type = "upiCollect"+[razorpay.connector_auth.BodyKey]+api_key="Razorpay Id"+key1 = "Razorpay Secret"+[mollie][[mollie.credit]]payment_method_type = "Mastercard"diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.tomlindex fba2c96884..8e1057b43e 100644--- a/crates/connector_configs/toml/production.toml+++ b/crates/connector_configs/toml/production.toml@@ -975,6 +975,12 @@ api_key="key"brand_id="Brand ID"destination_account_number="Destination Account Number"+[razorpay]+[razorpay.upi]+ payment_method_type = "upiCollect"+[razorpay.connector_auth.BodyKey]+api_key="Razorpay Id"+key1 = "Razorpay Secret"[mollie][[mollie.credit]]diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.tomlindex 22f280e91b..a37d720362 100644--- a/crates/connector_configs/toml/sandbox.toml+++ b/crates/connector_configs/toml/sandbox.toml@@ -1170,6 +1170,13 @@ api_key="key"brand_id="Brand ID"destination_account_number="Destination Account Number"+[razorpay]+[razorpay.upi]+ payment_method_type = "upiCollect"+[razorpay.connector_auth.BodyKey]+api_key="Razorpay Id"+key1 = "Razorpay Secret"+[mollie][[mollie.credit]]payment_method_type = "Mastercard"diff --git a/crates/hyperswitch_interfaces/src/configs.rs b/crates/hyperswitch_interfaces/src/configs.rsindex 6d9024bc1c..74684fd5ab 100644--- a/crates/hyperswitch_interfaces/src/configs.rs+++ b/crates/hyperswitch_interfaces/src/configs.rs@@ -1,4 +1,5 @@//! Configs interface+use masking::Secret;use router_derive;use serde::Deserialize;use storage_impl::errors::ApplicationError;@@ -63,6 +64,7 @@ pub struct Connectors {pub powertranz: ConnectorParams,pub prophetpay: ConnectorParams,pub rapyd: ConnectorParams,+ pub razorpay: ConnectorParamsWithKeys,pub riskified: ConnectorParams,pub shift4: ConnectorParams,pub signifyd: ConnectorParams,@@ -90,6 +92,18 @@ pub struct ConnectorParams {pub secondary_base_url: Option<String>,}+/// struct ConnectorParamsWithKeys+#[derive(Debug, Deserialize, Clone, Default, router_derive::ConfigValidate)]+#[serde(default)]+pub struct ConnectorParamsWithKeys {+ /// base url+ pub base_url: String,+ /// api key+ pub api_key: Secret<String>,+ /// merchant ID+ pub merchant_id: Secret<String>,+}+/// struct ConnectorParamsWithModeType#[derive(Debug, Deserialize, Clone, Default, router_derive::ConfigValidate)]#[serde(default)]diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rsindex 4b8863547c..bab567899f 100644--- a/crates/router/src/configs/defaults.rs+++ b/crates/router/src/configs/defaults.rs@@ -8641,6 +8641,36 @@ impl Default for super::settings::RequiredFields {),])),),+ (+ enums::PaymentMethod::Upi,+ PaymentMethodType(HashMap::from([+ (+ enums::PaymentMethodType::UpiCollect,+ ConnectorFields {+ fields: HashMap::from([+ (+ enums::Connector::Razorpay,+ RequiredFieldFinal {+ mandate : HashMap::new(),+ non_mandate : HashMap::new(),+ common : HashMap::from([+ (+ "payment_method_data.upi.upi_collect.vpa_id".to_string(),+ RequiredFieldInfo {+ required_field: "payment_method_data.upi.upi_collect.vpa_id".to_string(),+ display_name: "vpa_id".to_string(),+ field_type: enums::FieldType::UserVpaId,+ value: None,+ }+ ),+ ]),+ }+ ),+ ]),+ },+ ),+ ])),+ ),(enums::PaymentMethod::BankDebit,PaymentMethodType(HashMap::from([(diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rsindex 03f295518b..12421ab0fa 100644--- a/crates/router/src/connector.rs+++ b/crates/router/src/connector.rs@@ -49,6 +49,7 @@ pub mod placetopay;pub mod powertranz;pub mod prophetpay;pub mod rapyd;+pub mod razorpay;pub mod riskified;pub mod shift4;pub mod signifyd;@@ -80,8 +81,8 @@ pub use self::{multisafepay::Multisafepay, netcetera::Netcetera, nexinets::Nexinets, nmi::Nmi, noon::Noon,nuvei::Nuvei, opayo::Opayo, opennode::Opennode, payeezy::Payeezy, payme::Payme, payone::Payone,paypal::Paypal, payu::Payu, placetopay::Placetopay, powertranz::Powertranz,- prophetpay::Prophetpay, rapyd::Rapyd, riskified::Riskified, shift4::Shift4, signifyd::Signifyd,- square::Square, stax::Stax, stripe::Stripe, threedsecureio::Threedsecureio, trustpay::Trustpay,- tsys::Tsys, volt::Volt, wise::Wise, worldline::Worldline, worldpay::Worldpay, zen::Zen,- zsl::Zsl,+ prophetpay::Prophetpay, rapyd::Rapyd, razorpay::Razorpay, riskified::Riskified, shift4::Shift4,+ signifyd::Signifyd, square::Square, stax::Stax, stripe::Stripe, threedsecureio::Threedsecureio,+ trustpay::Trustpay, tsys::Tsys, volt::Volt, wise::Wise, worldline::Worldline,+ worldpay::Worldpay, zen::Zen, zsl::Zsl,};diff --git a/crates/router/src/connector/razorpay.rs b/crates/router/src/connector/razorpay.rsnew file mode 100644index 0000000000..836f71e3c1--- /dev/null+++ b/crates/router/src/connector/razorpay.rs@@ -0,0 +1,670 @@+pub mod transformers;++use common_utils::{+ ext_traits::ByteSliceExt,+ types::{AmountConvertor, FloatMajorUnit, FloatMajorUnitForConnector},+};+use error_stack::{Report, ResultExt};+use masking::ExposeInterface;+use transformers as razorpay;++use super::utils::{self as connector_utils};+use crate::{+ configs::settings,+ consts,+ core::errors::{self, CustomResult},+ events::connector_api_logs::ConnectorEvent,+ headers, logger,+ services::{+ self,+ request::{self, Mask},+ ConnectorIntegration, ConnectorValidation,+ },+ types::{+ self,+ api::{self, ConnectorCommon, ConnectorCommonExt},+ ErrorResponse, RequestContent, Response,+ },+ utils::BytesExt,+};++#[derive(Clone)]+pub struct Razorpay {+ amount_converter: &'static (dyn AmountConvertor<Output = FloatMajorUnit> + Sync),+}++impl Razorpay {+ pub fn new() -> &'static Self {+ &Self {+ amount_converter: &FloatMajorUnitForConnector,+ }+ }+}++impl api::Payment for Razorpay {}+impl api::PaymentSession for Razorpay {}+impl api::ConnectorAccessToken for Razorpay {}+impl api::MandateSetup for Razorpay {}+impl api::PaymentAuthorize for Razorpay {}+impl api::PaymentSync for Razorpay {}+impl api::PaymentCapture for Razorpay {}+impl api::PaymentVoid for Razorpay {}+impl api::Refund for Razorpay {}+impl api::RefundExecute for Razorpay {}+impl api::RefundSync for Razorpay {}+impl api::PaymentToken for Razorpay {}++impl+ ConnectorIntegration<+ api::PaymentMethodToken,+ types::PaymentMethodTokenizationData,+ types::PaymentsResponseData,+ > for Razorpay+{+ // Not Implemented (R)+}++impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Razorpay+where+ Self: ConnectorIntegration<Flow, Request, Response>,+{+ fn build_headers(+ &self,+ _req: &types::RouterData<Flow, Request, Response>,+ connectors: &settings::Connectors,+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {+ let header = vec![+ (+ headers::CONTENT_TYPE.to_string(),+ self.get_content_type().to_string().into(),+ ),+ (+ headers::AUTHORIZATION.to_string(),+ format!("Basic {}", connectors.razorpay.api_key.clone().expose()).into_masked(),+ ),+ ];+ Ok(header)+ }+}++impl ConnectorCommon for Razorpay {+ fn id(&self) -> &'static str {+ "razorpay"+ }++ fn get_currency_unit(&self) -> api::CurrencyUnit {+ api::CurrencyUnit::Base+ }++ fn common_get_content_type(&self) -> &'static str {+ "application/json"+ }++ fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {+ connectors.razorpay.base_url.as_ref()+ }++ fn build_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ let response: Result<razorpay::ErrorResponse, Report<common_utils::errors::ParsingError>> =+ res.response.parse_struct("Razorpay ErrorResponse");++ match response {+ Ok(response_data) => {+ event_builder.map(|i| i.set_error_response_body(&response_data));+ router_env::logger::info!(connector_response=?response_data);+ match response_data {+ razorpay::ErrorResponse::RazorpayErrorResponse(error_response) => {+ Ok(ErrorResponse {+ status_code: res.status_code,+ code: error_response.error_info.code,+ message: error_response+ .error_info+ .fields+ .iter()+ .map(|error| error.field_name.clone())+ .collect::<Vec<String>>()+ .join(" & "),+ reason: Some(+ error_response+ .error_info+ .fields+ .iter()+ .map(|error| error.field_name.clone())+ .collect::<Vec<String>>()+ .join(" & "),+ ),+ attempt_status: None,+ connector_transaction_id: None,+ })+ }+ razorpay::ErrorResponse::RazorpayStringError(error_string) => {+ Ok(ErrorResponse {+ status_code: res.status_code,+ code: consts::NO_ERROR_CODE.to_string(),+ message: error_string.clone(),+ reason: Some(error_string.clone()),+ attempt_status: None,+ connector_transaction_id: None,+ })+ }+ }+ }+ Err(error_msg) => {+ event_builder.map(|event| event.set_error(serde_json::json!({"error": res.response.escape_ascii().to_string(), "status_code": res.status_code})));+ logger::error!(deserialization_error =? error_msg);+ crate::utils::handle_json_response_deserialization_failure(res, "razorpay")+ }+ }+ }+}++impl ConnectorValidation for Razorpay {+ //TODO: implement functions when support enabled+}++impl ConnectorIntegration<api::Session, types::PaymentsSessionData, types::PaymentsResponseData>+ for Razorpay+{+ //TODO: implement sessions flow+}++impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, types::AccessToken>+ for Razorpay+{+}++impl+ ConnectorIntegration<+ api::SetupMandate,+ types::SetupMandateRequestData,+ types::PaymentsResponseData,+ > for Razorpay+{+}++impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::PaymentsResponseData>+ for Razorpay+{+ fn get_headers(+ &self,+ req: &types::PaymentsAuthorizeRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &types::PaymentsAuthorizeRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Ok(format!(+ "{}gatewayProxy/txn/sendCollect",+ self.base_url(connectors)+ ))+ }++ fn get_request_body(+ &self,+ req: &types::PaymentsAuthorizeRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ let amount = connector_utils::convert_amount(+ self.amount_converter,+ req.request.minor_amount,+ req.request.currency,+ )?;+ let connector_router_data = razorpay::RazorpayRouterData::try_from((amount, req))?;+ let connector_req =+ razorpay::RazorpayPaymentsRequest::try_from((&connector_router_data, connectors))?;+ Ok(RequestContent::Json(Box::new(connector_req)))+ }++ fn build_request(+ &self,+ req: &types::PaymentsAuthorizeRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {+ Ok(Some(+ services::RequestBuilder::new()+ .method(services::Method::Post)+ .url(&types::PaymentsAuthorizeType::get_url(+ self, req, connectors,+ )?)+ .attach_default_headers()+ .headers(types::PaymentsAuthorizeType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::PaymentsAuthorizeType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &types::PaymentsAuthorizeRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {+ let response: razorpay::RazorpayPaymentsResponse = res+ .response+ .parse_struct("Razorpay PaymentsAuthorizeResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ types::RouterData::try_from(types::ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsResponseData>+ for Razorpay+{+ fn get_headers(+ &self,+ req: &types::PaymentsSyncRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &types::PaymentsSyncRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Ok(format!(+ "{}gatewayProxy/sync/transaction",+ self.base_url(connectors)+ ))+ }++ fn get_request_body(+ &self,+ req: &types::PaymentsSyncRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ let amount = connector_utils::convert_amount(+ self.amount_converter,+ req.request.amount,+ req.request.currency,+ )?;+ let connector_router_data = razorpay::RazorpayRouterData::try_from((amount, req))?;+ let connector_req =+ razorpay::RazorpayCreateSyncRequest::try_from((connector_router_data, connectors))?;+ Ok(RequestContent::Json(Box::new(connector_req)))+ }++ fn build_request(+ &self,+ req: &types::PaymentsSyncRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {+ let request = services::RequestBuilder::new()+ .method(services::Method::Post)+ .url(&types::PaymentsSyncType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)+ .set_body(types::PaymentsSyncType::get_request_body(+ self, req, connectors,+ )?)+ .build();+ Ok(Some(request))+ }++ fn handle_response(+ &self,+ data: &types::PaymentsSyncRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<types::PaymentsSyncRouterData, errors::ConnectorError> {+ let response: razorpay::RazorpaySyncResponse = res+ .response+ .parse_struct("razorpay PaymentsSyncResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ types::RouterData::try_from(types::ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::PaymentsResponseData>+ for Razorpay+{+ fn get_headers(+ &self,+ req: &types::PaymentsCaptureRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &types::PaymentsCaptureRouterData,+ _connectors: &settings::Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn get_request_body(+ &self,+ _req: &types::PaymentsCaptureRouterData,+ _connectors: &settings::Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())+ }++ fn build_request(+ &self,+ req: &types::PaymentsCaptureRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {+ Ok(Some(+ services::RequestBuilder::new()+ .method(services::Method::Post)+ .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::PaymentsCaptureType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::PaymentsCaptureType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &types::PaymentsCaptureRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<types::PaymentsCaptureRouterData, errors::ConnectorError> {+ let response: razorpay::RazorpayPaymentsResponse = res+ .response+ .parse_struct("Razorpay PaymentsCaptureResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ types::RouterData::try_from(types::ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsResponseData>+ for Razorpay+{+}++impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponseData>+ for Razorpay+{+ fn get_headers(+ &self,+ req: &types::RefundsRouterData<api::Execute>,+ connectors: &settings::Connectors,+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &types::RefundsRouterData<api::Execute>,+ connectors: &settings::Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Ok(format!("{}gatewayProxy/refund", self.base_url(connectors)))+ }++ fn get_request_body(+ &self,+ req: &types::RefundsRouterData<api::Execute>,+ connectors: &settings::Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ let amount = connector_utils::convert_amount(+ self.amount_converter,+ req.request.minor_refund_amount,+ req.request.currency,+ )?;+ let connector_router_data = razorpay::RazorpayRouterData::try_from((amount, req))?;+ let connector_req =+ razorpay::RazorpayRefundRequest::try_from((&connector_router_data, connectors))?;+ Ok(RequestContent::Json(Box::new(connector_req)))+ }++ fn build_request(+ &self,+ req: &types::RefundsRouterData<api::Execute>,+ connectors: &settings::Connectors,+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {+ let request = services::RequestBuilder::new()+ .method(services::Method::Post)+ .url(&types::RefundExecuteType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::RefundExecuteType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::RefundExecuteType::get_request_body(+ self, req, connectors,+ )?)+ .build();+ Ok(Some(request))+ }++ fn handle_response(+ &self,+ data: &types::RefundsRouterData<api::Execute>,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<types::RefundsRouterData<api::Execute>, errors::ConnectorError> {+ let response: razorpay::RefundResponse = res+ .response+ .parse_struct("razorpay RefundResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ types::RouterData::try_from(types::ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponseData> for Razorpay {+ fn get_headers(+ &self,+ req: &types::RefundSyncRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &types::RefundSyncRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Ok(format!(+ "{}gatewayProxy/sync/refund",+ self.base_url(connectors)+ ))+ }++ fn get_request_body(+ &self,+ req: &types::RefundSyncRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ let amount = connector_utils::convert_amount(+ self.amount_converter,+ req.request.minor_refund_amount,+ req.request.currency,+ )?;+ let connector_router_data = razorpay::RazorpayRouterData::try_from((amount, req))?;+ let connector_req =+ razorpay::RazorpayRefundRequest::try_from((&connector_router_data, connectors))?;+ Ok(RequestContent::Json(Box::new(connector_req)))+ }++ fn build_request(+ &self,+ req: &types::RefundSyncRouterData,+ connectors: &settings::Connectors,+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {+ Ok(Some(+ services::RequestBuilder::new()+ .method(services::Method::Post)+ .url(&types::RefundSyncType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::RefundSyncType::get_headers(self, req, connectors)?)+ .set_body(types::RefundSyncType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &types::RefundSyncRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<types::RefundSyncRouterData, errors::ConnectorError> {+ let response: razorpay::RefundResponse = res+ .response+ .parse_struct("razorpay RefundSyncResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ types::RouterData::try_from(types::ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++#[async_trait::async_trait]+impl api::IncomingWebhook for Razorpay {+ fn get_webhook_object_reference_id(+ &self,+ request: &api::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<api::webhooks::ObjectReferenceId, errors::ConnectorError> {+ let webhook_resource_object = get_webhook_object_from_body(request.body)?;+ match webhook_resource_object.refund {+ Some(refund_data) => Ok(api_models::webhooks::ObjectReferenceId::RefundId(+ api_models::webhooks::RefundIdType::RefundId(refund_data.entity.id),+ )),+ None => Ok(api_models::webhooks::ObjectReferenceId::PaymentId(+ api_models::payments::PaymentIdType::ConnectorTransactionId(+ webhook_resource_object.payment.entity.id,+ ),+ )),+ }+ }++ fn get_webhook_event_type(+ &self,+ request: &api::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<api::IncomingWebhookEvent, errors::ConnectorError> {+ let webhook_resource_object = get_webhook_object_from_body(request.body)?;+ Ok(api_models::webhooks::IncomingWebhookEvent::try_from(+ webhook_resource_object,+ )?)+ }++ fn get_webhook_resource_object(+ &self,+ request: &api::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {+ let webhook_resource_object = get_webhook_object_from_body(request.body)?;+ Ok(Box::new(webhook_resource_object))+ }+}++fn get_webhook_object_from_body(+ body: &[u8],+) -> CustomResult<razorpay::RazorpayWebhookPayload, errors::ConnectorError> {+ let details: razorpay::RazorpayWebhookEvent = body+ .parse_struct("RazorpayWebhookEvent")+ .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;++ Ok(details.payload)+}diff --git a/crates/router/src/connector/razorpay/transformers.rs b/crates/router/src/connector/razorpay/transformers.rsnew file mode 100644index 0000000000..5e9d6ff1dd--- /dev/null+++ b/crates/router/src/connector/razorpay/transformers.rs@@ -0,0 +1,1369 @@+use common_utils::{+ pii::{self, Email},+ types::FloatMajorUnit,+};+use error_stack::ResultExt;+use hyperswitch_domain_models::payment_method_data::UpiCollectData;+use masking::Secret;+use rand::Rng;+use serde::{Deserialize, Serialize};+use time::PrimitiveDateTime;++use crate::{+ configs::settings,+ consts,+ core::errors,+ types::{self, api, domain, storage::enums},+};++pub struct RazorpayRouterData<T> {+ pub amount: FloatMajorUnit,+ pub router_data: T,+}++impl<T> TryFrom<(FloatMajorUnit, T)> for RazorpayRouterData<T> {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from((amount, item): (FloatMajorUnit, T)) -> Result<Self, Self::Error> {+ Ok(Self {+ amount,+ router_data: item,+ })+ }+}++pub const VERSION: i32 = 1;++#[derive(Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct RazorpayPaymentsRequest {+ second_factor: SecondFactor,+ merchant_account: MerchantAccount,+ order_reference: OrderReference,+ txn_detail: TxnDetail,+ txn_card_info: TxnCardInfo,+ merchant_gateway_account: MerchantGatewayAccount,+ gateway: Gateway,+ transaction_create_req: TransactionCreateReq,+ is_mesh_enabled: bool,+ order_metadata_v2: OrderMetadataV2,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "camelCase")]++pub struct SecondFactor {+ txn_id: String,+ id: String,+ status: SecondFactorStatus,+ #[serde(rename = "type")]+ sf_type: SecondFactorType,+ version: i32,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ date_created: Option<PrimitiveDateTime>,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ last_updated: Option<PrimitiveDateTime>,+ transaction_id: Option<String>,+ url: Option<String>,+ epg_txn_id: Option<String>,+ transaction_detail_id: Option<String>,+ gateway_auth_required_params: Option<String>,+ authentication_account_id: Option<String>,+ can_accept_response: Option<bool>,+ challenges_attempted: Option<i32>,+ response_attempted: Option<i32>,+ partition_key: Option<String>,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum SecondFactorType {+ Otp,+ #[default]+ Vbv,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum SecondFactorStatus {+ Pending,+ #[default]+ Init,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct MerchantAccount {+ id: u64,+ merchant_id: Secret<String>,+ use_code_for_gateway_priority: bool,+ auto_refund_multiple_charged_transactions: bool,+ gateway_success_rate_based_outage_input: Option<String>,+ gateway_success_rate_based_decider_input: Option<String>,+ card_encoding_key: Option<String>,+ enable_unauthenticated_order_status_api: Option<bool>,+ enabled_instant_refund: Option<bool>,+ enable_reauthentication: Option<bool>,+ return_url: Option<String>,+ credit_balance: Option<i64>,+ internal_metadata: Option<String>,+ gateway_decided_by_health_enabled: Option<bool>,+ zip: Option<String>,+ enable_3d_secure_help_mail: Option<String>,+ payout_mid: Option<String>,+ gateway_priority_logic: Option<String>,+ enable_success_rate_based_gateway_elimination: Option<bool>,+ otp_enabled: Option<bool>,+ enable_sending_card_isin: Option<bool>,+ state: Option<String>,+ must_use_given_order_id_for_txn: Option<bool>,+ gateway_priority: Option<String>,+ timezone: Option<String>,+ user_id: Option<i64>,+ office_line_1: Option<String>,+ enable_save_card_before_auth: Option<bool>,+ office_line_2: Option<String>,+ merchant_legal_name: Option<String>,+ settlement_account_id: Option<i64>,+ external_metadata: Option<String>,+ office_line_3: Option<String>,+ enable_payment_response_hash: Option<bool>,+ prefix_merchant_id_for_card_key: Option<bool>,+ admin_contact_email: Option<String>,+ enable_reauthorization: Option<bool>,+ locker_id: Option<String>,+ enable_recapture: Option<bool>,+ contact_person_email: Option<String>,+ basilisk_key_id: Option<String>,+ whitelabel_enabled: Option<bool>,+ inline_checkout_enabled: Option<bool>,+ payu_merchant_key: Option<String>,+ encryption_key_ids: Option<String>,+ enable_gateway_reference_id_based_routing: Option<bool>,+ enabled: Option<bool>,+ enable_automatic_retry: Option<bool>,+ about_business: Option<String>,+ redirect_to_merchant_with_http_post: Option<bool>,+ webhook_api_version: Option<String>,+ express_checkout_enabled: Option<bool>,+ city: Option<String>,+ webhook_url: Option<String>,+ webhook_username: Option<String>,+ webhook_custom_headers: Option<String>,+ reverse_token_enabled: Option<bool>,+ webhook_configs: Option<String>,+ last_modified: Option<String>,+ token_locker_id: Option<String>,+ enable_sending_last_four_digits: Option<bool>,+ website: Option<String>,+ mobile: Option<String>,+ webhook_password: Option<String>,+ reseller_id: Option<String>,+ mobile_version: Option<String>,+ contact_person_primary: Option<String>,+ conflict_status_email: Option<String>,+ payu_test_mode: Option<bool>,+ payment_response_hash_key: Option<String>,+ enable_refunds_in_dashboard: Option<bool>,+ tenant_account_id: Option<String>,+ merchant_name: Option<String>,+ hdfc_test_mode: Option<bool>,+ enable_unauthenticated_card_add: Option<bool>,+ payu_salt: Option<String>,+ api_key: Option<String>,+ date_created: Option<String>,+ internal_hash_key: Option<String>,+ version: Option<i32>,+ mandatory_2fa: Option<bool>,+}++#[derive(Default, Debug, Serialize, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct OrderReference {+ id: String,+ amount: FloatMajorUnit,+ currency: String,+ order_id: String,+ status: OrderStatus,+ merchant_id: Secret<String>,+ order_uuid: String,+ order_type: OrderType,+ version: i32,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ date_created: Option<PrimitiveDateTime>,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ last_modified: Option<PrimitiveDateTime>,+ return_url: Option<String>,+ billing_address_id: Option<String>,+ internal_metadata: Option<String>,+ mandate_feature: Option<MandateFeature>,+ udf6: Option<String>,+ udf1: Option<String>,+ partition_key: Option<String>,+ amount_refunded: Option<FloatMajorUnit>,+ customer_phone: Option<String>,+ description: Option<String>,+ customer_email: Option<Email>,+ customer_id: Option<String>,+ refunded_entirely: Option<bool>,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum OrderType {+ MandatePayment,+ #[default]+ OrderPayment,+}++#[derive(Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "camelCase")]+pub enum MandateFeature {+ Disabled,+ Required,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum OrderStatus {+ Success,+ #[default]+ PendingAuthentication,+}++#[derive(Default, Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct TxnDetail {+ status: TxnStatus,+ merchant_id: Secret<String>,+ txn_id: String,+ express_checkout: bool,+ is_emi: bool,+ net_amount: FloatMajorUnit,+ txn_amount: FloatMajorUnit,+ emi_tenure: i32,+ txn_uuid: String,+ currency: String,+ version: i32,+ redirect: bool,+ id: String,+ #[serde(rename = "type")]+ txn_type: TxnType,+ order_id: String,+ add_to_locker: bool,+ merchant_gateway_account_id: u64,+ txn_mode: TxnMode,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ date_created: Option<PrimitiveDateTime>,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ last_modified: Option<PrimitiveDateTime>,+ gateway: Gateway,+ internal_metadata: Option<String>,+ txn_flow_type: Option<String>,+ source_object: Option<String>,+ partition_key: Option<String>,+ username: Option<String>,+ txn_object_type: Option<String>,+ internal_tracking_info: Option<String>,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum TxnType {+ AuthAndSettle,+ #[default]+ PreAuthAndSettle,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum TxnMode {+ Prod,+ #[default]+ Test,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct TxnCardInfo {+ txn_detail_id: String,+ txn_id: String,+ payment_method_type: String,+ id: String,+ payment_method: String,+ payment_source: Secret<String, pii::UpiVpaMaskingStrategy>,+ date_created: Option<PrimitiveDateTime>,+ partition_key: Option<String>,+ card_type: Option<String>,+ card_issuer_bank_name: Option<String>,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct MerchantGatewayAccount {+ merchant_id: Secret<String>,+ gateway: Gateway,+ account_details: String,+ version: i32,+ id: u64,+ test_mode: bool,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ date_created: Option<PrimitiveDateTime>,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ last_modified: Option<PrimitiveDateTime>,+ disabled: bool,+ payment_methods: Option<String>,+ enforce_payment_method_acceptance: Option<bool>,+ supported_payment_flows: Option<String>,+ is_juspay_account: Option<bool>,+}++#[derive(Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "snake_case")]+pub struct TransactionCreateReq {+ merchant_id: Secret<String>,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct OrderMetadataV2 {+ id: String,+ order_reference_id: String,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ date_created: Option<PrimitiveDateTime>,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ last_updated: Option<PrimitiveDateTime>,+ browser: Option<String>,+ operating_system: Option<String>,+ ip_address: Option<String>,+ partition_key: Option<String>,+ user_agent: Option<String>,+ browser_version: Option<String>,+ mobile: Option<String>,+ metadata: Option<String>,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq, Deserialize)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum Gateway {+ #[default]+ Razorpay,+ YesBiz,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+pub struct RazorpayCard {+ number: cards::CardNumber,+ expiry_month: Secret<String>,+ expiry_year: Secret<String>,+ cvc: Secret<String>,+ complete: bool,+}++fn generate_12_digit_number() -> u64 {+ let mut rng = rand::thread_rng();+ rng.gen_range(100_000_000_000..=999_999_999_999)+}++impl+ TryFrom<(+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ )> for RazorpayPaymentsRequest+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ (item, data): (+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ ),+ ) -> Result<Self, Self::Error> {+ let request = &item.router_data.request;+ let txn_card_info = match request.payment_method_data.clone() {+ domain::PaymentMethodData::Upi(upi_type) => match upi_type {+ domain::UpiData::UpiCollect(upi_data) => TxnCardInfo::try_from((item, upi_data)),+ hyperswitch_domain_models::payment_method_data::UpiData::UpiIntent(_) => Err(+ errors::ConnectorError::NotImplemented("Payment methods".to_string()).into(),+ ),+ },+ domain::PaymentMethodData::Card(_)+ | domain::PaymentMethodData::CardRedirect(_)+ | domain::PaymentMethodData::Wallet(_)+ | domain::PaymentMethodData::PayLater(_)+ | domain::PaymentMethodData::BankRedirect(_)+ | domain::PaymentMethodData::BankDebit(_)+ | domain::PaymentMethodData::BankTransfer(_)+ | domain::PaymentMethodData::Crypto(_)+ | domain::PaymentMethodData::MandatePayment+ | domain::PaymentMethodData::Reward+ | domain::PaymentMethodData::RealTimePayment(_)+ | domain::PaymentMethodData::Voucher(_)+ | domain::PaymentMethodData::GiftCard(_)+ | domain::PaymentMethodData::CardToken(_) => {+ Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into())+ }+ }?;+ let merchant_data = JuspayAuthData::try_from(data)?;+ let second_factor = SecondFactor::try_from(item)?;+ let merchant_account = MerchantAccount::try_from((item, data))?;+ let order_reference = OrderReference::try_from((item, data))?;+ let txn_detail = TxnDetail::try_from((item, data))?;+ let merchant_gateway_account = MerchantGatewayAccount::try_from((item, data))?;+ let gateway = Gateway::Razorpay;+ let transaction_create_req = TransactionCreateReq {+ merchant_id: merchant_data.merchant_id,+ };+ let is_mesh_enabled = false;+ let order_metadata_v2 = OrderMetadataV2::try_from(item)?;++ Ok(Self {+ second_factor,+ merchant_account,+ order_reference,+ txn_detail,+ txn_card_info,+ merchant_gateway_account,+ gateway,+ transaction_create_req,+ is_mesh_enabled,+ order_metadata_v2,+ })+ }+}++impl TryFrom<&RazorpayRouterData<&types::PaymentsAuthorizeRouterData>> for SecondFactor {+ type Error = error_stack::Report<errors::ConnectorError>;++ fn try_from(+ item: &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ ) -> Result<Self, Self::Error> {+ let ref_id = generate_12_digit_number();++ Ok(Self {+ txn_id: item.router_data.connector_request_reference_id.clone(),+ id: ref_id.to_string(),+ status: SecondFactorStatus::Pending,+ version: VERSION,+ sf_type: SecondFactorType::Vbv,+ date_created: Some(common_utils::date_time::now()),+ last_updated: Some(common_utils::date_time::now()),+ ..Default::default()+ })+ }+}++impl+ TryFrom<(+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ )> for MerchantAccount+{+ type Error = error_stack::Report<errors::ConnectorError>;++ fn try_from(+ (_item, data): (+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ ),+ ) -> Result<Self, Self::Error> {+ let merchant_data = JuspayAuthData::try_from(data)?;+ let ref_id = generate_12_digit_number();+ Ok(Self {+ id: ref_id,+ merchant_id: merchant_data.merchant_id,+ auto_refund_multiple_charged_transactions: false,+ use_code_for_gateway_priority: true,+ ..Default::default()+ })+ }+}++impl+ TryFrom<(+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ )> for OrderReference+{+ type Error = error_stack::Report<errors::ConnectorError>;++ fn try_from(+ (item, data): (+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ ),+ ) -> Result<Self, Self::Error> {+ let ref_id = generate_12_digit_number();+ let merchant_data = JuspayAuthData::try_from(data)?;+ Ok(Self {+ id: ref_id.to_string(),+ amount: item.amount,+ currency: item.router_data.request.currency.to_string(),+ status: OrderStatus::PendingAuthentication,+ merchant_id: merchant_data.merchant_id.clone(),+ order_id: item.router_data.connector_request_reference_id.clone(),+ version: VERSION,+ order_type: OrderType::OrderPayment,+ order_uuid: uuid::Uuid::new_v4().to_string(),+ date_created: Some(common_utils::date_time::now()),+ last_modified: Some(common_utils::date_time::now()),+ ..Default::default()+ })+ }+}++impl+ TryFrom<(+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ UpiCollectData,+ )> for TxnCardInfo+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ payment_data: (+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ UpiCollectData,+ ),+ ) -> Result<Self, Self::Error> {+ let item = payment_data.0;+ let upi_data = payment_data.1;+ let ref_id = generate_12_digit_number();+ let pm = common_enums::enums::PaymentMethod::Upi;+ 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(),+ id: ref_id.to_string(),+ payment_method: pm.to_string().to_uppercase(),+ payment_source: upi_data.vpa_id.ok_or(+ errors::ConnectorError::MissingRequiredField {+ field_name: "vpa_id",+ },+ )?,+ date_created: Some(common_utils::date_time::now()),+ ..Default::default()+ })+ }+}++impl+ TryFrom<(+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ )> for TxnDetail+{+ type Error = error_stack::Report<errors::ConnectorError>;++ fn try_from(+ (item, data): (+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ ),+ ) -> Result<Self, Self::Error> {+ let ref_id = generate_12_digit_number();+ let merchant_data = JuspayAuthData::try_from(data)?;+ let txn_mode: TxnMode = match item.router_data.test_mode {+ Some(true) | None => TxnMode::Test,+ Some(false) => TxnMode::Prod,+ };+ Ok(Self {+ order_id: item.router_data.connector_request_reference_id.clone(),+ express_checkout: false,+ txn_mode,+ merchant_id: merchant_data.merchant_id,+ status: TxnStatus::PendingVbv,+ net_amount: item.amount,+ txn_id: item.router_data.connector_request_reference_id.clone(),+ txn_amount: item.amount,+ emi_tenure: 0,+ txn_uuid: uuid::Uuid::new_v4().to_string(),+ id: ref_id.to_string(),+ merchant_gateway_account_id: ref_id,+ txn_type: TxnType::AuthAndSettle,+ redirect: true,+ version: VERSION,+ add_to_locker: false,+ currency: item.router_data.request.currency.to_string(),+ is_emi: false,+ gateway: Gateway::Razorpay,+ date_created: Some(common_utils::date_time::now()),+ last_modified: Some(common_utils::date_time::now()),+ ..Default::default()+ })+ }+}++impl+ TryFrom<(+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ )> for MerchantGatewayAccount+{+ type Error = error_stack::Report<errors::ConnectorError>;++ fn try_from(+ (item, data): (+ &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ &settings::Connectors,+ ),+ ) -> Result<Self, Self::Error> {+ let ref_id = generate_12_digit_number();+ let auth = RazorpayAuthType::try_from(&item.router_data.connector_auth_type)?;+ let merchant_data = JuspayAuthData::try_from(data)?;+ let account_details = AccountDetails {+ razorpay_id: auth.razorpay_id.clone(),+ razorpay_secret: auth.razorpay_secret,+ };+ Ok(Self {+ merchant_id: merchant_data.merchant_id,+ gateway: Gateway::Razorpay,+ disabled: false,+ id: ref_id,+ account_details: serde_json::to_string(&account_details)+ .change_context(errors::ConnectorError::ParsingFailed)?,+ test_mode: false,+ ..Default::default()+ })+ }+}+impl TryFrom<&RazorpayRouterData<&types::PaymentsAuthorizeRouterData>> for OrderMetadataV2 {+ type Error = error_stack::Report<errors::ConnectorError>;++ fn try_from(+ _item: &RazorpayRouterData<&types::PaymentsAuthorizeRouterData>,+ ) -> Result<Self, Self::Error> {+ let ref_id = generate_12_digit_number();+ Ok(Self {+ id: ref_id.to_string(),+ order_reference_id: ref_id.to_string(),+ date_created: Some(common_utils::date_time::now()),+ last_updated: Some(common_utils::date_time::now()),+ ..Default::default()+ })+ }+}++pub struct RazorpayAuthType {+ pub(super) razorpay_id: Secret<String>,+ pub(super) razorpay_secret: Secret<String>,+}++impl TryFrom<&types::ConnectorAuthType> for RazorpayAuthType {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {+ match auth_type {+ types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {+ razorpay_id: api_key.to_owned(),+ razorpay_secret: key1.to_owned(),+ }),+ _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),+ }+ }+}++pub struct JuspayAuthData {+ pub(super) merchant_id: Secret<String>,+}+impl TryFrom<&settings::Connectors> for JuspayAuthData {+ type Error = error_stack::Report<errors::ConnectorError>;++ fn try_from(connector_param: &settings::Connectors) -> Result<Self, Self::Error> {+ let settings::Connectors { razorpay, .. } = connector_param;+ Ok(Self {+ merchant_id: razorpay.merchant_id.clone(),+ })+ }+}++#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct RazorpayPaymentsResponse {+ contents: Contents,+ tag: Tag,+ code: u16,+}++#[derive(Debug, Clone, Serialize, Deserialize)]+pub enum Tag {+ Stateless,+}++#[derive(Debug, Clone, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ApiMetadata {+ ext_api_tag: String,+}++#[derive(Debug, Clone, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct Contents {+ send_webhook: bool,+ second_factor: Option<SecondFactorResponse>,+ pgr_response: Option<String>,+ api_metadata: ApiMetadata,+ pgr_info: PgrInfo,+ txn_status: TxnStatus,+ #[serde(rename = "updatePGR")]+ update_pgr: bool,+}++#[derive(Debug, Clone, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct SecondFactorResponse {+ id: u64,+ #[serde(rename = "type")]+ sf_type: String,+ version: i32,+ date_created: String,+ last_updated: String,+ epg_txn_id: String,+ status: String,+ txn_id: String,+ authentication_account_id: Option<String>,+ can_accept_response: Option<bool>,+ challenges_attempted: Option<i32>,+ gateway_auth_req_params: Option<String>,+ partition_key: Option<String>,+ response_attempted: Option<i32>,+ txn_detail_id: Option<String>,+ url: Option<String>,+}++#[derive(Debug, Clone, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct PgrInfo {+ resp_code: String,+ resp_message: Option<String>,+ response_xml: String,+ resptype: Option<String>,+}++#[derive(Debug, Default, Clone, Serialize, Deserialize)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum TxnStatus {+ Charged,+ Authorizing,+ #[default]+ PendingVbv,+}++impl From<TxnStatus> for enums::AttemptStatus {+ fn from(item: TxnStatus) -> Self {+ match item {+ TxnStatus::Authorizing => Self::Pending,+ TxnStatus::PendingVbv => Self::Failure,+ TxnStatus::Charged => Self::Charged,+ }+ }+}+impl From<enums::AttemptStatus> for TxnStatus {+ fn from(item: enums::AttemptStatus) -> Self {+ match item {+ enums::AttemptStatus::Pending => Self::Authorizing,+ enums::AttemptStatus::Failure => Self::PendingVbv,+ enums::AttemptStatus::Charged => Self::Charged,+ _ => Self::PendingVbv,+ }+ }+}++impl<F, T>+ TryFrom<types::ResponseRouterData<F, RazorpayPaymentsResponse, T, types::PaymentsResponseData>>+ for types::RouterData<F, T, types::PaymentsResponseData>+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: types::ResponseRouterData<+ F,+ RazorpayPaymentsResponse,+ T,+ types::PaymentsResponseData,+ >,+ ) -> Result<Self, Self::Error> {+ let second_factor = item.response.contents.second_factor;+ let status = enums::AttemptStatus::from(item.response.contents.txn_status);+ match second_factor {+ Some(second_factor) => Ok(Self {+ status,+ response: Ok(types::PaymentsResponseData::TransactionResponse {+ resource_id: types::ResponseId::ConnectorTransactionId(+ second_factor.epg_txn_id,+ ),+ redirection_data: None,+ mandate_reference: None,+ connector_metadata: None,+ network_txn_id: None,+ connector_response_reference_id: Some(second_factor.txn_id),+ incremental_authorization_allowed: None,+ charge_id: None,+ }),+ ..item.data+ }),+ None => {+ let message_code = item+ .response+ .contents+ .pgr_info+ .resp_message+ .clone()+ .unwrap_or(consts::NO_ERROR_MESSAGE.to_string());+ Ok(Self {+ status,+ response: Err(types::ErrorResponse {+ code: item.response.contents.pgr_info.resp_code.clone(),+ message: message_code.clone(),+ reason: Some(message_code.clone()),+ status_code: item.http_code,+ attempt_status: None,+ connector_transaction_id: None,+ }),+ ..item.data+ })+ }+ }+ }+}++#[derive(Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct RazorpayCreateSyncRequest {+ txn_detail: TxnDetail,+ merchant_gateway_account: MerchantGatewayAccount,+ order_reference: OrderReference,+ second_factor: SecondFactor,+ gateway_txn_data: GatewayTxnData,+}++#[derive(Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct GatewayTxnData {+ id: String,+ version: i32,+ gateway_data: String,+ gateway_status: String,+ match_status: String,+ txn_detail_id: String,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ date_created: Option<PrimitiveDateTime>,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ last_updated: Option<PrimitiveDateTime>,+}++#[derive(Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct AccountDetails {+ razorpay_id: Secret<String>,+ razorpay_secret: Secret<String>,+}++impl+ TryFrom<(+ RazorpayRouterData<&types::PaymentsSyncRouterData>,+ &settings::Connectors,+ )> for RazorpayCreateSyncRequest+{+ type Error = error_stack::Report<errors::ConnectorError>;++ fn try_from(+ (item, data): (+ RazorpayRouterData<&types::PaymentsSyncRouterData>,+ &settings::Connectors,+ ),+ ) -> Result<Self, Self::Error> {+ let ref_id = generate_12_digit_number();+ let auth = RazorpayAuthType::try_from(&item.router_data.connector_auth_type)?;+ let merchant_data = JuspayAuthData::try_from(data)?;+ let connector_transaction_id = item+ .router_data+ .request+ .connector_transaction_id+ .get_connector_transaction_id()+ .change_context(errors::ConnectorError::MissingConnectorTransactionID)?;+ let connector_request_reference_id = &item.router_data.connector_request_reference_id;++ let second_factor = SecondFactor {+ txn_id: connector_request_reference_id.clone(),+ id: ref_id.to_string(),+ status: SecondFactorStatus::Pending,+ version: VERSION,+ sf_type: SecondFactorType::Vbv,+ date_created: Some(common_utils::date_time::now()),+ last_updated: Some(common_utils::date_time::now()),+ epg_txn_id: Some(connector_transaction_id.clone()),+ ..Default::default()+ };+ let order_reference = OrderReference {+ id: ref_id.to_string(),+ amount: item.amount,+ currency: item.router_data.request.currency.to_string(),+ status: OrderStatus::PendingAuthentication,+ merchant_id: merchant_data.merchant_id.clone(),+ order_id: connector_request_reference_id.clone(),+ version: VERSION,+ order_type: OrderType::OrderPayment,+ order_uuid: uuid::Uuid::new_v4().to_string(),+ date_created: Some(common_utils::date_time::now()),+ last_modified: Some(common_utils::date_time::now()),+ ..Default::default()+ };+ let txn_mode: TxnMode = match item.router_data.test_mode {+ Some(true) | None => TxnMode::Test,+ Some(false) => TxnMode::Prod,+ };+ let txn_detail = TxnDetail {+ order_id: connector_request_reference_id.clone(),+ express_checkout: false,+ txn_mode,+ merchant_id: merchant_data.merchant_id.clone(),+ status: TxnStatus::from(item.router_data.status),+ net_amount: item.amount,+ txn_id: connector_request_reference_id.clone(),+ txn_amount: item.amount,+ emi_tenure: 0,+ txn_uuid: uuid::Uuid::new_v4().to_string(),+ id: ref_id.to_string(),+ merchant_gateway_account_id: 11476,+ txn_type: TxnType::AuthAndSettle,+ redirect: true,+ version: VERSION,+ add_to_locker: false,+ currency: item.router_data.request.currency.to_string(),+ is_emi: false,+ gateway: Gateway::Razorpay,+ date_created: Some(common_utils::date_time::now()),+ last_modified: Some(common_utils::date_time::now()),+ ..Default::default()+ };++ let account_details = AccountDetails {+ razorpay_id: auth.razorpay_id.clone(),+ razorpay_secret: auth.razorpay_secret,+ };+ let merchant_gateway_account = MerchantGatewayAccount {+ gateway: Gateway::Razorpay,+ disabled: false,+ id: ref_id,+ account_details: serde_json::to_string(&account_details)+ .change_context(errors::ConnectorError::ParsingFailed)?,+ test_mode: false,+ merchant_id: merchant_data.merchant_id,+ ..Default::default()+ };+ let gateway_txn_data = GatewayTxnData {+ id: ref_id.to_string(),+ version: VERSION,+ gateway_data: "".to_string(),+ gateway_status: "S".to_string(),+ match_status: "S".to_string(),+ txn_detail_id: ref_id.to_string(),+ date_created: Some(common_utils::date_time::now()),+ last_updated: Some(common_utils::date_time::now()),+ };+ Ok(Self {+ second_factor,+ merchant_gateway_account,+ order_reference,+ txn_detail,+ gateway_txn_data,+ })+ }+}++#[derive(Debug, Clone, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct RazorpaySyncResponse {+ status: PsyncStatus,+ is_stateful: bool,+ second_factor: SecondFactorResponse,+}++#[derive(Debug, Clone, Serialize, Deserialize)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]++pub enum PsyncStatus {+ Charged,+ Pending,+ Authorizing,+}++impl From<PsyncStatus> for enums::AttemptStatus {+ fn from(item: PsyncStatus) -> Self {+ match item {+ PsyncStatus::Charged => Self::Charged,+ PsyncStatus::Pending => Self::Pending,+ PsyncStatus::Authorizing => Self::Pending,+ }+ }+}++impl<F, T>+ TryFrom<types::ResponseRouterData<F, RazorpaySyncResponse, T, types::PaymentsResponseData>>+ for types::RouterData<F, T, types::PaymentsResponseData>+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: types::ResponseRouterData<F, RazorpaySyncResponse, T, types::PaymentsResponseData>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ status: enums::AttemptStatus::from(item.response.status),+ response: Ok(types::PaymentsResponseData::TransactionResponse {+ resource_id: types::ResponseId::ConnectorTransactionId(+ item.response.second_factor.epg_txn_id,+ ),+ redirection_data: None,+ mandate_reference: None,+ connector_metadata: None,+ network_txn_id: None,+ connector_response_reference_id: Some(item.response.second_factor.txn_id),+ incremental_authorization_allowed: None,+ charge_id: None,+ }),+ ..item.data+ })+ }+}++#[derive(Default, Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct RazorpayRefundRequest {+ order_metadata_v2: OrderMetadataV2,+ second_factor: SecondFactor,+ order_reference: OrderReference,+ txn_detail: TxnDetail,+ refund: Refund,+ payment_gateway_response: PaymentGatewayResponse,+ txn_card_info: TxnCardInfo,+ merchant_gateway_account: MerchantGatewayAccount,+}++#[derive(Default, Debug, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct Refund {+ id: u64,+ status: RefundStatus,+ amount: FloatMajorUnit,+ merchant_id: Option<Secret<String>>,+ gateway: Gateway,+ txn_detail_id: u64,+ unique_request_id: String,+ processed: bool,+ #[serde(default, with = "common_utils::custom_serde::iso8601::option")]+ date_created: Option<PrimitiveDateTime>,+}++#[derive(Default, Debug, Serialize, Deserialize)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]++pub enum RefundStatus {+ Success,+ Failure,+ #[default]+ Pending,+}++#[derive(Default, Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct PaymentGatewayResponse {+ id: String,+ version: i32,+}++impl<F>+ TryFrom<(+ &RazorpayRouterData<&types::RefundsRouterData<F>>,+ &settings::Connectors,+ )> for RazorpayRefundRequest+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ (item, data): (+ &RazorpayRouterData<&types::RefundsRouterData<F>>,+ &settings::Connectors,+ ),+ ) -> Result<Self, Self::Error> {+ let ref_id = generate_12_digit_number();+ let auth = RazorpayAuthType::try_from(&item.router_data.connector_auth_type)?;+ let merchant_data = JuspayAuthData::try_from(data)?;+ let connector_transaction_id = item.router_data.request.connector_transaction_id.clone();+ let connector_request_reference_id = &item.router_data.connector_request_reference_id;+ let order_metadata_v2 = OrderMetadataV2 {+ id: ref_id.to_string(),+ order_reference_id: ref_id.to_string(),+ date_created: Some(common_utils::date_time::now()),+ last_updated: Some(common_utils::date_time::now()),+ ..Default::default()+ };+ let second_factor = SecondFactor {+ txn_id: connector_request_reference_id.clone(),+ id: ref_id.to_string(),+ status: SecondFactorStatus::Pending,+ version: VERSION,+ sf_type: SecondFactorType::Vbv,+ date_created: Some(common_utils::date_time::now()),+ last_updated: Some(common_utils::date_time::now()),+ epg_txn_id: Some(connector_transaction_id.clone()),+ ..Default::default()+ };++ let order_reference = OrderReference {+ id: ref_id.to_string(),+ amount: item.amount,+ currency: item.router_data.request.currency.to_string(),+ status: OrderStatus::Success,+ merchant_id: merchant_data.merchant_id.clone(),+ order_id: connector_request_reference_id.clone(),+ version: VERSION,+ order_type: OrderType::OrderPayment,+ order_uuid: uuid::Uuid::new_v4().to_string(),+ date_created: Some(common_utils::date_time::now()),+ last_modified: Some(common_utils::date_time::now()),+ ..Default::default()+ };+ let txn_mode: TxnMode = match item.router_data.test_mode {+ Some(true) | None => TxnMode::Test,+ Some(false) => TxnMode::Prod,+ };+ let txn_detail = TxnDetail {+ order_id: connector_request_reference_id.clone(),+ express_checkout: false,+ txn_mode,+ merchant_id: merchant_data.merchant_id.clone(),+ status: TxnStatus::from(item.router_data.status),+ net_amount: item.amount,+ txn_id: connector_request_reference_id.clone(),+ txn_amount: item.amount,+ emi_tenure: 0,+ txn_uuid: uuid::Uuid::new_v4().to_string(),+ id: ref_id.to_string(),+ merchant_gateway_account_id: 11476,+ txn_type: TxnType::AuthAndSettle,+ redirect: true,+ version: VERSION,+ add_to_locker: false,+ currency: item.router_data.request.currency.to_string(),+ is_emi: false,+ gateway: Gateway::Razorpay,+ date_created: Some(common_utils::date_time::now()),+ last_modified: Some(common_utils::date_time::now()),+ ..Default::default()+ };++ let refund = Refund {+ id: ref_id,+ status: RefundStatus::Pending,+ amount: item.amount,+ merchant_id: Some(merchant_data.merchant_id.clone()),+ gateway: Gateway::Razorpay,+ txn_detail_id: ref_id,+ unique_request_id: item.router_data.request.refund_id.clone(),+ processed: false,+ date_created: Some(common_utils::date_time::now()),+ };+ let payment_gateway_response = PaymentGatewayResponse {+ id: ref_id.to_string(),+ version: VERSION,+ };+ let payment_source: Secret<String, pii::UpiVpaMaskingStrategy> =+ Secret::new("".to_string());++ let pm = common_enums::enums::PaymentMethod::Upi;++ let txn_card_info = TxnCardInfo {+ 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(),+ id: ref_id.to_string(),+ payment_method: pm.to_string().to_uppercase(),+ payment_source,+ date_created: Some(common_utils::date_time::now()),+ ..Default::default()+ };++ let account_details = AccountDetails {+ razorpay_id: auth.razorpay_id.clone(),+ razorpay_secret: auth.razorpay_secret,+ };++ let merchant_gateway_account = MerchantGatewayAccount {+ gateway: Gateway::Razorpay,+ disabled: false,+ id: ref_id,+ account_details: serde_json::to_string(&account_details)+ .change_context(errors::ConnectorError::ParsingFailed)?,+ test_mode: false,+ merchant_id: merchant_data.merchant_id,+ ..Default::default()+ };++ Ok(Self {+ order_metadata_v2,+ second_factor,+ order_reference,+ txn_detail,+ refund,+ payment_gateway_response,+ txn_card_info,+ merchant_gateway_account,+ })+ }+}++impl From<RefundStatus> for enums::RefundStatus {+ fn from(item: RefundStatus) -> Self {+ match item {+ RefundStatus::Success => Self::Success,+ RefundStatus::Failure => Self::Failure,+ RefundStatus::Pending => Self::Pending,+ }+ }+}++#[derive(Default, Debug, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]++pub struct RefundResponse {+ txn_id: Option<String>,+ refund: Refund,+}++impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>+ for types::RefundsRouterData<api::Execute>+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: types::RefundsResponseRouterData<api::Execute, RefundResponse>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ response: Ok(types::RefundsResponseData {+ connector_refund_id: item.response.refund.unique_request_id.to_string(),+ refund_status: enums::RefundStatus::from(item.response.refund.status),+ }),+ ..item.data+ })+ }+}++impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>+ for types::RefundsRouterData<api::RSync>+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: types::RefundsResponseRouterData<api::RSync, RefundResponse>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ response: Ok(types::RefundsResponseData {+ connector_refund_id: item.response.refund.unique_request_id.to_string(),+ refund_status: enums::RefundStatus::from(item.response.refund.status),+ }),+ ..item.data+ })+ }+}++#[derive(Debug, Serialize, Deserialize, PartialEq)]+#[serde(untagged)]+pub enum ErrorResponse {+ RazorpayErrorResponse(RazorpayErrorResponse),+ RazorpayStringError(String),+}++#[derive(Debug, Serialize, Deserialize, PartialEq)]+pub struct RazorpayErrorResponse {+ pub code: u16,+ pub error_code: Option<String>,+ pub status: String,+ pub error: bool,+ pub error_message: String,+ pub error_info: ErrorInfo,+}++#[derive(Debug, Serialize, Deserialize, PartialEq)]+pub struct ErrorInfo {+ pub code: String,+ pub user_message: String,+ pub developer_message: String,+ pub fields: Vec<Fields>,+}++#[derive(Debug, Serialize, Deserialize, PartialEq)]+pub struct Fields {+ pub field_name: String,+ pub reason: String,+}++#[derive(Debug, Serialize, Eq, PartialEq)]+#[serde(rename_all = "lowercase")]+pub enum RazorpayWebhookEventType {+ Disabled,+}++#[derive(Debug, Serialize, Deserialize)]+pub struct RazorpayWebhookEvent {+ pub payload: RazorpayWebhookPayload,+}++#[derive(Debug, Serialize, Deserialize)]+pub struct RazorpayWebhookPayload {+ pub refund: Option<RazorpayRefundWebhookPayload>,+ pub payment: RazorpayPaymentWebhookPayload,+}++#[derive(Debug, Serialize, Deserialize)]+pub struct RazorpayPaymentWebhookPayload {+ pub entity: WebhookPaymentEntity,+}++#[derive(Debug, Serialize, Deserialize)]+pub struct RazorpayRefundWebhookPayload {+ pub entity: WebhookRefundEntity,+}++#[derive(Debug, Serialize, Deserialize)]+pub struct WebhookRefundEntity {+ pub id: String,+ pub status: RazorpayRefundStatus,+}++#[derive(Debug, Serialize, Deserialize)]+pub struct WebhookPaymentEntity {+ pub id: String,+ pub status: RazorpayPaymentStatus,+}++#[derive(Debug, Serialize, Eq, PartialEq, Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum RazorpayPaymentStatus {+ Created,+ Authorized,+ Captured,+ Failed,+}++#[derive(Debug, Serialize, Eq, PartialEq, Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum RazorpayRefundStatus {+ Pending,+ Processed,+ Failed,+}++impl TryFrom<RazorpayWebhookPayload> for api_models::webhooks::IncomingWebhookEvent {+ type Error = errors::ConnectorError;+ fn try_from(webhook_payload: RazorpayWebhookPayload) -> Result<Self, Self::Error> {+ webhook_payload+ .refund+ .map_or(+ match webhook_payload.payment.entity.status {+ RazorpayPaymentStatus::Created => Some(Self::PaymentIntentProcessing),+ RazorpayPaymentStatus::Authorized => {+ Some(Self::PaymentIntentAuthorizationSuccess)+ }+ RazorpayPaymentStatus::Captured => Some(Self::PaymentIntentSuccess),+ RazorpayPaymentStatus::Failed => Some(Self::PaymentIntentFailure),+ },+ |refund_data| match refund_data.entity.status {+ RazorpayRefundStatus::Pending => None,+ RazorpayRefundStatus::Processed => Some(Self::RefundSuccess),+ RazorpayRefundStatus::Failed => Some(Self::RefundFailure),+ },+ )+ .ok_or(errors::ConnectorError::WebhookEventTypeNotFound)+ }+}diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex b6664e7b54..d51f463f23 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -2113,6 +2113,10 @@ pub(crate) fn validate_auth_and_metadata_type_with_connector(rapyd::transformers::RapydAuthType::try_from(val)?;Ok(())}+ api_enums::Connector::Razorpay => {+ razorpay::transformers::RazorpayAuthType::try_from(val)?;+ Ok(())+ }api_enums::Connector::Shift4 => {shift4::transformers::Shift4AuthType::try_from(val)?;Ok(())diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rsindex 6b3360feb6..f99f5fa5c1 100644--- a/crates/router/src/core/payments/connector_integration_v2_impls.rs+++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs@@ -649,6 +649,7 @@ default_imp_for_new_connector_integration_payment!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -730,6 +731,7 @@ default_imp_for_new_connector_integration_refund!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -806,6 +808,7 @@ default_imp_for_new_connector_integration_connector_access_token!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -904,6 +907,7 @@ default_imp_for_new_connector_integration_accept_dispute!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -984,6 +988,7 @@ default_imp_for_new_connector_integration_defend_dispute!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1048,6 +1053,7 @@ default_imp_for_new_connector_integration_submit_evidence!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1139,6 +1145,7 @@ default_imp_for_new_connector_integration_file_upload!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1212,6 +1219,7 @@ default_imp_for_new_connector_integration_payouts!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1295,6 +1303,7 @@ default_imp_for_new_connector_integration_payouts_create!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1378,6 +1387,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1461,6 +1471,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1544,6 +1555,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1627,6 +1639,7 @@ default_imp_for_new_connector_integration_payouts_quote!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1710,6 +1723,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1793,6 +1807,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1874,6 +1889,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1947,6 +1963,7 @@ default_imp_for_new_connector_integration_frm!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2030,6 +2047,7 @@ default_imp_for_new_connector_integration_frm_sale!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2113,6 +2131,7 @@ default_imp_for_new_connector_integration_frm_checkout!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2196,6 +2215,7 @@ default_imp_for_new_connector_integration_frm_transaction!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2279,6 +2299,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2362,6 +2383,7 @@ default_imp_for_new_connector_integration_frm_record_return!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2442,6 +2464,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2550,6 +2573,7 @@ default_imp_for_new_connector_integration_connector_authentication!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rsindex 23ab253ee5..fec9471ea9 100644--- a/crates/router/src/core/payments/flows.rs+++ b/crates/router/src/core/payments/flows.rs@@ -196,6 +196,7 @@ default_imp_for_complete_authorize!(connector::Payu,connector::Placetopay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -286,6 +287,7 @@ default_imp_for_webhook_source_verification!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Shift4,connector::Signifyd,@@ -379,6 +381,7 @@ default_imp_for_create_customer!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Shift4,connector::Signifyd,@@ -460,6 +463,7 @@ default_imp_for_connector_redirect_response!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Shift4,connector::Signifyd,@@ -534,6 +538,7 @@ default_imp_for_connector_request_id!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Shift4,connector::Signifyd,@@ -629,6 +634,7 @@ default_imp_for_accept_dispute!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Shift4,connector::Signifyd,@@ -743,6 +749,7 @@ default_imp_for_file_upload!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Shift4,connector::Signifyd,@@ -835,6 +842,7 @@ default_imp_for_submit_evidence!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Shift4,connector::Signifyd,@@ -927,6 +935,7 @@ default_imp_for_defend_dispute!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Shift4,connector::Signifyd,@@ -1013,6 +1022,7 @@ default_imp_for_pre_processing_steps!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1082,6 +1092,7 @@ default_imp_for_payouts!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1172,6 +1183,7 @@ default_imp_for_payouts_create!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1266,6 +1278,7 @@ default_imp_for_payouts_eligibility!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1354,6 +1367,7 @@ default_imp_for_payouts_fulfill!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1445,6 +1459,7 @@ default_imp_for_payouts_cancel!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1537,6 +1552,7 @@ default_imp_for_payouts_quote!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1630,6 +1646,7 @@ default_imp_for_payouts_recipient!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1726,6 +1743,7 @@ default_imp_for_payouts_recipient_account!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1819,6 +1837,7 @@ default_imp_for_approve!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1913,6 +1932,7 @@ default_imp_for_reject!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -1991,6 +2011,7 @@ default_imp_for_fraud_check!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Square,connector::Stax,connector::Stripe,@@ -2085,6 +2106,7 @@ default_imp_for_frm_sale!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Square,connector::Stax,connector::Stripe,@@ -2179,6 +2201,7 @@ default_imp_for_frm_checkout!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Square,connector::Stax,connector::Stripe,@@ -2273,6 +2296,7 @@ default_imp_for_frm_transaction!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Square,connector::Stax,connector::Stripe,@@ -2367,6 +2391,7 @@ default_imp_for_frm_fulfillment!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Square,connector::Stax,connector::Stripe,@@ -2461,6 +2486,7 @@ default_imp_for_frm_record_return!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Square,connector::Stax,connector::Stripe,@@ -2552,6 +2578,7 @@ default_imp_for_incremental_authorization!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2642,6 +2669,7 @@ default_imp_for_revoking_mandates!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2793,6 +2821,7 @@ default_imp_for_connector_authentication!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Square,@@ -2882,6 +2911,7 @@ default_imp_for_authorize_session_token!(connector::Powertranz,connector::Prophetpay,connector::Rapyd,+ connector::Razorpay,connector::Riskified,connector::Signifyd,connector::Stax,diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rsindex 85f838b62c..acb8b0ef93 100644--- a/crates/router/src/types/api.rs+++ b/crates/router/src/types/api.rs@@ -453,6 +453,9 @@ impl ConnectorData {enums::Connector::Prophetpay => {Ok(ConnectorEnum::Old(Box::new(&connector::Prophetpay)))}+ enums::Connector::Razorpay => {+ Ok(ConnectorEnum::Old(Box::new(connector::Razorpay::new())))+ }enums::Connector::Rapyd => Ok(ConnectorEnum::Old(Box::new(&connector::Rapyd))),enums::Connector::Shift4 => Ok(ConnectorEnum::Old(Box::new(&connector::Shift4))),enums::Connector::Square => Ok(ConnectorEnum::Old(Box::new(&connector::Square))),diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex 7c2e3fbd12..8f3ef929b1 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -271,6 +271,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {api_enums::Connector::Powertranz => Self::Powertranz,api_enums::Connector::Prophetpay => Self::Prophetpay,api_enums::Connector::Rapyd => Self::Rapyd,+ api_enums::Connector::Razorpay => Self::Razorpay,api_enums::Connector::Shift4 => Self::Shift4,api_enums::Connector::Signifyd => {Err(common_utils::errors::ValidationError::InvalidValue {diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rsindex a3c7ba5691..0283b6d284 100644--- a/crates/router/tests/connectors/main.rs+++ b/crates/router/tests/connectors/main.rs@@ -60,6 +60,7 @@ mod powertranz;#[cfg(feature = "dummy_connector")]mod prophetpay;mod rapyd;+mod razorpay;mod shift4;mod square;mod stax;diff --git a/crates/router/tests/connectors/razorpay.rs b/crates/router/tests/connectors/razorpay.rsnew file mode 100644index 0000000000..7ab77cc65c--- /dev/null+++ b/crates/router/tests/connectors/razorpay.rs@@ -0,0 +1,420 @@+use masking::Secret;+use router::types::{self, domain, storage::enums};+use test_utils::connector_auth;++use crate::utils::{self, ConnectorActions};++#[derive(Clone, Copy)]+struct RazorpayTest;+impl ConnectorActions for RazorpayTest {}+impl utils::Connector for RazorpayTest {+ fn get_data(&self) -> types::api::ConnectorData {+ use router::connector::Razorpay;+ utils::construct_connector_data_old(+ Box::new(Razorpay::new()),+ types::Connector::Razorpay,+ types::api::GetToken::Connector,+ None,+ )+ }++ fn get_auth_token(&self) -> types::ConnectorAuthType {+ utils::to_connector_auth_type(+ connector_auth::ConnectorAuthentication::new()+ .razorpay+ .expect("Missing connector authentication configuration")+ .into(),+ )+ }++ fn get_name(&self) -> String {+ "razorpay".to_string()+ }+}++static CONNECTOR: RazorpayTest = RazorpayTest {};++fn get_default_payment_info() -> Option<utils::PaymentInfo> {+ None+}++fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {+ None+}++// Cards Positive Tests+// Creates a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_only_authorize_payment() {+ let response = CONNECTOR+ .authorize_payment(payment_method_details(), get_default_payment_info())+ .await+ .expect("Authorize payment response");+ assert_eq!(response.status, enums::AttemptStatus::Authorized);+}++// Captures a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_capture_authorized_payment() {+ let response = CONNECTOR+ .authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info())+ .await+ .expect("Capture payment response");+ assert_eq!(response.status, enums::AttemptStatus::Charged);+}++// Partially captures a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_partially_capture_authorized_payment() {+ let response = CONNECTOR+ .authorize_and_capture_payment(+ payment_method_details(),+ Some(types::PaymentsCaptureData {+ amount_to_capture: 50,+ ..utils::PaymentCaptureType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .expect("Capture payment response");+ assert_eq!(response.status, enums::AttemptStatus::Charged);+}++// Synchronizes a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_sync_authorized_payment() {+ let authorize_response = CONNECTOR+ .authorize_payment(payment_method_details(), get_default_payment_info())+ .await+ .expect("Authorize payment response");+ let txn_id = utils::get_connector_transaction_id(authorize_response.response);+ let response = CONNECTOR+ .psync_retry_till_status_matches(+ enums::AttemptStatus::Authorized,+ Some(types::PaymentsSyncData {+ connector_transaction_id: types::ResponseId::ConnectorTransactionId(+ txn_id.unwrap(),+ ),+ ..Default::default()+ }),+ get_default_payment_info(),+ )+ .await+ .expect("PSync response");+ assert_eq!(response.status, enums::AttemptStatus::Authorized,);+}++// Voids a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_void_authorized_payment() {+ let response = CONNECTOR+ .authorize_and_void_payment(+ payment_method_details(),+ Some(types::PaymentsCancelData {+ connector_transaction_id: String::from(""),+ cancellation_reason: Some("requested_by_customer".to_string()),+ ..Default::default()+ }),+ get_default_payment_info(),+ )+ .await+ .expect("Void payment response");+ assert_eq!(response.status, enums::AttemptStatus::Voided);+}++// Refunds a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_refund_manually_captured_payment() {+ let response = CONNECTOR+ .capture_payment_and_refund(+ payment_method_details(),+ None,+ None,+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Partially refunds a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_partially_refund_manually_captured_payment() {+ let response = CONNECTOR+ .capture_payment_and_refund(+ payment_method_details(),+ None,+ Some(types::RefundsData {+ refund_amount: 50,+ ..utils::PaymentRefundType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Synchronizes a refund using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_sync_manually_captured_refund() {+ let refund_response = CONNECTOR+ .capture_payment_and_refund(+ payment_method_details(),+ None,+ None,+ get_default_payment_info(),+ )+ .await+ .unwrap();+ let response = CONNECTOR+ .rsync_retry_till_status_matches(+ enums::RefundStatus::Success,+ refund_response.response.unwrap().connector_refund_id,+ None,+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Creates a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_make_payment() {+ let authorize_response = CONNECTOR+ .make_payment(payment_method_details(), get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);+}++// Synchronizes a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_sync_auto_captured_payment() {+ let authorize_response = CONNECTOR+ .make_payment(payment_method_details(), get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);+ let txn_id = utils::get_connector_transaction_id(authorize_response.response);+ assert_ne!(txn_id, None, "Empty connector transaction id");+ let response = CONNECTOR+ .psync_retry_till_status_matches(+ enums::AttemptStatus::Charged,+ Some(types::PaymentsSyncData {+ connector_transaction_id: types::ResponseId::ConnectorTransactionId(+ txn_id.unwrap(),+ ),+ capture_method: Some(enums::CaptureMethod::Automatic),+ ..Default::default()+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(response.status, enums::AttemptStatus::Charged,);+}++// Refunds a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_refund_auto_captured_payment() {+ let response = CONNECTOR+ .make_payment_and_refund(payment_method_details(), None, get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Partially refunds a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_partially_refund_succeeded_payment() {+ let refund_response = CONNECTOR+ .make_payment_and_refund(+ payment_method_details(),+ Some(types::RefundsData {+ refund_amount: 50,+ ..utils::PaymentRefundType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ refund_response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Creates multiple refunds against a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_refund_succeeded_payment_multiple_times() {+ CONNECTOR+ .make_payment_and_multiple_refund(+ payment_method_details(),+ Some(types::RefundsData {+ refund_amount: 50,+ ..utils::PaymentRefundType::default().0+ }),+ get_default_payment_info(),+ )+ .await;+}++// Synchronizes a refund using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_sync_refund() {+ let refund_response = CONNECTOR+ .make_payment_and_refund(payment_method_details(), None, get_default_payment_info())+ .await+ .unwrap();+ let response = CONNECTOR+ .rsync_retry_till_status_matches(+ enums::RefundStatus::Success,+ refund_response.response.unwrap().connector_refund_id,+ None,+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Cards Negative scenarios+// Creates a payment with incorrect CVC.+#[actix_web::test]+async fn should_fail_payment_for_incorrect_cvc() {+ let response = CONNECTOR+ .make_payment(+ Some(types::PaymentsAuthorizeData {+ payment_method_data: domain::PaymentMethodData::Card(domain::Card {+ card_cvc: Secret::new("12345".to_string()),+ ..utils::CCardType::default().0+ }),+ ..utils::PaymentAuthorizeType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap_err().message,+ "Your card's security code is invalid.".to_string(),+ );+}++// Creates a payment with incorrect expiry month.+#[actix_web::test]+async fn should_fail_payment_for_invalid_exp_month() {+ let response = CONNECTOR+ .make_payment(+ Some(types::PaymentsAuthorizeData {+ payment_method_data: domain::PaymentMethodData::Card(domain::Card {+ card_exp_month: Secret::new("20".to_string()),+ ..utils::CCardType::default().0+ }),+ ..utils::PaymentAuthorizeType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap_err().message,+ "Your card's expiration month is invalid.".to_string(),+ );+}++// Creates a payment with incorrect expiry year.+#[actix_web::test]+async fn should_fail_payment_for_incorrect_expiry_year() {+ let response = CONNECTOR+ .make_payment(+ Some(types::PaymentsAuthorizeData {+ payment_method_data: domain::PaymentMethodData::Card(domain::Card {+ card_exp_year: Secret::new("2000".to_string()),+ ..utils::CCardType::default().0+ }),+ ..utils::PaymentAuthorizeType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap_err().message,+ "Your card's expiration year is invalid.".to_string(),+ );+}++// Voids a payment using automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_fail_void_payment_for_auto_capture() {+ let authorize_response = CONNECTOR+ .make_payment(payment_method_details(), get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);+ let txn_id = utils::get_connector_transaction_id(authorize_response.response);+ assert_ne!(txn_id, None, "Empty connector transaction id");+ let void_response = CONNECTOR+ .void_payment(txn_id.unwrap(), None, get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(+ void_response.response.unwrap_err().message,+ "You cannot cancel this PaymentIntent because it has a status of succeeded."+ );+}++// Captures a payment using invalid connector payment id.+#[actix_web::test]+async fn should_fail_capture_for_invalid_payment() {+ let capture_response = CONNECTOR+ .capture_payment("123456789".to_string(), None, get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(+ capture_response.response.unwrap_err().message,+ String::from("No such payment_intent: '123456789'")+ );+}++// Refunds a payment with refund amount higher than payment amount.+#[actix_web::test]+async fn should_fail_for_refund_amount_higher_than_payment_amount() {+ let response = CONNECTOR+ .make_payment_and_refund(+ payment_method_details(),+ Some(types::RefundsData {+ refund_amount: 150,+ ..utils::PaymentRefundType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap_err().message,+ "Refund amount (₹1.50) is greater than charge amount (₹1.00)",+ );+}++// Connector dependent test cases goes here++// [#478]: add unit tests for non 3DS, wallets & webhooks in connector testsdiff --git a/crates/router/tests/connectors/sample_auth.toml b/crates/router/tests/connectors/sample_auth.tomlindex ecebbbc4fa..cd4f854fa1 100644--- a/crates/router/tests/connectors/sample_auth.toml+++ b/crates/router/tests/connectors/sample_auth.toml@@ -240,3 +240,9 @@ api_key="API Key"[bamboraapac]api_key="API Key"++[razorpay]+api_key="API Key"+key1 = "Merchant id"+api_secret = "Razorpay Id"+key2 = "Razorpay Secret"diff --git a/crates/router_derive/src/macros/misc.rs b/crates/router_derive/src/macros/misc.rsindex 04c37e7595..e3dc5b61f7 100644--- a/crates/router_derive/src/macros/misc.rs+++ b/crates/router_derive/src/macros/misc.rs@@ -23,9 +23,10 @@ pub fn validate_config(input: syn::DeriveInput) -> Result<proc_macro2::TokenStrelet field_ident_string = field_ident.to_string();let is_optional_field = field_type_ident.eq("Option");+ let is_secret_field = field_type_ident.eq("Secret");// Do not call validate if it is an optional field- if !is_optional_field {+ if !is_optional_field && !is_secret_field {let is_leaf_field = field_type_ident.eq("String");let validate_expansion = if is_leaf_field {quote::quote!(common_utils::fp_utils::when(diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rsindex 9e09c2818f..e26b234e9d 100644--- a/crates/test_utils/src/connector_auth.rs+++ b/crates/test_utils/src/connector_auth.rs@@ -62,6 +62,7 @@ pub struct ConnectorAuthentication {pub powertranz: Option<BodyKey>,pub prophetpay: Option<HeaderKey>,pub rapyd: Option<BodyKey>,+ pub razorpay: Option<BodyKey>,pub shift4: Option<HeaderKey>,pub square: Option<BodyKey>,pub stax: Option<HeaderKey>,diff --git a/loadtest/config/development.toml b/loadtest/config/development.tomlindex 0bc855678a..49561629c9 100644--- a/loadtest/config/development.toml+++ b/loadtest/config/development.toml@@ -126,6 +126,7 @@ placetopay.base_url = "https://test.placetopay.com/rest/gateway"powertranz.base_url = "https://staging.ptranz.com/api/"prophetpay.base_url = "https://ccm-thirdparty.cps.golf/"rapyd.base_url = "https://sandboxapi.rapyd.net"+razorpay.base_url = "https://sandbox.juspay.in/"riskified.base_url = "https://sandbox.riskified.com/api"shift4.base_url = "https://api.shift4.com/"signifyd.base_url = "https://api.signifyd.com/"@@ -218,6 +219,9 @@ cards = [[pm_filters.volt]open_banking_uk = {country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL"}+[pm_filters.razorpay]+upi_collect = {country = "IN", currency = "INR"}+[pm_filters.adyen]boleto = { country = "BR", currency = "BRL" }sofort = { country = "AT,BE,DE,ES,CH,NL", currency = "CHF,EUR"}diff --git a/scripts/add_connector.sh b/scripts/add_connector.shindex f3e928d0e1..390654d567 100755--- a/scripts/add_connector.sh+++ b/scripts/add_connector.sh@@ -6,7 +6,7 @@ function find_prev_connector() {git checkout $selfcp $self $self.tmp# Add new connector to existing list and sort it- connectors=(aci adyen adyenplatform airwallex applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans dlocal dummyconnector ebanx fiserv forte globalpay globepay gocardless gpayments helcim iatapay klarna mifinity mollie multisafepay netcetera nexinets noon nuvei opayo opennode payeezy payme payone paypal payu placetopay powertranz prophetpay rapyd shift4 square stax stripe threedsecureio trustpay tsys volt wise worldline worldpay zsl "$1")+ connectors=(aci adyen adyenplatform airwallex applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans dlocal dummyconnector ebanx fiserv forte globalpay globepay gocardless gpayments helcim iatapay klarna mifinity mollie multisafepay netcetera nexinets noon nuvei opayo opennode payeezy payme payone paypal payu placetopay powertranz prophetpay rapyd razorpay shift4 square stax stripe threedsecureio trustpay tsys volt wise worldline worldpay zsl "$1")IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFSres=`echo ${sorted[@]}`sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp