Skip to content

Commit

Permalink
refactor: add router return url
Browse files Browse the repository at this point in the history
  • Loading branch information
swangi-kumari committed Oct 30, 2024
1 parent 41f3f26 commit 59f2b63
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct PaymentsPostSessionTokensData {
pub merchant_order_reference_id: Option<String>,
pub shipping_cost: Option<MinorUnit>,
pub setup_future_usage: Option<storage_enums::FutureUsage>,
pub router_return_url: Option<String>,
}

#[derive(Debug, Clone, PartialEq)]
Expand Down
1 change: 0 additions & 1 deletion crates/router/src/connector/paypal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,6 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
PaypalAuthResponse::PaypalThreeDsResponse(response) => {
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
println!("$$here PaypalThreeDsResponse");
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
Expand Down
12 changes: 6 additions & 6 deletions crates/router/src/connector/paypal/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>>
let payment_source = Some(PaymentSourceItem::Paypal(
PaypalRedirectionRequest::PaypalRedirectionStruct(PaypalRedirectionStruct {
experience_context: ContextStruct {
return_url: Some("https://google.com".to_string()),
cancel_url: Some("https://google.com".to_string()),
return_url: item.router_data.request.router_return_url.clone(),
cancel_url: item.router_data.request.router_return_url.clone(),
shipping_preference: ShippingPreference::GetFromFile,
user_action: Some(UserAction::PayNow),
},
Expand Down Expand Up @@ -1693,11 +1693,11 @@ impl<F, T>
mandate_reference: Box::new(Some(MandateReference {
connector_mandate_id: match item.response.payment_source.clone() {
Some(paypal_source) => match paypal_source {
PaymentSourceItemResponse::Paypal(paypal_source) => paypal_source
.attributes
.and_then(|attr| Some(attr.vault.id)),
PaymentSourceItemResponse::Paypal(paypal_source) => {
paypal_source.attributes.map(|attr| attr.vault.id)
}
PaymentSourceItemResponse::Card(card) => {
card.attributes.and_then(|attr| Some(attr.vault.id))
card.attributes.map(|attr| attr.vault.id)
}
},
None => None,
Expand Down
10 changes: 10 additions & 0 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2577,6 +2577,15 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPostSess
.payment_intent
.merchant_order_reference_id
.clone();
let router_base_url = &additional_data.router_base_url;
let connector_name = &additional_data.connector_name;
let attempt = &payment_data.payment_attempt;
let router_return_url = Some(helpers::create_redirect_url(
router_base_url,
attempt,
connector_name,
payment_data.creds_identifier.as_deref(),
));
Ok(Self {
amount, //need to change after we move to connector module
order_amount: payment_data.payment_intent.amount,
Expand All @@ -2585,6 +2594,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPostSess
capture_method: payment_data.payment_attempt.capture_method,
shipping_cost: payment_data.payment_intent.shipping_cost,
setup_future_usage: payment_data.payment_intent.setup_future_usage,
router_return_url,
})
}
}
Expand Down

0 comments on commit 59f2b63

Please sign in to comment.