-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Add dynamic secure link #7133
base: main
Are you sure you want to change the base?
Conversation
Changed Files
|
@@ -982,8 +982,6 @@ diesel::table! { | |||
description -> Nullable<Varchar>, | |||
#[max_length = 64] | |||
profile_id -> Nullable<Varchar>, | |||
#[max_length = 255] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the corresponding up and down sql for migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can choose to remove this in V2 though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with this, this is automatically generated
@@ -55,5 +54,4 @@ pub struct PaymentLinkNew { | |||
pub payment_link_config: Option<serde_json::Value>, | |||
pub description: Option<String>, | |||
pub profile_id: Option<common_utils::id_type::ProfileId>, | |||
pub secure_link: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrudulvajpayee4935 DB alterations are not allowed, this is a column removal, so let's not remove this one
You can add a comment on top of it saying this column is deprecated
crates/diesel_models/src/schema.rs
Outdated
@@ -1019,8 +1019,6 @@ diesel::table! { | |||
description -> Nullable<Varchar>, | |||
#[max_length = 64] | |||
profile_id -> Nullable<Varchar>, | |||
#[max_length = 255] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, don't remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is automatically generated when you do a diesel migration, don't make manual changes here
) | ||
} | ||
|
||
pub fn is_secure_payment_link_request( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fn is performing two steps - checking if request was for secure payment link and also validating the request if it was!
We can break it into two fns, and consume it in the main parent flow (initiate_payment_link_flow
)
First function will tell you the type of payment link, and once you match on it, you can use validation
Why? It helps keep the code readable and ensure the fn is doing what it is named after!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, instead of returning a bool
, can we make an enum? Something like PaymentLinkType
with two variants - OpenPaymentLink & SecurePaymentLink
) | ||
})?; | ||
|
||
// Validate origin / referer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move validation bits to validator.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments around refactoring
0cba98f
to
8a8006d
Compare
8a8006d
to
1bb2e38
Compare
46b2c95
to
fb21de6
Compare
crates/diesel_models/src/schema.rs
Outdated
@@ -1019,8 +1019,6 @@ diesel::table! { | |||
description -> Nullable<Varchar>, | |||
#[max_length = 64] | |||
profile_id -> Nullable<Varchar>, | |||
#[max_length = 255] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is automatically generated when you do a diesel migration, don't make manual changes here
@@ -982,8 +982,6 @@ diesel::table! { | |||
description -> Nullable<Varchar>, | |||
#[max_length = 64] | |||
profile_id -> Nullable<Varchar>, | |||
#[max_length = 255] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with this, this is automatically generated
crates/api_models/src/payments.rs
Outdated
@@ -6967,7 +6967,7 @@ pub struct RetrievePaymentLinkRequest { | |||
pub struct PaymentLinkResponse { | |||
/// URL for rendering the open payment link | |||
pub link: String, | |||
/// URL for rendering the secure payment link | |||
/// URL for rendering the secure payment link. It is deprecated now. | |||
pub secure_link: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove from API models
crates/api_models/src/payments.rs
Outdated
@@ -6997,7 +6997,7 @@ pub struct RetrievePaymentLinkResponse { | |||
pub status: PaymentLinkStatus, | |||
#[schema(value_type = Option<Currency>)] | |||
pub currency: Option<api_enums::Currency>, | |||
/// Secure payment link (with security checks and listing saved payment methods) | |||
/// Secure payment link (with security checks and listing saved payment methods). It is deprecated now. | |||
pub secure_link: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in the response
.and_then(|v| v.to_str().ok()) | ||
{ | ||
Some("iframe") => Self::SecurePaymentLink, | ||
Some(_) | None => Self::OpenPaymentLink, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
Some(_) | None => Self::OpenPaymentLink, | |
_ => Self::OpenPaymentLink, |
7d0161a
to
905c2de
Compare
905c2de
to
b703cb6
Compare
a5b3419
Type of Change
Description
We need to refactor the flow of generating payments link. Instead of having two separate routes for generating simple payment link and secure payment link we will maintain single route which will generate payment links accordingly with certain checks.
Additional Changes
Motivation and Context
How did you test it?
This can be tested by creating payment link using payment create curl. Single link will be provided in payment_link struct which can be used accordingly in secure or open environment.
1) Open environment
2) Secure environment
Checklist
cargo +nightly fmt --all
cargo clippy