Skip to content

Commit

Permalink
refactor: remove merchant return url from router_data
Browse files Browse the repository at this point in the history
  • Loading branch information
swangi-kumari committed Dec 19, 2024
1 parent 4bc88a7 commit 724179a
Show file tree
Hide file tree
Showing 44 changed files with 32 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn get_crypto_specific_payment_data(
) -> Result<BitpayPaymentsRequest, error_stack::Report<errors::ConnectorError>> {
let price = item.amount;
let currency = item.router_data.request.currency.to_string();
let redirect_url = item.router_data.request.get_return_url()?;
let redirect_url = item.router_data.request.get_router_return_url()?;
let notification_url = item.router_data.request.get_webhook_url()?;
let transaction_speed = TransactionSpeed::Medium;
let auth_type = item.router_data.connector_auth_type.clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ pub struct BokuErrorResponse {
}

fn get_hosted_data(item: &types::PaymentsAuthorizeRouterData) -> Option<BokuHostedData> {
item.return_url
item.request
.router_return_url
.clone()
.map(|url| BokuHostedData { forward_url: url })
}
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ fn get_crypto_specific_payment_data(
})?;
let pricing_type = connector_meta.pricing_type;
let local_price = get_local_price(item);
let redirect_url = item.request.get_return_url()?;
let cancel_url = item.request.get_return_url()?;
let redirect_url = item.request.get_router_return_url()?;
let cancel_url = item.request.get_router_return_url()?;

