-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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(payment_intent_v2): payment intent fields refactoring #5880
base: main
Are you sure you want to change the base?
refactor(payment_intent_v2): payment intent fields refactoring #5880
Conversation
…ges-v2_version_2_branch
… fields to payment intent
…ges-v2_version_2_branch
impl From<Option<bool>> for TaxCalculationOverride { | ||
fn from(value: Option<bool>) -> Self { | ||
match value { | ||
Some(true) => TaxCalculationOverride::Calculate, | ||
_ => TaxCalculationOverride::Skip, | ||
} | ||
} | ||
} |
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.
I don't think it is a good idea to map None and Some(false) to TaxCalculationOverride::Skip.
During conversion from domain model to diesel model, we will end up populating surcharge_applicable field with Some(false) even if it was None in DB.
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.
In KV store
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.
yes that is expected. We should always have a value, either true
or false
in the database. Also we will not be supporting redis kv in v2 on day one
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.
Since surcharge_applicable
in payment_intent
is an inferred field. It should be in payment_attempt
.
surcharge_applicable
is set to true during payment_method_list call. If any surcharge is calculated through the surcharge rules, we'll set surcharge_applicable
to true
.
Here you have considered it as flag to skip surcharge calculation.
The decision to skip surcharge calculation is made through surcharge_amount
field in payment_intent. If the merchant sends some surcharge_amount
through payments create call, we'll will skip surcharge calculation and send whatever surcharge sent by the merchant to the connector.
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.
All the fields in PaymentIntent
are about the intent of the merchant. In this case we cannot use this field for our internal use. This behaviour will need to change in v2. This field will only tell about whether merchant wants us to calculate the surcharge or not.
pub authentication_type: Option<common_enums::AuthenticationType>, | ||
pub amount_to_capture: Option<MinorUnit>, | ||
/// This contains the pre routing results that are done when routing is done during listing the payment methods. | ||
pub prerouting_algorithm: Option<serde_json::Value>, |
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.
Is this for tracking purpose then can we make this as prerouting_algorithm_id
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.
No no, we store a json in this field which is calculated in the payment methods list. We will not have a reference of this calculation anywhere in the routing table, so we cannot use the id here. Also this calculation will be for this payment only.
…ges-v2_version_2_branch
…ges-v2_version_2_branch
9f41fb7
Type of Change
Description
This PR addresses some comments that were left on #5783. Few fields have been mademandatory and renamed
statement_descriptor_name
tostatement_descriptor
currecy
,client_secret
andprofile_id
as a mandatory field in payment intentThis PR also move some other parts of the code under v1 flag, so that when the v2 code is written, these functions will be revisited and then they with either be refactored to be reused / rewritten.
This PR also adds the
PaymentGlobalId
support forPaymentIntent
Additional Changes
This affects the v2 payment intent schema
Motivation and Context
Refactor the fields in v1 that will be removed / not supported in v2 and refactor the code for general improvements in code quality.
How did you test it?
This PR does not add any feature. Only v2 code is affected. A sanity of payments should ensure that this PR does not introduce any bugs.
Impact
payment intent v2
Checklist
cargo +nightly fmt --all
cargo clippy