Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -19391,7 +19391,8 @@
"type": "string",
"description": "The URL to which you want the user to be redirected after the completion of the payment operation",
"example": "https://hyperswitch.io",
"nullable": true
"nullable": true,
"maxLength": 2048
},
"setup_future_usage": {
"allOf": [
Expand Down Expand Up @@ -19800,7 +19801,8 @@
"type": "string",
"description": "The URL to which you want the user to be redirected after the completion of the payment operation",
"example": "https://hyperswitch.io",
"nullable": true
"nullable": true,
"maxLength": 2048
},
"setup_future_usage": {
"allOf": [
Expand Down Expand Up @@ -21067,7 +21069,8 @@
"type": "string",
"description": "The URL to which you want the user to be redirected after the completion of the payment operation",
"example": "https://hyperswitch.io",
"nullable": true
"nullable": true,
"maxLength": 2048
},
"setup_future_usage": {
"allOf": [
Expand Down Expand Up @@ -22287,7 +22290,8 @@
"type": "string",
"description": "The URL to which you want the user to be redirected after the completion of the payment operation",
"example": "https://hyperswitch.io",
"nullable": true
"nullable": true,
"maxLength": 2048
},
"setup_future_usage": {
"allOf": [
Expand Down
2 changes: 1 addition & 1 deletion crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ pub struct PaymentsRequest {
pub description: Option<String>,

/// The URL to which you want the user to be redirected after the completion of the payment operation
#[schema(value_type = Option<String>, example = "https://hyperswitch.io")]
#[schema(value_type = Option<String>, example = "https://hyperswitch.io", max_length = 2048)]
pub return_url: Option<Url>,

#[schema(value_type = Option<FutureUsage>, example = "off_session")]
Expand Down
25 changes: 23 additions & 2 deletions crates/diesel_models/src/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ pub struct PaymentIntent {
pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
pub created_by: Option<String>,
pub is_iframe_redirection_enabled: Option<bool>,
pub extended_return_url: Option<String>,
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, diesel::AsExpression, PartialEq)]
Expand Down Expand Up @@ -423,6 +424,7 @@ pub struct PaymentIntentNew {
pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
pub created_by: Option<String>,
pub is_iframe_redirection_enabled: Option<bool>,
pub extended_return_url: Option<String>,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -671,6 +673,7 @@ pub struct PaymentIntentUpdateInternal {
pub tax_details: Option<TaxDetails>,
pub force_3ds_challenge: Option<bool>,
pub is_iframe_redirection_enabled: Option<bool>,
pub extended_return_url: Option<String>,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -715,6 +718,7 @@ impl PaymentIntentUpdate {
tax_details,
force_3ds_challenge,
is_iframe_redirection_enabled,
extended_return_url,
} = self.into();
PaymentIntent {
amount: amount.unwrap_or(source.amount),
Expand Down Expand Up @@ -763,6 +767,7 @@ impl PaymentIntentUpdate {
force_3ds_challenge: force_3ds_challenge.or(source.force_3ds_challenge),
is_iframe_redirection_enabled: is_iframe_redirection_enabled
.or(source.is_iframe_redirection_enabled),
extended_return_url: extended_return_url.or(source.extended_return_url),
..source
}
}
Expand Down Expand Up @@ -814,6 +819,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::Update(value) => Self {
amount: Some(value.amount),
Expand All @@ -823,7 +829,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
customer_id: value.customer_id,
shipping_address_id: value.shipping_address_id,
billing_address_id: value.billing_address_id,
return_url: value.return_url,
return_url: value.return_url.clone(),
business_country: value.business_country,
business_label: value.business_label,
description: value.description,
Expand Down Expand Up @@ -855,6 +861,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: value.force_3ds_challenge,
is_iframe_redirection_enabled: value.is_iframe_redirection_enabled,
extended_return_url: value.return_url,
},
PaymentIntentUpdate::PaymentCreateUpdate {
return_url,
Expand All @@ -865,7 +872,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
customer_details,
updated_by,
} => Self {
return_url,
return_url: return_url.clone(),
status,
customer_id,
shipping_address_id,
Expand Down Expand Up @@ -903,6 +910,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: return_url,
},
PaymentIntentUpdate::PGStatusUpdate {
status,
Expand Down Expand Up @@ -947,6 +955,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::MerchantStatusUpdate {
status,
Expand Down Expand Up @@ -992,6 +1001,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::ResponseUpdate {
// amount,
Expand Down Expand Up @@ -1044,6 +1054,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
active_attempt_id,
Expand Down Expand Up @@ -1088,6 +1099,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::StatusAndAttemptUpdate {
status,
Expand Down Expand Up @@ -1133,6 +1145,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::ApproveUpdate {
status,
Expand Down Expand Up @@ -1177,6 +1190,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::RejectUpdate {
status,
Expand Down Expand Up @@ -1221,6 +1235,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::SurchargeApplicableUpdate {
surcharge_applicable,
Expand Down Expand Up @@ -1264,6 +1279,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::IncrementalAuthorizationAmountUpdate { amount } => Self {
amount: Some(amount),
Expand Down Expand Up @@ -1304,6 +1320,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::AuthorizationCountUpdate {
authorization_count,
Expand Down Expand Up @@ -1346,6 +1363,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::CompleteAuthorizeUpdate {
shipping_address_id,
Expand Down Expand Up @@ -1388,6 +1406,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::ManualUpdate { status, updated_by } => Self {
status,
Expand Down Expand Up @@ -1428,6 +1447,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
tax_details: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
PaymentIntentUpdate::SessionResponseUpdate {
tax_details,
Expand Down Expand Up @@ -1473,6 +1493,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
is_payment_processor_token_flow: None,
force_3ds_challenge: None,
is_iframe_redirection_enabled: None,
extended_return_url: None,
},
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,8 @@ diesel::table! {
#[max_length = 255]
created_by -> Nullable<Varchar>,
is_iframe_redirection_enabled -> Nullable<Bool>,
#[max_length = 2048]
extended_return_url -> Nullable<Varchar>,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt
status,
amount_captured,
customer_id,
return_url,
return_url: return_url.clone(),
setup_future_usage,
off_session,
metadata,
Expand Down Expand Up @@ -1242,6 +1242,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt
tax_details,
force_3ds_challenge,
is_iframe_redirection_enabled,
extended_return_url: return_url,
}
}
}
Expand Down Expand Up @@ -1957,7 +1958,7 @@ impl behaviour::Conversion for PaymentIntent {
amount_captured: self.amount_captured,
customer_id: self.customer_id,
description: self.description,
return_url: self.return_url,
return_url: self.return_url.clone(),
metadata: self.metadata,
connector_id: self.connector_id,
shipping_address_id: self.shipping_address_id,
Expand Down Expand Up @@ -2010,6 +2011,7 @@ impl behaviour::Conversion for PaymentIntent {
force_3ds_challenge: self.force_3ds_challenge,
force_3ds_challenge_trigger: self.force_3ds_challenge_trigger,
is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,
extended_return_url: self.return_url,
})
}

Expand Down Expand Up @@ -2052,7 +2054,9 @@ impl behaviour::Conversion for PaymentIntent {
amount_captured: storage_model.amount_captured,
customer_id: storage_model.customer_id,
description: storage_model.description,
return_url: storage_model.return_url,
return_url: storage_model
.extended_return_url
.or(storage_model.return_url), // fallback to legacy
metadata: storage_model.metadata,
connector_id: storage_model.connector_id,
shipping_address_id: storage_model.shipping_address_id,
Expand Down Expand Up @@ -2126,7 +2130,7 @@ impl behaviour::Conversion for PaymentIntent {
amount_captured: self.amount_captured,
customer_id: self.customer_id,
description: self.description,
return_url: self.return_url,
return_url: self.return_url.clone(),
metadata: self.metadata,
connector_id: self.connector_id,
shipping_address_id: self.shipping_address_id,
Expand Down Expand Up @@ -2179,6 +2183,7 @@ impl behaviour::Conversion for PaymentIntent {
force_3ds_challenge: self.force_3ds_challenge,
force_3ds_challenge_trigger: self.force_3ds_challenge_trigger,
is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,
extended_return_url: self.return_url,
})
}
}
4 changes: 2 additions & 2 deletions cypress-tests/cypress/e2e/configs/Payment/Commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -1573,14 +1573,14 @@ export const connectorDetails = {
return_url_too_long: getCustomExchange({
Request: {
customer_id: "customer_1234567890",
return_url: "http://example.com/" + "a".repeat(237),
return_url: "http://example.com/" + "a".repeat(2031),
},
Response: {
status: 400,
body: {
error: {
message:
"return_url must be at most 255 characters long. Received 256 characters",
"return_url must be at most 2048 characters long. Received 2050 characters",
code: "IR_06",
type: "invalid_request",
},
Expand Down
22 changes: 12 additions & 10 deletions cypress-tests/cypress/e2e/spec/Payment/00022-Variations.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,18 @@ describe("Corner cases", () => {
);
});

// it("[Payment] return_url - too long", () => {
// const data = getConnectorDetails(globalState.get("connectorId"))["return_url_variations"]["return_url_too_long"];
// cy.createConfirmPaymentTest(
// paymentCreateConfirmBody,
// data,
// "no_three_ds",
// "automatic",
// globalState
// );
// });
it("[Payment] return_url - too long", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"return_url_variations"
]["return_url_too_long"];
cy.createConfirmPaymentTest(
paymentCreateConfirmBody,
data,
"no_three_ds",
"automatic",
globalState
);
});

it("[Payment] return_url - invalid format", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
ALTER TABLE payment_intent DROP COLUMN IF EXISTS extended_return_url;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE payment_intent ADD COLUMN IF NOT EXISTS extended_return_url VARCHAR(2048);
3 changes: 2 additions & 1 deletion v2_migrations/2025-01-13-081847_drop_v1_columns/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ ALTER TABLE payment_intent DROP COLUMN payment_id,
DROP COLUMN payment_confirm_source,
DROP COLUMN merchant_order_reference_id,
DROP COLUMN is_payment_processor_token_flow,
DROP COLUMN charges;
DROP COLUMN charges,
DROP COLUMN extended_return_url;

-- Run below queries only when V1 is deprecated
ALTER TABLE payment_attempt DROP COLUMN attempt_id,
Expand Down
Loading