Ok(CoinbasePaymentsRequest {
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl TryFrom<&MollieRouterData<&types::PaymentsAuthorizeRouterData>> for MollieP
value: item.amount.clone(),
};
let description = item.router_data.get_description()?;
let redirect_url = item.router_data.request.get_return_url()?;
let redirect_url = item.router_data.request.get_router_return_url()?;
let payment_method_data = match item.router_data.request.capture_method.unwrap_or_default()
{
enums::CaptureMethod::Automatic | enums::CaptureMethod::SequentialAutomatic => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym
.unwrap_or(consts::DEFAULT_LOCALE.to_string().to_string());
let custom = NovalnetCustom { lang };
let hook_url = item.router_data.request.get_webhook_url()?;
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let create_token = if item.router_data.request.is_mandate_payment() {
Some(1)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl TryFrom<&RapydRouterData<&types::PaymentsAuthorizeRouterData>> for RapydPay
.change_context(errors::ConnectorError::NotImplemented(
"payment_method".to_owned(),
))?;
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
Ok(Self {
amount: item.amount,
currency: item.router_data.request.currency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ impl
amount,
terminal_uuid: Secret::new(terminal_uuid),
signature: None,
url_redirect: item.router_data.request.get_return_url()?,
url_redirect: item.router_data.request.get_router_return_url()?,
};
checkout_request.signature =
Some(get_checkout_signature(&checkout_request, &session_data)?);
Expand Down
12 changes: 0 additions & 12 deletions crates/hyperswitch_connectors/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ pub trait RouterData {
fn get_billing_country(&self) -> Result<api_models::enums::CountryAlpha2, Error>;
fn get_billing_phone(&self) -> Result<&PhoneDetails, Error>;
fn get_description(&self) -> Result<String, Error>;
fn get_return_url(&self) -> Result<String, Error>;
fn get_billing_address(&self) -> Result<&AddressDetails, Error>;
fn get_shipping_address(&self) -> Result<&AddressDetails, Error>;
fn get_shipping_address_with_phone_number(&self) -> Result<&Address, Error>;
Expand Down Expand Up @@ -547,11 +546,6 @@ impl<Flow, Request, Response> RouterData
.clone()
.ok_or_else(missing_field_err("description"))
}
fn get_return_url(&self) -> Result<String, Error> {
self.return_url
.clone()
.ok_or_else(missing_field_err("return_url"))
}
fn get_billing_address(&self) -> Result<&AddressDetails, Error> {
self.address
.get_payment_method_billing()
Expand Down Expand Up @@ -1261,7 +1255,6 @@ pub trait PaymentsAuthorizeRequestData {
fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error>;
fn get_card(&self) -> Result<Card, Error>;
fn get_return_url(&self) -> Result<String, Error>;
fn connector_mandate_id(&self) -> Option<String>;
fn is_mandate_payment(&self) -> bool;
fn is_customer_initiated_mandate_payment(&self) -> bool;
Expand Down Expand Up @@ -1324,11 +1317,6 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
_ => Err(missing_field_err("card")()),
}
}
fn get_return_url(&self) -> Result<String, Error> {
self.router_return_url
.clone()
.ok_or_else(missing_field_err("return_url"))
}

fn get_complete_authorize_url(&self) -> Result<String, Error> {
self.complete_authorize_url
Expand Down
1 change: 0 additions & 1 deletion crates/hyperswitch_domain_models/src/router_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub struct RouterData<Flow, Request, Response> {
pub payment_method: common_enums::enums::PaymentMethod,
pub connector_auth_type: ConnectorAuthType,
pub description: Option<String>,
pub return_url: Option<String>,
pub address: PaymentAddress,
pub auth_type: common_enums::enums::AuthenticationType,
pub connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub struct PaymentFlowData {
pub status: common_enums::AttemptStatus,
pub payment_method: common_enums::PaymentMethod,
pub description: Option<String>,
pub return_url: Option<String>,
pub address: PaymentAddress,
pub auth_type: common_enums::AuthenticationType,
pub connector_meta_data: Option<pii::SecretSerdeValue>,
Expand Down Expand Up @@ -59,7 +58,6 @@ pub struct RefundFlowData {
pub attempt_id: String,
pub status: common_enums::AttemptStatus,
pub payment_method: common_enums::PaymentMethod,
pub return_url: Option<String>,
pub connector_meta_data: Option<pii::SecretSerdeValue>,
pub amount_captured: Option<i64>,
// minor amount for amount framework
Expand All @@ -75,7 +73,6 @@ pub struct PayoutFlowData {
pub merchant_id: common_utils::id_type::MerchantId,
pub customer_id: Option<common_utils::id_type::CustomerId>,
pub connector_customer: Option<String>,
pub return_url: Option<String>,
pub address: PaymentAddress,
pub connector_meta_data: Option<pii::SecretSerdeValue>,
pub connector_wallets_details: Option<pii::SecretSerdeValue>,
Expand All @@ -93,7 +90,6 @@ pub struct FrmFlowData {
pub attempt_id: String,
pub payment_method: common_enums::enums::PaymentMethod,
pub connector_request_reference_id: String,
pub return_url: Option<String>,
pub auth_type: common_enums::enums::AuthenticationType,
pub connector_wallets_details: Option<pii::SecretSerdeValue>,
pub connector_meta_data: Option<pii::SecretSerdeValue>,
Expand All @@ -115,7 +111,6 @@ pub struct DisputesFlowData {
pub payment_id: String,
pub attempt_id: String,
pub payment_method: common_enums::enums::PaymentMethod,
pub return_url: Option<String>,
pub connector_meta_data: Option<pii::SecretSerdeValue>,
pub amount_captured: Option<i64>,
// minor amount for amount framework
Expand Down Expand Up @@ -145,7 +140,6 @@ pub struct FilesFlowData {
pub merchant_id: common_utils::id_type::MerchantId,
pub payment_id: String,
pub attempt_id: String,
pub return_url: Option<String>,
pub connector_meta_data: Option<pii::SecretSerdeValue>,
pub connector_request_reference_id: String,
}
Expand Down
18 changes: 9 additions & 9 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,7 @@ impl
get_recurring_processing_model(item.router_data)?;
let browser_info = None;
let additional_data = get_additional_data(item.router_data);
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let payment_method_type = item.router_data.request.payment_method_type;
let payment_method = match mandate_ref_id {
payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids) => {
Expand Down Expand Up @@ -2811,7 +2811,7 @@ impl
get_address_info(item.router_data.get_optional_billing()).and_then(Result::ok);
let country_code = get_country_code(item.router_data.get_optional_billing());
let additional_data = get_additional_data(item.router_data);
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let card_holder_name = item.router_data.get_optional_billing_full_name();
let payment_method = AdyenPaymentMethod::try_from((card_data, card_holder_name))?;
let shopper_email = item.router_data.get_optional_billing_email();
Expand Down Expand Up @@ -2870,7 +2870,7 @@ impl
get_recurring_processing_model(item.router_data)?;
let browser_info = get_browser_info(item.router_data)?;
let additional_data = get_additional_data(item.router_data);
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let payment_method = AdyenPaymentMethod::try_from((bank_debit_data, item.router_data))?;
let country_code = get_country_code(item.router_data.get_optional_billing());
let request = AdyenPaymentRequest {
Expand Down Expand Up @@ -2927,7 +2927,7 @@ impl
let browser_info = get_browser_info(item.router_data)?;
let additional_data = get_additional_data(item.router_data);
let payment_method = AdyenPaymentMethod::try_from((voucher_data, item.router_data))?;
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let social_security_number = get_social_security_number(voucher_data);
let billing_address =
get_address_info(item.router_data.get_optional_billing()).and_then(Result::ok);
Expand Down Expand Up @@ -2984,7 +2984,7 @@ impl
let auth_type = AdyenAuthType::try_from(&item.router_data.connector_auth_type)?;
let shopper_interaction = AdyenShopperInteraction::from(item.router_data);
let payment_method = AdyenPaymentMethod::try_from((bank_transfer_data, item.router_data))?;
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let request = AdyenPaymentRequest {
amount,
merchant_account: auth_type.merchant_account,
Expand Down Expand Up @@ -3090,7 +3090,7 @@ impl
get_recurring_processing_model(item.router_data)?;
let browser_info = get_browser_info(item.router_data)?;
let additional_data = get_additional_data(item.router_data);
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let payment_method = AdyenPaymentMethod::try_from((
bank_redirect_data,
item.router_data.test_mode,
Expand Down Expand Up @@ -3275,7 +3275,7 @@ impl
);
let (recurring_processing_model, store_payment_method, _) =
get_recurring_processing_model(item.router_data)?;
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let shopper_name = get_shopper_name(item.router_data.get_optional_billing());
let shopper_email = item.router_data.get_optional_billing_email();
let billing_address =
Expand Down Expand Up @@ -3343,7 +3343,7 @@ impl
let auth_type = AdyenAuthType::try_from(&item.router_data.connector_auth_type)?;
let payment_method = AdyenPaymentMethod::try_from(card_redirect_data)?;
let shopper_interaction = AdyenShopperInteraction::from(item.router_data);
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let shopper_name = get_shopper_name(item.router_data.get_optional_billing());
let shopper_email = item.router_data.get_optional_billing_email();
let telephone_number = item
Expand Down Expand Up @@ -5443,7 +5443,7 @@ impl
get_address_info(item.router_data.get_optional_billing()).transpose()?;
let country_code = get_country_code(item.router_data.get_optional_billing());
let additional_data = get_additional_data(item.router_data);
let return_url = item.router_data.request.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
let card_holder_name = item.router_data.get_optional_billing_full_name();
let payment_method = AdyenPaymentMethod::try_from((token_data, card_holder_name))?;
let shopper_email = item.router_data.request.email.clone();
Expand Down
6 changes: 2 additions & 4 deletions crates/router/src/connector/iatapay/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use masking::{Secret, SwitchStrategy};
use serde::{Deserialize, Serialize};

use crate::{
connector::utils::{
self as connector_util, PaymentsAuthorizeRequestData, RefundsRequestData, RouterData,
},
connector::utils::{self as connector_util, PaymentsAuthorizeRequestData, RefundsRequestData},
consts,
core::errors,
services,
Expand Down Expand Up @@ -128,7 +126,7 @@ impl
>,
>,
) -> Result<Self, Self::Error> {
let return_url = item.router_data.get_return_url()?;
let return_url = item.router_data.request.get_router_return_url()?;
// Iatapay processes transactions through the payment method selected based on the country
let (country, payer_info, preferred_checkout_method) =
match item.router_data.request.payment_method_data.clone() {
Expand Down
6 changes: 3 additions & 3 deletions crates/router/src/connector/nuvei/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl NuveiAuthorizePreprocessingCommon for types::PaymentsAuthorizeData {
fn get_return_url_required(
&self,
) -> Result<String, error_stack::Report<errors::ConnectorError>> {
self.get_return_url()
self.get_router_return_url()
}

fn get_capture_method(&self) -> Option<enums::CaptureMethod> {
Expand Down Expand Up @@ -122,7 +122,7 @@ impl NuveiAuthorizePreprocessingCommon for types::PaymentsPreProcessingData {
fn get_return_url_required(
&self,
) -> Result<String, error_stack::Report<errors::ConnectorError>> {
self.get_return_url()
self.get_router_return_url()
}

fn get_capture_method(&self) -> Option<enums::CaptureMethod> {
Expand Down Expand Up @@ -1129,7 +1129,7 @@ where
browser_details,
v2_additional_params: additional_params,
notification_url: item.request.get_complete_authorize_url().clone(),
merchant_url: item.return_url.clone(),
merchant_url: Some(item.request.get_return_url_required()?),
platform_type: Some(PlatformType::Browser),
method_completion_ind: Some(MethodCompletion::Unavailable),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/opennode/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ fn get_crypto_specific_payment_data(
let currency = item.router_data.request.currency.to_string();
let description = item.router_data.get_description()?;
let auto_settle = true;
let success_url = item.router_data.get_return_url()?;
let success_url = item.router_data.request.get_router_return_url()?;
let callback_url = item.router_data.request.get_webhook_url()?;
let order_id = item.router_data.connector_request_reference_id.clone();

Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/connector/payme/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl TryFrom<&PaymeRouterData<&types::PaymentsPreProcessingRouterData>> for Gene
sale_payment_method: SalePaymentMethod::try_from(&pmd)?,
sale_type,
transaction_id: item.router_data.payment_id.clone(),
sale_return_url: item.router_data.request.get_return_url()?,
sale_return_url: item.router_data.request.get_router_return_url()?,
sale_callback_url: item.router_data.request.get_webhook_url()?,
language: LANGUAGE.to_string(),
services,
Expand Down Expand Up @@ -634,7 +634,7 @@ impl TryFrom<&PaymeRouterData<&types::PaymentsAuthorizeRouterData>> for MandateR
sale_price: item.amount.to_owned(),
transaction_id: item.router_data.payment_id.clone(),
product_name,
sale_return_url: item.router_data.request.get_return_url()?,
sale_return_url: item.router_data.request.get_router_return_url()?,
seller_payme_id,
sale_callback_url: item.router_data.request.get_webhook_url()?,
buyer_key: Secret::new(item.router_data.request.get_connector_mandate_id()?),
Expand Down
1 change: 0 additions & 1 deletion crates/router/src/connector/paypal/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ impl<F, T>
};
Ok(Self {
status,
return_url: None,
response: Ok(types::PaymentsResponseData::TransactionResponse {
resource_id: types::ResponseId::ConnectorTransactionId(info_response.id.clone()),
redirection_data: Box::new(None),
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/stripe/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3352,7 +3352,7 @@ impl
email: item.get_billing_email().or(item.request.get_email())?,
},
amount: Some(amount),
return_url: Some(item.get_return_url()?),
return_url: Some(item.request.get_router_return_url()?),
}),
),
domain::BankTransferData::AchBankTransfer { .. } => {
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/connector/trustpay/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ fn get_bank_redirection_request_data(
auth: TrustpayAuthType,
) -> Result<TrustpayPaymentsRequest, error_stack::Report<errors::ConnectorError>> {
let pm = TrustpayPaymentMethod::try_from(bank_redirection_data)?;
let return_url = item.request.get_return_url()?;
let return_url = item.request.get_router_return_url()?;
let payment_request =
TrustpayPaymentsRequest::BankRedirectPaymentRequest(Box::new(PaymentRequestBankRedirect {
payment_method: pm.clone(),
Expand Down Expand Up @@ -410,7 +410,7 @@ impl TryFrom<&TrustpayRouterData<&types::PaymentsAuthorizeRouterData>> for Trust
params,
amount,
ccard,
item.router_data.request.get_return_url()?,
item.router_data.request.get_router_return_url()?,
)?),
domain::PaymentMethodData::BankRedirect(ref bank_redirection_data) => {
get_bank_redirection_request_data(
Expand Down
Loading

0 comments on commit 724179a

Please sign in to comment.